]>
Commit | Line | Data |
---|---|---|
5526e819 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: htmlwin.cpp | |
3 | // Purpose: wxHtmlWindow class for parsing & displaying HTML (implementation) | |
4 | // Author: Vaclav Slavik | |
69941f05 | 5 | // RCS-ID: $Id$ |
5526e819 | 6 | // Copyright: (c) 1999 Vaclav Slavik |
65571936 | 7 | // Licence: wxWindows licence |
5526e819 VS |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | ||
14f355c2 | 11 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
892aeafc VS |
12 | #pragma implementation "htmlwin.h" |
13 | #pragma implementation "htmlproc.h" | |
5526e819 VS |
14 | #endif |
15 | ||
3096bd2f | 16 | #include "wx/wxprec.h" |
5526e819 VS |
17 | |
18 | #include "wx/defs.h" | |
f6bcfd97 | 19 | #if wxUSE_HTML && wxUSE_STREAMS |
5526e819 | 20 | |
2b5f62a0 | 21 | #ifdef __BORLANDC__ |
5526e819 VS |
22 | #pragma hdrstop |
23 | #endif | |
24 | ||
25 | #ifndef WXPRECOMP | |
04dbb646 VZ |
26 | #include "wx/log.h" |
27 | #include "wx/intl.h" | |
28 | #include "wx/dcclient.h" | |
29 | #include "wx/frame.h" | |
5526e819 VS |
30 | #endif |
31 | ||
69941f05 | 32 | #include "wx/html/htmlwin.h" |
892aeafc | 33 | #include "wx/html/htmlproc.h" |
892aeafc | 34 | #include "wx/list.h" |
e3774124 | 35 | #include "wx/clipbrd.h" |
2b2309a4 | 36 | #include "wx/dataobj.h" |
1338c59a VS |
37 | #include "wx/timer.h" |
38 | #include "wx/dcmemory.h" | |
7acd3625 | 39 | #include "wx/settings.h" |
04dbb646 VZ |
40 | |
41 | #include "wx/arrimpl.cpp" | |
892aeafc VS |
42 | #include "wx/listimpl.cpp" |
43 | ||
1338c59a | 44 | |
1338c59a VS |
45 | #if wxUSE_CLIPBOARD |
46 | // ---------------------------------------------------------------------------- | |
47 | // wxHtmlWinAutoScrollTimer: the timer used to generate a stream of scroll | |
48 | // events when a captured mouse is held outside the window | |
49 | // ---------------------------------------------------------------------------- | |
50 | ||
51 | class wxHtmlWinAutoScrollTimer : public wxTimer | |
52 | { | |
53 | public: | |
54 | wxHtmlWinAutoScrollTimer(wxScrolledWindow *win, | |
55 | wxEventType eventTypeToSend, | |
56 | int pos, int orient) | |
57 | { | |
58 | m_win = win; | |
59 | m_eventType = eventTypeToSend; | |
60 | m_pos = pos; | |
61 | m_orient = orient; | |
62 | } | |
63 | ||
64 | virtual void Notify(); | |
65 | ||
66 | private: | |
67 | wxScrolledWindow *m_win; | |
68 | wxEventType m_eventType; | |
69 | int m_pos, | |
70 | m_orient; | |
71 | ||
72 | DECLARE_NO_COPY_CLASS(wxHtmlWinAutoScrollTimer) | |
73 | }; | |
74 | ||
75 | void wxHtmlWinAutoScrollTimer::Notify() | |
76 | { | |
77 | // only do all this as long as the window is capturing the mouse | |
78 | if ( wxWindow::GetCapture() != m_win ) | |
79 | { | |
80 | Stop(); | |
81 | } | |
82 | else // we still capture the mouse, continue generating events | |
83 | { | |
84 | // first scroll the window if we are allowed to do it | |
85 | wxScrollWinEvent event1(m_eventType, m_pos, m_orient); | |
86 | event1.SetEventObject(m_win); | |
87 | if ( m_win->GetEventHandler()->ProcessEvent(event1) ) | |
88 | { | |
89 | // and then send a pseudo mouse-move event to refresh the selection | |
90 | wxMouseEvent event2(wxEVT_MOTION); | |
91 | wxGetMousePosition(&event2.m_x, &event2.m_y); | |
92 | ||
93 | // the mouse event coordinates should be client, not screen as | |
94 | // returned by wxGetMousePosition | |
95 | wxWindow *parentTop = m_win; | |
96 | while ( parentTop->GetParent() ) | |
97 | parentTop = parentTop->GetParent(); | |
98 | wxPoint ptOrig = parentTop->GetPosition(); | |
99 | event2.m_x -= ptOrig.x; | |
100 | event2.m_y -= ptOrig.y; | |
101 | ||
102 | event2.SetEventObject(m_win); | |
103 | ||
104 | // FIXME: we don't fill in the other members - ok? | |
105 | m_win->GetEventHandler()->ProcessEvent(event2); | |
106 | } | |
107 | else // can't scroll further, stop | |
108 | { | |
109 | Stop(); | |
110 | } | |
111 | } | |
112 | } | |
d659d703 VZ |
113 | |
114 | #endif // wxUSE_CLIPBOARD | |
1338c59a VS |
115 | |
116 | ||
117 | ||
892aeafc VS |
118 | //----------------------------------------------------------------------------- |
119 | // wxHtmlHistoryItem | |
120 | //----------------------------------------------------------------------------- | |
121 | ||
122 | // item of history list | |
4460b6c4 | 123 | class WXDLLIMPEXP_HTML wxHtmlHistoryItem |
892aeafc VS |
124 | { |
125 | public: | |
126 | wxHtmlHistoryItem(const wxString& p, const wxString& a) {m_Page = p, m_Anchor = a, m_Pos = 0;} | |
127 | int GetPos() const {return m_Pos;} | |
128 | void SetPos(int p) {m_Pos = p;} | |
129 | const wxString& GetPage() const {return m_Page;} | |
130 | const wxString& GetAnchor() const {return m_Anchor;} | |
131 | ||
132 | private: | |
133 | wxString m_Page; | |
134 | wxString m_Anchor; | |
135 | int m_Pos; | |
136 | }; | |
5526e819 | 137 | |
5526e819 VS |
138 | |
139 | //----------------------------------------------------------------------------- | |
892aeafc | 140 | // our private arrays: |
5526e819 VS |
141 | //----------------------------------------------------------------------------- |
142 | ||
892aeafc VS |
143 | WX_DECLARE_OBJARRAY(wxHtmlHistoryItem, wxHtmlHistoryArray); |
144 | WX_DEFINE_OBJARRAY(wxHtmlHistoryArray); | |
5526e819 | 145 | |
892aeafc VS |
146 | WX_DECLARE_LIST(wxHtmlProcessor, wxHtmlProcessorList); |
147 | WX_DEFINE_LIST(wxHtmlProcessorList); | |
5526e819 | 148 | |
892aeafc VS |
149 | //----------------------------------------------------------------------------- |
150 | // wxHtmlWindow | |
151 | //----------------------------------------------------------------------------- | |
5526e819 VS |
152 | |
153 | ||
4f417130 | 154 | void wxHtmlWindow::Init() |
5526e819 | 155 | { |
d1da8872 | 156 | m_tmpMouseMoved = false; |
846914d1 | 157 | m_tmpLastLink = NULL; |
f6010d8f | 158 | m_tmpLastCell = NULL; |
89de9af3 | 159 | m_tmpCanDrawLocks = 0; |
5526e819 | 160 | m_FS = new wxFileSystem(); |
67a99992 | 161 | #if wxUSE_STATUSBAR |
5526e819 | 162 | m_RelatedStatusBar = -1; |
67a99992 | 163 | #endif // wxUSE_STATUSBAR |
5526e819 | 164 | m_RelatedFrame = NULL; |
892aeafc | 165 | m_TitleFormat = wxT("%s"); |
d5db80c2 | 166 | m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString; |
5526e819 VS |
167 | m_Cell = NULL; |
168 | m_Parser = new wxHtmlWinParser(this); | |
4f9297b0 | 169 | m_Parser->SetFS(m_FS); |
5526e819 | 170 | m_HistoryPos = -1; |
d1da8872 | 171 | m_HistoryOn = true; |
892aeafc VS |
172 | m_History = new wxHtmlHistoryArray; |
173 | m_Processors = NULL; | |
4f417130 VS |
174 | m_Style = 0; |
175 | SetBorders(10); | |
adf2eb2d VS |
176 | m_selection = NULL; |
177 | m_makingSelection = false; | |
1338c59a VS |
178 | #if wxUSE_CLIPBOARD |
179 | m_timerAutoScroll = NULL; | |
6ce51985 | 180 | m_lastDoubleClick = 0; |
d659d703 | 181 | #endif // wxUSE_CLIPBOARD |
1338c59a | 182 | m_backBuffer = NULL; |
518ba663 | 183 | m_eraseBgInOnPaint = false; |
b3c03420 | 184 | m_tmpSelFromCell = NULL; |
4f417130 VS |
185 | } |
186 | ||
790dbce3 | 187 | bool wxHtmlWindow::Create(wxWindow *parent, wxWindowID id, |
4f417130 | 188 | const wxPoint& pos, const wxSize& size, |
790dbce3 | 189 | long style, const wxString& name) |
4f417130 | 190 | { |
790dbce3 | 191 | if (!wxScrolledWindow::Create(parent, id, pos, size, |
2a536376 VS |
192 | style | wxVSCROLL | wxHSCROLL, |
193 | name)) | |
d1da8872 | 194 | return false; |
4f417130 | 195 | |
a547ebff | 196 | m_Style = style; |
4f9297b0 | 197 | SetPage(wxT("<html><body></body></html>")); |
d1da8872 | 198 | return true; |
5526e819 VS |
199 | } |
200 | ||
201 | ||
5526e819 VS |
202 | wxHtmlWindow::~wxHtmlWindow() |
203 | { | |
1338c59a VS |
204 | #if wxUSE_CLIPBOARD |
205 | StopAutoScrolling(); | |
d659d703 | 206 | #endif // wxUSE_CLIPBOARD |
5526e819 VS |
207 | HistoryClear(); |
208 | ||
689c4829 VZ |
209 | delete m_selection; |
210 | ||
211 | delete m_Cell; | |
5526e819 | 212 | |
d80096a2 VZ |
213 | if ( m_Processors ) |
214 | { | |
215 | WX_CLEAR_LIST(wxHtmlProcessorList, *m_Processors); | |
216 | } | |
222ed1d6 | 217 | |
5526e819 VS |
218 | delete m_Parser; |
219 | delete m_FS; | |
892aeafc VS |
220 | delete m_History; |
221 | delete m_Processors; | |
1338c59a | 222 | delete m_backBuffer; |
5526e819 VS |
223 | } |
224 | ||
225 | ||
226 | ||
227 | void wxHtmlWindow::SetRelatedFrame(wxFrame* frame, const wxString& format) | |
228 | { | |
229 | m_RelatedFrame = frame; | |
230 | m_TitleFormat = format; | |
231 | } | |
232 | ||
233 | ||
234 | ||
67a99992 | 235 | #if wxUSE_STATUSBAR |
5526e819 VS |
236 | void wxHtmlWindow::SetRelatedStatusBar(int bar) |
237 | { | |
238 | m_RelatedStatusBar = bar; | |
239 | } | |
67a99992 | 240 | #endif // wxUSE_STATUSBAR |
269e8200 RD |
241 | |
242 | ||
243 | ||
8eb2940f | 244 | void wxHtmlWindow::SetFonts(wxString normal_face, wxString fixed_face, const int *sizes) |
5526e819 | 245 | { |
d5db80c2 VS |
246 | wxString op = m_OpenedPage; |
247 | ||
4f9297b0 | 248 | m_Parser->SetFonts(normal_face, fixed_face, sizes); |
892aeafc | 249 | // fonts changed => contents invalid, so reload the page: |
bfb9ee96 | 250 | SetPage(wxT("<html><body></body></html>")); |
10e5c7ea VS |
251 | if (!op.empty()) |
252 | LoadPage(op); | |
5526e819 VS |
253 | } |
254 | ||
10e5c7ea VS |
255 | void wxHtmlWindow::SetStandardFonts(int size, |
256 | const wxString& normal_face, | |
257 | const wxString& fixed_face) | |
7acd3625 | 258 | { |
10e5c7ea VS |
259 | wxString op = m_OpenedPage; |
260 | ||
261 | m_Parser->SetStandardFonts(size, normal_face, fixed_face); | |
262 | // fonts changed => contents invalid, so reload the page: | |
263 | SetPage(wxT("<html><body></body></html>")); | |
264 | if (!op.empty()) | |
265 | LoadPage(op); | |
7acd3625 | 266 | } |
5526e819 VS |
267 | |
268 | ||
269 | bool wxHtmlWindow::SetPage(const wxString& source) | |
270 | { | |
892aeafc VS |
271 | wxString newsrc(source); |
272 | ||
adf2eb2d VS |
273 | wxDELETE(m_selection); |
274 | ||
b3c03420 VS |
275 | // we will soon delete all the cells, so clear pointers to them: |
276 | m_tmpSelFromCell = NULL; | |
277 | ||
892aeafc | 278 | // pass HTML through registered processors: |
960ba969 | 279 | if (m_Processors || m_GlobalProcessors) |
892aeafc | 280 | { |
222ed1d6 | 281 | wxHtmlProcessorList::compatibility_iterator nodeL, nodeG; |
960ba969 | 282 | int prL, prG; |
892aeafc | 283 | |
222ed1d6 MB |
284 | nodeL = (m_Processors) ? m_Processors->GetFirst() : wxHtmlProcessorList::compatibility_iterator(); |
285 | nodeG = (m_GlobalProcessors) ? m_GlobalProcessors->GetFirst() : wxHtmlProcessorList::compatibility_iterator(); | |
960ba969 VS |
286 | |
287 | // VS: there are two lists, global and local, both of them sorted by | |
e421922f | 288 | // priority. Since we have to go through _both_ lists with |
960ba969 VS |
289 | // decreasing priority, we "merge-sort" the lists on-line by |
290 | // processing that one of the two heads that has higher priority | |
291 | // in every iteration | |
292 | while (nodeL || nodeG) | |
892aeafc VS |
293 | { |
294 | prL = (nodeL) ? nodeL->GetData()->GetPriority() : -1; | |
960ba969 VS |
295 | prG = (nodeG) ? nodeG->GetData()->GetPriority() : -1; |
296 | if (prL > prG) | |
892aeafc | 297 | { |
73348d09 VS |
298 | if (nodeL->GetData()->IsEnabled()) |
299 | newsrc = nodeL->GetData()->Process(newsrc); | |
892aeafc VS |
300 | nodeL = nodeL->GetNext(); |
301 | } | |
960ba969 | 302 | else // prL <= prG |
892aeafc | 303 | { |
73348d09 VS |
304 | if (nodeG->GetData()->IsEnabled()) |
305 | newsrc = nodeG->GetData()->Process(newsrc); | |
960ba969 | 306 | nodeG = nodeG->GetNext(); |
892aeafc VS |
307 | } |
308 | } | |
309 | } | |
5526e819 | 310 | |
892aeafc VS |
311 | // ...and run the parser on it: |
312 | wxClientDC *dc = new wxClientDC(this); | |
4f9297b0 | 313 | dc->SetMapMode(wxMM_TEXT); |
5526e819 | 314 | SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF)); |
97e490f8 | 315 | SetBackgroundImage(wxNullBitmap); |
d5db80c2 | 316 | m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString; |
4f9297b0 | 317 | m_Parser->SetDC(dc); |
33ac7e6f | 318 | if (m_Cell) |
4f9297b0 | 319 | { |
89de9af3 VS |
320 | delete m_Cell; |
321 | m_Cell = NULL; | |
f61815af | 322 | } |
892aeafc | 323 | m_Cell = (wxHtmlContainerCell*) m_Parser->Parse(newsrc); |
5526e819 | 324 | delete dc; |
4f9297b0 VS |
325 | m_Cell->SetIndent(m_Borders, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS); |
326 | m_Cell->SetAlignHor(wxHTML_ALIGN_CENTER); | |
5526e819 | 327 | CreateLayout(); |
bfb9ee96 | 328 | if (m_tmpCanDrawLocks == 0) |
892aeafc | 329 | Refresh(); |
d1da8872 | 330 | return true; |
5526e819 VS |
331 | } |
332 | ||
39029898 VS |
333 | bool wxHtmlWindow::AppendToPage(const wxString& source) |
334 | { | |
335 | return SetPage(*(GetParser()->GetSource()) + source); | |
336 | } | |
5526e819 VS |
337 | |
338 | bool wxHtmlWindow::LoadPage(const wxString& location) | |
339 | { | |
1ccabb81 | 340 | wxBusyCursor busyCursor; |
790dbce3 | 341 | |
5526e819 VS |
342 | wxFSFile *f; |
343 | bool rt_val; | |
d1da8872 | 344 | bool needs_refresh = false; |
33ac7e6f | 345 | |
89de9af3 | 346 | m_tmpCanDrawLocks++; |
e421922f | 347 | if (m_HistoryOn && (m_HistoryPos != -1)) |
4f9297b0 | 348 | { |
960ba969 | 349 | // store scroll position into history item: |
5526e819 | 350 | int x, y; |
e421922f | 351 | GetViewStart(&x, &y); |
892aeafc | 352 | (*m_History)[m_HistoryPos].SetPos(y); |
5526e819 VS |
353 | } |
354 | ||
e421922f | 355 | if (location[0] == wxT('#')) |
4f9297b0 | 356 | { |
960ba969 | 357 | // local anchor: |
5526e819 | 358 | wxString anch = location.Mid(1) /*1 to end*/; |
89de9af3 | 359 | m_tmpCanDrawLocks--; |
5526e819 | 360 | rt_val = ScrollToAnchor(anch); |
fc7dfaf8 VS |
361 | m_tmpCanDrawLocks++; |
362 | } | |
33ac7e6f | 363 | else if (location.Find(wxT('#')) != wxNOT_FOUND && location.BeforeFirst(wxT('#')) == m_OpenedPage) |
4f9297b0 | 364 | { |
fc7dfaf8 VS |
365 | wxString anch = location.AfterFirst(wxT('#')); |
366 | m_tmpCanDrawLocks--; | |
367 | rt_val = ScrollToAnchor(anch); | |
368 | m_tmpCanDrawLocks++; | |
369 | } | |
33ac7e6f KB |
370 | else if (location.Find(wxT('#')) != wxNOT_FOUND && |
371 | (m_FS->GetPath() + location.BeforeFirst(wxT('#'))) == m_OpenedPage) | |
e421922f | 372 | { |
fc7dfaf8 VS |
373 | wxString anch = location.AfterFirst(wxT('#')); |
374 | m_tmpCanDrawLocks--; | |
375 | rt_val = ScrollToAnchor(anch); | |
376 | m_tmpCanDrawLocks++; | |
5526e819 VS |
377 | } |
378 | ||
33ac7e6f | 379 | else |
4f9297b0 | 380 | { |
67a99992 WS |
381 | needs_refresh = true; |
382 | #if wxUSE_STATUSBAR | |
5526e819 | 383 | // load&display it: |
33ac7e6f | 384 | if (m_RelatedStatusBar != -1) |
e421922f | 385 | { |
4f9297b0 | 386 | m_RelatedFrame->SetStatusText(_("Connecting..."), m_RelatedStatusBar); |
67a99992 | 387 | Refresh(false); |
5526e819 | 388 | } |
67a99992 | 389 | #endif // wxUSE_STATUSBAR |
790dbce3 | 390 | |
6cc4e6b8 | 391 | f = m_Parser->OpenURL(wxHTML_URL_PAGE, location); |
33ac7e6f | 392 | |
7cb9cf89 VS |
393 | // try to interpret 'location' as filename instead of URL: |
394 | if (f == NULL) | |
395 | { | |
396 | wxFileName fn(location); | |
397 | wxString location2 = wxFileSystem::FileNameToURL(fn); | |
398 | f = m_Parser->OpenURL(wxHTML_URL_PAGE, location2); | |
399 | } | |
400 | ||
33ac7e6f | 401 | if (f == NULL) |
e421922f | 402 | { |
f6bcfd97 | 403 | wxLogError(_("Unable to open requested HTML document: %s"), location.c_str()); |
89de9af3 | 404 | m_tmpCanDrawLocks--; |
67a99992 | 405 | return false; |
5526e819 VS |
406 | } |
407 | ||
33ac7e6f | 408 | else |
e421922f | 409 | { |
222ed1d6 | 410 | wxList::compatibility_iterator node; |
5526e819 VS |
411 | wxString src = wxEmptyString; |
412 | ||
67a99992 | 413 | #if wxUSE_STATUSBAR |
33ac7e6f | 414 | if (m_RelatedStatusBar != -1) |
e421922f | 415 | { |
5526e819 | 416 | wxString msg = _("Loading : ") + location; |
4f9297b0 | 417 | m_RelatedFrame->SetStatusText(msg, m_RelatedStatusBar); |
67a99992 | 418 | Refresh(false); |
5526e819 | 419 | } |
67a99992 | 420 | #endif // wxUSE_STATUSBAR |
5526e819 VS |
421 | |
422 | node = m_Filters.GetFirst(); | |
4f9297b0 | 423 | while (node) |
e421922f | 424 | { |
4f9297b0 VS |
425 | wxHtmlFilter *h = (wxHtmlFilter*) node->GetData(); |
426 | if (h->CanRead(*f)) | |
e421922f | 427 | { |
4f9297b0 | 428 | src = h->ReadFile(*f); |
5526e819 VS |
429 | break; |
430 | } | |
4f9297b0 | 431 | node = node->GetNext(); |
5526e819 | 432 | } |
33ac7e6f | 433 | if (src == wxEmptyString) |
e421922f | 434 | { |
89de9af3 | 435 | if (m_DefaultFilter == NULL) m_DefaultFilter = GetDefaultFilter(); |
4f9297b0 | 436 | src = m_DefaultFilter->ReadFile(*f); |
89de9af3 | 437 | } |
5526e819 | 438 | |
4f9297b0 | 439 | m_FS->ChangePathTo(f->GetLocation()); |
5526e819 | 440 | rt_val = SetPage(src); |
4f9297b0 | 441 | m_OpenedPage = f->GetLocation(); |
33ac7e6f | 442 | if (f->GetAnchor() != wxEmptyString) |
e421922f | 443 | { |
4f9297b0 | 444 | ScrollToAnchor(f->GetAnchor()); |
5526e819 VS |
445 | } |
446 | ||
447 | delete f; | |
448 | ||
67a99992 | 449 | #if wxUSE_STATUSBAR |
d1da8872 | 450 | if (m_RelatedStatusBar != -1) |
67a99992 WS |
451 | m_RelatedFrame->SetStatusText(_("Done"), m_RelatedStatusBar); |
452 | #endif // wxUSE_STATUSBAR | |
5526e819 VS |
453 | } |
454 | } | |
455 | ||
4f9297b0 VS |
456 | if (m_HistoryOn) // add this page to history there: |
457 | { | |
892aeafc | 458 | int c = m_History->GetCount() - (m_HistoryPos + 1); |
5526e819 | 459 | |
0cb9cfb2 | 460 | if (m_HistoryPos < 0 || |
ee19c324 VS |
461 | (*m_History)[m_HistoryPos].GetPage() != m_OpenedPage || |
462 | (*m_History)[m_HistoryPos].GetAnchor() != m_OpenedAnchor) | |
463 | { | |
464 | m_HistoryPos++; | |
465 | for (int i = 0; i < c; i++) | |
b54e41c5 | 466 | m_History->RemoveAt(m_HistoryPos); |
ee19c324 VS |
467 | m_History->Add(new wxHtmlHistoryItem(m_OpenedPage, m_OpenedAnchor)); |
468 | } | |
5526e819 VS |
469 | } |
470 | ||
096824d7 VS |
471 | if (m_OpenedPageTitle == wxEmptyString) |
472 | OnSetTitle(wxFileNameFromPath(m_OpenedPage)); | |
fc7dfaf8 | 473 | |
33ac7e6f | 474 | if (needs_refresh) |
4f9297b0 | 475 | { |
fc7dfaf8 VS |
476 | m_tmpCanDrawLocks--; |
477 | Refresh(); | |
478 | } | |
479 | else | |
480 | m_tmpCanDrawLocks--; | |
481 | ||
5526e819 VS |
482 | return rt_val; |
483 | } | |
484 | ||
485 | ||
7cb9cf89 VS |
486 | bool wxHtmlWindow::LoadFile(const wxFileName& filename) |
487 | { | |
488 | wxString url = wxFileSystem::FileNameToURL(filename); | |
489 | return LoadPage(url); | |
490 | } | |
491 | ||
5526e819 VS |
492 | |
493 | bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor) | |
494 | { | |
4f9297b0 | 495 | const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor); |
f3c82859 VS |
496 | if (!c) |
497 | { | |
f6bcfd97 | 498 | wxLogWarning(_("HTML anchor %s does not exist."), anchor.c_str()); |
d1da8872 | 499 | return false; |
f3c82859 | 500 | } |
33ac7e6f | 501 | else |
4f9297b0 | 502 | { |
5526e819 | 503 | int y; |
269e8200 | 504 | |
4f9297b0 | 505 | for (y = 0; c != NULL; c = c->GetParent()) y += c->GetPosY(); |
efba2b89 | 506 | Scroll(-1, y / wxHTML_SCROLL_STEP); |
5526e819 | 507 | m_OpenedAnchor = anchor; |
d1da8872 | 508 | return true; |
5526e819 VS |
509 | } |
510 | } | |
511 | ||
512 | ||
d5db80c2 | 513 | void wxHtmlWindow::OnSetTitle(const wxString& title) |
5526e819 | 514 | { |
33ac7e6f | 515 | if (m_RelatedFrame) |
4f9297b0 | 516 | { |
5526e819 VS |
517 | wxString tit; |
518 | tit.Printf(m_TitleFormat, title.c_str()); | |
4f9297b0 | 519 | m_RelatedFrame->SetTitle(tit); |
5526e819 | 520 | } |
d5db80c2 | 521 | m_OpenedPageTitle = title; |
5526e819 VS |
522 | } |
523 | ||
524 | ||
525 | ||
526 | ||
527 | ||
528 | void wxHtmlWindow::CreateLayout() | |
529 | { | |
530 | int ClientWidth, ClientHeight; | |
531 | ||
532 | if (!m_Cell) return; | |
a547ebff | 533 | |
33ac7e6f | 534 | if (m_Style & wxHW_SCROLLBAR_NEVER) |
4f9297b0 VS |
535 | { |
536 | SetScrollbars(wxHTML_SCROLL_STEP, 1, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, 0); // always off | |
a547ebff | 537 | GetClientSize(&ClientWidth, &ClientHeight); |
4f9297b0 | 538 | m_Cell->Layout(ClientWidth); |
a547ebff VS |
539 | } |
540 | ||
541 | else { | |
542 | GetClientSize(&ClientWidth, &ClientHeight); | |
4f9297b0 | 543 | m_Cell->Layout(ClientWidth); |
33ac7e6f | 544 | if (ClientHeight < m_Cell->GetHeight() + GetCharHeight()) |
e421922f | 545 | { |
f3bcfd9b VS |
546 | SetScrollbars( |
547 | wxHTML_SCROLL_STEP, wxHTML_SCROLL_STEP, | |
4f9297b0 VS |
548 | m_Cell->GetWidth() / wxHTML_SCROLL_STEP, |
549 | (m_Cell->GetHeight() + GetCharHeight()) / wxHTML_SCROLL_STEP | |
f3bcfd9b | 550 | /*cheat: top-level frag is always container*/); |
a547ebff | 551 | } |
4f9297b0 | 552 | else /* we fit into window, no need for scrollbars */ |
e421922f | 553 | { |
4f9297b0 | 554 | SetScrollbars(wxHTML_SCROLL_STEP, 1, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, 0); // disable... |
89de9af3 | 555 | GetClientSize(&ClientWidth, &ClientHeight); |
4f9297b0 | 556 | m_Cell->Layout(ClientWidth); // ...and relayout |
89de9af3 | 557 | } |
a547ebff | 558 | } |
5526e819 VS |
559 | } |
560 | ||
269e8200 | 561 | |
5526e819 VS |
562 | |
563 | void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path) | |
564 | { | |
565 | wxString oldpath; | |
566 | wxString tmp; | |
d5db80c2 VS |
567 | int p_fontsizes[7]; |
568 | wxString p_fff, p_ffn; | |
5526e819 | 569 | |
33ac7e6f | 570 | if (path != wxEmptyString) |
4f9297b0 VS |
571 | { |
572 | oldpath = cfg->GetPath(); | |
573 | cfg->SetPath(path); | |
5526e819 VS |
574 | } |
575 | ||
892aeafc VS |
576 | m_Borders = cfg->Read(wxT("wxHtmlWindow/Borders"), m_Borders); |
577 | p_fff = cfg->Read(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser->m_FontFaceFixed); | |
578 | p_ffn = cfg->Read(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser->m_FontFaceNormal); | |
bfb9ee96 | 579 | for (int i = 0; i < 7; i++) |
4f9297b0 | 580 | { |
66a77a74 | 581 | tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i); |
4f9297b0 | 582 | p_fontsizes[i] = cfg->Read(tmp, m_Parser->m_FontsSizes[i]); |
5526e819 | 583 | } |
8eb2940f | 584 | SetFonts(p_ffn, p_fff, p_fontsizes); |
5526e819 VS |
585 | |
586 | if (path != wxEmptyString) | |
4f9297b0 | 587 | cfg->SetPath(oldpath); |
5526e819 VS |
588 | } |
589 | ||
590 | ||
591 | ||
592 | void wxHtmlWindow::WriteCustomization(wxConfigBase *cfg, wxString path) | |
593 | { | |
594 | wxString oldpath; | |
595 | wxString tmp; | |
596 | ||
33ac7e6f | 597 | if (path != wxEmptyString) |
4f9297b0 VS |
598 | { |
599 | oldpath = cfg->GetPath(); | |
600 | cfg->SetPath(path); | |
5526e819 VS |
601 | } |
602 | ||
892aeafc VS |
603 | cfg->Write(wxT("wxHtmlWindow/Borders"), (long) m_Borders); |
604 | cfg->Write(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser->m_FontFaceFixed); | |
605 | cfg->Write(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser->m_FontFaceNormal); | |
bfb9ee96 | 606 | for (int i = 0; i < 7; i++) |
4f9297b0 | 607 | { |
66a77a74 | 608 | tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i); |
4f9297b0 | 609 | cfg->Write(tmp, (long) m_Parser->m_FontsSizes[i]); |
5526e819 VS |
610 | } |
611 | ||
612 | if (path != wxEmptyString) | |
4f9297b0 | 613 | cfg->SetPath(oldpath); |
5526e819 VS |
614 | } |
615 | ||
616 | ||
617 | ||
618 | bool wxHtmlWindow::HistoryBack() | |
619 | { | |
620 | wxString a, l; | |
621 | ||
d1da8872 | 622 | if (m_HistoryPos < 1) return false; |
5526e819 | 623 | |
bbda1088 VS |
624 | // store scroll position into history item: |
625 | int x, y; | |
e421922f | 626 | GetViewStart(&x, &y); |
892aeafc | 627 | (*m_History)[m_HistoryPos].SetPos(y); |
bbda1088 VS |
628 | |
629 | // go to previous position: | |
5526e819 VS |
630 | m_HistoryPos--; |
631 | ||
892aeafc VS |
632 | l = (*m_History)[m_HistoryPos].GetPage(); |
633 | a = (*m_History)[m_HistoryPos].GetAnchor(); | |
d1da8872 | 634 | m_HistoryOn = false; |
89de9af3 | 635 | m_tmpCanDrawLocks++; |
5526e819 | 636 | if (a == wxEmptyString) LoadPage(l); |
fc7dfaf8 | 637 | else LoadPage(l + wxT("#") + a); |
d1da8872 | 638 | m_HistoryOn = true; |
89de9af3 | 639 | m_tmpCanDrawLocks--; |
892aeafc | 640 | Scroll(0, (*m_History)[m_HistoryPos].GetPos()); |
5526e819 | 641 | Refresh(); |
d1da8872 | 642 | return true; |
5526e819 VS |
643 | } |
644 | ||
1b113a81 VS |
645 | bool wxHtmlWindow::HistoryCanBack() |
646 | { | |
d1da8872 WS |
647 | if (m_HistoryPos < 1) return false; |
648 | return true ; | |
1b113a81 | 649 | } |
5526e819 VS |
650 | |
651 | ||
652 | bool wxHtmlWindow::HistoryForward() | |
653 | { | |
654 | wxString a, l; | |
655 | ||
d1da8872 WS |
656 | if (m_HistoryPos == -1) return false; |
657 | if (m_HistoryPos >= (int)m_History->GetCount() - 1)return false; | |
5526e819 VS |
658 | |
659 | m_OpenedPage = wxEmptyString; // this will disable adding new entry into history in LoadPage() | |
660 | ||
661 | m_HistoryPos++; | |
892aeafc VS |
662 | l = (*m_History)[m_HistoryPos].GetPage(); |
663 | a = (*m_History)[m_HistoryPos].GetAnchor(); | |
d1da8872 | 664 | m_HistoryOn = false; |
89de9af3 | 665 | m_tmpCanDrawLocks++; |
5526e819 | 666 | if (a == wxEmptyString) LoadPage(l); |
fc7dfaf8 | 667 | else LoadPage(l + wxT("#") + a); |
d1da8872 | 668 | m_HistoryOn = true; |
89de9af3 | 669 | m_tmpCanDrawLocks--; |
892aeafc | 670 | Scroll(0, (*m_History)[m_HistoryPos].GetPos()); |
5526e819 | 671 | Refresh(); |
d1da8872 | 672 | return true; |
5526e819 VS |
673 | } |
674 | ||
1b113a81 VS |
675 | bool wxHtmlWindow::HistoryCanForward() |
676 | { | |
d1da8872 WS |
677 | if (m_HistoryPos == -1) return false; |
678 | if (m_HistoryPos >= (int)m_History->GetCount() - 1)return false; | |
679 | return true ; | |
1b113a81 | 680 | } |
5526e819 VS |
681 | |
682 | ||
683 | void wxHtmlWindow::HistoryClear() | |
684 | { | |
892aeafc | 685 | m_History->Empty(); |
5526e819 VS |
686 | m_HistoryPos = -1; |
687 | } | |
688 | ||
892aeafc VS |
689 | void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor) |
690 | { | |
691 | if (!m_Processors) | |
692 | { | |
693 | m_Processors = new wxHtmlProcessorList; | |
892aeafc | 694 | } |
222ed1d6 | 695 | wxHtmlProcessorList::compatibility_iterator node; |
bfb9ee96 | 696 | |
892aeafc VS |
697 | for (node = m_Processors->GetFirst(); node; node = node->GetNext()) |
698 | { | |
bfb9ee96 | 699 | if (processor->GetPriority() > node->GetData()->GetPriority()) |
892aeafc VS |
700 | { |
701 | m_Processors->Insert(node, processor); | |
960ba969 | 702 | return; |
892aeafc VS |
703 | } |
704 | } | |
960ba969 | 705 | m_Processors->Append(processor); |
892aeafc VS |
706 | } |
707 | ||
960ba969 | 708 | /*static */ void wxHtmlWindow::AddGlobalProcessor(wxHtmlProcessor *processor) |
892aeafc | 709 | { |
960ba969 | 710 | if (!m_GlobalProcessors) |
892aeafc | 711 | { |
960ba969 | 712 | m_GlobalProcessors = new wxHtmlProcessorList; |
892aeafc | 713 | } |
222ed1d6 | 714 | wxHtmlProcessorList::compatibility_iterator node; |
e421922f | 715 | |
960ba969 | 716 | for (node = m_GlobalProcessors->GetFirst(); node; node = node->GetNext()) |
892aeafc | 717 | { |
bfb9ee96 | 718 | if (processor->GetPriority() > node->GetData()->GetPriority()) |
892aeafc | 719 | { |
960ba969 VS |
720 | m_GlobalProcessors->Insert(node, processor); |
721 | return; | |
892aeafc VS |
722 | } |
723 | } | |
960ba969 | 724 | m_GlobalProcessors->Append(processor); |
892aeafc VS |
725 | } |
726 | ||
5526e819 VS |
727 | |
728 | ||
729 | wxList wxHtmlWindow::m_Filters; | |
a76015e6 | 730 | wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL; |
960ba969 | 731 | wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL; |
a76015e6 VS |
732 | |
733 | void wxHtmlWindow::CleanUpStatics() | |
734 | { | |
eeb029a9 | 735 | wxDELETE(m_DefaultFilter); |
222ed1d6 MB |
736 | WX_CLEAR_LIST(wxList, m_Filters); |
737 | if (m_GlobalProcessors) | |
738 | WX_CLEAR_LIST(wxHtmlProcessorList, *m_GlobalProcessors); | |
eeb029a9 | 739 | wxDELETE(m_GlobalProcessors); |
a76015e6 VS |
740 | } |
741 | ||
742 | ||
5526e819 VS |
743 | |
744 | void wxHtmlWindow::AddFilter(wxHtmlFilter *filter) | |
745 | { | |
5526e819 VS |
746 | m_Filters.Append(filter); |
747 | } | |
748 | ||
749 | ||
36c4ff4d VS |
750 | bool wxHtmlWindow::IsSelectionEnabled() const |
751 | { | |
752 | #if wxUSE_CLIPBOARD | |
753 | return !(m_Style & wxHW_NO_SELECTION); | |
754 | #else | |
755 | return false; | |
756 | #endif | |
757 | } | |
d659d703 | 758 | |
e3774124 | 759 | |
1338c59a | 760 | #if wxUSE_CLIPBOARD |
977b867e | 761 | wxString wxHtmlWindow::DoSelectionToText(wxHtmlSelection *sel) |
e3774124 | 762 | { |
977b867e | 763 | if ( !sel ) |
e3774124 VS |
764 | return wxEmptyString; |
765 | ||
f30e67db VS |
766 | wxClientDC dc(this); |
767 | ||
977b867e | 768 | const wxHtmlCell *end = sel->GetToCell(); |
e3774124 | 769 | wxString text; |
977b867e | 770 | wxHtmlTerminalCellsInterator i(sel->GetFromCell(), end); |
e3774124 VS |
771 | if ( i ) |
772 | { | |
977b867e | 773 | text << i->ConvertToText(sel); |
e3774124 VS |
774 | ++i; |
775 | } | |
776 | const wxHtmlCell *prev = *i; | |
777 | while ( i ) | |
778 | { | |
779 | if ( prev->GetParent() != i->GetParent() ) | |
780 | text << _T('\n'); | |
977b867e | 781 | text << i->ConvertToText(*i == end ? sel : NULL); |
e3774124 VS |
782 | prev = *i; |
783 | ++i; | |
784 | } | |
785 | return text; | |
786 | } | |
787 | ||
977b867e VS |
788 | wxString wxHtmlWindow::ToText() |
789 | { | |
790 | if (m_Cell) | |
791 | { | |
792 | wxHtmlSelection sel; | |
793 | sel.Set(m_Cell->GetFirstTerminal(), m_Cell->GetLastTerminal()); | |
794 | return DoSelectionToText(&sel); | |
795 | } | |
796 | else | |
797 | return wxEmptyString; | |
798 | } | |
799 | ||
d659d703 VZ |
800 | #endif // wxUSE_CLIPBOARD |
801 | ||
8feaa81f | 802 | bool wxHtmlWindow::CopySelection(ClipboardType t) |
e3774124 | 803 | { |
d659d703 | 804 | #if wxUSE_CLIPBOARD |
e3774124 VS |
805 | if ( m_selection ) |
806 | { | |
28b2ac5b | 807 | #if defined(__UNIX__) && !defined(__WXMAC__) |
e3774124 | 808 | wxTheClipboard->UsePrimarySelection(t == Primary); |
d659d703 VZ |
809 | #else // !__UNIX__ |
810 | // Primary selection exists only under X11, so don't do anything under | |
811 | // the other platforms when we try to access it | |
812 | // | |
813 | // TODO: this should be abstracted at wxClipboard level! | |
814 | if ( t == Primary ) | |
8feaa81f | 815 | return false; |
d659d703 VZ |
816 | #endif // __UNIX__/!__UNIX__ |
817 | ||
e3774124 VS |
818 | if ( wxTheClipboard->Open() ) |
819 | { | |
d659d703 | 820 | const wxString txt(SelectionToText()); |
e3774124 VS |
821 | wxTheClipboard->SetData(new wxTextDataObject(txt)); |
822 | wxTheClipboard->Close(); | |
823 | wxLogTrace(_T("wxhtmlselection"), | |
824 | _("Copied to clipboard:\"%s\""), txt.c_str()); | |
8feaa81f VZ |
825 | |
826 | return true; | |
e3774124 VS |
827 | } |
828 | } | |
d659d703 | 829 | #endif // wxUSE_CLIPBOARD |
8feaa81f VZ |
830 | |
831 | return false; | |
e3774124 | 832 | } |
5526e819 VS |
833 | |
834 | ||
0b2dadd3 | 835 | void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) |
5526e819 | 836 | { |
31d8b4ad VS |
837 | const wxMouseEvent *e = link.GetEvent(); |
838 | if (e == NULL || e->LeftUp()) | |
839 | LoadPage(link.GetHref()); | |
5526e819 VS |
840 | } |
841 | ||
f6010d8f VZ |
842 | void wxHtmlWindow::OnCellClicked(wxHtmlCell *cell, |
843 | wxCoord x, wxCoord y, | |
844 | const wxMouseEvent& event) | |
19193a2c | 845 | { |
f6010d8f | 846 | wxCHECK_RET( cell, _T("can't be called with NULL cell") ); |
5526e819 | 847 | |
f6010d8f VZ |
848 | cell->OnMouseClick(this, x, y, event); |
849 | } | |
850 | ||
851 | void wxHtmlWindow::OnCellMouseHover(wxHtmlCell * WXUNUSED(cell), | |
852 | wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) | |
853 | { | |
854 | // do nothing here | |
855 | } | |
5526e819 | 856 | |
12148be2 | 857 | void wxHtmlWindow::OnEraseBackground(wxEraseEvent& event) |
1338c59a | 858 | { |
97e490f8 VZ |
859 | if ( !m_bmpBg.Ok() ) |
860 | { | |
518ba663 VZ |
861 | // don't even skip the event, if we don't have a bg bitmap we're going |
862 | // to overwrite background in OnPaint() below anyhow, so letting the | |
863 | // default handling take place would only result in flicker, just set a | |
864 | // flag to erase the background below | |
865 | m_eraseBgInOnPaint = true; | |
97e490f8 VZ |
866 | return; |
867 | } | |
868 | ||
869 | wxDC& dc = *event.GetDC(); | |
870 | ||
871 | // if the image is not fully opaque, we have to erase the background before | |
872 | // drawing it, however avoid doing it for opaque images as this would just | |
873 | // result in extra flicker without any other effect as background is | |
874 | // completely covered anyhow | |
875 | if ( m_bmpBg.GetMask() ) | |
876 | { | |
877 | dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); | |
878 | dc.Clear(); | |
879 | } | |
880 | ||
881 | const wxSize sizeWin(GetClientSize()); | |
882 | const wxSize sizeBmp(m_bmpBg.GetWidth(), m_bmpBg.GetHeight()); | |
883 | for ( wxCoord x = 0; x < sizeWin.x; x += sizeBmp.x ) | |
884 | { | |
885 | for ( wxCoord y = 0; y < sizeWin.y; y += sizeBmp.y ) | |
886 | { | |
887 | dc.DrawBitmap(m_bmpBg, x, y, true /* use mask */); | |
888 | } | |
889 | } | |
1338c59a VS |
890 | } |
891 | ||
892 | void wxHtmlWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) | |
5526e819 | 893 | { |
1338c59a VS |
894 | wxPaintDC dc(this); |
895 | ||
518ba663 VZ |
896 | if (m_tmpCanDrawLocks > 0 || m_Cell == NULL) |
897 | return; | |
5526e819 | 898 | |
b835e9bf | 899 | int x, y; |
e421922f | 900 | GetViewStart(&x, &y); |
1338c59a VS |
901 | wxRect rect = GetUpdateRegion().GetBox(); |
902 | wxSize sz = GetSize(); | |
903 | ||
904 | wxMemoryDC dcm; | |
905 | if ( !m_backBuffer ) | |
906 | m_backBuffer = new wxBitmap(sz.x, sz.y); | |
d659d703 | 907 | dcm.SelectObject(*m_backBuffer); |
a03ae172 | 908 | |
518ba663 VZ |
909 | if ( m_eraseBgInOnPaint ) |
910 | { | |
911 | dcm.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); | |
912 | dcm.Clear(); | |
913 | ||
914 | m_eraseBgInOnPaint = false; | |
915 | } | |
916 | else // someone has already erased the background, keep it | |
917 | { | |
918 | // preserve the existing background, otherwise we'd erase anything the | |
919 | // user code had drawn in its EVT_ERASE_BACKGROUND handler when we do | |
920 | // the Blit back below | |
921 | dcm.Blit(0, rect.GetTop(), | |
922 | sz.x, rect.GetBottom() - rect.GetTop() + 1, | |
923 | &dc, | |
924 | 0, rect.GetTop()); | |
925 | } | |
a03ae172 | 926 | |
7f461f8a | 927 | PrepareDC(dcm); |
1338c59a VS |
928 | dcm.SetMapMode(wxMM_TEXT); |
929 | dcm.SetBackgroundMode(wxTRANSPARENT); | |
d659d703 | 930 | |
f30e67db VS |
931 | wxHtmlRenderingInfo rinfo; |
932 | wxDefaultHtmlRenderingStyle rstyle; | |
933 | rinfo.SetSelection(m_selection); | |
934 | rinfo.SetStyle(&rstyle); | |
1338c59a | 935 | m_Cell->Draw(dcm, 0, 0, |
790dbce3 | 936 | y * wxHTML_SCROLL_STEP + rect.GetTop(), |
36c4ff4d | 937 | y * wxHTML_SCROLL_STEP + rect.GetBottom(), |
f30e67db | 938 | rinfo); |
d1da8872 WS |
939 | |
940 | //#define DEBUG_HTML_SELECTION | |
03693319 VS |
941 | #ifdef DEBUG_HTML_SELECTION |
942 | { | |
943 | int xc, yc, x, y; | |
944 | wxGetMousePosition(&xc, &yc); | |
945 | ScreenToClient(&xc, &yc); | |
946 | CalcUnscrolledPosition(xc, yc, &x, &y); | |
947 | wxHtmlCell *at = m_Cell->FindCellByPos(x, y); | |
d1da8872 | 948 | wxHtmlCell *before = |
03693319 | 949 | m_Cell->FindCellByPos(x, y, wxHTML_FIND_NEAREST_BEFORE); |
d1da8872 | 950 | wxHtmlCell *after = |
03693319 | 951 | m_Cell->FindCellByPos(x, y, wxHTML_FIND_NEAREST_AFTER); |
d1da8872 | 952 | |
03693319 VS |
953 | dcm.SetBrush(*wxTRANSPARENT_BRUSH); |
954 | dcm.SetPen(*wxBLACK_PEN); | |
955 | if (at) | |
956 | dcm.DrawRectangle(at->GetAbsPos(), | |
957 | wxSize(at->GetWidth(),at->GetHeight())); | |
958 | dcm.SetPen(*wxGREEN_PEN); | |
959 | if (before) | |
960 | dcm.DrawRectangle(before->GetAbsPos().x+1, before->GetAbsPos().y+1, | |
961 | before->GetWidth()-2,before->GetHeight()-2); | |
962 | dcm.SetPen(*wxRED_PEN); | |
963 | if (after) | |
964 | dcm.DrawRectangle(after->GetAbsPos().x+2, after->GetAbsPos().y+2, | |
965 | after->GetWidth()-4,after->GetHeight()-4); | |
966 | } | |
967 | #endif | |
d1da8872 | 968 | |
1338c59a VS |
969 | dcm.SetDeviceOrigin(0,0); |
970 | dc.Blit(0, rect.GetTop(), | |
971 | sz.x, rect.GetBottom() - rect.GetTop() + 1, | |
972 | &dcm, | |
973 | 0, rect.GetTop()); | |
5526e819 VS |
974 | } |
975 | ||
976 | ||
977 | ||
978 | ||
979 | void wxHtmlWindow::OnSize(wxSizeEvent& event) | |
980 | { | |
1338c59a VS |
981 | wxDELETE(m_backBuffer); |
982 | ||
5526e819 VS |
983 | wxScrolledWindow::OnSize(event); |
984 | CreateLayout(); | |
1338c59a VS |
985 | |
986 | // Recompute selection if necessary: | |
987 | if ( m_selection ) | |
988 | { | |
989 | m_selection->Set(m_selection->GetFromCell(), | |
990 | m_selection->GetToCell()); | |
991 | m_selection->ClearPrivPos(); | |
992 | } | |
d659d703 | 993 | |
f6bcfd97 | 994 | Refresh(); |
5526e819 VS |
995 | } |
996 | ||
997 | ||
fc7a2a60 | 998 | void wxHtmlWindow::OnMouseMove(wxMouseEvent& WXUNUSED(event)) |
5526e819 | 999 | { |
31d8b4ad VS |
1000 | m_tmpMouseMoved = true; |
1001 | } | |
5526e819 | 1002 | |
adf2eb2d | 1003 | void wxHtmlWindow::OnMouseDown(wxMouseEvent& event) |
31d8b4ad | 1004 | { |
0994d968 | 1005 | #if wxUSE_CLIPBOARD |
adf2eb2d | 1006 | if ( event.LeftDown() && IsSelectionEnabled() ) |
4f9297b0 | 1007 | { |
0994d968 VS |
1008 | const long TRIPLECLICK_LEN = 200; // 0.2 sec after doubleclick |
1009 | if ( wxGetLocalTimeMillis() - m_lastDoubleClick <= TRIPLECLICK_LEN ) | |
adf2eb2d | 1010 | { |
0994d968 | 1011 | SelectLine(CalcUnscrolledPosition(event.GetPosition())); |
d659d703 | 1012 | |
5de65c69 | 1013 | (void) CopySelection(); |
adf2eb2d | 1014 | } |
0994d968 | 1015 | else |
d659d703 | 1016 | { |
0994d968 | 1017 | m_makingSelection = true; |
d659d703 | 1018 | |
0994d968 VS |
1019 | if ( m_selection ) |
1020 | { | |
1021 | wxDELETE(m_selection); | |
1022 | Refresh(); | |
1023 | } | |
1024 | m_tmpSelFromPos = CalcUnscrolledPosition(event.GetPosition()); | |
1025 | m_tmpSelFromCell = NULL; | |
5526e819 | 1026 | |
0994d968 VS |
1027 | CaptureMouse(); |
1028 | } | |
adf2eb2d | 1029 | } |
d659d703 | 1030 | #endif // wxUSE_CLIPBOARD |
adf2eb2d | 1031 | } |
5526e819 | 1032 | |
adf2eb2d VS |
1033 | void wxHtmlWindow::OnMouseUp(wxMouseEvent& event) |
1034 | { | |
1338c59a | 1035 | #if wxUSE_CLIPBOARD |
adf2eb2d VS |
1036 | if ( m_makingSelection ) |
1037 | { | |
1038 | ReleaseMouse(); | |
1039 | m_makingSelection = false; | |
1040 | ||
1041 | // did the user move the mouse far enough from starting point? | |
8feaa81f | 1042 | if ( CopySelection(Primary) ) |
adf2eb2d VS |
1043 | { |
1044 | // we don't want mouse up event that ended selecting to be | |
1045 | // handled as mouse click and e.g. follow hyperlink: | |
1046 | return; | |
1047 | } | |
1048 | } | |
d659d703 VZ |
1049 | #endif // wxUSE_CLIPBOARD |
1050 | ||
adf2eb2d VS |
1051 | SetFocus(); |
1052 | if ( m_Cell ) | |
1053 | { | |
1054 | wxPoint pos = CalcUnscrolledPosition(event.GetPosition()); | |
31d8b4ad | 1055 | wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y); |
f6010d8f | 1056 | |
d659d703 VZ |
1057 | // check is needed because FindCellByPos returns terminal cell and |
1058 | // containers may have empty borders -- in this case NULL will be | |
1059 | // returned | |
31d8b4ad VS |
1060 | if ( cell ) |
1061 | OnCellClicked(cell, pos.x, pos.y, event); | |
5526e819 VS |
1062 | } |
1063 | } | |
1064 | ||
1065 | ||
1066 | ||
5180055b JS |
1067 | void wxHtmlWindow::OnInternalIdle() |
1068 | { | |
1069 | wxWindow::OnInternalIdle(); | |
d1da8872 | 1070 | |
33ac7e6f | 1071 | if (m_tmpMouseMoved && (m_Cell != NULL)) |
4f9297b0 | 1072 | { |
03693319 VS |
1073 | #ifdef DEBUG_HTML_SELECTION |
1074 | Refresh(); | |
1075 | #endif | |
adf2eb2d VS |
1076 | int xc, yc, x, y; |
1077 | wxGetMousePosition(&xc, &yc); | |
1078 | ScreenToClient(&xc, &yc); | |
1079 | CalcUnscrolledPosition(xc, yc, &x, &y); | |
0cb9cfb2 | 1080 | |
f6010d8f | 1081 | wxHtmlCell *cell = m_Cell->FindCellByPos(x, y); |
adf2eb2d VS |
1082 | |
1083 | // handle selection update: | |
1084 | if ( m_makingSelection ) | |
1085 | { | |
adf2eb2d | 1086 | if ( !m_tmpSelFromCell ) |
748418c0 VS |
1087 | m_tmpSelFromCell = m_Cell->FindCellByPos( |
1088 | m_tmpSelFromPos.x,m_tmpSelFromPos.y); | |
d1da8872 | 1089 | |
03693319 VS |
1090 | // NB: a trick - we adjust selFromPos to be upper left or bottom |
1091 | // right corner of the first cell of the selection depending | |
1092 | // on whether the mouse is moving to the right or to the left. | |
1093 | // This gives us more "natural" behaviour when selecting | |
1094 | // a line (specifically, first cell of the next line is not | |
1095 | // included if you drag selection from left to right over | |
1096 | // entire line): | |
1097 | wxPoint dirFromPos; | |
1098 | if ( !m_tmpSelFromCell ) | |
1099 | { | |
1100 | dirFromPos = m_tmpSelFromPos; | |
1101 | } | |
1102 | else | |
1103 | { | |
1104 | dirFromPos = m_tmpSelFromCell->GetAbsPos(); | |
1105 | if ( x < m_tmpSelFromPos.x ) | |
1106 | { | |
1107 | dirFromPos.x += m_tmpSelFromCell->GetWidth(); | |
1108 | dirFromPos.y += m_tmpSelFromCell->GetHeight(); | |
1109 | } | |
1110 | } | |
d1da8872 | 1111 | bool goingDown = dirFromPos.y < y || |
03693319 VS |
1112 | (dirFromPos.y == y && dirFromPos.x < x); |
1113 | ||
1114 | // determine selection span: | |
748418c0 | 1115 | if ( /*still*/ !m_tmpSelFromCell ) |
adf2eb2d VS |
1116 | { |
1117 | if (goingDown) | |
1118 | { | |
5a1597e9 VS |
1119 | m_tmpSelFromCell = m_Cell->FindCellByPos( |
1120 | m_tmpSelFromPos.x,m_tmpSelFromPos.y, | |
1121 | wxHTML_FIND_NEAREST_AFTER); | |
adf2eb2d VS |
1122 | if (!m_tmpSelFromCell) |
1123 | m_tmpSelFromCell = m_Cell->GetFirstTerminal(); | |
1124 | } | |
1125 | else | |
1126 | { | |
5a1597e9 VS |
1127 | m_tmpSelFromCell = m_Cell->FindCellByPos( |
1128 | m_tmpSelFromPos.x,m_tmpSelFromPos.y, | |
1129 | wxHTML_FIND_NEAREST_BEFORE); | |
adf2eb2d VS |
1130 | if (!m_tmpSelFromCell) |
1131 | m_tmpSelFromCell = m_Cell->GetLastTerminal(); | |
1132 | } | |
1133 | } | |
1134 | ||
1135 | wxHtmlCell *selcell = cell; | |
1136 | if (!selcell) | |
1137 | { | |
1138 | if (goingDown) | |
1139 | { | |
1140 | selcell = m_Cell->FindCellByPos(x, y, | |
03693319 | 1141 | wxHTML_FIND_NEAREST_BEFORE); |
adf2eb2d VS |
1142 | if (!selcell) |
1143 | selcell = m_Cell->GetLastTerminal(); | |
1144 | } | |
1145 | else | |
1146 | { | |
1147 | selcell = m_Cell->FindCellByPos(x, y, | |
03693319 | 1148 | wxHTML_FIND_NEAREST_AFTER); |
adf2eb2d VS |
1149 | if (!selcell) |
1150 | selcell = m_Cell->GetFirstTerminal(); | |
1151 | } | |
1152 | } | |
1153 | ||
1154 | // NB: it may *rarely* happen that the code above didn't find one | |
1155 | // of the cells, e.g. if wxHtmlWindow doesn't contain any | |
d659d703 | 1156 | // visible cells. |
adf2eb2d | 1157 | if ( selcell && m_tmpSelFromCell ) |
d659d703 | 1158 | { |
adf2eb2d VS |
1159 | if ( !m_selection ) |
1160 | { | |
1161 | // start selecting only if mouse movement was big enough | |
1162 | // (otherwise it was meant as mouse click, not selection): | |
1163 | const int PRECISION = 2; | |
1164 | wxPoint diff = m_tmpSelFromPos - wxPoint(x,y); | |
1165 | if (abs(diff.x) > PRECISION || abs(diff.y) > PRECISION) | |
1166 | { | |
1167 | m_selection = new wxHtmlSelection(); | |
1168 | } | |
1169 | } | |
1170 | if ( m_selection ) | |
1171 | { | |
e3774124 | 1172 | if ( m_tmpSelFromCell->IsBefore(selcell) ) |
adf2eb2d VS |
1173 | { |
1174 | m_selection->Set(m_tmpSelFromPos, m_tmpSelFromCell, | |
f30e67db | 1175 | wxPoint(x,y), selcell); } |
adf2eb2d VS |
1176 | else |
1177 | { | |
1178 | m_selection->Set(wxPoint(x,y), selcell, | |
1179 | m_tmpSelFromPos, m_tmpSelFromCell); | |
1180 | } | |
1338c59a VS |
1181 | m_selection->ClearPrivPos(); |
1182 | Refresh(); | |
adf2eb2d VS |
1183 | } |
1184 | } | |
1185 | } | |
d659d703 | 1186 | |
adf2eb2d | 1187 | // handle cursor and status bar text changes: |
f6010d8f | 1188 | if ( cell != m_tmpLastCell ) |
e421922f | 1189 | { |
f6010d8f | 1190 | wxHtmlLinkInfo *lnk = cell ? cell->GetLink(x, y) : NULL; |
77bae5e2 VS |
1191 | wxCursor cur; |
1192 | if (cell) | |
1193 | cur = cell->GetCursor(); | |
1194 | else | |
1195 | cur = *wxSTANDARD_CURSOR; | |
1196 | SetCursor(cur); | |
f6010d8f VZ |
1197 | |
1198 | if (lnk != m_tmpLastLink) | |
e421922f | 1199 | { |
67a99992 | 1200 | #if wxUSE_STATUSBAR |
f6010d8f VZ |
1201 | if (lnk == NULL) |
1202 | { | |
f6010d8f | 1203 | if (m_RelatedStatusBar != -1) |
31eefb99 VS |
1204 | m_RelatedFrame->SetStatusText(wxEmptyString, |
1205 | m_RelatedStatusBar); | |
f6010d8f VZ |
1206 | } |
1207 | else | |
1208 | { | |
f6010d8f | 1209 | if (m_RelatedStatusBar != -1) |
31eefb99 VS |
1210 | m_RelatedFrame->SetStatusText(lnk->GetHref(), |
1211 | m_RelatedStatusBar); | |
f6010d8f | 1212 | } |
67a99992 | 1213 | #endif // wxUSE_STATUSBAR |
f6010d8f | 1214 | m_tmpLastLink = lnk; |
622ea783 | 1215 | } |
f6010d8f VZ |
1216 | |
1217 | m_tmpLastCell = cell; | |
5526e819 | 1218 | } |
f6010d8f VZ |
1219 | else // mouse moved but stayed in the same cell |
1220 | { | |
1221 | if ( cell ) | |
1222 | OnCellMouseHover(cell, x, y); | |
1223 | } | |
1224 | ||
d1da8872 | 1225 | m_tmpMouseMoved = false; |
5526e819 VS |
1226 | } |
1227 | } | |
1228 | ||
e3774124 | 1229 | #if wxUSE_CLIPBOARD |
1338c59a VS |
1230 | void wxHtmlWindow::StopAutoScrolling() |
1231 | { | |
1232 | if ( m_timerAutoScroll ) | |
1233 | { | |
1234 | wxDELETE(m_timerAutoScroll); | |
1235 | } | |
1236 | } | |
1237 | ||
1238 | void wxHtmlWindow::OnMouseEnter(wxMouseEvent& event) | |
1239 | { | |
1240 | StopAutoScrolling(); | |
1241 | event.Skip(); | |
1242 | } | |
1243 | ||
1244 | void wxHtmlWindow::OnMouseLeave(wxMouseEvent& event) | |
1245 | { | |
1246 | // don't prevent the usual processing of the event from taking place | |
1247 | event.Skip(); | |
1248 | ||
1249 | // when a captured mouse leave a scrolled window we start generate | |
1250 | // scrolling events to allow, for example, extending selection beyond the | |
1251 | // visible area in some controls | |
1252 | if ( wxWindow::GetCapture() == this ) | |
1253 | { | |
1254 | // where is the mouse leaving? | |
1255 | int pos, orient; | |
1256 | wxPoint pt = event.GetPosition(); | |
1257 | if ( pt.x < 0 ) | |
1258 | { | |
1259 | orient = wxHORIZONTAL; | |
1260 | pos = 0; | |
1261 | } | |
1262 | else if ( pt.y < 0 ) | |
1263 | { | |
1264 | orient = wxVERTICAL; | |
1265 | pos = 0; | |
1266 | } | |
1267 | else // we're lower or to the right of the window | |
1268 | { | |
1269 | wxSize size = GetClientSize(); | |
1270 | if ( pt.x > size.x ) | |
1271 | { | |
1272 | orient = wxHORIZONTAL; | |
1273 | pos = GetVirtualSize().x / wxHTML_SCROLL_STEP; | |
1274 | } | |
1275 | else if ( pt.y > size.y ) | |
1276 | { | |
1277 | orient = wxVERTICAL; | |
1278 | pos = GetVirtualSize().y / wxHTML_SCROLL_STEP; | |
1279 | } | |
1280 | else // this should be impossible | |
1281 | { | |
1282 | // but seems to happen sometimes under wxMSW - maybe it's a bug | |
1283 | // there but for now just ignore it | |
1284 | ||
1285 | //wxFAIL_MSG( _T("can't understand where has mouse gone") ); | |
1286 | ||
1287 | return; | |
1288 | } | |
1289 | } | |
1290 | ||
1291 | // only start the auto scroll timer if the window can be scrolled in | |
1292 | // this direction | |
1293 | if ( !HasScrollbar(orient) ) | |
1294 | return; | |
1295 | ||
1296 | delete m_timerAutoScroll; | |
1297 | m_timerAutoScroll = new wxHtmlWinAutoScrollTimer | |
1298 | ( | |
1299 | this, | |
1300 | pos == 0 ? wxEVT_SCROLLWIN_LINEUP | |
1301 | : wxEVT_SCROLLWIN_LINEDOWN, | |
1302 | pos, | |
1303 | orient | |
1304 | ); | |
1305 | m_timerAutoScroll->Start(50); // FIXME: make configurable | |
1306 | } | |
1307 | } | |
1308 | ||
e3774124 VS |
1309 | void wxHtmlWindow::OnKeyUp(wxKeyEvent& event) |
1310 | { | |
31eefb99 VS |
1311 | if ( IsSelectionEnabled() && |
1312 | event.GetKeyCode() == 'C' && event.ControlDown() ) | |
e3774124 | 1313 | { |
5de65c69 | 1314 | (void) CopySelection(); |
e3774124 | 1315 | } |
e3774124 VS |
1316 | } |
1317 | ||
fc7a2a60 | 1318 | void wxHtmlWindow::OnCopy(wxCommandEvent& WXUNUSED(event)) |
e3774124 | 1319 | { |
5de65c69 | 1320 | (void) CopySelection(); |
e3774124 | 1321 | } |
d659d703 | 1322 | |
31eefb99 VS |
1323 | void wxHtmlWindow::OnDoubleClick(wxMouseEvent& event) |
1324 | { | |
1325 | // select word under cursor: | |
1326 | if ( IsSelectionEnabled() ) | |
1327 | { | |
0994d968 | 1328 | SelectWord(CalcUnscrolledPosition(event.GetPosition())); |
d659d703 | 1329 | |
5de65c69 | 1330 | (void) CopySelection(Primary); |
d659d703 | 1331 | |
0994d968 | 1332 | m_lastDoubleClick = wxGetLocalTimeMillis(); |
31eefb99 VS |
1333 | } |
1334 | else | |
1335 | event.Skip(); | |
1336 | } | |
0994d968 VS |
1337 | |
1338 | void wxHtmlWindow::SelectWord(const wxPoint& pos) | |
1339 | { | |
2a536376 | 1340 | if ( m_Cell ) |
0994d968 | 1341 | { |
2a536376 VS |
1342 | wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y); |
1343 | if ( cell ) | |
1344 | { | |
1345 | delete m_selection; | |
1346 | m_selection = new wxHtmlSelection(); | |
1347 | m_selection->Set(cell, cell); | |
1348 | RefreshRect(wxRect(CalcScrolledPosition(cell->GetAbsPos()), | |
1349 | wxSize(cell->GetWidth(), cell->GetHeight()))); | |
1350 | } | |
0994d968 VS |
1351 | } |
1352 | } | |
1353 | ||
1354 | void wxHtmlWindow::SelectLine(const wxPoint& pos) | |
1355 | { | |
2a536376 | 1356 | if ( m_Cell ) |
0994d968 | 1357 | { |
2a536376 VS |
1358 | wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y); |
1359 | if ( cell ) | |
0994d968 | 1360 | { |
2a536376 VS |
1361 | // We use following heuristic to find a "line": let the line be all |
1362 | // cells in same container as the cell under mouse cursor that are | |
1363 | // neither completely above nor completely bellow the clicked cell | |
1364 | // (i.e. are likely to be words positioned on same line of text). | |
1365 | ||
1366 | int y1 = cell->GetAbsPos().y; | |
1367 | int y2 = y1 + cell->GetHeight(); | |
1368 | int y; | |
1369 | const wxHtmlCell *c; | |
1370 | const wxHtmlCell *before = NULL; | |
1371 | const wxHtmlCell *after = NULL; | |
1372 | ||
1373 | // find last cell of line: | |
1374 | for ( c = cell->GetNext(); c; c = c->GetNext()) | |
1375 | { | |
1376 | y = c->GetAbsPos().y; | |
1377 | if ( y + c->GetHeight() > y1 && y < y2 ) | |
1378 | after = c; | |
1379 | else | |
1380 | break; | |
1381 | } | |
1382 | if ( !after ) | |
1383 | after = cell; | |
0994d968 | 1384 | |
2a536376 VS |
1385 | // find first cell of line: |
1386 | for ( c = cell->GetParent()->GetFirstChild(); | |
1387 | c && c != cell; c = c->GetNext()) | |
0994d968 | 1388 | { |
2a536376 VS |
1389 | y = c->GetAbsPos().y; |
1390 | if ( y + c->GetHeight() > y1 && y < y2 ) | |
1391 | { | |
1392 | if ( ! before ) | |
1393 | before = c; | |
1394 | } | |
1395 | else | |
1396 | before = NULL; | |
0994d968 | 1397 | } |
2a536376 VS |
1398 | if ( !before ) |
1399 | before = cell; | |
1400 | ||
1401 | delete m_selection; | |
1402 | m_selection = new wxHtmlSelection(); | |
1403 | m_selection->Set(before, after); | |
1404 | ||
1405 | Refresh(); | |
0994d968 | 1406 | } |
2a536376 VS |
1407 | } |
1408 | } | |
d659d703 | 1409 | |
2a536376 VS |
1410 | void wxHtmlWindow::SelectAll() |
1411 | { | |
1412 | if ( m_Cell ) | |
1413 | { | |
0994d968 VS |
1414 | delete m_selection; |
1415 | m_selection = new wxHtmlSelection(); | |
2a536376 | 1416 | m_selection->Set(m_Cell->GetFirstTerminal(), m_Cell->GetLastTerminal()); |
0994d968 VS |
1417 | Refresh(); |
1418 | } | |
1419 | } | |
2a536376 | 1420 | |
d659d703 | 1421 | #endif // wxUSE_CLIPBOARD |
e3774124 VS |
1422 | |
1423 | ||
5526e819 | 1424 | |
bfb9ee96 | 1425 | IMPLEMENT_ABSTRACT_CLASS(wxHtmlProcessor,wxObject) |
5526e819 | 1426 | |
786a2425 SC |
1427 | #if wxUSE_EXTENDED_RTTI |
1428 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxHtmlWindow, wxScrolledWindow,"wx/html/htmlwin.h") | |
1429 | ||
459f2add | 1430 | wxBEGIN_PROPERTIES_TABLE(wxHtmlWindow) |
786a2425 | 1431 | /* |
d1da8872 WS |
1432 | TODO PROPERTIES |
1433 | style , wxHW_SCROLLBAR_AUTO | |
1434 | borders , (dimension) | |
1435 | url , string | |
1436 | htmlcode , string | |
786a2425 | 1437 | */ |
459f2add | 1438 | wxEND_PROPERTIES_TABLE() |
786a2425 | 1439 | |
459f2add SC |
1440 | wxBEGIN_HANDLERS_TABLE(wxHtmlWindow) |
1441 | wxEND_HANDLERS_TABLE() | |
786a2425 | 1442 | |
d1da8872 | 1443 | wxCONSTRUCTOR_5( wxHtmlWindow , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) |
786a2425 | 1444 | #else |
5526e819 | 1445 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow,wxScrolledWindow) |
786a2425 | 1446 | #endif |
5526e819 VS |
1447 | |
1448 | BEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow) | |
1449 | EVT_SIZE(wxHtmlWindow::OnSize) | |
adf2eb2d VS |
1450 | EVT_LEFT_DOWN(wxHtmlWindow::OnMouseDown) |
1451 | EVT_LEFT_UP(wxHtmlWindow::OnMouseUp) | |
1452 | EVT_RIGHT_UP(wxHtmlWindow::OnMouseUp) | |
31d8b4ad | 1453 | EVT_MOTION(wxHtmlWindow::OnMouseMove) |
1338c59a VS |
1454 | EVT_ERASE_BACKGROUND(wxHtmlWindow::OnEraseBackground) |
1455 | EVT_PAINT(wxHtmlWindow::OnPaint) | |
e3774124 | 1456 | #if wxUSE_CLIPBOARD |
31eefb99 | 1457 | EVT_LEFT_DCLICK(wxHtmlWindow::OnDoubleClick) |
1338c59a VS |
1458 | EVT_ENTER_WINDOW(wxHtmlWindow::OnMouseEnter) |
1459 | EVT_LEAVE_WINDOW(wxHtmlWindow::OnMouseLeave) | |
e3774124 VS |
1460 | EVT_KEY_UP(wxHtmlWindow::OnKeyUp) |
1461 | EVT_MENU(wxID_COPY, wxHtmlWindow::OnCopy) | |
d659d703 | 1462 | #endif // wxUSE_CLIPBOARD |
5526e819 VS |
1463 | END_EVENT_TABLE() |
1464 | ||
1465 | ||
1466 | ||
1467 | ||
1468 | ||
a76015e6 VS |
1469 | // A module to allow initialization/cleanup |
1470 | // without calling these functions from app.cpp or from | |
1471 | // the user's application. | |
1472 | ||
1473 | class wxHtmlWinModule: public wxModule | |
1474 | { | |
1475 | DECLARE_DYNAMIC_CLASS(wxHtmlWinModule) | |
1476 | public: | |
1477 | wxHtmlWinModule() : wxModule() {} | |
d1da8872 | 1478 | bool OnInit() { return true; } |
a76015e6 VS |
1479 | void OnExit() { wxHtmlWindow::CleanUpStatics(); } |
1480 | }; | |
1481 | ||
1482 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule, wxModule) | |
1483 | ||
5526e819 | 1484 | |
0cecad31 VS |
1485 | // This hack forces the linker to always link in m_* files |
1486 | // (wxHTML doesn't work without handlers from these files) | |
1487 | #include "wx/html/forcelnk.h" | |
1488 | FORCE_WXHTML_MODULES() | |
5526e819 | 1489 | |
d659d703 VZ |
1490 | #endif // wxUSE_HTML |
1491 |