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