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 GetTagName()64 wxString GetTagName() const { return m_tagName; } SetTagName(const wxString & name)65 void SetTagName(const wxString& name) { m_tagName = name; } 66 IsSelected()67 bool IsSelected() const { return m_isSelected; } SetSelected(bool sel)68 void SetSelected(bool sel) { m_isSelected = sel; } 69 GetText()70 wxString GetText() const { return m_text; } SetText(const wxString & text)71 void SetText(const wxString& text) { m_text = text; } 72 GetImageSrc()73 wxString GetImageSrc() const { return m_imageSrc; } SetImageSrc(const wxString & src)74 void SetImageSrc(const wxString& src) { m_imageSrc = src; } 75 GetLink()76 wxString GetLink() const { return m_link; } SetLink(const wxString & link)77 void SetLink(const wxString& link) { m_link = link; } 78 GetInnerNode()79 WebDOMNode* GetInnerNode() { return m_innerNode; } SetInnerNode(WebDOMNode * node)80 void SetInnerNode(WebDOMNode* node) { m_innerNode = node; } 81 GetURLElement()82 WebDOMElement* GetURLElement() { return m_urlElement; } SetURLElement(WebDOMElement * url)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 119 bool CanGoBack(); 120 bool CanGoForward(); 121 122 bool CanCut(); 123 bool CanCopy(); 124 bool CanPaste(); 125 126 void Cut(); 127 void Copy(); 128 void Paste(); 129 130 bool CanUndo(); 131 bool CanRedo(); 132 133 void Undo(); 134 void Redo(); 135 136 wxString GetPageSource(); 137 void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString, const wxString& mimetype = wxT("text/html")); 138 139 wxString GetInnerText(); 140 wxString GetAsMarkup(); 141 wxString GetExternalRepresentation(); 142 143 wxWebKitSelection GetSelection(); 144 wxString GetSelectionAsHTML(); 145 wxString GetSelectionAsText(); 146 147 wxString RunScript(const wxString& javascript); 148 bool ExecuteEditCommand(const wxString& command, const wxString& parameter = wxEmptyString); 149 EditState GetEditCommandState(const wxString& command) const; 150 wxString GetEditCommandValue(const wxString& command) const; 151 152 bool FindString(const wxString& string, bool forward = true, 153 bool caseSensitive = false, bool wrapSelection = true, 154 bool startInSelection = true); 155 156 bool CanIncreaseTextSize() const; 157 void IncreaseTextSize(); 158 bool CanDecreaseTextSize() const; 159 void DecreaseTextSize(); 160 void ResetTextSize(); 161 void MakeEditable(bool enable); 162 bool IsEditable() const; 163 164 WebCore::Frame* GetFrame(); 165 166 wxWebViewDOMElementInfo HitTest(const wxPoint& post) const; 167 168 bool ShouldClose() const; 169 170 wxWebKitCompatibilityMode GetCompatibilityMode() const; 171 172 void GrantUniversalAccess(); 173 174 private: 175 float m_textMagnifier; 176 bool m_isInitialized; 177 bool m_beingDestroyed; 178 WebFramePrivate* m_impl; 179 180 }; 181 182 #endif // ifndef WXWEBFRAME_H 183