Add support for searching and highlighting a wxWebView.

Currently supports WebView on GTK and IE. Closes #14045.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton
2012-08-28 17:13:13 +00:00
parent de3d7096fe
commit 66ac040060
9 changed files with 609 additions and 1 deletions

View File

@@ -96,6 +96,9 @@ public:
virtual void Undo();
virtual void Redo();
//Find function
virtual long Find(const wxString& text, int flags = wxWEB_VIEW_FIND_DEFAULT);
//Editing functions
virtual void SetEditable(bool enable = true);
virtual bool IsEditable() const;
@@ -142,6 +145,9 @@ private:
void SetWebkitZoom(float level);
float GetWebkitZoom() const;
//Find helper function
void FindClear();
// focus event handler: calls GTKUpdateBitmap()
void GTKOnFocus(wxFocusEvent& event);
@@ -150,6 +156,12 @@ private:
wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList;
//variables used for Find()
int m_findFlags;
wxString m_findText;
int m_findPosition;
int m_findCount;
wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
};

View File

@@ -244,10 +244,13 @@ public:
/* END OF MSHTMHST.H implementation */
struct IHTMLDocument2;
struct IHTMLElement;
struct IMarkupPointer;
class wxFSFile;
class ClassFactory;
class wxIEContainer;
class DocHostUIHandler;
class wxFindPointers;
class WXDLLIMPEXP_WEBVIEW wxWebViewIE : public wxWebView
{
@@ -320,6 +323,9 @@ public:
virtual void Undo();
virtual void Redo();
//Find function
virtual long Find(const wxString& text, int flags = wxWEB_VIEW_FIND_DEFAULT);
//Editing functions
virtual void SetEditable(bool enable = true);
virtual bool IsEditable() const;
@@ -384,10 +390,21 @@ private:
bool m_historyLoadingFromList;
bool m_historyEnabled;
//Generic helper functions for IHtmlDocument commands
//We store find flag, results and position.
wxVector<wxFindPointers> m_findPointers;
int m_findFlags;
wxString m_findText;
int m_findPosition;
//Generic helper functions
bool CanExecCommand(wxString command) const;
void ExecCommand(wxString command);
wxCOMPtr<IHTMLDocument2> GetDocument() const;
bool IsElementVisible(IHTMLElement* elm);
//Find helper functions.
void FindInternal(const wxString& text, int flags, int internal_flag);
long FindNext(int direction = 1);
void FindClear();
//Toggles control features see INTERNETFEATURELIST for values.
bool EnableControlFeature(long flag, bool enable = true);
@@ -517,6 +534,18 @@ public:
DECLARE_IUNKNOWN_METHODS;
};
class wxFindPointers
{
public:
wxFindPointers(IMarkupPointer *ptrBegin, IMarkupPointer *ptrEnd)
{
begin = ptrBegin;
end = ptrEnd;
}
//The two markup pointers.
IMarkupPointer *begin, *end;
};
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
#endif // wxWebViewIE_H

View File

@@ -86,6 +86,9 @@ public:
virtual void Undo();
virtual void Redo();
//Find function
virtual long Find(const wxString& text, int flags = wxWEB_VIEW_FIND_DEFAULT) { return wxNOT_FOUND; };
//Clipboard functions
virtual bool CanCut() const { return true; }
virtual bool CanCopy() const { return true; }

View File

@@ -68,6 +68,16 @@ enum wxWebViewReloadFlags
wxWEB_VIEW_RELOAD_NO_CACHE
};
enum wxWebViewFindFlags
{
wxWEB_VIEW_FIND_WRAP = 0x0001,
wxWEB_VIEW_FIND_ENTIRE_WORD = 0x0002,
wxWEB_VIEW_FIND_MATCH_CASE = 0x0004,
wxWEB_VIEW_FIND_HIGHLIGHT_RESULT = 0x0008,
wxWEB_VIEW_FIND_BACKWARDS = 0x0010,
wxWEB_VIEW_FIND_DEFAULT = 0
};
enum wxWebViewBackend
{
wxWEB_VIEW_BACKEND_DEFAULT,
@@ -181,6 +191,8 @@ public:
//Get the pointer to the underlying native engine.
virtual void* GetNativeBackend() const = 0;
//Find function
virtual long Find(const wxString& text, int flags = wxWEB_VIEW_FIND_DEFAULT) = 0;
protected:
virtual void DoSetPage(const wxString& html, const wxString& baseUrl) = 0;