]>
Commit | Line | Data |
---|---|---|
2c990ba6 KO |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: webkit.h | |
3 | // Purpose: wxWebKitCtrl - embeddable web kit control | |
4 | // Author: Jethro Grassie / Kevin Ollivier | |
5 | // Modified by: | |
6 | // Created: 2004-4-16 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Jethro Grassie / Kevin Ollivier | |
77ffb593 | 9 | // Licence: wxWidgets licence |
2c990ba6 KO |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_WEBKIT_H | |
13 | #define _WX_WEBKIT_H | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "webkit.h" | |
17 | #endif | |
18 | ||
19 | #if !defined(__WXMAC__) && !defined(__WXCOCOA__) | |
20 | #error "wxWebKitCtrl not implemented for this platform" | |
21 | #endif | |
22 | ||
23 | #ifdef __WXCOCOA | |
24 | #include <WebKit/WebKit.h> | |
25 | #endif | |
26 | #include "wx/control.h" | |
27 | ||
28 | // ---------------------------------------------------------------------------- | |
29 | // Web Kit Control | |
30 | // ---------------------------------------------------------------------------- | |
31 | ||
32 | class wxWebKitCtrl : public wxControl | |
33 | { | |
34 | public: | |
35 | DECLARE_DYNAMIC_CLASS(wxWebKitCtrl) | |
36 | ||
37 | wxWebKitCtrl() {}; | |
38 | wxWebKitCtrl(wxWindow *parent, | |
39 | wxWindowID winID, | |
40 | const wxString& strURL, | |
41 | const wxPoint& pos = wxDefaultPosition, | |
42 | const wxSize& size = wxDefaultSize, long style = 0, | |
43 | const wxValidator& validator = wxDefaultValidator, | |
44 | const wxString& name = wxString("default_webkit_name")) | |
45 | { | |
46 | Create(parent, winID, strURL, pos, size, style, validator, name); | |
47 | }; | |
48 | bool Create(wxWindow *parent, | |
49 | wxWindowID winID, | |
50 | const wxString& strURL, | |
51 | const wxPoint& pos = wxDefaultPosition, | |
52 | const wxSize& size = wxDefaultSize, long style = 0, | |
53 | const wxValidator& validator = wxDefaultValidator, | |
54 | const wxString& name = wxString("default_webkit_name")); | |
55 | virtual ~wxWebKitCtrl(); | |
56 | ||
57 | void LoadURL(const wxString &url); | |
58 | ||
59 | bool CanGoBack(); | |
60 | bool CanGoForward(); | |
61 | bool GoBack(); | |
62 | bool GoForward(); | |
63 | void Reload(); | |
64 | void Stop(); | |
65 | bool CanGetPageSource(); | |
66 | wxString GetPageSource(); | |
67 | void SetPageSource(wxString& source, const wxString& baseUrl = wxString("")); | |
68 | ||
69 | //we need to resize the webview when the control size changes | |
70 | //void OnSize(wxSizeEvent &event); | |
71 | protected: | |
72 | DECLARE_EVENT_TABLE() | |
73 | ||
74 | private: | |
75 | wxWindow *m_parent; | |
76 | wxWindowID m_windowID; | |
77 | wxString m_currentURL; | |
78 | wxString m_pageTitle; | |
79 | void* m_webView; | |
80 | //It should be WebView, but WebView is Cocoa only, so any class which included | |
81 | //this header would have to link to Cocoa, so for now use void* instead. | |
82 | }; | |
83 | ||
84 | // ---------------------------------------------------------------------------- | |
85 | // Web Kit Events | |
86 | // ---------------------------------------------------------------------------- | |
87 | ||
88 | enum { | |
89 | wxWEBKIT_STATE_START = 1, | |
90 | wxWEBKIT_STATE_NEGOTIATING = 2, | |
91 | wxWEBKIT_STATE_REDIRECTING = 4, | |
92 | wxWEBKIT_STATE_TRANSFERRING = 8, | |
93 | wxWEBKIT_STATE_STOP = 16, | |
94 | wxWEBKIT_STATE_FAILED = 32 | |
95 | }; | |
96 | ||
97 | class wxWebKitStateChangedEvent : public wxCommandEvent | |
98 | { | |
99 | DECLARE_DYNAMIC_CLASS( wxWebKitStateChangedEvent ) | |
100 | ||
101 | public: | |
102 | int GetState() { return m_state; } | |
103 | void SetState(const int state) { m_state = state; } | |
104 | wxString GetURL() { return m_url; } | |
105 | void SetURL(const wxString& url) { m_url = url; } | |
106 | ||
107 | wxWebKitStateChangedEvent( wxWindow* win = (wxWindow*) NULL ); | |
108 | wxEvent *Clone(void) const { return new wxWebKitStateChangedEvent(*this); } | |
109 | ||
110 | protected: | |
111 | int m_state; | |
112 | wxString m_url; | |
113 | }; | |
114 | ||
115 | typedef void (wxEvtHandler::*wxWebKitStateChangedEventFunction)(wxWebKitStateChangedEvent&); | |
116 | ||
117 | BEGIN_DECLARE_EVENT_TYPES() | |
118 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_WEBKIT_STATE_CHANGED, -1) | |
119 | END_DECLARE_EVENT_TYPES() | |
120 | ||
121 | #define EVT_WEBKIT_STATE_CHANGED(func) \ | |
122 | DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBKIT_STATE_CHANGED, \ | |
123 | -1, \ | |
124 | -1, \ | |
125 | (wxObjectEventFunction) \ | |
126 | (wxWebKitStateChangedEventFunction) & func, \ | |
127 | (wxObject *) NULL ), | |
128 | ||
129 | #endif // _WX_WEBKIT_H_ |