initial import
[vuplus_webkit] / Source / WebKit / wx / WebFrame.h
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 #include "WebKitDefines.h"
37
38 class WebDOMElement;
39 class WebDOMNode;
40
41 #include "WebDOMSelection.h"
42
43 class Element;
44
45 class WebFramePrivate;
46 class WebViewFrameData;
47 class wxWebView;
48
49 namespace WebCore {
50     class ChromeClientWx;
51     class EditorClientWx;
52     class FrameLoaderClientWx;
53     class Frame;    
54 }
55
56 class WXDLLIMPEXP_WEBKIT wxWebViewDOMElementInfo
57 {
58 public:
59     wxWebViewDOMElementInfo();
60     wxWebViewDOMElementInfo(const wxWebViewDOMElementInfo& other);
61
62     ~wxWebViewDOMElementInfo();
63
64     wxString GetTagName() const { return m_tagName; }
65     void SetTagName(const wxString& name) { m_tagName = name; }
66
67     bool IsSelected() const { return m_isSelected; }
68     void SetSelected(bool sel) { m_isSelected = sel; }
69
70     wxString GetText() const { return m_text; }
71     void SetText(const wxString& text) { m_text = text; }
72
73     wxString GetImageSrc() const { return m_imageSrc; }
74     void SetImageSrc(const wxString& src) { m_imageSrc = src; }
75
76     wxString GetLink() const { return m_link; }
77     void SetLink(const wxString& link) { m_link = link; }
78     
79     WebDOMNode* GetInnerNode() { return m_innerNode; }
80     void SetInnerNode(WebDOMNode* node) { m_innerNode = node; }
81     
82     WebDOMElement* GetURLElement() { return m_urlElement; }
83     void SetURLElement(WebDOMElement* url) { m_urlElement = url; }
84
85 private:
86     WebDOMNode* m_innerNode;
87     WebDOMElement* m_urlElement;
88     bool m_isSelected;
89     wxString m_tagName;
90     wxString m_text;
91     wxString m_imageSrc;
92     wxString m_link;
93 };
94
95 // based on enums in WebCore/dom/Document.h
96 enum wxWebKitCompatibilityMode { QuirksMode, LimitedQuirksMode, NoQuirksMode };
97
98 class WXDLLIMPEXP_WEBKIT wxWebFrame
99 {
100 public:
101     // ChromeClientWx needs to get the Page* stored by the wxWebView
102     // for the createWindow function. 
103     friend class WebCore::ChromeClientWx;
104     friend class WebCore::FrameLoaderClientWx;
105     friend class WebCore::EditorClientWx;
106     friend class wxWebView;
107
108 public:
109     wxWebFrame(wxWebView* container, wxWebFrame* parent = NULL, WebViewFrameData* data = NULL);
110     
111     ~wxWebFrame();
112     
113     void LoadURL(const wxString& url);
114     bool GoBack();
115     bool GoForward();
116     void Stop();
117     void Reload();
118     void Print(bool showDialog = true);
119     
120     bool CanGoBack();
121     bool CanGoForward();
122     
123     bool CanCut();
124     bool CanCopy();
125     bool CanPaste();
126     
127     void Cut();
128     void Copy();
129     void Paste();
130     
131     bool CanUndo();
132     bool CanRedo();
133     
134     void Undo();
135     void Redo();
136     
137     wxString GetName();
138     
139     wxString GetPageSource();
140     void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString, const wxString& mimetype = wxT("text/html"));
141     
142     wxString GetInnerText();
143     wxString GetAsMarkup();
144     wxString GetExternalRepresentation();
145     
146     wxWebKitSelection GetSelection();
147     wxString GetSelectionAsHTML();
148     wxString GetSelectionAsText();
149     
150     wxString RunScript(const wxString& javascript);
151     bool ExecuteEditCommand(const wxString& command, const wxString& parameter = wxEmptyString);
152     EditState GetEditCommandState(const wxString& command) const;
153     wxString GetEditCommandValue(const wxString& command) const;
154     
155     bool FindString(const wxString& string, bool forward = true,
156         bool caseSensitive = false, bool wrapSelection = true,
157         bool startInSelection = true);
158     
159     bool CanIncreaseTextSize() const;
160     void IncreaseTextSize();
161     bool CanDecreaseTextSize() const;
162     void DecreaseTextSize();
163     void ResetTextSize();
164     void MakeEditable(bool enable);
165     bool IsEditable() const;
166     
167     WebCore::Frame* GetFrame();
168
169     wxWebViewDOMElementInfo HitTest(const wxPoint& post) const;
170     
171     bool ShouldClose() const;
172     
173     wxWebKitCompatibilityMode GetCompatibilityMode() const;
174     
175     void GrantUniversalAccess();
176     
177 private:
178     float m_textMagnifier;
179     bool m_isInitialized;
180     bool m_beingDestroyed;
181     WebFramePrivate* m_impl;
182     
183 };
184
185 #ifndef SWIG
186 wxWebFrame* kit(WebCore::Frame*);
187 #endif
188
189 #endif // ifndef WXWEBFRAME_H