]> git.saurik.com Git - wxWidgets.git/blob - src/html/htmlwin.cpp
install wxUniv headers in make install and include wxUniv sources in make dist
[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 #ifdef __GNUG__
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 __BORDLANDC__
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
36 #include "wx/arrimpl.cpp"
37 #include "wx/listimpl.cpp"
38
39 //-----------------------------------------------------------------------------
40 // wxHtmlHistoryItem
41 //-----------------------------------------------------------------------------
42
43 // item of history list
44 class WXDLLEXPORT wxHtmlHistoryItem : public wxObject
45 {
46 public:
47 wxHtmlHistoryItem(const wxString& p, const wxString& a) {m_Page = p, m_Anchor = a, m_Pos = 0;}
48 int GetPos() const {return m_Pos;}
49 void SetPos(int p) {m_Pos = p;}
50 const wxString& GetPage() const {return m_Page;}
51 const wxString& GetAnchor() const {return m_Anchor;}
52
53 private:
54 wxString m_Page;
55 wxString m_Anchor;
56 int m_Pos;
57 };
58
59
60 //-----------------------------------------------------------------------------
61 // our private arrays:
62 //-----------------------------------------------------------------------------
63
64 WX_DECLARE_OBJARRAY(wxHtmlHistoryItem, wxHtmlHistoryArray);
65 WX_DEFINE_OBJARRAY(wxHtmlHistoryArray);
66
67 WX_DECLARE_LIST(wxHtmlProcessor, wxHtmlProcessorList);
68 WX_DEFINE_LIST(wxHtmlProcessorList);
69
70 //-----------------------------------------------------------------------------
71 // wxHtmlWindow
72 //-----------------------------------------------------------------------------
73
74
75 void wxHtmlWindow::Init()
76 {
77 m_tmpMouseMoved = FALSE;
78 m_tmpLastLink = NULL;
79 m_tmpLastCell = NULL;
80 m_tmpCanDrawLocks = 0;
81 m_FS = new wxFileSystem();
82 m_RelatedStatusBar = -1;
83 m_RelatedFrame = NULL;
84 m_TitleFormat = wxT("%s");
85 m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
86 m_Cell = NULL;
87 m_Parser = new wxHtmlWinParser(this);
88 m_Parser->SetFS(m_FS);
89 m_HistoryPos = -1;
90 m_HistoryOn = TRUE;
91 m_History = new wxHtmlHistoryArray;
92 m_Processors = NULL;
93 m_Style = 0;
94 SetBorders(10);
95 }
96
97 bool wxHtmlWindow::Create(wxWindow *parent, wxWindowID id,
98 const wxPoint& pos, const wxSize& size,
99 long style, const wxString& name)
100 {
101 if (!wxScrolledWindow::Create(parent, id, pos, size,
102 style | wxVSCROLL | wxHSCROLL, name))
103 return FALSE;
104
105 m_Style = style;
106 SetPage(wxT("<html><body></body></html>"));
107 return TRUE;
108 }
109
110
111 wxHtmlWindow::~wxHtmlWindow()
112 {
113 HistoryClear();
114
115 if (m_Cell) delete m_Cell;
116
117 delete m_Parser;
118 delete m_FS;
119 delete m_History;
120 delete m_Processors;
121 }
122
123
124
125 void wxHtmlWindow::SetRelatedFrame(wxFrame* frame, const wxString& format)
126 {
127 m_RelatedFrame = frame;
128 m_TitleFormat = format;
129 }
130
131
132
133 void wxHtmlWindow::SetRelatedStatusBar(int bar)
134 {
135 m_RelatedStatusBar = bar;
136 }
137
138
139
140 void wxHtmlWindow::SetFonts(wxString normal_face, wxString fixed_face, const int *sizes)
141 {
142 wxString op = m_OpenedPage;
143
144 m_Parser->SetFonts(normal_face, fixed_face, sizes);
145 // fonts changed => contents invalid, so reload the page:
146 SetPage(wxT("<html><body></body></html>"));
147 if (!op.IsEmpty()) LoadPage(op);
148 }
149
150
151
152 bool wxHtmlWindow::SetPage(const wxString& source)
153 {
154 wxString newsrc(source);
155
156 // pass HTML through registered processors:
157 if (m_Processors || m_GlobalProcessors)
158 {
159 wxHtmlProcessorList::Node *nodeL, *nodeG;
160 int prL, prG;
161
162 nodeL = (m_Processors) ? m_Processors->GetFirst() : NULL;
163 nodeG = (m_GlobalProcessors) ? m_GlobalProcessors->GetFirst() : NULL;
164
165 // VS: there are two lists, global and local, both of them sorted by
166 // priority. Since we have to go through _both_ lists with
167 // decreasing priority, we "merge-sort" the lists on-line by
168 // processing that one of the two heads that has higher priority
169 // in every iteration
170 while (nodeL || nodeG)
171 {
172 prL = (nodeL) ? nodeL->GetData()->GetPriority() : -1;
173 prG = (nodeG) ? nodeG->GetData()->GetPriority() : -1;
174 if (prL > prG)
175 {
176 if (nodeL->GetData()->IsEnabled())
177 newsrc = nodeL->GetData()->Process(newsrc);
178 nodeL = nodeL->GetNext();
179 }
180 else // prL <= prG
181 {
182 if (nodeG->GetData()->IsEnabled())
183 newsrc = nodeG->GetData()->Process(newsrc);
184 nodeG = nodeG->GetNext();
185 }
186 }
187 }
188
189 // ...and run the parser on it:
190 wxClientDC *dc = new wxClientDC(this);
191 dc->SetMapMode(wxMM_TEXT);
192 SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
193 m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
194 m_Parser->SetDC(dc);
195 if (m_Cell)
196 {
197 delete m_Cell;
198 m_Cell = NULL;
199 }
200 m_Cell = (wxHtmlContainerCell*) m_Parser->Parse(newsrc);
201 delete dc;
202 m_Cell->SetIndent(m_Borders, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS);
203 m_Cell->SetAlignHor(wxHTML_ALIGN_CENTER);
204 CreateLayout();
205 if (m_tmpCanDrawLocks == 0)
206 Refresh();
207 return TRUE;
208 }
209
210 bool wxHtmlWindow::AppendToPage(const wxString& source)
211 {
212 return SetPage(*(GetParser()->GetSource()) + source);
213 }
214
215 bool wxHtmlWindow::LoadPage(const wxString& location)
216 {
217 wxBusyCursor busyCursor;
218
219 wxFSFile *f;
220 bool rt_val;
221 bool needs_refresh = FALSE;
222
223 m_tmpCanDrawLocks++;
224 if (m_HistoryOn && (m_HistoryPos != -1))
225 {
226 // store scroll position into history item:
227 int x, y;
228 GetViewStart(&x, &y);
229 (*m_History)[m_HistoryPos].SetPos(y);
230 }
231
232 if (location[0] == wxT('#'))
233 {
234 // local anchor:
235 wxString anch = location.Mid(1) /*1 to end*/;
236 m_tmpCanDrawLocks--;
237 rt_val = ScrollToAnchor(anch);
238 m_tmpCanDrawLocks++;
239 }
240 else if (location.Find(wxT('#')) != wxNOT_FOUND && location.BeforeFirst(wxT('#')) == m_OpenedPage)
241 {
242 wxString anch = location.AfterFirst(wxT('#'));
243 m_tmpCanDrawLocks--;
244 rt_val = ScrollToAnchor(anch);
245 m_tmpCanDrawLocks++;
246 }
247 else if (location.Find(wxT('#')) != wxNOT_FOUND &&
248 (m_FS->GetPath() + location.BeforeFirst(wxT('#'))) == m_OpenedPage)
249 {
250 wxString anch = location.AfterFirst(wxT('#'));
251 m_tmpCanDrawLocks--;
252 rt_val = ScrollToAnchor(anch);
253 m_tmpCanDrawLocks++;
254 }
255
256 else
257 {
258 needs_refresh = TRUE;
259 // load&display it:
260 if (m_RelatedStatusBar != -1)
261 {
262 m_RelatedFrame->SetStatusText(_("Connecting..."), m_RelatedStatusBar);
263 Refresh(FALSE);
264 }
265
266 if ( !m_Parser->CanOpenURL(location) )
267 {
268 wxLogError(_("Access denied to document '%s'!"), location.c_str());
269 return FALSE;
270 }
271
272 f = m_FS->OpenFile(location);
273
274 if (f == NULL)
275 {
276 wxLogError(_("Unable to open requested HTML document: %s"), location.c_str());
277 m_tmpCanDrawLocks--;
278 return FALSE;
279 }
280
281 else
282 {
283 wxNode *node;
284 wxString src = wxEmptyString;
285
286 if (m_RelatedStatusBar != -1)
287 {
288 wxString msg = _("Loading : ") + location;
289 m_RelatedFrame->SetStatusText(msg, m_RelatedStatusBar);
290 Refresh(FALSE);
291 }
292
293 node = m_Filters.GetFirst();
294 while (node)
295 {
296 wxHtmlFilter *h = (wxHtmlFilter*) node->GetData();
297 if (h->CanRead(*f))
298 {
299 src = h->ReadFile(*f);
300 break;
301 }
302 node = node->GetNext();
303 }
304 if (src == wxEmptyString)
305 {
306 if (m_DefaultFilter == NULL) m_DefaultFilter = GetDefaultFilter();
307 src = m_DefaultFilter->ReadFile(*f);
308 }
309
310 m_FS->ChangePathTo(f->GetLocation());
311 rt_val = SetPage(src);
312 m_OpenedPage = f->GetLocation();
313 if (f->GetAnchor() != wxEmptyString)
314 {
315 ScrollToAnchor(f->GetAnchor());
316 }
317
318 delete f;
319
320 if (m_RelatedStatusBar != -1) m_RelatedFrame->SetStatusText(_("Done"), m_RelatedStatusBar);
321 }
322 }
323
324 if (m_HistoryOn) // add this page to history there:
325 {
326 int c = m_History->GetCount() - (m_HistoryPos + 1);
327
328 if (m_HistoryPos < 0 ||
329 (*m_History)[m_HistoryPos].GetPage() != m_OpenedPage ||
330 (*m_History)[m_HistoryPos].GetAnchor() != m_OpenedAnchor)
331 {
332 m_HistoryPos++;
333 for (int i = 0; i < c; i++)
334 m_History->RemoveAt(m_HistoryPos);
335 m_History->Add(new wxHtmlHistoryItem(m_OpenedPage, m_OpenedAnchor));
336 }
337 }
338
339 if (m_OpenedPageTitle == wxEmptyString)
340 OnSetTitle(wxFileNameFromPath(m_OpenedPage));
341
342 if (needs_refresh)
343 {
344 m_tmpCanDrawLocks--;
345 Refresh();
346 }
347 else
348 m_tmpCanDrawLocks--;
349
350 return rt_val;
351 }
352
353
354
355 bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor)
356 {
357 const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
358 if (!c)
359 {
360 wxLogWarning(_("HTML anchor %s does not exist."), anchor.c_str());
361 return FALSE;
362 }
363 else
364 {
365 int y;
366
367 for (y = 0; c != NULL; c = c->GetParent()) y += c->GetPosY();
368 Scroll(-1, y / wxHTML_SCROLL_STEP);
369 m_OpenedAnchor = anchor;
370 return TRUE;
371 }
372 }
373
374
375 void wxHtmlWindow::OnSetTitle(const wxString& title)
376 {
377 if (m_RelatedFrame)
378 {
379 wxString tit;
380 tit.Printf(m_TitleFormat, title.c_str());
381 m_RelatedFrame->SetTitle(tit);
382 }
383 m_OpenedPageTitle = title;
384 }
385
386
387
388
389
390 void wxHtmlWindow::CreateLayout()
391 {
392 int ClientWidth, ClientHeight;
393
394 if (!m_Cell) return;
395
396 if (m_Style & wxHW_SCROLLBAR_NEVER)
397 {
398 SetScrollbars(wxHTML_SCROLL_STEP, 1, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, 0); // always off
399 GetClientSize(&ClientWidth, &ClientHeight);
400 m_Cell->Layout(ClientWidth);
401 }
402
403 else {
404 GetClientSize(&ClientWidth, &ClientHeight);
405 m_Cell->Layout(ClientWidth);
406 if (ClientHeight < m_Cell->GetHeight() + GetCharHeight())
407 {
408 SetScrollbars(
409 wxHTML_SCROLL_STEP, wxHTML_SCROLL_STEP,
410 m_Cell->GetWidth() / wxHTML_SCROLL_STEP,
411 (m_Cell->GetHeight() + GetCharHeight()) / wxHTML_SCROLL_STEP
412 /*cheat: top-level frag is always container*/);
413 }
414 else /* we fit into window, no need for scrollbars */
415 {
416 SetScrollbars(wxHTML_SCROLL_STEP, 1, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, 0); // disable...
417 GetClientSize(&ClientWidth, &ClientHeight);
418 m_Cell->Layout(ClientWidth); // ...and relayout
419 }
420 }
421 }
422
423
424
425 void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path)
426 {
427 wxString oldpath;
428 wxString tmp;
429 int p_fontsizes[7];
430 wxString p_fff, p_ffn;
431
432 if (path != wxEmptyString)
433 {
434 oldpath = cfg->GetPath();
435 cfg->SetPath(path);
436 }
437
438 m_Borders = cfg->Read(wxT("wxHtmlWindow/Borders"), m_Borders);
439 p_fff = cfg->Read(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser->m_FontFaceFixed);
440 p_ffn = cfg->Read(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser->m_FontFaceNormal);
441 for (int i = 0; i < 7; i++)
442 {
443 tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i);
444 p_fontsizes[i] = cfg->Read(tmp, m_Parser->m_FontsSizes[i]);
445 }
446 SetFonts(p_ffn, p_fff, p_fontsizes);
447
448 if (path != wxEmptyString)
449 cfg->SetPath(oldpath);
450 }
451
452
453
454 void wxHtmlWindow::WriteCustomization(wxConfigBase *cfg, wxString path)
455 {
456 wxString oldpath;
457 wxString tmp;
458
459 if (path != wxEmptyString)
460 {
461 oldpath = cfg->GetPath();
462 cfg->SetPath(path);
463 }
464
465 cfg->Write(wxT("wxHtmlWindow/Borders"), (long) m_Borders);
466 cfg->Write(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser->m_FontFaceFixed);
467 cfg->Write(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser->m_FontFaceNormal);
468 for (int i = 0; i < 7; i++)
469 {
470 tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i);
471 cfg->Write(tmp, (long) m_Parser->m_FontsSizes[i]);
472 }
473
474 if (path != wxEmptyString)
475 cfg->SetPath(oldpath);
476 }
477
478
479
480 bool wxHtmlWindow::HistoryBack()
481 {
482 wxString a, l;
483
484 if (m_HistoryPos < 1) return FALSE;
485
486 // store scroll position into history item:
487 int x, y;
488 GetViewStart(&x, &y);
489 (*m_History)[m_HistoryPos].SetPos(y);
490
491 // go to previous position:
492 m_HistoryPos--;
493
494 l = (*m_History)[m_HistoryPos].GetPage();
495 a = (*m_History)[m_HistoryPos].GetAnchor();
496 m_HistoryOn = FALSE;
497 m_tmpCanDrawLocks++;
498 if (a == wxEmptyString) LoadPage(l);
499 else LoadPage(l + wxT("#") + a);
500 m_HistoryOn = TRUE;
501 m_tmpCanDrawLocks--;
502 Scroll(0, (*m_History)[m_HistoryPos].GetPos());
503 Refresh();
504 return TRUE;
505 }
506
507 bool wxHtmlWindow::HistoryCanBack()
508 {
509 if (m_HistoryPos < 1) return FALSE;
510 return TRUE ;
511 }
512
513
514 bool wxHtmlWindow::HistoryForward()
515 {
516 wxString a, l;
517
518 if (m_HistoryPos == -1) return FALSE;
519 if (m_HistoryPos >= (int)m_History->GetCount() - 1)return FALSE;
520
521 m_OpenedPage = wxEmptyString; // this will disable adding new entry into history in LoadPage()
522
523 m_HistoryPos++;
524 l = (*m_History)[m_HistoryPos].GetPage();
525 a = (*m_History)[m_HistoryPos].GetAnchor();
526 m_HistoryOn = FALSE;
527 m_tmpCanDrawLocks++;
528 if (a == wxEmptyString) LoadPage(l);
529 else LoadPage(l + wxT("#") + a);
530 m_HistoryOn = TRUE;
531 m_tmpCanDrawLocks--;
532 Scroll(0, (*m_History)[m_HistoryPos].GetPos());
533 Refresh();
534 return TRUE;
535 }
536
537 bool wxHtmlWindow::HistoryCanForward()
538 {
539 if (m_HistoryPos == -1) return FALSE;
540 if (m_HistoryPos >= (int)m_History->GetCount() - 1)return FALSE;
541 return TRUE ;
542 }
543
544
545 void wxHtmlWindow::HistoryClear()
546 {
547 m_History->Empty();
548 m_HistoryPos = -1;
549 }
550
551 void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor)
552 {
553 if (!m_Processors)
554 {
555 m_Processors = new wxHtmlProcessorList;
556 m_Processors->DeleteContents(TRUE);
557 }
558 wxHtmlProcessorList::Node *node;
559
560 for (node = m_Processors->GetFirst(); node; node = node->GetNext())
561 {
562 if (processor->GetPriority() > node->GetData()->GetPriority())
563 {
564 m_Processors->Insert(node, processor);
565 return;
566 }
567 }
568 m_Processors->Append(processor);
569 }
570
571 /*static */ void wxHtmlWindow::AddGlobalProcessor(wxHtmlProcessor *processor)
572 {
573 if (!m_GlobalProcessors)
574 {
575 m_GlobalProcessors = new wxHtmlProcessorList;
576 m_GlobalProcessors->DeleteContents(TRUE);
577 }
578 wxHtmlProcessorList::Node *node;
579
580 for (node = m_GlobalProcessors->GetFirst(); node; node = node->GetNext())
581 {
582 if (processor->GetPriority() > node->GetData()->GetPriority())
583 {
584 m_GlobalProcessors->Insert(node, processor);
585 return;
586 }
587 }
588 m_GlobalProcessors->Append(processor);
589 }
590
591
592
593 wxList wxHtmlWindow::m_Filters;
594 wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL;
595 wxCursor *wxHtmlWindow::s_cur_hand = NULL;
596 wxCursor *wxHtmlWindow::s_cur_arrow = NULL;
597 wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL;
598
599 void wxHtmlWindow::CleanUpStatics()
600 {
601 delete m_DefaultFilter;
602 m_DefaultFilter = NULL;
603 m_Filters.DeleteContents(TRUE);
604 m_Filters.Clear();
605 delete m_GlobalProcessors;
606 m_GlobalProcessors = NULL;
607 delete s_cur_hand;
608 delete s_cur_arrow;
609 }
610
611
612
613 void wxHtmlWindow::AddFilter(wxHtmlFilter *filter)
614 {
615 m_Filters.Append(filter);
616 }
617
618
619
620
621 void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
622 {
623 LoadPage(link.GetHref());
624 }
625
626 void wxHtmlWindow::OnCellClicked(wxHtmlCell *cell,
627 wxCoord x, wxCoord y,
628 const wxMouseEvent& event)
629 {
630 wxCHECK_RET( cell, _T("can't be called with NULL cell") );
631
632 cell->OnMouseClick(this, x, y, event);
633 }
634
635 void wxHtmlWindow::OnCellMouseHover(wxHtmlCell * WXUNUSED(cell),
636 wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
637 {
638 // do nothing here
639 }
640
641 void wxHtmlWindow::OnDraw(wxDC& dc)
642 {
643 if (m_tmpCanDrawLocks > 0 || m_Cell == NULL) return;
644
645 int x, y;
646 wxRect rect = GetUpdateRegion().GetBox();
647
648 dc.SetMapMode(wxMM_TEXT);
649 dc.SetBackgroundMode(wxTRANSPARENT);
650 GetViewStart(&x, &y);
651
652 m_Cell->Draw(dc, 0, 0,
653 y * wxHTML_SCROLL_STEP + rect.GetTop(),
654 y * wxHTML_SCROLL_STEP + rect.GetBottom());
655 }
656
657
658
659
660 void wxHtmlWindow::OnSize(wxSizeEvent& event)
661 {
662 wxScrolledWindow::OnSize(event);
663 CreateLayout();
664 Refresh();
665 }
666
667
668 void wxHtmlWindow::OnMouseEvent(wxMouseEvent& event)
669 {
670 m_tmpMouseMoved = TRUE;
671
672 if (event.ButtonDown())
673 {
674 if ( m_Cell )
675 {
676 int sx, sy;
677 GetViewStart(&sx, &sy);
678 sx *= wxHTML_SCROLL_STEP;
679 sy *= wxHTML_SCROLL_STEP;
680
681 wxPoint pos = event.GetPosition();
682 pos.x += sx;
683 pos.y += sy;
684
685 wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y);
686
687 // VZ: is it possible that we don't find anything at all?
688 // VS: yes. FindCellByPos returns terminal cell and
689 // containers may have empty borders
690 if ( cell )
691 OnCellClicked(cell, pos.x, pos.y, event);
692 }
693 }
694 }
695
696
697
698 void wxHtmlWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
699 {
700 if (s_cur_hand == NULL)
701 {
702 s_cur_hand = new wxCursor(wxCURSOR_HAND);
703 s_cur_arrow = new wxCursor(wxCURSOR_ARROW);
704 }
705
706 if (m_tmpMouseMoved && (m_Cell != NULL))
707 {
708 int sx, sy;
709 GetViewStart(&sx, &sy);
710 sx *= wxHTML_SCROLL_STEP;
711 sy *= wxHTML_SCROLL_STEP;
712
713 int x, y;
714 wxGetMousePosition(&x, &y);
715 ScreenToClient(&x, &y);
716 x += sx;
717 y += sy;
718
719 wxHtmlCell *cell = m_Cell->FindCellByPos(x, y);
720 if ( cell != m_tmpLastCell )
721 {
722 wxHtmlLinkInfo *lnk = cell ? cell->GetLink(x, y) : NULL;
723
724 if (lnk != m_tmpLastLink)
725 {
726 if (lnk == NULL)
727 {
728 SetCursor(*s_cur_arrow);
729 if (m_RelatedStatusBar != -1)
730 m_RelatedFrame->SetStatusText(wxEmptyString, m_RelatedStatusBar);
731 }
732 else
733 {
734 SetCursor(*s_cur_hand);
735 if (m_RelatedStatusBar != -1)
736 m_RelatedFrame->SetStatusText(lnk->GetHref(), m_RelatedStatusBar);
737 }
738 m_tmpLastLink = lnk;
739 }
740
741 m_tmpLastCell = cell;
742 }
743 else // mouse moved but stayed in the same cell
744 {
745 if ( cell )
746 OnCellMouseHover(cell, x, y);
747 }
748
749 m_tmpMouseMoved = FALSE;
750 }
751 }
752
753
754 IMPLEMENT_ABSTRACT_CLASS(wxHtmlProcessor,wxObject)
755
756 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow,wxScrolledWindow)
757
758 BEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow)
759 EVT_SIZE(wxHtmlWindow::OnSize)
760 EVT_LEFT_DOWN(wxHtmlWindow::OnMouseEvent)
761 EVT_RIGHT_DOWN(wxHtmlWindow::OnMouseEvent)
762 EVT_MOTION(wxHtmlWindow::OnMouseEvent)
763 EVT_IDLE(wxHtmlWindow::OnIdle)
764 END_EVENT_TABLE()
765
766
767
768
769
770 // A module to allow initialization/cleanup
771 // without calling these functions from app.cpp or from
772 // the user's application.
773
774 class wxHtmlWinModule: public wxModule
775 {
776 DECLARE_DYNAMIC_CLASS(wxHtmlWinModule)
777 public:
778 wxHtmlWinModule() : wxModule() {}
779 bool OnInit() { return TRUE; }
780 void OnExit() { wxHtmlWindow::CleanUpStatics(); }
781 };
782
783 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule, wxModule)
784
785
786 // This hack forces the linker to always link in m_* files
787 // (wxHTML doesn't work without handlers from these files)
788 #include "wx/html/forcelnk.h"
789 FORCE_WXHTML_MODULES()
790
791 #endif