]>
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 | } | |
caf448e3 WS |
829 | #else |
830 | wxUnusedVar(t); | |
d659d703 | 831 | #endif // wxUSE_CLIPBOARD |
8feaa81f VZ |
832 | |
833 | return false; | |
e3774124 | 834 | } |
5526e819 VS |
835 | |
836 | ||
0b2dadd3 | 837 | void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) |
5526e819 | 838 | { |
31d8b4ad VS |
839 | const wxMouseEvent *e = link.GetEvent(); |
840 | if (e == NULL || e->LeftUp()) | |
841 | LoadPage(link.GetHref()); | |
5526e819 VS |
842 | } |
843 | ||
f6010d8f VZ |
844 | void wxHtmlWindow::OnCellClicked(wxHtmlCell *cell, |
845 | wxCoord x, wxCoord y, | |
846 | const wxMouseEvent& event) | |
19193a2c | 847 | { |
f6010d8f | 848 | wxCHECK_RET( cell, _T("can't be called with NULL cell") ); |
5526e819 | 849 | |
f6010d8f VZ |
850 | cell->OnMouseClick(this, x, y, event); |
851 | } | |
852 | ||
853 | void wxHtmlWindow::OnCellMouseHover(wxHtmlCell * WXUNUSED(cell), | |
854 | wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) | |
855 | { | |
856 | // do nothing here | |
857 | } | |
5526e819 | 858 | |
12148be2 | 859 | void wxHtmlWindow::OnEraseBackground(wxEraseEvent& event) |
1338c59a | 860 | { |
97e490f8 VZ |
861 | if ( !m_bmpBg.Ok() ) |
862 | { | |
518ba663 VZ |
863 | // don't even skip the event, if we don't have a bg bitmap we're going |
864 | // to overwrite background in OnPaint() below anyhow, so letting the | |
865 | // default handling take place would only result in flicker, just set a | |
866 | // flag to erase the background below | |
867 | m_eraseBgInOnPaint = true; | |
97e490f8 VZ |
868 | return; |
869 | } | |
870 | ||
871 | wxDC& dc = *event.GetDC(); | |
872 | ||
873 | // if the image is not fully opaque, we have to erase the background before | |
874 | // drawing it, however avoid doing it for opaque images as this would just | |
875 | // result in extra flicker without any other effect as background is | |
876 | // completely covered anyhow | |
877 | if ( m_bmpBg.GetMask() ) | |
878 | { | |
879 | dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); | |
880 | dc.Clear(); | |
881 | } | |
882 | ||
883 | const wxSize sizeWin(GetClientSize()); | |
884 | const wxSize sizeBmp(m_bmpBg.GetWidth(), m_bmpBg.GetHeight()); | |
885 | for ( wxCoord x = 0; x < sizeWin.x; x += sizeBmp.x ) | |
886 | { | |
887 | for ( wxCoord y = 0; y < sizeWin.y; y += sizeBmp.y ) | |
888 | { | |
889 | dc.DrawBitmap(m_bmpBg, x, y, true /* use mask */); | |
890 | } | |
891 | } | |
1338c59a VS |
892 | } |
893 | ||
894 | void wxHtmlWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) | |
5526e819 | 895 | { |
1338c59a VS |
896 | wxPaintDC dc(this); |
897 | ||
518ba663 VZ |
898 | if (m_tmpCanDrawLocks > 0 || m_Cell == NULL) |
899 | return; | |
5526e819 | 900 | |
b835e9bf | 901 | int x, y; |
e421922f | 902 | GetViewStart(&x, &y); |
1338c59a VS |
903 | wxRect rect = GetUpdateRegion().GetBox(); |
904 | wxSize sz = GetSize(); | |
905 | ||
906 | wxMemoryDC dcm; | |
907 | if ( !m_backBuffer ) | |
908 | m_backBuffer = new wxBitmap(sz.x, sz.y); | |
d659d703 | 909 | dcm.SelectObject(*m_backBuffer); |
a03ae172 | 910 | |
518ba663 VZ |
911 | if ( m_eraseBgInOnPaint ) |
912 | { | |
913 | dcm.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); | |
914 | dcm.Clear(); | |
915 | ||
916 | m_eraseBgInOnPaint = false; | |
917 | } | |
918 | else // someone has already erased the background, keep it | |
919 | { | |
920 | // preserve the existing background, otherwise we'd erase anything the | |
921 | // user code had drawn in its EVT_ERASE_BACKGROUND handler when we do | |
922 | // the Blit back below | |
923 | dcm.Blit(0, rect.GetTop(), | |
924 | sz.x, rect.GetBottom() - rect.GetTop() + 1, | |
925 | &dc, | |
926 | 0, rect.GetTop()); | |
927 | } | |
a03ae172 | 928 | |
7f461f8a | 929 | PrepareDC(dcm); |
1338c59a VS |
930 | dcm.SetMapMode(wxMM_TEXT); |
931 | dcm.SetBackgroundMode(wxTRANSPARENT); | |
d659d703 | 932 | |
f30e67db VS |
933 | wxHtmlRenderingInfo rinfo; |
934 | wxDefaultHtmlRenderingStyle rstyle; | |
935 | rinfo.SetSelection(m_selection); | |
936 | rinfo.SetStyle(&rstyle); | |
1338c59a | 937 | m_Cell->Draw(dcm, 0, 0, |
790dbce3 | 938 | y * wxHTML_SCROLL_STEP + rect.GetTop(), |
36c4ff4d | 939 | y * wxHTML_SCROLL_STEP + rect.GetBottom(), |
f30e67db | 940 | rinfo); |
d1da8872 WS |
941 | |
942 | //#define DEBUG_HTML_SELECTION | |
03693319 VS |
943 | #ifdef DEBUG_HTML_SELECTION |
944 | { | |
945 | int xc, yc, x, y; | |
946 | wxGetMousePosition(&xc, &yc); | |
947 | ScreenToClient(&xc, &yc); | |
948 | CalcUnscrolledPosition(xc, yc, &x, &y); | |
949 | wxHtmlCell *at = m_Cell->FindCellByPos(x, y); | |
d1da8872 | 950 | wxHtmlCell *before = |
03693319 | 951 | m_Cell->FindCellByPos(x, y, wxHTML_FIND_NEAREST_BEFORE); |
d1da8872 | 952 | wxHtmlCell *after = |
03693319 | 953 | m_Cell->FindCellByPos(x, y, wxHTML_FIND_NEAREST_AFTER); |
d1da8872 | 954 | |
03693319 VS |
955 | dcm.SetBrush(*wxTRANSPARENT_BRUSH); |
956 | dcm.SetPen(*wxBLACK_PEN); | |
957 | if (at) | |
958 | dcm.DrawRectangle(at->GetAbsPos(), | |
959 | wxSize(at->GetWidth(),at->GetHeight())); | |
960 | dcm.SetPen(*wxGREEN_PEN); | |
961 | if (before) | |
962 | dcm.DrawRectangle(before->GetAbsPos().x+1, before->GetAbsPos().y+1, | |
963 | before->GetWidth()-2,before->GetHeight()-2); | |
964 | dcm.SetPen(*wxRED_PEN); | |
965 | if (after) | |
966 | dcm.DrawRectangle(after->GetAbsPos().x+2, after->GetAbsPos().y+2, | |
967 | after->GetWidth()-4,after->GetHeight()-4); | |
968 | } | |
969 | #endif | |
d1da8872 | 970 | |
1338c59a VS |
971 | dcm.SetDeviceOrigin(0,0); |
972 | dc.Blit(0, rect.GetTop(), | |
973 | sz.x, rect.GetBottom() - rect.GetTop() + 1, | |
974 | &dcm, | |
975 | 0, rect.GetTop()); | |
5526e819 VS |
976 | } |
977 | ||
978 | ||
979 | ||
980 | ||
981 | void wxHtmlWindow::OnSize(wxSizeEvent& event) | |
982 | { | |
1338c59a VS |
983 | wxDELETE(m_backBuffer); |
984 | ||
5526e819 VS |
985 | wxScrolledWindow::OnSize(event); |
986 | CreateLayout(); | |
1338c59a VS |
987 | |
988 | // Recompute selection if necessary: | |
989 | if ( m_selection ) | |
990 | { | |
991 | m_selection->Set(m_selection->GetFromCell(), | |
992 | m_selection->GetToCell()); | |
993 | m_selection->ClearPrivPos(); | |
994 | } | |
d659d703 | 995 | |
f6bcfd97 | 996 | Refresh(); |
5526e819 VS |
997 | } |
998 | ||
999 | ||
fc7a2a60 | 1000 | void wxHtmlWindow::OnMouseMove(wxMouseEvent& WXUNUSED(event)) |
5526e819 | 1001 | { |
31d8b4ad VS |
1002 | m_tmpMouseMoved = true; |
1003 | } | |
5526e819 | 1004 | |
adf2eb2d | 1005 | void wxHtmlWindow::OnMouseDown(wxMouseEvent& event) |
31d8b4ad | 1006 | { |
0994d968 | 1007 | #if wxUSE_CLIPBOARD |
adf2eb2d | 1008 | if ( event.LeftDown() && IsSelectionEnabled() ) |
4f9297b0 | 1009 | { |
0994d968 VS |
1010 | const long TRIPLECLICK_LEN = 200; // 0.2 sec after doubleclick |
1011 | if ( wxGetLocalTimeMillis() - m_lastDoubleClick <= TRIPLECLICK_LEN ) | |
adf2eb2d | 1012 | { |
0994d968 | 1013 | SelectLine(CalcUnscrolledPosition(event.GetPosition())); |
d659d703 | 1014 | |
5de65c69 | 1015 | (void) CopySelection(); |
adf2eb2d | 1016 | } |
0994d968 | 1017 | else |
d659d703 | 1018 | { |
0994d968 | 1019 | m_makingSelection = true; |
d659d703 | 1020 | |
0994d968 VS |
1021 | if ( m_selection ) |
1022 | { | |
1023 | wxDELETE(m_selection); | |
1024 | Refresh(); | |
1025 | } | |
1026 | m_tmpSelFromPos = CalcUnscrolledPosition(event.GetPosition()); | |
1027 | m_tmpSelFromCell = NULL; | |
5526e819 | 1028 | |
0994d968 VS |
1029 | CaptureMouse(); |
1030 | } | |
adf2eb2d | 1031 | } |
caf448e3 WS |
1032 | #else |
1033 | wxUnusedVar(event); | |
d659d703 | 1034 | #endif // wxUSE_CLIPBOARD |
adf2eb2d | 1035 | } |
5526e819 | 1036 | |
adf2eb2d VS |
1037 | void wxHtmlWindow::OnMouseUp(wxMouseEvent& event) |
1038 | { | |
1338c59a | 1039 | #if wxUSE_CLIPBOARD |
adf2eb2d VS |
1040 | if ( m_makingSelection ) |
1041 | { | |
1042 | ReleaseMouse(); | |
1043 | m_makingSelection = false; | |
1044 | ||
1045 | // did the user move the mouse far enough from starting point? | |
8feaa81f | 1046 | if ( CopySelection(Primary) ) |
adf2eb2d VS |
1047 | { |
1048 | // we don't want mouse up event that ended selecting to be | |
1049 | // handled as mouse click and e.g. follow hyperlink: | |
1050 | return; | |
1051 | } | |
1052 | } | |
d659d703 VZ |
1053 | #endif // wxUSE_CLIPBOARD |
1054 | ||
adf2eb2d VS |
1055 | SetFocus(); |
1056 | if ( m_Cell ) | |
1057 | { | |
1058 | wxPoint pos = CalcUnscrolledPosition(event.GetPosition()); | |
31d8b4ad | 1059 | wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y); |
f6010d8f | 1060 | |
d659d703 VZ |
1061 | // check is needed because FindCellByPos returns terminal cell and |
1062 | // containers may have empty borders -- in this case NULL will be | |
1063 | // returned | |
31d8b4ad VS |
1064 | if ( cell ) |
1065 | OnCellClicked(cell, pos.x, pos.y, event); | |
5526e819 VS |
1066 | } |
1067 | } | |
1068 | ||
1069 | ||
1070 | ||
5180055b JS |
1071 | void wxHtmlWindow::OnInternalIdle() |
1072 | { | |
1073 | wxWindow::OnInternalIdle(); | |
d1da8872 | 1074 | |
33ac7e6f | 1075 | if (m_tmpMouseMoved && (m_Cell != NULL)) |
4f9297b0 | 1076 | { |
03693319 VS |
1077 | #ifdef DEBUG_HTML_SELECTION |
1078 | Refresh(); | |
1079 | #endif | |
adf2eb2d VS |
1080 | int xc, yc, x, y; |
1081 | wxGetMousePosition(&xc, &yc); | |
1082 | ScreenToClient(&xc, &yc); | |
1083 | CalcUnscrolledPosition(xc, yc, &x, &y); | |
0cb9cfb2 | 1084 | |
f6010d8f | 1085 | wxHtmlCell *cell = m_Cell->FindCellByPos(x, y); |
adf2eb2d VS |
1086 | |
1087 | // handle selection update: | |
1088 | if ( m_makingSelection ) | |
1089 | { | |
adf2eb2d | 1090 | if ( !m_tmpSelFromCell ) |
748418c0 VS |
1091 | m_tmpSelFromCell = m_Cell->FindCellByPos( |
1092 | m_tmpSelFromPos.x,m_tmpSelFromPos.y); | |
d1da8872 | 1093 | |
03693319 VS |
1094 | // NB: a trick - we adjust selFromPos to be upper left or bottom |
1095 | // right corner of the first cell of the selection depending | |
1096 | // on whether the mouse is moving to the right or to the left. | |
1097 | // This gives us more "natural" behaviour when selecting | |
1098 | // a line (specifically, first cell of the next line is not | |
1099 | // included if you drag selection from left to right over | |
1100 | // entire line): | |
1101 | wxPoint dirFromPos; | |
1102 | if ( !m_tmpSelFromCell ) | |
1103 | { | |
1104 | dirFromPos = m_tmpSelFromPos; | |
1105 | } | |
1106 | else | |
1107 | { | |
1108 | dirFromPos = m_tmpSelFromCell->GetAbsPos(); | |
1109 | if ( x < m_tmpSelFromPos.x ) | |
1110 | { | |
1111 | dirFromPos.x += m_tmpSelFromCell->GetWidth(); | |
1112 | dirFromPos.y += m_tmpSelFromCell->GetHeight(); | |
1113 | } | |
1114 | } | |
d1da8872 | 1115 | bool goingDown = dirFromPos.y < y || |
03693319 VS |
1116 | (dirFromPos.y == y && dirFromPos.x < x); |
1117 | ||
1118 | // determine selection span: | |
748418c0 | 1119 | if ( /*still*/ !m_tmpSelFromCell ) |
adf2eb2d VS |
1120 | { |
1121 | if (goingDown) | |
1122 | { | |
5a1597e9 VS |
1123 | m_tmpSelFromCell = m_Cell->FindCellByPos( |
1124 | m_tmpSelFromPos.x,m_tmpSelFromPos.y, | |
1125 | wxHTML_FIND_NEAREST_AFTER); | |
adf2eb2d VS |
1126 | if (!m_tmpSelFromCell) |
1127 | m_tmpSelFromCell = m_Cell->GetFirstTerminal(); | |
1128 | } | |
1129 | else | |
1130 | { | |
5a1597e9 VS |
1131 | m_tmpSelFromCell = m_Cell->FindCellByPos( |
1132 | m_tmpSelFromPos.x,m_tmpSelFromPos.y, | |
1133 | wxHTML_FIND_NEAREST_BEFORE); | |
adf2eb2d VS |
1134 | if (!m_tmpSelFromCell) |
1135 | m_tmpSelFromCell = m_Cell->GetLastTerminal(); | |
1136 | } | |
1137 | } | |
1138 | ||
1139 | wxHtmlCell *selcell = cell; | |
1140 | if (!selcell) | |
1141 | { | |
1142 | if (goingDown) | |
1143 | { | |
1144 | selcell = m_Cell->FindCellByPos(x, y, | |
03693319 | 1145 | wxHTML_FIND_NEAREST_BEFORE); |
adf2eb2d VS |
1146 | if (!selcell) |
1147 | selcell = m_Cell->GetLastTerminal(); | |
1148 | } | |
1149 | else | |
1150 | { | |
1151 | selcell = m_Cell->FindCellByPos(x, y, | |
03693319 | 1152 | wxHTML_FIND_NEAREST_AFTER); |
adf2eb2d VS |
1153 | if (!selcell) |
1154 | selcell = m_Cell->GetFirstTerminal(); | |
1155 | } | |
1156 | } | |
1157 | ||
1158 | // NB: it may *rarely* happen that the code above didn't find one | |
1159 | // of the cells, e.g. if wxHtmlWindow doesn't contain any | |
d659d703 | 1160 | // visible cells. |
adf2eb2d | 1161 | if ( selcell && m_tmpSelFromCell ) |
d659d703 | 1162 | { |
adf2eb2d VS |
1163 | if ( !m_selection ) |
1164 | { | |
1165 | // start selecting only if mouse movement was big enough | |
1166 | // (otherwise it was meant as mouse click, not selection): | |
1167 | const int PRECISION = 2; | |
1168 | wxPoint diff = m_tmpSelFromPos - wxPoint(x,y); | |
1169 | if (abs(diff.x) > PRECISION || abs(diff.y) > PRECISION) | |
1170 | { | |
1171 | m_selection = new wxHtmlSelection(); | |
1172 | } | |
1173 | } | |
1174 | if ( m_selection ) | |
1175 | { | |
e3774124 | 1176 | if ( m_tmpSelFromCell->IsBefore(selcell) ) |
adf2eb2d VS |
1177 | { |
1178 | m_selection->Set(m_tmpSelFromPos, m_tmpSelFromCell, | |
f30e67db | 1179 | wxPoint(x,y), selcell); } |
adf2eb2d VS |
1180 | else |
1181 | { | |
1182 | m_selection->Set(wxPoint(x,y), selcell, | |
1183 | m_tmpSelFromPos, m_tmpSelFromCell); | |
1184 | } | |
1338c59a VS |
1185 | m_selection->ClearPrivPos(); |
1186 | Refresh(); | |
adf2eb2d VS |
1187 | } |
1188 | } | |
1189 | } | |
d659d703 | 1190 | |
adf2eb2d | 1191 | // handle cursor and status bar text changes: |
f6010d8f | 1192 | if ( cell != m_tmpLastCell ) |
e421922f | 1193 | { |
f6010d8f | 1194 | wxHtmlLinkInfo *lnk = cell ? cell->GetLink(x, y) : NULL; |
77bae5e2 VS |
1195 | wxCursor cur; |
1196 | if (cell) | |
1197 | cur = cell->GetCursor(); | |
1198 | else | |
1199 | cur = *wxSTANDARD_CURSOR; | |
1200 | SetCursor(cur); | |
f6010d8f VZ |
1201 | |
1202 | if (lnk != m_tmpLastLink) | |
e421922f | 1203 | { |
67a99992 | 1204 | #if wxUSE_STATUSBAR |
f6010d8f VZ |
1205 | if (lnk == NULL) |
1206 | { | |
f6010d8f | 1207 | if (m_RelatedStatusBar != -1) |
31eefb99 VS |
1208 | m_RelatedFrame->SetStatusText(wxEmptyString, |
1209 | m_RelatedStatusBar); | |
f6010d8f VZ |
1210 | } |
1211 | else | |
1212 | { | |
f6010d8f | 1213 | if (m_RelatedStatusBar != -1) |
31eefb99 VS |
1214 | m_RelatedFrame->SetStatusText(lnk->GetHref(), |
1215 | m_RelatedStatusBar); | |
f6010d8f | 1216 | } |
67a99992 | 1217 | #endif // wxUSE_STATUSBAR |
f6010d8f | 1218 | m_tmpLastLink = lnk; |
622ea783 | 1219 | } |
f6010d8f VZ |
1220 | |
1221 | m_tmpLastCell = cell; | |
5526e819 | 1222 | } |
f6010d8f VZ |
1223 | else // mouse moved but stayed in the same cell |
1224 | { | |
1225 | if ( cell ) | |
1226 | OnCellMouseHover(cell, x, y); | |
1227 | } | |
1228 | ||
d1da8872 | 1229 | m_tmpMouseMoved = false; |
5526e819 VS |
1230 | } |
1231 | } | |
1232 | ||
e3774124 | 1233 | #if wxUSE_CLIPBOARD |
1338c59a VS |
1234 | void wxHtmlWindow::StopAutoScrolling() |
1235 | { | |
1236 | if ( m_timerAutoScroll ) | |
1237 | { | |
1238 | wxDELETE(m_timerAutoScroll); | |
1239 | } | |
1240 | } | |
1241 | ||
1242 | void wxHtmlWindow::OnMouseEnter(wxMouseEvent& event) | |
1243 | { | |
1244 | StopAutoScrolling(); | |
1245 | event.Skip(); | |
1246 | } | |
1247 | ||
1248 | void wxHtmlWindow::OnMouseLeave(wxMouseEvent& event) | |
1249 | { | |
1250 | // don't prevent the usual processing of the event from taking place | |
1251 | event.Skip(); | |
1252 | ||
1253 | // when a captured mouse leave a scrolled window we start generate | |
1254 | // scrolling events to allow, for example, extending selection beyond the | |
1255 | // visible area in some controls | |
1256 | if ( wxWindow::GetCapture() == this ) | |
1257 | { | |
1258 | // where is the mouse leaving? | |
1259 | int pos, orient; | |
1260 | wxPoint pt = event.GetPosition(); | |
1261 | if ( pt.x < 0 ) | |
1262 | { | |
1263 | orient = wxHORIZONTAL; | |
1264 | pos = 0; | |
1265 | } | |
1266 | else if ( pt.y < 0 ) | |
1267 | { | |
1268 | orient = wxVERTICAL; | |
1269 | pos = 0; | |
1270 | } | |
1271 | else // we're lower or to the right of the window | |
1272 | { | |
1273 | wxSize size = GetClientSize(); | |
1274 | if ( pt.x > size.x ) | |
1275 | { | |
1276 | orient = wxHORIZONTAL; | |
1277 | pos = GetVirtualSize().x / wxHTML_SCROLL_STEP; | |
1278 | } | |
1279 | else if ( pt.y > size.y ) | |
1280 | { | |
1281 | orient = wxVERTICAL; | |
1282 | pos = GetVirtualSize().y / wxHTML_SCROLL_STEP; | |
1283 | } | |
1284 | else // this should be impossible | |
1285 | { | |
1286 | // but seems to happen sometimes under wxMSW - maybe it's a bug | |
1287 | // there but for now just ignore it | |
1288 | ||
1289 | //wxFAIL_MSG( _T("can't understand where has mouse gone") ); | |
1290 | ||
1291 | return; | |
1292 | } | |
1293 | } | |
1294 | ||
1295 | // only start the auto scroll timer if the window can be scrolled in | |
1296 | // this direction | |
1297 | if ( !HasScrollbar(orient) ) | |
1298 | return; | |
1299 | ||
1300 | delete m_timerAutoScroll; | |
1301 | m_timerAutoScroll = new wxHtmlWinAutoScrollTimer | |
1302 | ( | |
1303 | this, | |
1304 | pos == 0 ? wxEVT_SCROLLWIN_LINEUP | |
1305 | : wxEVT_SCROLLWIN_LINEDOWN, | |
1306 | pos, | |
1307 | orient | |
1308 | ); | |
1309 | m_timerAutoScroll->Start(50); // FIXME: make configurable | |
1310 | } | |
1311 | } | |
1312 | ||
e3774124 VS |
1313 | void wxHtmlWindow::OnKeyUp(wxKeyEvent& event) |
1314 | { | |
31eefb99 VS |
1315 | if ( IsSelectionEnabled() && |
1316 | event.GetKeyCode() == 'C' && event.ControlDown() ) | |
e3774124 | 1317 | { |
5de65c69 | 1318 | (void) CopySelection(); |
e3774124 | 1319 | } |
e3774124 VS |
1320 | } |
1321 | ||
fc7a2a60 | 1322 | void wxHtmlWindow::OnCopy(wxCommandEvent& WXUNUSED(event)) |
e3774124 | 1323 | { |
5de65c69 | 1324 | (void) CopySelection(); |
e3774124 | 1325 | } |
d659d703 | 1326 | |
31eefb99 VS |
1327 | void wxHtmlWindow::OnDoubleClick(wxMouseEvent& event) |
1328 | { | |
1329 | // select word under cursor: | |
1330 | if ( IsSelectionEnabled() ) | |
1331 | { | |
0994d968 | 1332 | SelectWord(CalcUnscrolledPosition(event.GetPosition())); |
d659d703 | 1333 | |
5de65c69 | 1334 | (void) CopySelection(Primary); |
d659d703 | 1335 | |
0994d968 | 1336 | m_lastDoubleClick = wxGetLocalTimeMillis(); |
31eefb99 VS |
1337 | } |
1338 | else | |
1339 | event.Skip(); | |
1340 | } | |
0994d968 VS |
1341 | |
1342 | void wxHtmlWindow::SelectWord(const wxPoint& pos) | |
1343 | { | |
2a536376 | 1344 | if ( m_Cell ) |
0994d968 | 1345 | { |
2a536376 VS |
1346 | wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y); |
1347 | if ( cell ) | |
1348 | { | |
1349 | delete m_selection; | |
1350 | m_selection = new wxHtmlSelection(); | |
1351 | m_selection->Set(cell, cell); | |
1352 | RefreshRect(wxRect(CalcScrolledPosition(cell->GetAbsPos()), | |
1353 | wxSize(cell->GetWidth(), cell->GetHeight()))); | |
1354 | } | |
0994d968 VS |
1355 | } |
1356 | } | |
1357 | ||
1358 | void wxHtmlWindow::SelectLine(const wxPoint& pos) | |
1359 | { | |
2a536376 | 1360 | if ( m_Cell ) |
0994d968 | 1361 | { |
2a536376 VS |
1362 | wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y); |
1363 | if ( cell ) | |
0994d968 | 1364 | { |
2a536376 VS |
1365 | // We use following heuristic to find a "line": let the line be all |
1366 | // cells in same container as the cell under mouse cursor that are | |
1367 | // neither completely above nor completely bellow the clicked cell | |
1368 | // (i.e. are likely to be words positioned on same line of text). | |
1369 | ||
1370 | int y1 = cell->GetAbsPos().y; | |
1371 | int y2 = y1 + cell->GetHeight(); | |
1372 | int y; | |
1373 | const wxHtmlCell *c; | |
1374 | const wxHtmlCell *before = NULL; | |
1375 | const wxHtmlCell *after = NULL; | |
1376 | ||
1377 | // find last cell of line: | |
1378 | for ( c = cell->GetNext(); c; c = c->GetNext()) | |
1379 | { | |
1380 | y = c->GetAbsPos().y; | |
1381 | if ( y + c->GetHeight() > y1 && y < y2 ) | |
1382 | after = c; | |
1383 | else | |
1384 | break; | |
1385 | } | |
1386 | if ( !after ) | |
1387 | after = cell; | |
0994d968 | 1388 | |
2a536376 VS |
1389 | // find first cell of line: |
1390 | for ( c = cell->GetParent()->GetFirstChild(); | |
1391 | c && c != cell; c = c->GetNext()) | |
0994d968 | 1392 | { |
2a536376 VS |
1393 | y = c->GetAbsPos().y; |
1394 | if ( y + c->GetHeight() > y1 && y < y2 ) | |
1395 | { | |
1396 | if ( ! before ) | |
1397 | before = c; | |
1398 | } | |
1399 | else | |
1400 | before = NULL; | |
0994d968 | 1401 | } |
2a536376 VS |
1402 | if ( !before ) |
1403 | before = cell; | |
1404 | ||
1405 | delete m_selection; | |
1406 | m_selection = new wxHtmlSelection(); | |
1407 | m_selection->Set(before, after); | |
1408 | ||
1409 | Refresh(); | |
0994d968 | 1410 | } |
2a536376 VS |
1411 | } |
1412 | } | |
d659d703 | 1413 | |
2a536376 VS |
1414 | void wxHtmlWindow::SelectAll() |
1415 | { | |
1416 | if ( m_Cell ) | |
1417 | { | |
0994d968 VS |
1418 | delete m_selection; |
1419 | m_selection = new wxHtmlSelection(); | |
2a536376 | 1420 | m_selection->Set(m_Cell->GetFirstTerminal(), m_Cell->GetLastTerminal()); |
0994d968 VS |
1421 | Refresh(); |
1422 | } | |
1423 | } | |
2a536376 | 1424 | |
d659d703 | 1425 | #endif // wxUSE_CLIPBOARD |
e3774124 VS |
1426 | |
1427 | ||
5526e819 | 1428 | |
bfb9ee96 | 1429 | IMPLEMENT_ABSTRACT_CLASS(wxHtmlProcessor,wxObject) |
5526e819 | 1430 | |
786a2425 SC |
1431 | #if wxUSE_EXTENDED_RTTI |
1432 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxHtmlWindow, wxScrolledWindow,"wx/html/htmlwin.h") | |
1433 | ||
459f2add | 1434 | wxBEGIN_PROPERTIES_TABLE(wxHtmlWindow) |
786a2425 | 1435 | /* |
d1da8872 WS |
1436 | TODO PROPERTIES |
1437 | style , wxHW_SCROLLBAR_AUTO | |
1438 | borders , (dimension) | |
1439 | url , string | |
1440 | htmlcode , string | |
786a2425 | 1441 | */ |
459f2add | 1442 | wxEND_PROPERTIES_TABLE() |
786a2425 | 1443 | |
459f2add SC |
1444 | wxBEGIN_HANDLERS_TABLE(wxHtmlWindow) |
1445 | wxEND_HANDLERS_TABLE() | |
786a2425 | 1446 | |
d1da8872 | 1447 | wxCONSTRUCTOR_5( wxHtmlWindow , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) |
786a2425 | 1448 | #else |
5526e819 | 1449 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow,wxScrolledWindow) |
786a2425 | 1450 | #endif |
5526e819 VS |
1451 | |
1452 | BEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow) | |
1453 | EVT_SIZE(wxHtmlWindow::OnSize) | |
adf2eb2d VS |
1454 | EVT_LEFT_DOWN(wxHtmlWindow::OnMouseDown) |
1455 | EVT_LEFT_UP(wxHtmlWindow::OnMouseUp) | |
1456 | EVT_RIGHT_UP(wxHtmlWindow::OnMouseUp) | |
31d8b4ad | 1457 | EVT_MOTION(wxHtmlWindow::OnMouseMove) |
1338c59a VS |
1458 | EVT_ERASE_BACKGROUND(wxHtmlWindow::OnEraseBackground) |
1459 | EVT_PAINT(wxHtmlWindow::OnPaint) | |
e3774124 | 1460 | #if wxUSE_CLIPBOARD |
31eefb99 | 1461 | EVT_LEFT_DCLICK(wxHtmlWindow::OnDoubleClick) |
1338c59a VS |
1462 | EVT_ENTER_WINDOW(wxHtmlWindow::OnMouseEnter) |
1463 | EVT_LEAVE_WINDOW(wxHtmlWindow::OnMouseLeave) | |
e3774124 VS |
1464 | EVT_KEY_UP(wxHtmlWindow::OnKeyUp) |
1465 | EVT_MENU(wxID_COPY, wxHtmlWindow::OnCopy) | |
d659d703 | 1466 | #endif // wxUSE_CLIPBOARD |
5526e819 VS |
1467 | END_EVENT_TABLE() |
1468 | ||
1469 | ||
1470 | ||
1471 | ||
1472 | ||
a76015e6 VS |
1473 | // A module to allow initialization/cleanup |
1474 | // without calling these functions from app.cpp or from | |
1475 | // the user's application. | |
1476 | ||
1477 | class wxHtmlWinModule: public wxModule | |
1478 | { | |
1479 | DECLARE_DYNAMIC_CLASS(wxHtmlWinModule) | |
1480 | public: | |
1481 | wxHtmlWinModule() : wxModule() {} | |
d1da8872 | 1482 | bool OnInit() { return true; } |
a76015e6 VS |
1483 | void OnExit() { wxHtmlWindow::CleanUpStatics(); } |
1484 | }; | |
1485 | ||
1486 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule, wxModule) | |
1487 | ||
5526e819 | 1488 | |
0cecad31 VS |
1489 | // This hack forces the linker to always link in m_* files |
1490 | // (wxHTML doesn't work without handlers from these files) | |
1491 | #include "wx/html/forcelnk.h" | |
1492 | FORCE_WXHTML_MODULES() | |
5526e819 | 1493 | |
d659d703 VZ |
1494 | #endif // wxUSE_HTML |
1495 |