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
;
645 const wxHtmlCell
*end
= m_selection
->GetToCell();
647 wxHtmlTerminalCellsInterator
i(m_selection
->GetFromCell(), end
);
650 text
<< i
->ConvertToText(m_selection
);
653 const wxHtmlCell
*prev
= *i
;
656 if ( prev
->GetParent() != i
->GetParent() )
658 text
<< i
->ConvertToText(*i
== end
? m_selection
: NULL
);
665 void wxHtmlWindow::CopySelection(ClipboardType t
)
670 wxTheClipboard
->UsePrimarySelection(t
== Primary
);
671 wxString
txt(SelectionToText());
672 if ( wxTheClipboard
->Open() )
674 wxTheClipboard
->SetData(new wxTextDataObject(txt
));
675 wxTheClipboard
->Close();
676 wxLogTrace(_T("wxhtmlselection"),
677 _("Copied to clipboard:\"%s\""), txt
.c_str());
684 void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo
& link
)
686 const wxMouseEvent
*e
= link
.GetEvent();
687 if (e
== NULL
|| e
->LeftUp())
688 LoadPage(link
.GetHref());
691 void wxHtmlWindow::OnCellClicked(wxHtmlCell
*cell
,
692 wxCoord x
, wxCoord y
,
693 const wxMouseEvent
& event
)
695 wxCHECK_RET( cell
, _T("can't be called with NULL cell") );
697 cell
->OnMouseClick(this, x
, y
, event
);
700 void wxHtmlWindow::OnCellMouseHover(wxHtmlCell
* WXUNUSED(cell
),
701 wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
))
706 void wxHtmlWindow::OnDraw(wxDC
& dc
)
708 if (m_tmpCanDrawLocks
> 0 || m_Cell
== NULL
) return;
711 wxRect rect
= GetUpdateRegion().GetBox();
713 dc
.SetMapMode(wxMM_TEXT
);
714 dc
.SetBackgroundMode(wxTRANSPARENT
);
715 GetViewStart(&x
, &y
);
717 wxHtmlRenderingState
rstate(m_selection
);
718 m_Cell
->Draw(dc
, 0, 0,
719 y
* wxHTML_SCROLL_STEP
+ rect
.GetTop(),
720 y
* wxHTML_SCROLL_STEP
+ rect
.GetBottom(),
727 void wxHtmlWindow::OnSize(wxSizeEvent
& event
)
729 wxScrolledWindow::OnSize(event
);
735 void wxHtmlWindow::OnMouseMove(wxMouseEvent
& event
)
737 m_tmpMouseMoved
= true;
740 void wxHtmlWindow::OnMouseDown(wxMouseEvent
& event
)
742 if ( event
.LeftDown() && IsSelectionEnabled() )
744 m_makingSelection
= true;
748 wxDELETE(m_selection
);
751 m_tmpSelFromPos
= CalcUnscrolledPosition(event
.GetPosition());
752 m_tmpSelFromCell
= NULL
;
758 void wxHtmlWindow::OnMouseUp(wxMouseEvent
& event
)
760 if ( m_makingSelection
)
763 m_makingSelection
= false;
765 // did the user move the mouse far enough from starting point?
768 // we don't want mouse up event that ended selecting to be
769 // handled as mouse click and e.g. follow hyperlink:
777 wxPoint pos
= CalcUnscrolledPosition(event
.GetPosition());
778 wxHtmlCell
*cell
= m_Cell
->FindCellByPos(pos
.x
, pos
.y
);
780 // VZ: is it possible that we don't find anything at all?
781 // VS: yes. FindCellByPos returns terminal cell and
782 // containers may have empty borders
784 OnCellClicked(cell
, pos
.x
, pos
.y
, event
);
790 void wxHtmlWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
))
792 if (s_cur_hand
== NULL
)
794 s_cur_hand
= new wxCursor(wxCURSOR_HAND
);
795 s_cur_arrow
= new wxCursor(wxCURSOR_ARROW
);
798 if (m_tmpMouseMoved
&& (m_Cell
!= NULL
))
801 wxGetMousePosition(&xc
, &yc
);
802 ScreenToClient(&xc
, &yc
);
803 CalcUnscrolledPosition(xc
, yc
, &x
, &y
);
805 wxHtmlCell
*cell
= m_Cell
->FindCellByPos(x
, y
);
807 // handle selection update:
808 if ( m_makingSelection
)
810 bool goingDown
= m_tmpSelFromPos
.y
< y
||
811 m_tmpSelFromPos
.y
== y
&& m_tmpSelFromPos
.x
< x
;
813 if ( !m_tmpSelFromCell
)
817 m_tmpSelFromCell
= m_Cell
->FindCellByPos(x
, y
,
818 wxHTML_FIND_NEAREST_AFTER
);
819 if (!m_tmpSelFromCell
)
820 m_tmpSelFromCell
= m_Cell
->GetFirstTerminal();
824 m_tmpSelFromCell
= m_Cell
->FindCellByPos(x
, y
,
825 wxHTML_FIND_NEAREST_BEFORE
);
826 if (!m_tmpSelFromCell
)
827 m_tmpSelFromCell
= m_Cell
->GetLastTerminal();
831 wxHtmlCell
*selcell
= cell
;
836 selcell
= m_Cell
->FindCellByPos(x
, y
,
837 wxHTML_FIND_NEAREST_AFTER
);
839 selcell
= m_Cell
->GetLastTerminal();
843 selcell
= m_Cell
->FindCellByPos(x
, y
,
844 wxHTML_FIND_NEAREST_BEFORE
);
846 selcell
= m_Cell
->GetFirstTerminal();
850 // NB: it may *rarely* happen that the code above didn't find one
851 // of the cells, e.g. if wxHtmlWindow doesn't contain any
853 if ( selcell
&& m_tmpSelFromCell
)
857 // start selecting only if mouse movement was big enough
858 // (otherwise it was meant as mouse click, not selection):
859 const int PRECISION
= 2;
860 wxPoint diff
= m_tmpSelFromPos
- wxPoint(x
,y
);
861 if (abs(diff
.x
) > PRECISION
|| abs(diff
.y
) > PRECISION
)
863 m_selection
= new wxHtmlSelection();
868 if ( m_tmpSelFromCell
->IsBefore(selcell
) )
870 m_selection
->Set(m_tmpSelFromPos
, m_tmpSelFromCell
,
871 wxPoint(x
,y
), selcell
);
875 m_selection
->Set(wxPoint(x
,y
), selcell
,
876 m_tmpSelFromPos
, m_tmpSelFromCell
);
878 Refresh(); // FIXME - optimize!
880 CopySelection(Primary
);
886 // handle cursor and status bar text changes:
887 if ( cell
!= m_tmpLastCell
)
889 wxHtmlLinkInfo
*lnk
= cell
? cell
->GetLink(x
, y
) : NULL
;
891 if (lnk
!= m_tmpLastLink
)
895 SetCursor(*s_cur_arrow
);
896 if (m_RelatedStatusBar
!= -1)
897 m_RelatedFrame
->SetStatusText(wxEmptyString
, m_RelatedStatusBar
);
901 SetCursor(*s_cur_hand
);
902 if (m_RelatedStatusBar
!= -1)
903 m_RelatedFrame
->SetStatusText(lnk
->GetHref(), m_RelatedStatusBar
);
908 m_tmpLastCell
= cell
;
910 else // mouse moved but stayed in the same cell
913 OnCellMouseHover(cell
, x
, y
);
916 m_tmpMouseMoved
= FALSE
;
921 void wxHtmlWindow::OnKeyUp(wxKeyEvent
& event
)
923 if ( event
.GetKeyCode() == 'C' && event
.ControlDown() )
932 void wxHtmlWindow::OnCopy(wxCommandEvent
& event
)
941 IMPLEMENT_ABSTRACT_CLASS(wxHtmlProcessor
,wxObject
)
943 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow
,wxScrolledWindow
)
945 BEGIN_EVENT_TABLE(wxHtmlWindow
, wxScrolledWindow
)
946 EVT_SIZE(wxHtmlWindow::OnSize
)
947 EVT_LEFT_DOWN(wxHtmlWindow::OnMouseDown
)
948 EVT_LEFT_UP(wxHtmlWindow::OnMouseUp
)
949 EVT_RIGHT_UP(wxHtmlWindow::OnMouseUp
)
950 EVT_MOTION(wxHtmlWindow::OnMouseMove
)
951 EVT_IDLE(wxHtmlWindow::OnIdle
)
953 EVT_KEY_UP(wxHtmlWindow::OnKeyUp
)
954 EVT_MENU(wxID_COPY
, wxHtmlWindow::OnCopy
)
962 // A module to allow initialization/cleanup
963 // without calling these functions from app.cpp or from
964 // the user's application.
966 class wxHtmlWinModule
: public wxModule
968 DECLARE_DYNAMIC_CLASS(wxHtmlWinModule
)
970 wxHtmlWinModule() : wxModule() {}
971 bool OnInit() { return TRUE
; }
972 void OnExit() { wxHtmlWindow::CleanUpStatics(); }
975 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule
, wxModule
)
978 // This hack forces the linker to always link in m_* files
979 // (wxHTML doesn't work without handlers from these files)
980 #include "wx/html/forcelnk.h"
981 FORCE_WXHTML_MODULES()