• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef WXWEBFRAME_H
29 #define WXWEBFRAME_H
30 
31 #include "wx/wxprec.h"
32 #ifndef WX_PRECOMP
33     #include "wx/wx.h"
34 #endif
35 
36 class WebFramePrivate;
37 class WebViewFrameData;
38 class wxWebView;
39 
40 namespace WebCore {
41     class ChromeClientWx;
42     class FrameLoaderClientWx;
43     class EditorClientWx;
44     class Frame;
45 }
46 
47 #ifndef SWIG
48 
49 #if !wxCHECK_VERSION(2,9,0) && wxCHECK_GCC_VERSION(4,0)
50 #define WXDLLIMPEXP_WEBKIT __attribute__ ((visibility("default")))
51 #elif WXMAKINGDLL_WEBKIT
52 #define WXDLLIMPEXP_WEBKIT WXEXPORT
53 #elif defined(WXUSINGDLL_WEBKIT)
54 #define WXDLLIMPEXP_WEBKIT WXIMPORT
55 #endif
56 
57 #else
58 #define WXDLLIMPEXP_WEBKIT
59 #endif // SWIG
60 
61 class WXDLLIMPEXP_WEBKIT wxWebViewDOMElementInfo
62 {
63 public:
64     wxWebViewDOMElementInfo();
65 
~wxWebViewDOMElementInfo()66     ~wxWebViewDOMElementInfo() { }
67 
GetTagName()68     wxString GetTagName() const { return m_tagName; }
SetTagName(const wxString & name)69     void SetTagName(const wxString& name) { m_tagName = name; }
70 
IsSelected()71     bool IsSelected() const { return m_isSelected; }
SetSelected(bool sel)72     void SetSelected(bool sel) { m_isSelected = sel; }
73 
GetText()74     wxString GetText() const { return m_text; }
SetText(const wxString & text)75     void SetText(const wxString& text) { m_text = text; }
76 
GetImageSrc()77     wxString GetImageSrc() const { return m_imageSrc; }
SetImageSrc(const wxString & src)78     void SetImageSrc(const wxString& src) { m_imageSrc = src; }
79 
GetLink()80     wxString GetLink() const { return m_link; }
SetLink(const wxString & link)81     void SetLink(const wxString& link) { m_link = link; }
82 
83 private:
84     void* m_domElement;
85     bool m_isSelected;
86     wxString m_tagName;
87     wxString m_text;
88     wxString m_imageSrc;
89     wxString m_link;
90 };
91 
92 class WXDLLIMPEXP_WEBKIT wxWebFrame
93 {
94     // ChromeClientWx needs to get the Page* stored by the wxWebView
95     // for the createWindow function.
96     friend class WebCore::ChromeClientWx;
97     friend class WebCore::FrameLoaderClientWx;
98     friend class WebCore::EditorClientWx;
99     friend class wxWebView;
100 
101 public:
102     wxWebFrame(wxWebView* container, wxWebFrame* parent = NULL, WebViewFrameData* data = NULL);
103 
104     ~wxWebFrame();
105 
106     void LoadURL(const wxString& url);
107     bool GoBack();
108     bool GoForward();
109     void Stop();
110     void Reload();
111 
112     bool CanGoBack();
113     bool CanGoForward();
114 
115     bool CanCut();
116     bool CanCopy();
117     bool CanPaste();
118 
119     void Cut();
120     void Copy();
121     void Paste();
122 
123     bool CanUndo();
124     bool CanRedo();
125 
126     void Undo();
127     void Redo();
128 
129     wxString GetPageSource();
130     void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString);
131 
132     wxString GetInnerText();
133     wxString GetAsMarkup();
134     wxString GetExternalRepresentation();
135 
136     wxString RunScript(const wxString& javascript);
137 
138     bool FindString(const wxString& string, bool forward = true,
139         bool caseSensitive = false, bool wrapSelection = true,
140         bool startInSelection = true);
141 
142     bool CanIncreaseTextSize() const;
143     void IncreaseTextSize();
144     bool CanDecreaseTextSize() const;
145     void DecreaseTextSize();
146     void ResetTextSize();
147     void MakeEditable(bool enable);
IsEditable()148     bool IsEditable() const { return m_isEditable; }
149 
GetPageTitle()150     wxString GetPageTitle() const { return m_title; }
SetPageTitle(const wxString & title)151     void SetPageTitle(const wxString& title) { m_title = title; }
152 
153     WebCore::Frame* GetFrame();
154 
155     wxWebViewDOMElementInfo HitTest(const wxPoint& post) const;
156 
157 private:
158     float m_textMagnifier;
159     bool m_isEditable;
160     bool m_isInitialized;
161     bool m_beingDestroyed;
162     WebFramePrivate* m_impl;
163     wxString m_title;
164 
165 };
166 
167 #endif // ifndef WXWEBFRAME_H
168