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