]> git.saurik.com Git - wxWidgets.git/blob - src/html/htmlwin.cpp
Cygwin compile fix
[wxWidgets.git] / src / html / htmlwin.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: htmlwin.cpp
3 // Purpose: wxHtmlWindow class for parsing & displaying HTML (implementation)
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10
11 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
12 #pragma implementation "htmlwin.h"
13 #pragma implementation "htmlproc.h"
14 #endif
15
16 #include "wx/wxprec.h"
17
18 #include "wx/defs.h"
19 #if wxUSE_HTML && wxUSE_STREAMS
20
21 #ifdef __BORLANDC__
22 #pragma hdrstop
23 #endif
24
25 #ifndef WXPRECOMP
26 #include "wx/log.h"
27 #include "wx/intl.h"
28 #include "wx/dcclient.h"
29 #include "wx/frame.h"
30 #endif
31
32 #include "wx/html/htmlwin.h"
33 #include "wx/html/htmlproc.h"
34 #include "wx/list.h"
35 #include "wx/clipbrd.h"
36 #include "wx/dataobj.h"
37 #include "wx/timer.h"
38 #include "wx/dcmemory.h"
39 #include "wx/settings.h"
40
41 #include "wx/arrimpl.cpp"
42 #include "wx/listimpl.cpp"
43
44
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 }
113
114 #endif // wxUSE_CLIPBOARD
115
116
117
118 //-----------------------------------------------------------------------------
119 // wxHtmlHistoryItem
120 //-----------------------------------------------------------------------------
121
122 // item of history list
123 class WXDLLIMPEXP_HTML wxHtmlHistoryItem
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 };
137
138
139 //-----------------------------------------------------------------------------
140 // our private arrays:
141 //-----------------------------------------------------------------------------
142
143 WX_DECLARE_OBJARRAY(wxHtmlHistoryItem, wxHtmlHistoryArray);
144 WX_DEFINE_OBJARRAY(wxHtmlHistoryArray);
145
146 WX_DECLARE_LIST(wxHtmlProcessor, wxHtmlProcessorList);
147 WX_DEFINE_LIST(wxHtmlProcessorList);
148
149 //-----------------------------------------------------------------------------
150 // wxHtmlWindow
151 //-----------------------------------------------------------------------------
152
153
154 void wxHtmlWindow::Init()
155 {
156 m_tmpMouseMoved = false;
157 m_tmpLastLink = NULL;
158 m_tmpLastCell = NULL;
159 m_tmpCanDrawLocks = 0;
160 m_FS = new wxFileSystem();
161 #if wxUSE_STATUSBAR
162 m_RelatedStatusBar = -1;
163 #endif // wxUSE_STATUSBAR
164 m_RelatedFrame = NULL;
165 m_TitleFormat = wxT("%s");
166 m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
167 m_Cell = NULL;
168 m_Parser = new wxHtmlWinParser(this);
169 m_Parser->SetFS(m_FS);
170 m_HistoryPos = -1;
171 m_HistoryOn = true;
172 m_History = new wxHtmlHistoryArray;
173 m_Processors = NULL;
174 m_Style = 0;
175 SetBorders(10);
176 m_selection = NULL;
177 m_makingSelection = false;
178 #if wxUSE_CLIPBOARD
179 m_timerAutoScroll = NULL;
180 m_lastDoubleClick = 0;
181 #endif // wxUSE_CLIPBOARD
182 m_backBuffer = NULL;
183 m_eraseBgInOnPaint = false;
184 m_tmpSelFromCell = NULL;
185 }
186
187 bool wxHtmlWindow::Create(wxWindow *parent, wxWindowID id,
188 const wxPoint& pos, const wxSize& size,
189 long style, const wxString& name)
190 {
191 if (!wxScrolledWindow::Create(parent, id, pos, size,
192 style | wxVSCROLL | wxHSCROLL,
193 name))
194 return false;
195
196 m_Style = style;
197 SetPage(wxT("<html><body></body></html>"));
198 return true;
199 }
200
201
202 wxHtmlWindow::~wxHtmlWindow()
203 {
204 #if wxUSE_CLIPBOARD
205 StopAutoScrolling();
206 #endif // wxUSE_CLIPBOARD
207 HistoryClear();
208
209 delete m_selection;
210
211 delete m_Cell;
212
213 if ( m_Processors )
214 {
215 WX_CLEAR_LIST(wxHtmlProcessorList, *m_Processors);
216 }
217
218 delete m_Parser;
219 delete m_FS;
220 delete m_History;
221 delete m_Processors;
222 delete m_backBuffer;
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
235 #if wxUSE_STATUSBAR
236 void wxHtmlWindow::SetRelatedStatusBar(int bar)
237 {
238 m_RelatedStatusBar = bar;
239 }
240 #endif // wxUSE_STATUSBAR
241
242
243
244 void wxHtmlWindow::SetFonts(wxString normal_face, wxString fixed_face, const int *sizes)
245 {
246 wxString op = m_OpenedPage;
247
248 m_Parser->SetFonts(normal_face, fixed_face, sizes);
249 // fonts changed => contents invalid, so reload the page:
250 SetPage(wxT("<html><body></body></html>"));
251 if (!op.empty())
252 LoadPage(op);
253 }
254
255 void wxHtmlWindow::SetStandardFonts(int size,
256 const wxString& normal_face,
257 const wxString& fixed_face)
258 {
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);
266 }
267
268
269 bool wxHtmlWindow::SetPage(const wxString& source)
270 {
271 wxString newsrc(source);
272
273 wxDELETE(m_selection);
274
275 // we will soon delete all the cells, so clear pointers to them:
276 m_tmpSelFromCell = NULL;
277
278 // pass HTML through registered processors:
279 if (m_Processors || m_GlobalProcessors)
280 {
281 wxHtmlProcessorList::compatibility_iterator nodeL, nodeG;
282 int prL, prG;
283
284 nodeL = (m_Processors) ? m_Processors->GetFirst() : wxHtmlProcessorList::compatibility_iterator();
285 nodeG = (m_GlobalProcessors) ? m_GlobalProcessors->GetFirst() : wxHtmlProcessorList::compatibility_iterator();
286
287 // VS: there are two lists, global and local, both of them sorted by
288 // priority. Since we have to go through _both_ lists with
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)
293 {
294 prL = (nodeL) ? nodeL->GetData()->GetPriority() : -1;
295 prG = (nodeG) ? nodeG->GetData()->GetPriority() : -1;
296 if (prL > prG)
297 {
298 if (nodeL->GetData()->IsEnabled())
299 newsrc = nodeL->GetData()->Process(newsrc);
300 nodeL = nodeL->GetNext();
301 }
302 else // prL <= prG
303 {
304 if (nodeG->GetData()->IsEnabled())
305 newsrc = nodeG->GetData()->Process(newsrc);
306 nodeG = nodeG->GetNext();
307 }
308 }
309 }
310
311 // ...and run the parser on it:
312 wxClientDC *dc = new wxClientDC(this);
313 dc->SetMapMode(wxMM_TEXT);
314 SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
315 SetBackgroundImage(wxNullBitmap);
316 m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
317 m_Parser->SetDC(dc);
318 if (m_Cell)
319 {
320 delete m_Cell;
321 m_Cell = NULL;
322 }
323 m_Cell = (wxHtmlContainerCell*) m_Parser->Parse(newsrc);
324 delete dc;
325 m_Cell->SetIndent(m_Borders, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS);
326 m_Cell->SetAlignHor(wxHTML_ALIGN_CENTER);
327 CreateLayout();
328 if (m_tmpCanDrawLocks == 0)
329 Refresh();
330 return true;
331 }
332
333 bool wxHtmlWindow::AppendToPage(const wxString& source)
334 {
335 return SetPage(*(GetParser()->GetSource()) + source);
336 }
337
338 bool wxHtmlWindow::LoadPage(const wxString& location)
339 {
340 wxBusyCursor busyCursor;
341
342 wxFSFile *f;
343 bool rt_val;
344 bool needs_refresh = false;
345
346 m_tmpCanDrawLocks++;
347 if (m_HistoryOn && (m_HistoryPos != -1))
348 {
349 // store scroll position into history item:
350 int x, y;
351 GetViewStart(&x, &y);
352 (*m_History)[m_HistoryPos].SetPos(y);
353 }
354
355 if (location[0] == wxT('#'))
356 {
357 // local anchor:
358 wxString anch = location.Mid(1) /*1 to end*/;
359 m_tmpCanDrawLocks--;
360 rt_val = ScrollToAnchor(anch);
361 m_tmpCanDrawLocks++;
362 }
363 else if (location.Find(wxT('#')) != wxNOT_FOUND && location.BeforeFirst(wxT('#')) == m_OpenedPage)
364 {
365 wxString anch = location.AfterFirst(wxT('#'));
366 m_tmpCanDrawLocks--;
367 rt_val = ScrollToAnchor(anch);
368 m_tmpCanDrawLocks++;
369 }
370 else if (location.Find(wxT('#')) != wxNOT_FOUND &&
371 (m_FS->GetPath() + location.BeforeFirst(wxT('#'))) == m_OpenedPage)
372 {
373 wxString anch = location.AfterFirst(wxT('#'));
374 m_tmpCanDrawLocks--;
375 rt_val = ScrollToAnchor(anch);
376 m_tmpCanDrawLocks++;
377 }
378
379 else
380 {
381 needs_refresh = true;
382 #if wxUSE_STATUSBAR
383 // load&display it:
384 if (m_RelatedStatusBar != -1)
385 {
386 m_RelatedFrame->SetStatusText(_("Connecting..."), m_RelatedStatusBar);
387 Refresh(false);
388 }
389 #endif // wxUSE_STATUSBAR
390
391 f = m_Parser->OpenURL(wxHTML_URL_PAGE, location);
392
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
401 if (f == NULL)
402 {
403 wxLogError(_("Unable to open requested HTML document: %s"), location.c_str());
404 m_tmpCanDrawLocks--;
405 return false;
406 }
407
408 else
409 {
410 wxList::compatibility_iterator node;
411 wxString src = wxEmptyString;
412
413 #if wxUSE_STATUSBAR
414 if (m_RelatedStatusBar != -1)
415 {
416 wxString msg = _("Loading : ") + location;
417 m_RelatedFrame->SetStatusText(msg, m_RelatedStatusBar);
418 Refresh(false);
419 }
420 #endif // wxUSE_STATUSBAR
421
422 node = m_Filters.GetFirst();
423 while (node)
424 {
425 wxHtmlFilter *h = (wxHtmlFilter*) node->GetData();
426 if (h->CanRead(*f))
427 {
428 src = h->ReadFile(*f);
429 break;
430 }
431 node = node->GetNext();
432 }
433 if (src == wxEmptyString)
434 {
435 if (m_DefaultFilter == NULL) m_DefaultFilter = GetDefaultFilter();
436 src = m_DefaultFilter->ReadFile(*f);
437 }
438
439 m_FS->ChangePathTo(f->GetLocation());
440 rt_val = SetPage(src);
441 m_OpenedPage = f->GetLocation();
442 if (f->GetAnchor() != wxEmptyString)
443 {
444 ScrollToAnchor(f->GetAnchor());
445 }
446
447 delete f;
448
449 #if wxUSE_STATUSBAR
450 if (m_RelatedStatusBar != -1)
451 m_RelatedFrame->SetStatusText(_("Done"), m_RelatedStatusBar);
452 #endif // wxUSE_STATUSBAR
453 }
454 }
455
456 if (m_HistoryOn) // add this page to history there:
457 {
458 int c = m_History->GetCount() - (m_HistoryPos + 1);
459
460 if (m_HistoryPos < 0 ||
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++)
466 m_History->RemoveAt(m_HistoryPos);
467 m_History->Add(new wxHtmlHistoryItem(m_OpenedPage, m_OpenedAnchor));
468 }
469 }
470
471 if (m_OpenedPageTitle == wxEmptyString)
472 OnSetTitle(wxFileNameFromPath(m_OpenedPage));
473
474 if (needs_refresh)
475 {
476 m_tmpCanDrawLocks--;
477 Refresh();
478 }
479 else
480 m_tmpCanDrawLocks--;
481
482 return rt_val;
483 }
484
485
486 bool wxHtmlWindow::LoadFile(const wxFileName& filename)
487 {
488 wxString url = wxFileSystem::FileNameToURL(filename);
489 return LoadPage(url);
490 }
491
492
493 bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor)
494 {
495 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
496 if (!c)
497 {
498 wxLogWarning(_("HTML anchor %s does not exist."), anchor.c_str());
499 return false;
500 }
501 else
502 {
503 int y;
504
505 for (y = 0; c != NULL; c = c->GetParent()) y += c->GetPosY();
506 Scroll(-1, y / wxHTML_SCROLL_STEP);
507 m_OpenedAnchor = anchor;
508 return true;
509 }
510 }
511
512
513 void wxHtmlWindow::OnSetTitle(const wxString& title)
514 {
515 if (m_RelatedFrame)
516 {
517 wxString tit;
518 tit.Printf(m_TitleFormat, title.c_str());
519 m_RelatedFrame->SetTitle(tit);
520 }
521 m_OpenedPageTitle = title;
522 }
523
524
525
526
527
528 void wxHtmlWindow::CreateLayout()
529 {
530 int ClientWidth, ClientHeight;
531
532 if (!m_Cell) return;
533
534 if (m_Style & wxHW_SCROLLBAR_NEVER)
535 {
536 SetScrollbars(wxHTML_SCROLL_STEP, 1, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, 0); // always off
537 GetClientSize(&ClientWidth, &ClientHeight);
538 m_Cell->Layout(ClientWidth);
539 }
540
541 else {
542 GetClientSize(&ClientWidth, &ClientHeight);
543 m_Cell->Layout(ClientWidth);
544 if (ClientHeight < m_Cell->GetHeight() + GetCharHeight())
545 {
546 SetScrollbars(
547 wxHTML_SCROLL_STEP, wxHTML_SCROLL_STEP,
548 m_Cell->GetWidth() / wxHTML_SCROLL_STEP,
549 (m_Cell->GetHeight() + GetCharHeight()) / wxHTML_SCROLL_STEP
550 /*cheat: top-level frag is always container*/);
551 }
552 else /* we fit into window, no need for scrollbars */
553 {
554 SetScrollbars(wxHTML_SCROLL_STEP, 1, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, 0); // disable...
555 GetClientSize(&ClientWidth, &ClientHeight);
556 m_Cell->Layout(ClientWidth); // ...and relayout
557 }
558 }
559 }
560
561
562
563 void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path)
564 {
565 wxString oldpath;
566 wxString tmp;
567 int p_fontsizes[7];
568 wxString p_fff, p_ffn;
569
570 if (path != wxEmptyString)
571 {
572 oldpath = cfg->GetPath();
573 cfg->SetPath(path);
574 }
575
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);
579 for (int i = 0; i < 7; i++)
580 {
581 tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i);
582 p_fontsizes[i] = cfg->Read(tmp, m_Parser->m_FontsSizes[i]);
583 }
584 SetFonts(p_ffn, p_fff, p_fontsizes);
585
586 if (path != wxEmptyString)
587 cfg->SetPath(oldpath);
588 }
589
590
591
592 void wxHtmlWindow::WriteCustomization(wxConfigBase *cfg, wxString path)
593 {
594 wxString oldpath;
595 wxString tmp;
596
597 if (path != wxEmptyString)
598 {
599 oldpath = cfg->GetPath();
600 cfg->SetPath(path);
601 }
602
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);
606 for (int i = 0; i < 7; i++)
607 {
608 tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i);
609 cfg->Write(tmp, (long) m_Parser->m_FontsSizes[i]);
610 }
611
612 if (path != wxEmptyString)
613 cfg->SetPath(oldpath);
614 }
615
616
617
618 bool wxHtmlWindow::HistoryBack()
619 {
620 wxString a, l;
621
622 if (m_HistoryPos < 1) return false;
623
624 // store scroll position into history item:
625 int x, y;
626 GetViewStart(&x, &y);
627 (*m_History)[m_HistoryPos].SetPos(y);
628
629 // go to previous position:
630 m_HistoryPos--;
631
632 l = (*m_History)[m_HistoryPos].GetPage();
633 a = (*m_History)[m_HistoryPos].GetAnchor();
634 m_HistoryOn = false;
635 m_tmpCanDrawLocks++;
636 if (a == wxEmptyString) LoadPage(l);
637 else LoadPage(l + wxT("#") + a);
638 m_HistoryOn = true;
639 m_tmpCanDrawLocks--;
640 Scroll(0, (*m_History)[m_HistoryPos].GetPos());
641 Refresh();
642 return true;
643 }
644
645 bool wxHtmlWindow::HistoryCanBack()
646 {
647 if (m_HistoryPos < 1) return false;
648 return true ;
649 }
650
651
652 bool wxHtmlWindow::HistoryForward()
653 {
654 wxString a, l;
655
656 if (m_HistoryPos == -1) return false;
657 if (m_HistoryPos >= (int)m_History->GetCount() - 1)return false;
658
659 m_OpenedPage = wxEmptyString; // this will disable adding new entry into history in LoadPage()
660
661 m_HistoryPos++;
662 l = (*m_History)[m_HistoryPos].GetPage();
663 a = (*m_History)[m_HistoryPos].GetAnchor();
664 m_HistoryOn = false;
665 m_tmpCanDrawLocks++;
666 if (a == wxEmptyString) LoadPage(l);
667 else LoadPage(l + wxT("#") + a);
668 m_HistoryOn = true;
669 m_tmpCanDrawLocks--;
670 Scroll(0, (*m_History)[m_HistoryPos].GetPos());
671 Refresh();
672 return true;
673 }
674
675 bool wxHtmlWindow::HistoryCanForward()
676 {
677 if (m_HistoryPos == -1) return false;
678 if (m_HistoryPos >= (int)m_History->GetCount() - 1)return false;
679 return true ;
680 }
681
682
683 void wxHtmlWindow::HistoryClear()
684 {
685 m_History->Empty();
686 m_HistoryPos = -1;
687 }
688
689 void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor)
690 {
691 if (!m_Processors)
692 {
693 m_Processors = new wxHtmlProcessorList;
694 }
695 wxHtmlProcessorList::compatibility_iterator node;
696
697 for (node = m_Processors->GetFirst(); node; node = node->GetNext())
698 {
699 if (processor->GetPriority() > node->GetData()->GetPriority())
700 {
701 m_Processors->Insert(node, processor);
702 return;
703 }
704 }
705 m_Processors->Append(processor);
706 }
707
708 /*static */ void wxHtmlWindow::AddGlobalProcessor(wxHtmlProcessor *processor)
709 {
710 if (!m_GlobalProcessors)
711 {
712 m_GlobalProcessors = new wxHtmlProcessorList;
713 }
714 wxHtmlProcessorList::compatibility_iterator node;
715
716 for (node = m_GlobalProcessors->GetFirst(); node; node = node->GetNext())
717 {
718 if (processor->GetPriority() > node->GetData()->GetPriority())
719 {
720 m_GlobalProcessors->Insert(node, processor);
721 return;
722 }
723 }
724 m_GlobalProcessors->Append(processor);
725 }
726
727
728
729 wxList wxHtmlWindow::m_Filters;
730 wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL;
731 wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL;
732
733 void wxHtmlWindow::CleanUpStatics()
734 {
735 wxDELETE(m_DefaultFilter);
736 WX_CLEAR_LIST(wxList, m_Filters);
737 if (m_GlobalProcessors)
738 WX_CLEAR_LIST(wxHtmlProcessorList, *m_GlobalProcessors);
739 wxDELETE(m_GlobalProcessors);
740 }
741
742
743
744 void wxHtmlWindow::AddFilter(wxHtmlFilter *filter)
745 {
746 m_Filters.Append(filter);
747 }
748
749
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 }
758
759
760 #if wxUSE_CLIPBOARD
761 wxString wxHtmlWindow::DoSelectionToText(wxHtmlSelection *sel)
762 {
763 if ( !sel )
764 return wxEmptyString;
765
766 wxClientDC dc(this);
767
768 const wxHtmlCell *end = sel->GetToCell();
769 wxString text;
770 wxHtmlTerminalCellsInterator i(sel->GetFromCell(), end);
771 if ( i )
772 {
773 text << i->ConvertToText(sel);
774 ++i;
775 }
776 const wxHtmlCell *prev = *i;
777 while ( i )
778 {
779 if ( prev->GetParent() != i->GetParent() )
780 text << _T('\n');
781 text << i->ConvertToText(*i == end ? sel : NULL);
782 prev = *i;
783 ++i;
784 }
785 return text;
786 }
787
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
800 #endif // wxUSE_CLIPBOARD
801
802 bool wxHtmlWindow::CopySelection(ClipboardType t)
803 {
804 #if wxUSE_CLIPBOARD
805 if ( m_selection )
806 {
807 #if defined(__UNIX__) && !defined(__WXMAC__)
808 wxTheClipboard->UsePrimarySelection(t == Primary);
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 )
815 return false;
816 #endif // __UNIX__/!__UNIX__
817
818 if ( wxTheClipboard->Open() )
819 {
820 const wxString txt(SelectionToText());
821 wxTheClipboard->SetData(new wxTextDataObject(txt));
822 wxTheClipboard->Close();
823 wxLogTrace(_T("wxhtmlselection"),
824 _("Copied to clipboard:\"%s\""), txt.c_str());
825
826 return true;
827 }
828 }
829 #else
830 wxUnusedVar(t);
831 #endif // wxUSE_CLIPBOARD
832
833 return false;
834 }
835
836
837 void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
838 {
839 const wxMouseEvent *e = link.GetEvent();
840 if (e == NULL || e->LeftUp())
841 LoadPage(link.GetHref());
842 }
843
844 void wxHtmlWindow::OnCellClicked(wxHtmlCell *cell,
845 wxCoord x, wxCoord y,
846 const wxMouseEvent& event)
847 {
848 wxCHECK_RET( cell, _T("can't be called with NULL cell") );
849
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 }
858
859 void wxHtmlWindow::OnEraseBackground(wxEraseEvent& event)
860 {
861 if ( !m_bmpBg.Ok() )
862 {
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;
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 }
892 }
893
894 void wxHtmlWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
895 {
896 wxPaintDC dc(this);
897
898 if (m_tmpCanDrawLocks > 0 || m_Cell == NULL)
899 return;
900
901 int x, y;
902 GetViewStart(&x, &y);
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);
909 dcm.SelectObject(*m_backBuffer);
910
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 }
928
929 PrepareDC(dcm);
930 dcm.SetMapMode(wxMM_TEXT);
931 dcm.SetBackgroundMode(wxTRANSPARENT);
932
933 wxHtmlRenderingInfo rinfo;
934 wxDefaultHtmlRenderingStyle rstyle;
935 rinfo.SetSelection(m_selection);
936 rinfo.SetStyle(&rstyle);
937 m_Cell->Draw(dcm, 0, 0,
938 y * wxHTML_SCROLL_STEP + rect.GetTop(),
939 y * wxHTML_SCROLL_STEP + rect.GetBottom(),
940 rinfo);
941
942 //#define DEBUG_HTML_SELECTION
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);
950 wxHtmlCell *before =
951 m_Cell->FindCellByPos(x, y, wxHTML_FIND_NEAREST_BEFORE);
952 wxHtmlCell *after =
953 m_Cell->FindCellByPos(x, y, wxHTML_FIND_NEAREST_AFTER);
954
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
970
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());
976 }
977
978
979
980
981 void wxHtmlWindow::OnSize(wxSizeEvent& event)
982 {
983 wxDELETE(m_backBuffer);
984
985 wxScrolledWindow::OnSize(event);
986 CreateLayout();
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 }
995
996 Refresh();
997 }
998
999
1000 void wxHtmlWindow::OnMouseMove(wxMouseEvent& WXUNUSED(event))
1001 {
1002 m_tmpMouseMoved = true;
1003 }
1004
1005 void wxHtmlWindow::OnMouseDown(wxMouseEvent& event)
1006 {
1007 #if wxUSE_CLIPBOARD
1008 if ( event.LeftDown() && IsSelectionEnabled() )
1009 {
1010 const long TRIPLECLICK_LEN = 200; // 0.2 sec after doubleclick
1011 if ( wxGetLocalTimeMillis() - m_lastDoubleClick <= TRIPLECLICK_LEN )
1012 {
1013 SelectLine(CalcUnscrolledPosition(event.GetPosition()));
1014
1015 (void) CopySelection();
1016 }
1017 else
1018 {
1019 m_makingSelection = true;
1020
1021 if ( m_selection )
1022 {
1023 wxDELETE(m_selection);
1024 Refresh();
1025 }
1026 m_tmpSelFromPos = CalcUnscrolledPosition(event.GetPosition());
1027 m_tmpSelFromCell = NULL;
1028
1029 CaptureMouse();
1030 }
1031 }
1032 #else
1033 wxUnusedVar(event);
1034 #endif // wxUSE_CLIPBOARD
1035 }
1036
1037 void wxHtmlWindow::OnMouseUp(wxMouseEvent& event)
1038 {
1039 #if wxUSE_CLIPBOARD
1040 if ( m_makingSelection )
1041 {
1042 ReleaseMouse();
1043 m_makingSelection = false;
1044
1045 // did the user move the mouse far enough from starting point?
1046 if ( CopySelection(Primary) )
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 }
1053 #endif // wxUSE_CLIPBOARD
1054
1055 SetFocus();
1056 if ( m_Cell )
1057 {
1058 wxPoint pos = CalcUnscrolledPosition(event.GetPosition());
1059 wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y);
1060
1061 // check is needed because FindCellByPos returns terminal cell and
1062 // containers may have empty borders -- in this case NULL will be
1063 // returned
1064 if ( cell )
1065 OnCellClicked(cell, pos.x, pos.y, event);
1066 }
1067 }
1068
1069
1070
1071 void wxHtmlWindow::OnInternalIdle()
1072 {
1073 wxWindow::OnInternalIdle();
1074
1075 if (m_tmpMouseMoved && (m_Cell != NULL))
1076 {
1077 #ifdef DEBUG_HTML_SELECTION
1078 Refresh();
1079 #endif
1080 int xc, yc, x, y;
1081 wxGetMousePosition(&xc, &yc);
1082 ScreenToClient(&xc, &yc);
1083 CalcUnscrolledPosition(xc, yc, &x, &y);
1084
1085 wxHtmlCell *cell = m_Cell->FindCellByPos(x, y);
1086
1087 // handle selection update:
1088 if ( m_makingSelection )
1089 {
1090 if ( !m_tmpSelFromCell )
1091 m_tmpSelFromCell = m_Cell->FindCellByPos(
1092 m_tmpSelFromPos.x,m_tmpSelFromPos.y);
1093
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 }
1115 bool goingDown = dirFromPos.y < y ||
1116 (dirFromPos.y == y && dirFromPos.x < x);
1117
1118 // determine selection span:
1119 if ( /*still*/ !m_tmpSelFromCell )
1120 {
1121 if (goingDown)
1122 {
1123 m_tmpSelFromCell = m_Cell->FindCellByPos(
1124 m_tmpSelFromPos.x,m_tmpSelFromPos.y,
1125 wxHTML_FIND_NEAREST_AFTER);
1126 if (!m_tmpSelFromCell)
1127 m_tmpSelFromCell = m_Cell->GetFirstTerminal();
1128 }
1129 else
1130 {
1131 m_tmpSelFromCell = m_Cell->FindCellByPos(
1132 m_tmpSelFromPos.x,m_tmpSelFromPos.y,
1133 wxHTML_FIND_NEAREST_BEFORE);
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,
1145 wxHTML_FIND_NEAREST_BEFORE);
1146 if (!selcell)
1147 selcell = m_Cell->GetLastTerminal();
1148 }
1149 else
1150 {
1151 selcell = m_Cell->FindCellByPos(x, y,
1152 wxHTML_FIND_NEAREST_AFTER);
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
1160 // visible cells.
1161 if ( selcell && m_tmpSelFromCell )
1162 {
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 {
1176 if ( m_tmpSelFromCell->IsBefore(selcell) )
1177 {
1178 m_selection->Set(m_tmpSelFromPos, m_tmpSelFromCell,
1179 wxPoint(x,y), selcell); }
1180 else
1181 {
1182 m_selection->Set(wxPoint(x,y), selcell,
1183 m_tmpSelFromPos, m_tmpSelFromCell);
1184 }
1185 m_selection->ClearPrivPos();
1186 Refresh();
1187 }
1188 }
1189 }
1190
1191 // handle cursor and status bar text changes:
1192 if ( cell != m_tmpLastCell )
1193 {
1194 wxHtmlLinkInfo *lnk = cell ? cell->GetLink(x, y) : NULL;
1195 wxCursor cur;
1196 if (cell)
1197 cur = cell->GetCursor();
1198 else
1199 cur = *wxSTANDARD_CURSOR;
1200 SetCursor(cur);
1201
1202 if (lnk != m_tmpLastLink)
1203 {
1204 #if wxUSE_STATUSBAR
1205 if (lnk == NULL)
1206 {
1207 if (m_RelatedStatusBar != -1)
1208 m_RelatedFrame->SetStatusText(wxEmptyString,
1209 m_RelatedStatusBar);
1210 }
1211 else
1212 {
1213 if (m_RelatedStatusBar != -1)
1214 m_RelatedFrame->SetStatusText(lnk->GetHref(),
1215 m_RelatedStatusBar);
1216 }
1217 #endif // wxUSE_STATUSBAR
1218 m_tmpLastLink = lnk;
1219 }
1220
1221 m_tmpLastCell = cell;
1222 }
1223 else // mouse moved but stayed in the same cell
1224 {
1225 if ( cell )
1226 OnCellMouseHover(cell, x, y);
1227 }
1228
1229 m_tmpMouseMoved = false;
1230 }
1231 }
1232
1233 #if wxUSE_CLIPBOARD
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
1313 void wxHtmlWindow::OnKeyUp(wxKeyEvent& event)
1314 {
1315 if ( IsSelectionEnabled() &&
1316 event.GetKeyCode() == 'C' && event.ControlDown() )
1317 {
1318 (void) CopySelection();
1319 }
1320 }
1321
1322 void wxHtmlWindow::OnCopy(wxCommandEvent& WXUNUSED(event))
1323 {
1324 (void) CopySelection();
1325 }
1326
1327 void wxHtmlWindow::OnDoubleClick(wxMouseEvent& event)
1328 {
1329 // select word under cursor:
1330 if ( IsSelectionEnabled() )
1331 {
1332 SelectWord(CalcUnscrolledPosition(event.GetPosition()));
1333
1334 (void) CopySelection(Primary);
1335
1336 m_lastDoubleClick = wxGetLocalTimeMillis();
1337 }
1338 else
1339 event.Skip();
1340 }
1341
1342 void wxHtmlWindow::SelectWord(const wxPoint& pos)
1343 {
1344 if ( m_Cell )
1345 {
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 }
1355 }
1356 }
1357
1358 void wxHtmlWindow::SelectLine(const wxPoint& pos)
1359 {
1360 if ( m_Cell )
1361 {
1362 wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y);
1363 if ( cell )
1364 {
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;
1388
1389 // find first cell of line:
1390 for ( c = cell->GetParent()->GetFirstChild();
1391 c && c != cell; c = c->GetNext())
1392 {
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;
1401 }
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();
1410 }
1411 }
1412 }
1413
1414 void wxHtmlWindow::SelectAll()
1415 {
1416 if ( m_Cell )
1417 {
1418 delete m_selection;
1419 m_selection = new wxHtmlSelection();
1420 m_selection->Set(m_Cell->GetFirstTerminal(), m_Cell->GetLastTerminal());
1421 Refresh();
1422 }
1423 }
1424
1425 #endif // wxUSE_CLIPBOARD
1426
1427
1428
1429 IMPLEMENT_ABSTRACT_CLASS(wxHtmlProcessor,wxObject)
1430
1431 #if wxUSE_EXTENDED_RTTI
1432 IMPLEMENT_DYNAMIC_CLASS_XTI(wxHtmlWindow, wxScrolledWindow,"wx/html/htmlwin.h")
1433
1434 wxBEGIN_PROPERTIES_TABLE(wxHtmlWindow)
1435 /*
1436 TODO PROPERTIES
1437 style , wxHW_SCROLLBAR_AUTO
1438 borders , (dimension)
1439 url , string
1440 htmlcode , string
1441 */
1442 wxEND_PROPERTIES_TABLE()
1443
1444 wxBEGIN_HANDLERS_TABLE(wxHtmlWindow)
1445 wxEND_HANDLERS_TABLE()
1446
1447 wxCONSTRUCTOR_5( wxHtmlWindow , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle )
1448 #else
1449 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow,wxScrolledWindow)
1450 #endif
1451
1452 BEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow)
1453 EVT_SIZE(wxHtmlWindow::OnSize)
1454 EVT_LEFT_DOWN(wxHtmlWindow::OnMouseDown)
1455 EVT_LEFT_UP(wxHtmlWindow::OnMouseUp)
1456 EVT_RIGHT_UP(wxHtmlWindow::OnMouseUp)
1457 EVT_MOTION(wxHtmlWindow::OnMouseMove)
1458 EVT_ERASE_BACKGROUND(wxHtmlWindow::OnEraseBackground)
1459 EVT_PAINT(wxHtmlWindow::OnPaint)
1460 #if wxUSE_CLIPBOARD
1461 EVT_LEFT_DCLICK(wxHtmlWindow::OnDoubleClick)
1462 EVT_ENTER_WINDOW(wxHtmlWindow::OnMouseEnter)
1463 EVT_LEAVE_WINDOW(wxHtmlWindow::OnMouseLeave)
1464 EVT_KEY_UP(wxHtmlWindow::OnKeyUp)
1465 EVT_MENU(wxID_COPY, wxHtmlWindow::OnCopy)
1466 #endif // wxUSE_CLIPBOARD
1467 END_EVENT_TABLE()
1468
1469
1470
1471
1472
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() {}
1482 bool OnInit() { return true; }
1483 void OnExit() { wxHtmlWindow::CleanUpStatics(); }
1484 };
1485
1486 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule, wxModule)
1487
1488
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()
1493
1494 #endif // wxUSE_HTML
1495