1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlWindow class for parsing & displaying HTML (implementation)
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "htmlwin.h"
13 #pragma implementation "htmlproc.h"
16 #include "wx/wxprec.h"
19 #if wxUSE_HTML && wxUSE_STREAMS
28 #include "wx/dcclient.h"
32 #include "wx/html/htmlwin.h"
33 #include "wx/html/htmlproc.h"
35 #include "wx/clipbrd.h"
37 #include "wx/arrimpl.cpp"
38 #include "wx/listimpl.cpp"
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 // item of history list
45 class WXDLLEXPORT wxHtmlHistoryItem
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
;}
61 //-----------------------------------------------------------------------------
62 // our private arrays:
63 //-----------------------------------------------------------------------------
65 WX_DECLARE_OBJARRAY(wxHtmlHistoryItem
, wxHtmlHistoryArray
);
66 WX_DEFINE_OBJARRAY(wxHtmlHistoryArray
);
68 WX_DECLARE_LIST(wxHtmlProcessor
, wxHtmlProcessorList
);
69 WX_DEFINE_LIST(wxHtmlProcessorList
);
71 //-----------------------------------------------------------------------------
73 //-----------------------------------------------------------------------------
76 void wxHtmlWindow::Init()
78 m_tmpMouseMoved
= FALSE
;
81 m_tmpCanDrawLocks
= 0;
82 m_FS
= new wxFileSystem();
83 m_RelatedStatusBar
= -1;
84 m_RelatedFrame
= NULL
;
85 m_TitleFormat
= wxT("%s");
86 m_OpenedPage
= m_OpenedAnchor
= m_OpenedPageTitle
= wxEmptyString
;
88 m_Parser
= new wxHtmlWinParser(this);
89 m_Parser
->SetFS(m_FS
);
92 m_History
= new wxHtmlHistoryArray
;
97 m_makingSelection
= false;
100 bool wxHtmlWindow::Create(wxWindow
*parent
, wxWindowID id
,
101 const wxPoint
& pos
, const wxSize
& size
,
102 long style
, const wxString
& name
)
104 if (!wxScrolledWindow::Create(parent
, id
, pos
, size
,
105 style
| wxVSCROLL
| wxHSCROLL
, name
))
109 SetPage(wxT("<html><body></body></html>"));
114 wxHtmlWindow::~wxHtmlWindow()
118 if (m_Cell
) delete m_Cell
;
128 void wxHtmlWindow::SetRelatedFrame(wxFrame
* frame
, const wxString
& format
)
130 m_RelatedFrame
= frame
;
131 m_TitleFormat
= format
;
136 void wxHtmlWindow::SetRelatedStatusBar(int bar
)
138 m_RelatedStatusBar
= bar
;
143 void wxHtmlWindow::SetFonts(wxString normal_face
, wxString fixed_face
, const int *sizes
)
145 wxString op
= m_OpenedPage
;
147 m_Parser
->SetFonts(normal_face
, fixed_face
, sizes
);
148 // fonts changed => contents invalid, so reload the page:
149 SetPage(wxT("<html><body></body></html>"));
150 if (!op
.IsEmpty()) LoadPage(op
);
155 bool wxHtmlWindow::SetPage(const wxString
& source
)
157 wxString
newsrc(source
);
159 wxDELETE(m_selection
);
161 // pass HTML through registered processors:
162 if (m_Processors
|| m_GlobalProcessors
)
164 wxHtmlProcessorList::Node
*nodeL
, *nodeG
;
167 nodeL
= (m_Processors
) ? m_Processors
->GetFirst() : NULL
;
168 nodeG
= (m_GlobalProcessors
) ? m_GlobalProcessors
->GetFirst() : NULL
;
170 // VS: there are two lists, global and local, both of them sorted by
171 // priority. Since we have to go through _both_ lists with
172 // decreasing priority, we "merge-sort" the lists on-line by
173 // processing that one of the two heads that has higher priority
174 // in every iteration
175 while (nodeL
|| nodeG
)
177 prL
= (nodeL
) ? nodeL
->GetData()->GetPriority() : -1;
178 prG
= (nodeG
) ? nodeG
->GetData()->GetPriority() : -1;
181 if (nodeL
->GetData()->IsEnabled())
182 newsrc
= nodeL
->GetData()->Process(newsrc
);
183 nodeL
= nodeL
->GetNext();
187 if (nodeG
->GetData()->IsEnabled())
188 newsrc
= nodeG
->GetData()->Process(newsrc
);
189 nodeG
= nodeG
->GetNext();
194 // ...and run the parser on it:
195 wxClientDC
*dc
= new wxClientDC(this);
196 dc
->SetMapMode(wxMM_TEXT
);
197 SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
198 m_OpenedPage
= m_OpenedAnchor
= m_OpenedPageTitle
= wxEmptyString
;
205 m_Cell
= (wxHtmlContainerCell
*) m_Parser
->Parse(newsrc
);
207 m_Cell
->SetIndent(m_Borders
, wxHTML_INDENT_ALL
, wxHTML_UNITS_PIXELS
);
208 m_Cell
->SetAlignHor(wxHTML_ALIGN_CENTER
);
210 if (m_tmpCanDrawLocks
== 0)
215 bool wxHtmlWindow::AppendToPage(const wxString
& source
)
217 return SetPage(*(GetParser()->GetSource()) + source
);
220 bool wxHtmlWindow::LoadPage(const wxString
& location
)
222 wxBusyCursor busyCursor
;
226 bool needs_refresh
= FALSE
;
229 if (m_HistoryOn
&& (m_HistoryPos
!= -1))
231 // store scroll position into history item:
233 GetViewStart(&x
, &y
);
234 (*m_History
)[m_HistoryPos
].SetPos(y
);
237 if (location
[0] == wxT('#'))
240 wxString anch
= location
.Mid(1) /*1 to end*/;
242 rt_val
= ScrollToAnchor(anch
);
245 else if (location
.Find(wxT('#')) != wxNOT_FOUND
&& location
.BeforeFirst(wxT('#')) == m_OpenedPage
)
247 wxString anch
= location
.AfterFirst(wxT('#'));
249 rt_val
= ScrollToAnchor(anch
);
252 else if (location
.Find(wxT('#')) != wxNOT_FOUND
&&
253 (m_FS
->GetPath() + location
.BeforeFirst(wxT('#'))) == m_OpenedPage
)
255 wxString anch
= location
.AfterFirst(wxT('#'));
257 rt_val
= ScrollToAnchor(anch
);
263 needs_refresh
= TRUE
;
265 if (m_RelatedStatusBar
!= -1)
267 m_RelatedFrame
->SetStatusText(_("Connecting..."), m_RelatedStatusBar
);
271 f
= m_Parser
->OpenURL(wxHTML_URL_PAGE
, location
);
273 // try to interpret 'location' as filename instead of URL:
276 wxFileName
fn(location
);
277 wxString location2
= wxFileSystem::FileNameToURL(fn
);
278 f
= m_Parser
->OpenURL(wxHTML_URL_PAGE
, location2
);
283 wxLogError(_("Unable to open requested HTML document: %s"), location
.c_str());
291 wxString src
= wxEmptyString
;
293 if (m_RelatedStatusBar
!= -1)
295 wxString msg
= _("Loading : ") + location
;
296 m_RelatedFrame
->SetStatusText(msg
, m_RelatedStatusBar
);
300 node
= m_Filters
.GetFirst();
303 wxHtmlFilter
*h
= (wxHtmlFilter
*) node
->GetData();
306 src
= h
->ReadFile(*f
);
309 node
= node
->GetNext();
311 if (src
== wxEmptyString
)
313 if (m_DefaultFilter
== NULL
) m_DefaultFilter
= GetDefaultFilter();
314 src
= m_DefaultFilter
->ReadFile(*f
);
317 m_FS
->ChangePathTo(f
->GetLocation());
318 rt_val
= SetPage(src
);
319 m_OpenedPage
= f
->GetLocation();
320 if (f
->GetAnchor() != wxEmptyString
)
322 ScrollToAnchor(f
->GetAnchor());
327 if (m_RelatedStatusBar
!= -1) m_RelatedFrame
->SetStatusText(_("Done"), m_RelatedStatusBar
);
331 if (m_HistoryOn
) // add this page to history there:
333 int c
= m_History
->GetCount() - (m_HistoryPos
+ 1);
335 if (m_HistoryPos
< 0 ||
336 (*m_History
)[m_HistoryPos
].GetPage() != m_OpenedPage
||
337 (*m_History
)[m_HistoryPos
].GetAnchor() != m_OpenedAnchor
)
340 for (int i
= 0; i
< c
; i
++)
341 m_History
->RemoveAt(m_HistoryPos
);
342 m_History
->Add(new wxHtmlHistoryItem(m_OpenedPage
, m_OpenedAnchor
));
346 if (m_OpenedPageTitle
== wxEmptyString
)
347 OnSetTitle(wxFileNameFromPath(m_OpenedPage
));
361 bool wxHtmlWindow::LoadFile(const wxFileName
& filename
)
363 wxString url
= wxFileSystem::FileNameToURL(filename
);
364 return LoadPage(url
);
368 bool wxHtmlWindow::ScrollToAnchor(const wxString
& anchor
)
370 const wxHtmlCell
*c
= m_Cell
->Find(wxHTML_COND_ISANCHOR
, &anchor
);
373 wxLogWarning(_("HTML anchor %s does not exist."), anchor
.c_str());
380 for (y
= 0; c
!= NULL
; c
= c
->GetParent()) y
+= c
->GetPosY();
381 Scroll(-1, y
/ wxHTML_SCROLL_STEP
);
382 m_OpenedAnchor
= anchor
;
388 void wxHtmlWindow::OnSetTitle(const wxString
& title
)
393 tit
.Printf(m_TitleFormat
, title
.c_str());
394 m_RelatedFrame
->SetTitle(tit
);
396 m_OpenedPageTitle
= title
;
403 void wxHtmlWindow::CreateLayout()
405 int ClientWidth
, ClientHeight
;
409 if (m_Style
& wxHW_SCROLLBAR_NEVER
)
411 SetScrollbars(wxHTML_SCROLL_STEP
, 1, m_Cell
->GetWidth() / wxHTML_SCROLL_STEP
, 0); // always off
412 GetClientSize(&ClientWidth
, &ClientHeight
);
413 m_Cell
->Layout(ClientWidth
);
417 GetClientSize(&ClientWidth
, &ClientHeight
);
418 m_Cell
->Layout(ClientWidth
);
419 if (ClientHeight
< m_Cell
->GetHeight() + GetCharHeight())
422 wxHTML_SCROLL_STEP
, wxHTML_SCROLL_STEP
,
423 m_Cell
->GetWidth() / wxHTML_SCROLL_STEP
,
424 (m_Cell
->GetHeight() + GetCharHeight()) / wxHTML_SCROLL_STEP
425 /*cheat: top-level frag is always container*/);
427 else /* we fit into window, no need for scrollbars */
429 SetScrollbars(wxHTML_SCROLL_STEP
, 1, m_Cell
->GetWidth() / wxHTML_SCROLL_STEP
, 0); // disable...
430 GetClientSize(&ClientWidth
, &ClientHeight
);
431 m_Cell
->Layout(ClientWidth
); // ...and relayout
438 void wxHtmlWindow::ReadCustomization(wxConfigBase
*cfg
, wxString path
)
443 wxString p_fff
, p_ffn
;
445 if (path
!= wxEmptyString
)
447 oldpath
= cfg
->GetPath();
451 m_Borders
= cfg
->Read(wxT("wxHtmlWindow/Borders"), m_Borders
);
452 p_fff
= cfg
->Read(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser
->m_FontFaceFixed
);
453 p_ffn
= cfg
->Read(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser
->m_FontFaceNormal
);
454 for (int i
= 0; i
< 7; i
++)
456 tmp
.Printf(wxT("wxHtmlWindow/FontsSize%i"), i
);
457 p_fontsizes
[i
] = cfg
->Read(tmp
, m_Parser
->m_FontsSizes
[i
]);
459 SetFonts(p_ffn
, p_fff
, p_fontsizes
);
461 if (path
!= wxEmptyString
)
462 cfg
->SetPath(oldpath
);
467 void wxHtmlWindow::WriteCustomization(wxConfigBase
*cfg
, wxString path
)
472 if (path
!= wxEmptyString
)
474 oldpath
= cfg
->GetPath();
478 cfg
->Write(wxT("wxHtmlWindow/Borders"), (long) m_Borders
);
479 cfg
->Write(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser
->m_FontFaceFixed
);
480 cfg
->Write(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser
->m_FontFaceNormal
);
481 for (int i
= 0; i
< 7; i
++)
483 tmp
.Printf(wxT("wxHtmlWindow/FontsSize%i"), i
);
484 cfg
->Write(tmp
, (long) m_Parser
->m_FontsSizes
[i
]);
487 if (path
!= wxEmptyString
)
488 cfg
->SetPath(oldpath
);
493 bool wxHtmlWindow::HistoryBack()
497 if (m_HistoryPos
< 1) return FALSE
;
499 // store scroll position into history item:
501 GetViewStart(&x
, &y
);
502 (*m_History
)[m_HistoryPos
].SetPos(y
);
504 // go to previous position:
507 l
= (*m_History
)[m_HistoryPos
].GetPage();
508 a
= (*m_History
)[m_HistoryPos
].GetAnchor();
511 if (a
== wxEmptyString
) LoadPage(l
);
512 else LoadPage(l
+ wxT("#") + a
);
515 Scroll(0, (*m_History
)[m_HistoryPos
].GetPos());
520 bool wxHtmlWindow::HistoryCanBack()
522 if (m_HistoryPos
< 1) return FALSE
;
527 bool wxHtmlWindow::HistoryForward()
531 if (m_HistoryPos
== -1) return FALSE
;
532 if (m_HistoryPos
>= (int)m_History
->GetCount() - 1)return FALSE
;
534 m_OpenedPage
= wxEmptyString
; // this will disable adding new entry into history in LoadPage()
537 l
= (*m_History
)[m_HistoryPos
].GetPage();
538 a
= (*m_History
)[m_HistoryPos
].GetAnchor();
541 if (a
== wxEmptyString
) LoadPage(l
);
542 else LoadPage(l
+ wxT("#") + a
);
545 Scroll(0, (*m_History
)[m_HistoryPos
].GetPos());
550 bool wxHtmlWindow::HistoryCanForward()
552 if (m_HistoryPos
== -1) return FALSE
;
553 if (m_HistoryPos
>= (int)m_History
->GetCount() - 1)return FALSE
;
558 void wxHtmlWindow::HistoryClear()
564 void wxHtmlWindow::AddProcessor(wxHtmlProcessor
*processor
)
568 m_Processors
= new wxHtmlProcessorList
;
569 m_Processors
->DeleteContents(TRUE
);
571 wxHtmlProcessorList::Node
*node
;
573 for (node
= m_Processors
->GetFirst(); node
; node
= node
->GetNext())
575 if (processor
->GetPriority() > node
->GetData()->GetPriority())
577 m_Processors
->Insert(node
, processor
);
581 m_Processors
->Append(processor
);
584 /*static */ void wxHtmlWindow::AddGlobalProcessor(wxHtmlProcessor
*processor
)
586 if (!m_GlobalProcessors
)
588 m_GlobalProcessors
= new wxHtmlProcessorList
;
589 m_GlobalProcessors
->DeleteContents(TRUE
);
591 wxHtmlProcessorList::Node
*node
;
593 for (node
= m_GlobalProcessors
->GetFirst(); node
; node
= node
->GetNext())
595 if (processor
->GetPriority() > node
->GetData()->GetPriority())
597 m_GlobalProcessors
->Insert(node
, processor
);
601 m_GlobalProcessors
->Append(processor
);
606 wxList
wxHtmlWindow::m_Filters
;
607 wxHtmlFilter
*wxHtmlWindow::m_DefaultFilter
= NULL
;
608 wxCursor
*wxHtmlWindow::s_cur_hand
= NULL
;
609 wxCursor
*wxHtmlWindow::s_cur_arrow
= NULL
;
610 wxHtmlProcessorList
*wxHtmlWindow::m_GlobalProcessors
= NULL
;
612 void wxHtmlWindow::CleanUpStatics()
614 wxDELETE(m_DefaultFilter
);
615 m_Filters
.DeleteContents(TRUE
);
617 wxDELETE(m_GlobalProcessors
);
618 wxDELETE(s_cur_hand
);
619 wxDELETE(s_cur_arrow
);
624 void wxHtmlWindow::AddFilter(wxHtmlFilter
*filter
)
626 m_Filters
.Append(filter
);
630 bool wxHtmlWindow::IsSelectionEnabled() const
633 return !(m_Style
& wxHW_NO_SELECTION
);
640 wxString
wxHtmlWindow::SelectionToText()
643 return wxEmptyString
;
647 const wxHtmlCell
*end
= m_selection
->GetToCell();
649 wxHtmlTerminalCellsInterator
i(m_selection
->GetFromCell(), end
);
652 text
<< i
->ConvertToText(m_selection
);
655 const wxHtmlCell
*prev
= *i
;
658 if ( prev
->GetParent() != i
->GetParent() )
660 text
<< i
->ConvertToText(*i
== end
? m_selection
: NULL
);
667 void wxHtmlWindow::CopySelection(ClipboardType t
)
672 wxTheClipboard
->UsePrimarySelection(t
== Primary
);
673 wxString
txt(SelectionToText());
674 if ( wxTheClipboard
->Open() )
676 wxTheClipboard
->SetData(new wxTextDataObject(txt
));
677 wxTheClipboard
->Close();
678 wxLogTrace(_T("wxhtmlselection"),
679 _("Copied to clipboard:\"%s\""), txt
.c_str());
686 void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo
& link
)
688 const wxMouseEvent
*e
= link
.GetEvent();
689 if (e
== NULL
|| e
->LeftUp())
690 LoadPage(link
.GetHref());
693 void wxHtmlWindow::OnCellClicked(wxHtmlCell
*cell
,
694 wxCoord x
, wxCoord y
,
695 const wxMouseEvent
& event
)
697 wxCHECK_RET( cell
, _T("can't be called with NULL cell") );
699 cell
->OnMouseClick(this, x
, y
, event
);
702 void wxHtmlWindow::OnCellMouseHover(wxHtmlCell
* WXUNUSED(cell
),
703 wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
))
708 void wxHtmlWindow::OnDraw(wxDC
& dc
)
710 if (m_tmpCanDrawLocks
> 0 || m_Cell
== NULL
) return;
713 wxRect rect
= GetUpdateRegion().GetBox();
715 dc
.SetMapMode(wxMM_TEXT
);
716 dc
.SetBackgroundMode(wxTRANSPARENT
);
717 GetViewStart(&x
, &y
);
719 wxHtmlRenderingInfo rinfo
;
720 wxDefaultHtmlRenderingStyle rstyle
;
721 rinfo
.SetSelection(m_selection
);
722 rinfo
.SetStyle(&rstyle
);
723 m_Cell
->Draw(dc
, 0, 0,
724 y
* wxHTML_SCROLL_STEP
+ rect
.GetTop(),
725 y
* wxHTML_SCROLL_STEP
+ rect
.GetBottom(),
732 void wxHtmlWindow::OnSize(wxSizeEvent
& event
)
734 wxScrolledWindow::OnSize(event
);
740 void wxHtmlWindow::OnMouseMove(wxMouseEvent
& event
)
742 m_tmpMouseMoved
= true;
745 void wxHtmlWindow::OnMouseDown(wxMouseEvent
& event
)
747 if ( event
.LeftDown() && IsSelectionEnabled() )
749 m_makingSelection
= true;
753 wxDELETE(m_selection
);
756 m_tmpSelFromPos
= CalcUnscrolledPosition(event
.GetPosition());
757 m_tmpSelFromCell
= NULL
;
763 void wxHtmlWindow::OnMouseUp(wxMouseEvent
& event
)
765 if ( m_makingSelection
)
768 m_makingSelection
= false;
770 // did the user move the mouse far enough from starting point?
774 CopySelection(Primary
);
776 // we don't want mouse up event that ended selecting to be
777 // handled as mouse click and e.g. follow hyperlink:
785 wxPoint pos
= CalcUnscrolledPosition(event
.GetPosition());
786 wxHtmlCell
*cell
= m_Cell
->FindCellByPos(pos
.x
, pos
.y
);
788 // VZ: is it possible that we don't find anything at all?
789 // VS: yes. FindCellByPos returns terminal cell and
790 // containers may have empty borders
792 OnCellClicked(cell
, pos
.x
, pos
.y
, event
);
798 void wxHtmlWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
))
800 if (s_cur_hand
== NULL
)
802 s_cur_hand
= new wxCursor(wxCURSOR_HAND
);
803 s_cur_arrow
= new wxCursor(wxCURSOR_ARROW
);
806 if (m_tmpMouseMoved
&& (m_Cell
!= NULL
))
809 wxGetMousePosition(&xc
, &yc
);
810 ScreenToClient(&xc
, &yc
);
811 CalcUnscrolledPosition(xc
, yc
, &x
, &y
);
813 wxHtmlCell
*cell
= m_Cell
->FindCellByPos(x
, y
);
815 // handle selection update:
816 if ( m_makingSelection
)
818 bool goingDown
= m_tmpSelFromPos
.y
< y
||
819 m_tmpSelFromPos
.y
== y
&& m_tmpSelFromPos
.x
< x
;
821 if ( !m_tmpSelFromCell
)
825 m_tmpSelFromCell
= m_Cell
->FindCellByPos(
826 m_tmpSelFromPos
.x
,m_tmpSelFromPos
.y
,
827 wxHTML_FIND_NEAREST_AFTER
);
828 if (!m_tmpSelFromCell
)
829 m_tmpSelFromCell
= m_Cell
->GetFirstTerminal();
833 m_tmpSelFromCell
= m_Cell
->FindCellByPos(
834 m_tmpSelFromPos
.x
,m_tmpSelFromPos
.y
,
835 wxHTML_FIND_NEAREST_BEFORE
);
836 if (!m_tmpSelFromCell
)
837 m_tmpSelFromCell
= m_Cell
->GetLastTerminal();
841 wxHtmlCell
*selcell
= cell
;
846 selcell
= m_Cell
->FindCellByPos(x
, y
,
847 wxHTML_FIND_NEAREST_AFTER
);
849 selcell
= m_Cell
->GetLastTerminal();
853 selcell
= m_Cell
->FindCellByPos(x
, y
,
854 wxHTML_FIND_NEAREST_BEFORE
);
856 selcell
= m_Cell
->GetFirstTerminal();
860 // NB: it may *rarely* happen that the code above didn't find one
861 // of the cells, e.g. if wxHtmlWindow doesn't contain any
863 if ( selcell
&& m_tmpSelFromCell
)
867 // start selecting only if mouse movement was big enough
868 // (otherwise it was meant as mouse click, not selection):
869 const int PRECISION
= 2;
870 wxPoint diff
= m_tmpSelFromPos
- wxPoint(x
,y
);
871 if (abs(diff
.x
) > PRECISION
|| abs(diff
.y
) > PRECISION
)
873 m_selection
= new wxHtmlSelection();
878 if ( m_tmpSelFromCell
->IsBefore(selcell
) )
880 m_selection
->Set(m_tmpSelFromPos
, m_tmpSelFromCell
,
881 wxPoint(x
,y
), selcell
); }
884 m_selection
->Set(wxPoint(x
,y
), selcell
,
885 m_tmpSelFromPos
, m_tmpSelFromCell
);
889 m_selection
->GetFromCell()->SetSelectionPrivPos(
891 m_selection
->GetToCell()->SetSelectionPrivPos(
894 Refresh(); // FIXME - optimize!
899 // handle cursor and status bar text changes:
900 if ( cell
!= m_tmpLastCell
)
902 wxHtmlLinkInfo
*lnk
= cell
? cell
->GetLink(x
, y
) : NULL
;
904 if (lnk
!= m_tmpLastLink
)
908 SetCursor(*s_cur_arrow
);
909 if (m_RelatedStatusBar
!= -1)
910 m_RelatedFrame
->SetStatusText(wxEmptyString
, m_RelatedStatusBar
);
914 SetCursor(*s_cur_hand
);
915 if (m_RelatedStatusBar
!= -1)
916 m_RelatedFrame
->SetStatusText(lnk
->GetHref(), m_RelatedStatusBar
);
921 m_tmpLastCell
= cell
;
923 else // mouse moved but stayed in the same cell
926 OnCellMouseHover(cell
, x
, y
);
929 m_tmpMouseMoved
= FALSE
;
934 void wxHtmlWindow::OnKeyUp(wxKeyEvent
& event
)
936 if ( event
.GetKeyCode() == 'C' && event
.ControlDown() )
945 void wxHtmlWindow::OnCopy(wxCommandEvent
& event
)
954 IMPLEMENT_ABSTRACT_CLASS(wxHtmlProcessor
,wxObject
)
956 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow
,wxScrolledWindow
)
958 BEGIN_EVENT_TABLE(wxHtmlWindow
, wxScrolledWindow
)
959 EVT_SIZE(wxHtmlWindow::OnSize
)
960 EVT_LEFT_DOWN(wxHtmlWindow::OnMouseDown
)
961 EVT_LEFT_UP(wxHtmlWindow::OnMouseUp
)
962 EVT_RIGHT_UP(wxHtmlWindow::OnMouseUp
)
963 EVT_MOTION(wxHtmlWindow::OnMouseMove
)
964 EVT_IDLE(wxHtmlWindow::OnIdle
)
966 EVT_KEY_UP(wxHtmlWindow::OnKeyUp
)
967 EVT_MENU(wxID_COPY
, wxHtmlWindow::OnCopy
)
975 // A module to allow initialization/cleanup
976 // without calling these functions from app.cpp or from
977 // the user's application.
979 class wxHtmlWinModule
: public wxModule
981 DECLARE_DYNAMIC_CLASS(wxHtmlWinModule
)
983 wxHtmlWinModule() : wxModule() {}
984 bool OnInit() { return TRUE
; }
985 void OnExit() { wxHtmlWindow::CleanUpStatics(); }
988 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule
, wxModule
)
991 // This hack forces the linker to always link in m_* files
992 // (wxHTML doesn't work without handlers from these files)
993 #include "wx/html/forcelnk.h"
994 FORCE_WXHTML_MODULES()