]> git.saurik.com Git - wxWidgets.git/blob - src/html/htmlwin.cpp
'Y' positioning fixes for OS/2 controls
[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 wxFSFile *f;
218 bool rt_val;
219 bool needs_refresh = FALSE;
220
221 SetCursor(*wxHOURGLASS_CURSOR);
222 wxYield(); Refresh(FALSE);
223
224 m_tmpCanDrawLocks++;
225 if (m_HistoryOn && (m_HistoryPos != -1))
226 {
227 // store scroll position into history item:
228 int x, y;
229 GetViewStart(&x, &y);
230 (*m_History)[m_HistoryPos].SetPos(y);
231 }
232
233 if (location[0] == wxT('#'))
234 {
235 // local anchor:
236 wxString anch = location.Mid(1) /*1 to end*/;
237 m_tmpCanDrawLocks--;
238 rt_val = ScrollToAnchor(anch);
239 m_tmpCanDrawLocks++;
240 }
241 else if (location.Find(wxT('#')) != wxNOT_FOUND && location.BeforeFirst(wxT('#')) == m_OpenedPage)
242 {
243 wxString anch = location.AfterFirst(wxT('#'));
244 m_tmpCanDrawLocks--;
245 rt_val = ScrollToAnchor(anch);
246 m_tmpCanDrawLocks++;
247 }
248 else if (location.Find(wxT('#')) != wxNOT_FOUND &&
249 (m_FS->GetPath() + location.BeforeFirst(wxT('#'))) == m_OpenedPage)
250 {
251 wxString anch = location.AfterFirst(wxT('#'));
252 m_tmpCanDrawLocks--;
253 rt_val = ScrollToAnchor(anch);
254 m_tmpCanDrawLocks++;
255 }
256
257 else
258 {
259 needs_refresh = TRUE;
260 // load&display it:
261 if (m_RelatedStatusBar != -1)
262 {
263 m_RelatedFrame->SetStatusText(_("Connecting..."), m_RelatedStatusBar);
264 Refresh(FALSE);
265 }
266
267 f = m_FS->OpenFile(location);
268
269 if (f == NULL)
270 {
271 wxLogError(_("Unable to open requested HTML document: %s"), location.c_str());
272 m_tmpCanDrawLocks--;
273
274 SetCursor(*wxSTANDARD_CURSOR);
275 return FALSE;
276 }
277
278 else
279 {
280 wxNode *node;
281 wxString src = wxEmptyString;
282
283 if (m_RelatedStatusBar != -1)
284 {
285 wxString msg = _("Loading : ") + location;
286 m_RelatedFrame->SetStatusText(msg, m_RelatedStatusBar);
287 Refresh(FALSE);
288 }
289
290 node = m_Filters.GetFirst();
291 while (node)
292 {
293 wxHtmlFilter *h = (wxHtmlFilter*) node->GetData();
294 if (h->CanRead(*f))
295 {
296 src = h->ReadFile(*f);
297 break;
298 }
299 node = node->GetNext();
300 }
301 if (src == wxEmptyString)
302 {
303 if (m_DefaultFilter == NULL) m_DefaultFilter = GetDefaultFilter();
304 src = m_DefaultFilter->ReadFile(*f);
305 }
306
307 m_FS->ChangePathTo(f->GetLocation());
308 rt_val = SetPage(src);
309 m_OpenedPage = f->GetLocation();
310 if (f->GetAnchor() != wxEmptyString)
311 {
312 wxYield();
313 ScrollToAnchor(f->GetAnchor());
314 }
315
316 delete f;
317
318 if (m_RelatedStatusBar != -1) m_RelatedFrame->SetStatusText(_("Done"), m_RelatedStatusBar);
319 }
320 }
321
322 if (m_HistoryOn) // add this page to history there:
323 {
324 int c = m_History->GetCount() - (m_HistoryPos + 1);
325
326 if (m_HistoryPos < 0 ||
327 (*m_History)[m_HistoryPos].GetPage() != m_OpenedPage ||
328 (*m_History)[m_HistoryPos].GetAnchor() != m_OpenedAnchor)
329 {
330 m_HistoryPos++;
331 for (int i = 0; i < c; i++)
332 m_History->RemoveAt(m_HistoryPos);
333 m_History->Add(new wxHtmlHistoryItem(m_OpenedPage, m_OpenedAnchor));
334 }
335 }
336
337 if (m_OpenedPageTitle == wxEmptyString)
338 OnSetTitle(wxFileNameFromPath(m_OpenedPage));
339 SetCursor(*wxSTANDARD_CURSOR);
340
341 if (needs_refresh)
342 {
343 wxYield();
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 wxYield();
502 m_tmpCanDrawLocks--;
503 Scroll(0, (*m_History)[m_HistoryPos].GetPos());
504 Refresh();
505 return TRUE;
506 }
507
508 bool wxHtmlWindow::HistoryCanBack()
509 {
510 if (m_HistoryPos < 1) return FALSE;
511 return TRUE ;
512 }
513
514
515 bool wxHtmlWindow::HistoryForward()
516 {
517 wxString a, l;
518
519 if (m_HistoryPos == -1) return FALSE;
520 if (m_HistoryPos >= (int)m_History->GetCount() - 1)return FALSE;
521
522 m_OpenedPage = wxEmptyString; // this will disable adding new entry into history in LoadPage()
523
524 m_HistoryPos++;
525 l = (*m_History)[m_HistoryPos].GetPage();
526 a = (*m_History)[m_HistoryPos].GetAnchor();
527 m_HistoryOn = FALSE;
528 m_tmpCanDrawLocks++;
529 if (a == wxEmptyString) LoadPage(l);
530 else LoadPage(l + wxT("#") + a);
531 m_HistoryOn = TRUE;
532 wxYield();
533 m_tmpCanDrawLocks--;
534 Scroll(0, (*m_History)[m_HistoryPos].GetPos());
535 Refresh();
536 return TRUE;
537 }
538
539 bool wxHtmlWindow::HistoryCanForward()
540 {
541 if (m_HistoryPos == -1) return FALSE;
542 if (m_HistoryPos >= (int)m_History->GetCount() - 1)return FALSE;
543 return TRUE ;
544 }
545
546
547 void wxHtmlWindow::HistoryClear()
548 {
549 m_History->Empty();
550 m_HistoryPos = -1;
551 }
552
553 void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor)
554 {
555 if (!m_Processors)
556 {
557 m_Processors = new wxHtmlProcessorList;
558 m_Processors->DeleteContents(TRUE);
559 }
560 wxHtmlProcessorList::Node *node;
561
562 for (node = m_Processors->GetFirst(); node; node = node->GetNext())
563 {
564 if (processor->GetPriority() > node->GetData()->GetPriority())
565 {
566 m_Processors->Insert(node, processor);
567 return;
568 }
569 }
570 m_Processors->Append(processor);
571 }
572
573 /*static */ void wxHtmlWindow::AddGlobalProcessor(wxHtmlProcessor *processor)
574 {
575 if (!m_GlobalProcessors)
576 {
577 m_GlobalProcessors = new wxHtmlProcessorList;
578 m_GlobalProcessors->DeleteContents(TRUE);
579 }
580 wxHtmlProcessorList::Node *node;
581
582 for (node = m_GlobalProcessors->GetFirst(); node; node = node->GetNext())
583 {
584 if (processor->GetPriority() > node->GetData()->GetPriority())
585 {
586 m_GlobalProcessors->Insert(node, processor);
587 return;
588 }
589 }
590 m_GlobalProcessors->Append(processor);
591 }
592
593
594
595 wxList wxHtmlWindow::m_Filters;
596 wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL;
597 wxCursor *wxHtmlWindow::s_cur_hand = NULL;
598 wxCursor *wxHtmlWindow::s_cur_arrow = NULL;
599 wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL;
600
601 void wxHtmlWindow::CleanUpStatics()
602 {
603 delete m_DefaultFilter;
604 m_DefaultFilter = NULL;
605 m_Filters.DeleteContents(TRUE);
606 m_Filters.Clear();
607 delete m_GlobalProcessors;
608 m_GlobalProcessors = NULL;
609 delete s_cur_hand;
610 delete s_cur_arrow;
611 }
612
613
614
615 void wxHtmlWindow::AddFilter(wxHtmlFilter *filter)
616 {
617 m_Filters.Append(filter);
618 }
619
620
621
622
623 void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
624 {
625 LoadPage(link.GetHref());
626 }
627
628 void wxHtmlWindow::OnCellClicked(wxHtmlCell *cell,
629 wxCoord x, wxCoord y,
630 const wxMouseEvent& event)
631 {
632 wxCHECK_RET( cell, _T("can't be called with NULL cell") );
633
634 cell->OnMouseClick(this, x, y, event);
635 }
636
637 void wxHtmlWindow::OnCellMouseHover(wxHtmlCell * WXUNUSED(cell),
638 wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
639 {
640 // do nothing here
641 }
642
643 void wxHtmlWindow::OnDraw(wxDC& dc)
644 {
645 if (m_tmpCanDrawLocks > 0 || m_Cell == NULL) return;
646
647 int x, y;
648 wxRect rect = GetUpdateRegion().GetBox();
649
650 dc.SetMapMode(wxMM_TEXT);
651 dc.SetBackgroundMode(wxTRANSPARENT);
652 GetViewStart(&x, &y);
653
654 m_Cell->Draw(dc, 0, 0,
655 y * wxHTML_SCROLL_STEP + rect.GetTop(),
656 y * wxHTML_SCROLL_STEP + rect.GetBottom());
657 }
658
659
660
661
662 void wxHtmlWindow::OnSize(wxSizeEvent& event)
663 {
664 wxScrolledWindow::OnSize(event);
665 CreateLayout();
666 Refresh();
667 }
668
669
670 void wxHtmlWindow::OnMouseEvent(wxMouseEvent& event)
671 {
672 m_tmpMouseMoved = TRUE;
673
674 if (event.ButtonDown())
675 {
676 if ( m_Cell )
677 {
678 int sx, sy;
679 GetViewStart(&sx, &sy);
680 sx *= wxHTML_SCROLL_STEP;
681 sy *= wxHTML_SCROLL_STEP;
682
683 wxPoint pos = event.GetPosition();
684 pos.x += sx;
685 pos.y += sy;
686
687 wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y);
688
689 // VZ: is it possible that we don't find anything at all?
690 // VS: yes. FindCellByPos returns terminal cell and
691 // containers may have empty borders
692 if ( cell )
693 OnCellClicked(cell, pos.x, pos.y, event);
694 }
695 }
696 }
697
698
699
700 void wxHtmlWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
701 {
702 if (s_cur_hand == NULL)
703 {
704 s_cur_hand = new wxCursor(wxCURSOR_HAND);
705 s_cur_arrow = new wxCursor(wxCURSOR_ARROW);
706 }
707
708 if (m_tmpMouseMoved && (m_Cell != NULL))
709 {
710 int sx, sy;
711 GetViewStart(&sx, &sy);
712 sx *= wxHTML_SCROLL_STEP;
713 sy *= wxHTML_SCROLL_STEP;
714
715 int x, y;
716 wxGetMousePosition(&x, &y);
717 ScreenToClient(&x, &y);
718 x += sx;
719 y += sy;
720
721 wxHtmlCell *cell = m_Cell->FindCellByPos(x, y);
722 if ( cell != m_tmpLastCell )
723 {
724 wxHtmlLinkInfo *lnk = cell ? cell->GetLink(x, y) : NULL;
725
726 if (lnk != m_tmpLastLink)
727 {
728 if (lnk == NULL)
729 {
730 SetCursor(*s_cur_arrow);
731 if (m_RelatedStatusBar != -1)
732 m_RelatedFrame->SetStatusText(wxEmptyString, m_RelatedStatusBar);
733 }
734 else
735 {
736 SetCursor(*s_cur_hand);
737 if (m_RelatedStatusBar != -1)
738 m_RelatedFrame->SetStatusText(lnk->GetHref(), m_RelatedStatusBar);
739 }
740 m_tmpLastLink = lnk;
741 }
742
743 m_tmpLastCell = cell;
744 }
745 else // mouse moved but stayed in the same cell
746 {
747 if ( cell )
748 OnCellMouseHover(cell, x, y);
749 }
750
751 m_tmpMouseMoved = FALSE;
752 }
753 }
754
755
756 IMPLEMENT_ABSTRACT_CLASS(wxHtmlProcessor,wxObject)
757
758 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow,wxScrolledWindow)
759
760 BEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow)
761 EVT_SIZE(wxHtmlWindow::OnSize)
762 EVT_LEFT_DOWN(wxHtmlWindow::OnMouseEvent)
763 EVT_RIGHT_DOWN(wxHtmlWindow::OnMouseEvent)
764 EVT_MOTION(wxHtmlWindow::OnMouseEvent)
765 EVT_IDLE(wxHtmlWindow::OnIdle)
766 END_EVENT_TABLE()
767
768
769
770
771
772 // A module to allow initialization/cleanup
773 // without calling these functions from app.cpp or from
774 // the user's application.
775
776 class wxHtmlWinModule: public wxModule
777 {
778 DECLARE_DYNAMIC_CLASS(wxHtmlWinModule)
779 public:
780 wxHtmlWinModule() : wxModule() {}
781 bool OnInit() { return TRUE; }
782 void OnExit() { wxHtmlWindow::CleanUpStatics(); }
783 };
784
785 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule, wxModule)
786
787
788 // This hack forces the linker to always link in m_* files
789 // (wxHTML doesn't work without handlers from these files)
790 #include "wx/html/forcelnk.h"
791 FORCE_WXHTML_MODULES()
792
793 #endif