1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/htmlwin.cpp
3 // Purpose: wxHtmlWindow class for parsing & displaying HTML (implementation)
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #include "wx/wxprec.h"
16 #if wxUSE_HTML && wxUSE_STREAMS
22 #include "wx/dcclient.h"
24 #include "wx/dcmemory.h"
26 #include "wx/settings.h"
27 #include "wx/dataobj.h"
28 #include "wx/statusbr.h"
31 #include "wx/html/htmlwin.h"
32 #include "wx/html/htmlproc.h"
33 #include "wx/clipbrd.h"
35 #include "wx/arrimpl.cpp"
36 #include "wx/listimpl.cpp"
38 // uncomment this line to visually show the extent of the selection
39 //#define DEBUG_HTML_SELECTION
42 IMPLEMENT_DYNAMIC_CLASS(wxHtmlLinkEvent
, wxCommandEvent
)
43 IMPLEMENT_DYNAMIC_CLASS(wxHtmlCellEvent
, wxCommandEvent
)
45 wxDEFINE_EVENT( wxEVT_COMMAND_HTML_CELL_CLICKED
, wxHtmlCellEvent
);
46 wxDEFINE_EVENT( wxEVT_COMMAND_HTML_CELL_HOVER
, wxHtmlCellEvent
);
47 wxDEFINE_EVENT( wxEVT_COMMAND_HTML_LINK_CLICKED
, wxHtmlLinkEvent
);
51 // ----------------------------------------------------------------------------
52 // wxHtmlWinAutoScrollTimer: the timer used to generate a stream of scroll
53 // events when a captured mouse is held outside the window
54 // ----------------------------------------------------------------------------
56 class wxHtmlWinAutoScrollTimer
: public wxTimer
59 wxHtmlWinAutoScrollTimer(wxScrolledWindow
*win
,
60 wxEventType eventTypeToSend
,
64 m_eventType
= eventTypeToSend
;
69 virtual void Notify();
72 wxScrolledWindow
*m_win
;
73 wxEventType m_eventType
;
77 wxDECLARE_NO_COPY_CLASS(wxHtmlWinAutoScrollTimer
);
80 void wxHtmlWinAutoScrollTimer::Notify()
82 // only do all this as long as the window is capturing the mouse
83 if ( wxWindow::GetCapture() != m_win
)
87 else // we still capture the mouse, continue generating events
89 // first scroll the window if we are allowed to do it
90 wxScrollWinEvent
event1(m_eventType
, m_pos
, m_orient
);
91 event1
.SetEventObject(m_win
);
92 if ( m_win
->GetEventHandler()->ProcessEvent(event1
) )
94 // and then send a pseudo mouse-move event to refresh the selection
95 wxMouseEvent
event2(wxEVT_MOTION
);
96 wxGetMousePosition(&event2
.m_x
, &event2
.m_y
);
98 // the mouse event coordinates should be client, not screen as
99 // returned by wxGetMousePosition
100 wxWindow
*parentTop
= m_win
;
101 while ( parentTop
->GetParent() )
102 parentTop
= parentTop
->GetParent();
103 wxPoint ptOrig
= parentTop
->GetPosition();
104 event2
.m_x
-= ptOrig
.x
;
105 event2
.m_y
-= ptOrig
.y
;
107 event2
.SetEventObject(m_win
);
109 // FIXME: we don't fill in the other members - ok?
110 m_win
->GetEventHandler()->ProcessEvent(event2
);
112 else // can't scroll further, stop
119 #endif // wxUSE_CLIPBOARD
123 //-----------------------------------------------------------------------------
125 //-----------------------------------------------------------------------------
127 // item of history list
128 class WXDLLIMPEXP_HTML wxHtmlHistoryItem
131 wxHtmlHistoryItem(const wxString
& p
, const wxString
& a
) {m_Page
= p
, m_Anchor
= a
, m_Pos
= 0;}
132 int GetPos() const {return m_Pos
;}
133 void SetPos(int p
) {m_Pos
= p
;}
134 const wxString
& GetPage() const {return m_Page
;}
135 const wxString
& GetAnchor() const {return m_Anchor
;}
144 //-----------------------------------------------------------------------------
145 // our private arrays:
146 //-----------------------------------------------------------------------------
148 WX_DECLARE_OBJARRAY(wxHtmlHistoryItem
, wxHtmlHistoryArray
);
149 WX_DEFINE_OBJARRAY(wxHtmlHistoryArray
)
151 WX_DECLARE_LIST(wxHtmlProcessor
, wxHtmlProcessorList
);
152 WX_DEFINE_LIST(wxHtmlProcessorList
)
154 //-----------------------------------------------------------------------------
155 // wxHtmlWindowMouseHelper
156 //-----------------------------------------------------------------------------
158 wxHtmlWindowMouseHelper::wxHtmlWindowMouseHelper(wxHtmlWindowInterface
*iface
)
159 : m_tmpMouseMoved(false),
166 void wxHtmlWindowMouseHelper::HandleMouseMoved()
168 m_tmpMouseMoved
= true;
171 bool wxHtmlWindowMouseHelper::HandleMouseClick(wxHtmlCell
*rootCell
,
173 const wxMouseEvent
& event
)
178 wxHtmlCell
*cell
= rootCell
->FindCellByPos(pos
.x
, pos
.y
);
179 // this check is needed because FindCellByPos returns terminal cell and
180 // containers may have empty borders -- in this case NULL will be
185 // adjust the coordinates to be relative to this cell:
186 wxPoint relpos
= pos
- cell
->GetAbsPos(rootCell
);
188 return OnCellClicked(cell
, relpos
.x
, relpos
.y
, event
);
191 void wxHtmlWindowMouseHelper::HandleIdle(wxHtmlCell
*rootCell
,
194 wxHtmlCell
*cell
= rootCell
? rootCell
->FindCellByPos(pos
.x
, pos
.y
) : NULL
;
196 if (cell
!= m_tmpLastCell
)
198 wxHtmlLinkInfo
*lnk
= NULL
;
201 // adjust the coordinates to be relative to this cell:
202 wxPoint relpos
= pos
- cell
->GetAbsPos(rootCell
);
203 lnk
= cell
->GetLink(relpos
.x
, relpos
.y
);
208 cur
= cell
->GetMouseCursor(m_interface
);
210 cur
= m_interface
->GetHTMLCursor(
211 wxHtmlWindowInterface::HTMLCursor_Default
);
213 m_interface
->GetHTMLWindow()->SetCursor(cur
);
215 if (lnk
!= m_tmpLastLink
)
218 m_interface
->SetHTMLStatusText(lnk
->GetHref());
220 m_interface
->SetHTMLStatusText(wxEmptyString
);
225 m_tmpLastCell
= cell
;
227 else // mouse moved but stayed in the same cell
231 OnCellMouseHover(cell
, pos
.x
, pos
.y
);
235 m_tmpMouseMoved
= false;
238 bool wxHtmlWindowMouseHelper::OnCellClicked(wxHtmlCell
*cell
,
239 wxCoord x
, wxCoord y
,
240 const wxMouseEvent
& event
)
242 wxHtmlCellEvent
ev(wxEVT_COMMAND_HTML_CELL_CLICKED
,
243 m_interface
->GetHTMLWindow()->GetId(),
244 cell
, wxPoint(x
,y
), event
);
246 if (!m_interface
->GetHTMLWindow()->GetEventHandler()->ProcessEvent(ev
))
248 // if the event wasn't handled, do the default processing here:
250 wxASSERT_MSG( cell
, wxT("can't be called with NULL cell") );
252 cell
->ProcessMouseClick(m_interface
, ev
.GetPoint(), ev
.GetMouseEvent());
255 // true if a link was clicked, false otherwise
256 return ev
.GetLinkClicked();
259 void wxHtmlWindowMouseHelper::OnCellMouseHover(wxHtmlCell
* cell
,
263 wxHtmlCellEvent
ev(wxEVT_COMMAND_HTML_CELL_HOVER
,
264 m_interface
->GetHTMLWindow()->GetId(),
265 cell
, wxPoint(x
,y
), wxMouseEvent());
266 m_interface
->GetHTMLWindow()->GetEventHandler()->ProcessEvent(ev
);
272 //-----------------------------------------------------------------------------
274 //-----------------------------------------------------------------------------
276 wxList
wxHtmlWindow::m_Filters
;
277 wxHtmlFilter
*wxHtmlWindow::m_DefaultFilter
= NULL
;
278 wxHtmlProcessorList
*wxHtmlWindow::m_GlobalProcessors
= NULL
;
279 wxCursor
*wxHtmlWindow::ms_cursorLink
= NULL
;
280 wxCursor
*wxHtmlWindow::ms_cursorText
= NULL
;
282 void wxHtmlWindow::CleanUpStatics()
284 wxDELETE(m_DefaultFilter
);
285 WX_CLEAR_LIST(wxList
, m_Filters
);
286 if (m_GlobalProcessors
)
287 WX_CLEAR_LIST(wxHtmlProcessorList
, *m_GlobalProcessors
);
288 wxDELETE(m_GlobalProcessors
);
289 wxDELETE(ms_cursorLink
);
290 wxDELETE(ms_cursorText
);
293 void wxHtmlWindow::Init()
295 m_tmpCanDrawLocks
= 0;
296 m_FS
= new wxFileSystem();
298 m_RelatedStatusBar
= NULL
;
299 m_RelatedStatusBarIndex
= -1;
300 #endif // wxUSE_STATUSBAR
301 m_RelatedFrame
= NULL
;
302 m_TitleFormat
= wxT("%s");
303 m_OpenedPage
= m_OpenedAnchor
= m_OpenedPageTitle
= wxEmptyString
;
305 m_Parser
= new wxHtmlWinParser(this);
306 m_Parser
->SetFS(m_FS
);
309 m_History
= new wxHtmlHistoryArray
;
313 m_makingSelection
= false;
315 m_timerAutoScroll
= NULL
;
316 m_lastDoubleClick
= 0;
317 #endif // wxUSE_CLIPBOARD
318 m_tmpSelFromCell
= NULL
;
321 bool wxHtmlWindow::Create(wxWindow
*parent
, wxWindowID id
,
322 const wxPoint
& pos
, const wxSize
& size
,
323 long style
, const wxString
& name
)
325 if (!wxScrolledWindow::Create(parent
, id
, pos
, size
,
326 style
| wxVSCROLL
| wxHSCROLL
,
330 // We can't erase our background in EVT_ERASE_BACKGROUND handler and use
331 // double buffering in EVT_PAINT handler as this requires blitting back
332 // something already drawn on the window to the backing store bitmap when
333 // handling EVT_PAINT but blitting in this direction is simply not
334 // supported by OS X.
336 // So instead we use a hack with artificial EVT_ERASE_BACKGROUND generation
337 // from OnPaint() and this means that we never need the "real" erase event
338 // at all so disable it to avoid executing any user-defined handlers twice
339 // (and to avoid processing unnecessary event if no handlers are defined).
340 SetBackgroundStyle(wxBG_STYLE_PAINT
);
341 SetPage(wxT("<html><body></body></html>"));
343 SetInitialSize(size
);
348 wxHtmlWindow::~wxHtmlWindow()
352 #endif // wxUSE_CLIPBOARD
361 WX_CLEAR_LIST(wxHtmlProcessorList
, *m_Processors
);
372 void wxHtmlWindow::SetRelatedFrame(wxFrame
* frame
, const wxString
& format
)
374 m_RelatedFrame
= frame
;
375 m_TitleFormat
= format
;
381 void wxHtmlWindow::SetRelatedStatusBar(int index
)
383 m_RelatedStatusBarIndex
= index
;
386 void wxHtmlWindow::SetRelatedStatusBar(wxStatusBar
* statusbar
, int index
)
388 m_RelatedStatusBar
= statusbar
;
389 m_RelatedStatusBarIndex
= index
;
392 #endif // wxUSE_STATUSBAR
396 void wxHtmlWindow::SetFonts(const wxString
& normal_face
, const wxString
& fixed_face
, const int *sizes
)
398 m_Parser
->SetFonts(normal_face
, fixed_face
, sizes
);
400 // re-layout the page after changing fonts:
401 DoSetPage(*(m_Parser
->GetSource()));
404 void wxHtmlWindow::SetStandardFonts(int size
,
405 const wxString
& normal_face
,
406 const wxString
& fixed_face
)
408 m_Parser
->SetStandardFonts(size
, normal_face
, fixed_face
);
410 // re-layout the page after changing fonts:
411 DoSetPage(*(m_Parser
->GetSource()));
414 bool wxHtmlWindow::SetPage(const wxString
& source
)
416 m_OpenedPage
= m_OpenedAnchor
= m_OpenedPageTitle
= wxEmptyString
;
417 return DoSetPage(source
);
420 bool wxHtmlWindow::DoSetPage(const wxString
& source
)
422 wxString
newsrc(source
);
424 wxDELETE(m_selection
);
426 // we will soon delete all the cells, so clear pointers to them:
427 m_tmpSelFromCell
= NULL
;
429 // pass HTML through registered processors:
430 if (m_Processors
|| m_GlobalProcessors
)
432 wxHtmlProcessorList::compatibility_iterator nodeL
, nodeG
;
436 nodeL
= m_Processors
->GetFirst();
437 if ( m_GlobalProcessors
)
438 nodeG
= m_GlobalProcessors
->GetFirst();
440 // VS: there are two lists, global and local, both of them sorted by
441 // priority. Since we have to go through _both_ lists with
442 // decreasing priority, we "merge-sort" the lists on-line by
443 // processing that one of the two heads that has higher priority
444 // in every iteration
445 while (nodeL
|| nodeG
)
447 prL
= (nodeL
) ? nodeL
->GetData()->GetPriority() : -1;
448 prG
= (nodeG
) ? nodeG
->GetData()->GetPriority() : -1;
451 if (nodeL
->GetData()->IsEnabled())
452 newsrc
= nodeL
->GetData()->Process(newsrc
);
453 nodeL
= nodeL
->GetNext();
457 if (nodeG
->GetData()->IsEnabled())
458 newsrc
= nodeG
->GetData()->Process(newsrc
);
459 nodeG
= nodeG
->GetNext();
464 // ...and run the parser on it:
465 wxClientDC
*dc
= new wxClientDC(this);
466 dc
->SetMapMode(wxMM_TEXT
);
467 SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
468 SetBackgroundImage(wxNullBitmap
);
474 // notice that it's important to set m_Cell to NULL here before calling
475 // Parse() below, even if it will be overwritten by its return value:
476 // without this we may crash if it's used from inside Parse()
479 m_Cell
= (wxHtmlContainerCell
*) m_Parser
->Parse(newsrc
);
481 m_Cell
->SetIndent(m_Borders
, wxHTML_INDENT_ALL
, wxHTML_UNITS_PIXELS
);
482 m_Cell
->SetAlignHor(wxHTML_ALIGN_CENTER
);
484 if (m_tmpCanDrawLocks
== 0)
489 bool wxHtmlWindow::AppendToPage(const wxString
& source
)
491 return DoSetPage(*(GetParser()->GetSource()) + source
);
494 bool wxHtmlWindow::LoadPage(const wxString
& location
)
496 wxCHECK_MSG( !location
.empty(), false, "location must be non-empty" );
498 wxBusyCursor busyCursor
;
501 bool needs_refresh
= false;
504 if (m_HistoryOn
&& (m_HistoryPos
!= -1))
506 // store scroll position into history item:
508 GetViewStart(&x
, &y
);
509 (*m_History
)[m_HistoryPos
].SetPos(y
);
512 // first check if we're moving to an anchor in the same page
513 size_t posLocalAnchor
= location
.Find('#');
514 if ( posLocalAnchor
!= wxString::npos
&& posLocalAnchor
!= 0 )
516 // check if the part before the anchor is the same as the (either
517 // relative or absolute) URI of the current page
518 const wxString beforeAnchor
= location
.substr(0, posLocalAnchor
);
519 if ( beforeAnchor
!= m_OpenedPage
&&
520 m_FS
->GetPath() + beforeAnchor
!= m_OpenedPage
)
522 // indicate that we're not moving to a local anchor
523 posLocalAnchor
= wxString::npos
;
527 if ( posLocalAnchor
!= wxString::npos
)
530 rt_val
= ScrollToAnchor(location
.substr(posLocalAnchor
+ 1));
533 else // moving to another page
535 needs_refresh
= true;
538 if (m_RelatedStatusBarIndex
!= -1)
540 SetHTMLStatusText(_("Connecting..."));
543 #endif // wxUSE_STATUSBAR
545 wxFSFile
*f
= m_Parser
->OpenURL(wxHTML_URL_PAGE
, location
);
547 // try to interpret 'location' as filename instead of URL:
550 wxFileName
fn(location
);
551 wxString location2
= wxFileSystem::FileNameToURL(fn
);
552 f
= m_Parser
->OpenURL(wxHTML_URL_PAGE
, location2
);
557 wxLogError(_("Unable to open requested HTML document: %s"), location
.c_str());
559 SetHTMLStatusText(wxEmptyString
);
565 wxList::compatibility_iterator node
;
566 wxString src
= wxEmptyString
;
569 if (m_RelatedStatusBarIndex
!= -1)
571 wxString msg
= _("Loading : ") + location
;
572 SetHTMLStatusText(msg
);
575 #endif // wxUSE_STATUSBAR
577 node
= m_Filters
.GetFirst();
580 wxHtmlFilter
*h
= (wxHtmlFilter
*) node
->GetData();
583 src
= h
->ReadFile(*f
);
586 node
= node
->GetNext();
588 if (src
== wxEmptyString
)
590 if (m_DefaultFilter
== NULL
) m_DefaultFilter
= GetDefaultFilter();
591 src
= m_DefaultFilter
->ReadFile(*f
);
594 m_FS
->ChangePathTo(f
->GetLocation());
595 rt_val
= SetPage(src
);
596 m_OpenedPage
= f
->GetLocation();
597 if (f
->GetAnchor() != wxEmptyString
)
599 ScrollToAnchor(f
->GetAnchor());
605 if (m_RelatedStatusBarIndex
!= -1)
607 SetHTMLStatusText(_("Done"));
609 #endif // wxUSE_STATUSBAR
613 if (m_HistoryOn
) // add this page to history there:
615 int c
= m_History
->GetCount() - (m_HistoryPos
+ 1);
617 if (m_HistoryPos
< 0 ||
618 (*m_History
)[m_HistoryPos
].GetPage() != m_OpenedPage
||
619 (*m_History
)[m_HistoryPos
].GetAnchor() != m_OpenedAnchor
)
622 for (int i
= 0; i
< c
; i
++)
623 m_History
->RemoveAt(m_HistoryPos
);
624 m_History
->Add(new wxHtmlHistoryItem(m_OpenedPage
, m_OpenedAnchor
));
628 if (m_OpenedPageTitle
== wxEmptyString
)
629 OnSetTitle(wxFileNameFromPath(m_OpenedPage
));
643 bool wxHtmlWindow::LoadFile(const wxFileName
& filename
)
645 wxString url
= wxFileSystem::FileNameToURL(filename
);
646 return LoadPage(url
);
650 bool wxHtmlWindow::ScrollToAnchor(const wxString
& anchor
)
652 const wxHtmlCell
*c
= m_Cell
->Find(wxHTML_COND_ISANCHOR
, &anchor
);
655 wxLogWarning(_("HTML anchor %s does not exist."), anchor
.c_str());
660 // Go to next visible cell in current container, if it exists. This
661 // yields a bit better (even though still imperfect) results in that
662 // there's better chance of using a suitable cell for upper Y
663 // coordinate value. See bug #11406 for additional discussion.
664 const wxHtmlCell
*c_save
= c
;
665 while ( c
&& c
->IsFormattingCell() )
672 for (y
= 0; c
!= NULL
; c
= c
->GetParent()) y
+= c
->GetPosY();
673 Scroll(-1, y
/ wxHTML_SCROLL_STEP
);
674 m_OpenedAnchor
= anchor
;
680 void wxHtmlWindow::OnSetTitle(const wxString
& title
)
685 tit
.Printf(m_TitleFormat
, title
.c_str());
686 m_RelatedFrame
->SetTitle(tit
);
688 m_OpenedPageTitle
= title
;
695 void wxHtmlWindow::CreateLayout()
697 int ClientWidth
, ClientHeight
;
701 if ( HasFlag(wxHW_SCROLLBAR_NEVER
) )
703 SetScrollbars(1, 1, 0, 0); // always off
704 GetClientSize(&ClientWidth
, &ClientHeight
);
705 m_Cell
->Layout(ClientWidth
);
707 else // !wxHW_SCROLLBAR_NEVER
709 GetClientSize(&ClientWidth
, &ClientHeight
);
710 m_Cell
->Layout(ClientWidth
);
711 if (ClientHeight
< m_Cell
->GetHeight() + GetCharHeight())
714 wxHTML_SCROLL_STEP
, wxHTML_SCROLL_STEP
,
715 m_Cell
->GetWidth() / wxHTML_SCROLL_STEP
,
716 (m_Cell
->GetHeight() + GetCharHeight()) / wxHTML_SCROLL_STEP
717 /*cheat: top-level frag is always container*/);
719 else /* we fit into window, no need for scrollbars */
721 SetScrollbars(wxHTML_SCROLL_STEP
, 1, m_Cell
->GetWidth() / wxHTML_SCROLL_STEP
, 0); // disable...
722 GetClientSize(&ClientWidth
, &ClientHeight
);
723 m_Cell
->Layout(ClientWidth
); // ...and relayout
730 void wxHtmlWindow::ReadCustomization(wxConfigBase
*cfg
, wxString path
)
735 wxString p_fff
, p_ffn
;
737 if (path
!= wxEmptyString
)
739 oldpath
= cfg
->GetPath();
743 m_Borders
= cfg
->Read(wxT("wxHtmlWindow/Borders"), m_Borders
);
744 p_fff
= cfg
->Read(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser
->m_FontFaceFixed
);
745 p_ffn
= cfg
->Read(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser
->m_FontFaceNormal
);
746 for (int i
= 0; i
< 7; i
++)
748 tmp
.Printf(wxT("wxHtmlWindow/FontsSize%i"), i
);
749 p_fontsizes
[i
] = cfg
->Read(tmp
, m_Parser
->m_FontsSizes
[i
]);
751 SetFonts(p_ffn
, p_fff
, p_fontsizes
);
753 if (path
!= wxEmptyString
)
754 cfg
->SetPath(oldpath
);
759 void wxHtmlWindow::WriteCustomization(wxConfigBase
*cfg
, wxString path
)
764 if (path
!= wxEmptyString
)
766 oldpath
= cfg
->GetPath();
770 cfg
->Write(wxT("wxHtmlWindow/Borders"), (long) m_Borders
);
771 cfg
->Write(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser
->m_FontFaceFixed
);
772 cfg
->Write(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser
->m_FontFaceNormal
);
773 for (int i
= 0; i
< 7; i
++)
775 tmp
.Printf(wxT("wxHtmlWindow/FontsSize%i"), i
);
776 cfg
->Write(tmp
, (long) m_Parser
->m_FontsSizes
[i
]);
779 if (path
!= wxEmptyString
)
780 cfg
->SetPath(oldpath
);
785 bool wxHtmlWindow::HistoryBack()
789 if (m_HistoryPos
< 1) return false;
791 // store scroll position into history item:
793 GetViewStart(&x
, &y
);
794 (*m_History
)[m_HistoryPos
].SetPos(y
);
796 // go to previous position:
799 l
= (*m_History
)[m_HistoryPos
].GetPage();
800 a
= (*m_History
)[m_HistoryPos
].GetAnchor();
803 if (a
== wxEmptyString
) LoadPage(l
);
804 else LoadPage(l
+ wxT("#") + a
);
807 Scroll(0, (*m_History
)[m_HistoryPos
].GetPos());
812 bool wxHtmlWindow::HistoryCanBack()
814 if (m_HistoryPos
< 1) return false;
819 bool wxHtmlWindow::HistoryForward()
823 if (m_HistoryPos
== -1) return false;
824 if (m_HistoryPos
>= (int)m_History
->GetCount() - 1)return false;
826 m_OpenedPage
= wxEmptyString
; // this will disable adding new entry into history in LoadPage()
829 l
= (*m_History
)[m_HistoryPos
].GetPage();
830 a
= (*m_History
)[m_HistoryPos
].GetAnchor();
833 if (a
== wxEmptyString
) LoadPage(l
);
834 else LoadPage(l
+ wxT("#") + a
);
837 Scroll(0, (*m_History
)[m_HistoryPos
].GetPos());
842 bool wxHtmlWindow::HistoryCanForward()
844 if (m_HistoryPos
== -1) return false;
845 if (m_HistoryPos
>= (int)m_History
->GetCount() - 1)return false;
850 void wxHtmlWindow::HistoryClear()
856 void wxHtmlWindow::AddProcessor(wxHtmlProcessor
*processor
)
860 m_Processors
= new wxHtmlProcessorList
;
862 wxHtmlProcessorList::compatibility_iterator node
;
864 for (node
= m_Processors
->GetFirst(); node
; node
= node
->GetNext())
866 if (processor
->GetPriority() > node
->GetData()->GetPriority())
868 m_Processors
->Insert(node
, processor
);
872 m_Processors
->Append(processor
);
875 /*static */ void wxHtmlWindow::AddGlobalProcessor(wxHtmlProcessor
*processor
)
877 if (!m_GlobalProcessors
)
879 m_GlobalProcessors
= new wxHtmlProcessorList
;
881 wxHtmlProcessorList::compatibility_iterator node
;
883 for (node
= m_GlobalProcessors
->GetFirst(); node
; node
= node
->GetNext())
885 if (processor
->GetPriority() > node
->GetData()->GetPriority())
887 m_GlobalProcessors
->Insert(node
, processor
);
891 m_GlobalProcessors
->Append(processor
);
896 void wxHtmlWindow::AddFilter(wxHtmlFilter
*filter
)
898 m_Filters
.Append(filter
);
902 bool wxHtmlWindow::IsSelectionEnabled() const
905 return !HasFlag(wxHW_NO_SELECTION
);
913 wxString
wxHtmlWindow::DoSelectionToText(wxHtmlSelection
*sel
)
916 return wxEmptyString
;
921 wxHtmlTerminalCellsInterator
i(sel
->GetFromCell(), sel
->GetToCell());
922 const wxHtmlCell
*prev
= NULL
;
926 // When converting HTML content to plain text, the entire paragraph
927 // (container in wxHTML) goes on single line. A new paragraph (that
928 // should go on its own line) has its own container. Therefore, the
929 // simplest way of detecting where to insert newlines in plain text
930 // is to check if the parent container changed -- if it did, we moved
931 // to a new paragraph.
932 if ( prev
&& prev
->GetParent() != i
->GetParent() )
935 // NB: we don't need to pass the selection to ConvertToText() in the
936 // middle of the selected text; it's only useful when only part of
937 // a cell is selected
938 text
<< i
->ConvertToText(sel
);
946 wxString
wxHtmlWindow::ToText()
951 sel
.Set(m_Cell
->GetFirstTerminal(), m_Cell
->GetLastTerminal());
952 return DoSelectionToText(&sel
);
955 return wxEmptyString
;
958 #endif // wxUSE_CLIPBOARD
960 bool wxHtmlWindow::CopySelection(ClipboardType t
)
965 #if defined(__UNIX__) && !defined(__WXMAC__)
966 wxTheClipboard
->UsePrimarySelection(t
== Primary
);
968 // Primary selection exists only under X11, so don't do anything under
969 // the other platforms when we try to access it
971 // TODO: this should be abstracted at wxClipboard level!
974 #endif // __UNIX__/!__UNIX__
976 if ( wxTheClipboard
->Open() )
978 const wxString
txt(SelectionToText());
979 wxTheClipboard
->SetData(new wxTextDataObject(txt
));
980 wxTheClipboard
->Close();
981 wxLogTrace(wxT("wxhtmlselection"),
982 _("Copied to clipboard:\"%s\""), txt
.c_str());
989 #endif // wxUSE_CLIPBOARD
995 void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo
& link
)
997 wxHtmlLinkEvent
event(GetId(), link
);
998 event
.SetEventObject(this);
999 if (!GetEventHandler()->ProcessEvent(event
))
1001 // the default behaviour is to load the URL in this window
1002 const wxMouseEvent
*e
= event
.GetLinkInfo().GetEvent();
1003 if (e
== NULL
|| e
->LeftUp())
1004 LoadPage(event
.GetLinkInfo().GetHref());
1008 void wxHtmlWindow::DoEraseBackground(wxDC
& dc
)
1010 // if we don't have any background bitmap we just fill it with background
1011 // colour and we also must do it if the background bitmap is not fully
1012 // opaque as otherwise junk could be left there
1013 if ( !m_bmpBg
.IsOk() || m_bmpBg
.GetMask() )
1015 dc
.SetBackground(GetBackgroundColour());
1019 if ( m_bmpBg
.IsOk() )
1021 // draw the background bitmap tiling it over the entire window area
1022 const wxSize sz
= GetClientSize();
1023 const wxSize
sizeBmp(m_bmpBg
.GetWidth(), m_bmpBg
.GetHeight());
1024 for ( wxCoord x
= 0; x
< sz
.x
; x
+= sizeBmp
.x
)
1026 for ( wxCoord y
= 0; y
< sz
.y
; y
+= sizeBmp
.y
)
1028 dc
.DrawBitmap(m_bmpBg
, x
, y
, true /* use mask */);
1034 void wxHtmlWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
1036 wxPaintDC
dcPaint(this);
1038 if (m_tmpCanDrawLocks
> 0 || m_Cell
== NULL
)
1042 GetViewStart(&x
, &y
);
1043 const wxRect rect
= GetUpdateRegion().GetBox();
1044 const wxSize sz
= GetClientSize();
1046 // set up the DC we're drawing on: if the window is already double buffered
1047 // we do it directly on wxPaintDC, otherwise we allocate a backing store
1048 // buffer and compose the drawing there and then blit it to screen all at
1052 if ( IsDoubleBuffered() )
1056 else // window is not double buffered by the system, do it ourselves
1058 if ( !m_backBuffer
.IsOk() )
1059 m_backBuffer
.Create(sz
.x
, sz
.y
);
1060 dcm
.SelectObject(m_backBuffer
);
1066 // erase the background: for compatibility, we must generate the event to
1067 // allow the user-defined handlers to do it
1068 wxEraseEvent
eraseEvent(GetId(), dc
);
1069 eraseEvent
.SetEventObject(this);
1070 if ( !ProcessWindowEvent(eraseEvent
) )
1072 // erase background ourselves
1073 DoEraseBackground(*dc
);
1075 //else: background erased by the user-defined handler
1078 // draw the HTML window contents
1079 dc
->SetMapMode(wxMM_TEXT
);
1080 dc
->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT
);
1082 wxHtmlRenderingInfo rinfo
;
1083 wxDefaultHtmlRenderingStyle rstyle
;
1084 rinfo
.SetSelection(m_selection
);
1085 rinfo
.SetStyle(&rstyle
);
1086 m_Cell
->Draw(*dc
, 0, 0,
1087 y
* wxHTML_SCROLL_STEP
+ rect
.GetTop(),
1088 y
* wxHTML_SCROLL_STEP
+ rect
.GetBottom(),
1091 #ifdef DEBUG_HTML_SELECTION
1094 wxGetMousePosition(&xc
, &yc
);
1095 ScreenToClient(&xc
, &yc
);
1096 CalcUnscrolledPosition(xc
, yc
, &x
, &y
);
1097 wxHtmlCell
*at
= m_Cell
->FindCellByPos(x
, y
);
1098 wxHtmlCell
*before
=
1099 m_Cell
->FindCellByPos(x
, y
, wxHTML_FIND_NEAREST_BEFORE
);
1101 m_Cell
->FindCellByPos(x
, y
, wxHTML_FIND_NEAREST_AFTER
);
1103 dc
->SetBrush(*wxTRANSPARENT_BRUSH
);
1104 dc
->SetPen(*wxBLACK_PEN
);
1106 dc
->DrawRectangle(at
->GetAbsPos(),
1107 wxSize(at
->GetWidth(),at
->GetHeight()));
1108 dc
->SetPen(*wxGREEN_PEN
);
1110 dc
->DrawRectangle(before
->GetAbsPos().x
+1, before
->GetAbsPos().y
+1,
1111 before
->GetWidth()-2,before
->GetHeight()-2);
1112 dc
->SetPen(*wxRED_PEN
);
1114 dc
->DrawRectangle(after
->GetAbsPos().x
+2, after
->GetAbsPos().y
+2,
1115 after
->GetWidth()-4,after
->GetHeight()-4);
1117 #endif // DEBUG_HTML_SELECTION
1119 if ( dc
!= &dcPaint
)
1121 dc
->SetDeviceOrigin(0,0);
1122 dcPaint
.Blit(0, rect
.GetTop(),
1123 sz
.x
, rect
.GetBottom() - rect
.GetTop() + 1,
1132 void wxHtmlWindow::OnSize(wxSizeEvent
& event
)
1136 m_backBuffer
= wxNullBitmap
;
1140 // Recompute selection if necessary:
1143 m_selection
->Set(m_selection
->GetFromCell(),
1144 m_selection
->GetToCell());
1145 m_selection
->ClearPrivPos();
1152 void wxHtmlWindow::OnMouseMove(wxMouseEvent
& WXUNUSED(event
))
1154 wxHtmlWindowMouseHelper::HandleMouseMoved();
1157 void wxHtmlWindow::OnMouseDown(wxMouseEvent
& event
)
1160 if ( event
.LeftDown() && IsSelectionEnabled() )
1162 const long TRIPLECLICK_LEN
= 200; // 0.2 sec after doubleclick
1163 if ( wxGetLocalTimeMillis() - m_lastDoubleClick
<= TRIPLECLICK_LEN
)
1165 SelectLine(CalcUnscrolledPosition(event
.GetPosition()));
1167 (void) CopySelection();
1171 m_makingSelection
= true;
1175 wxDELETE(m_selection
);
1178 m_tmpSelFromPos
= CalcUnscrolledPosition(event
.GetPosition());
1179 m_tmpSelFromCell
= NULL
;
1184 #endif // wxUSE_CLIPBOARD
1186 // in any case, let the default handler set focus to this window
1190 void wxHtmlWindow::OnMouseUp(wxMouseEvent
& event
)
1193 if ( m_makingSelection
)
1196 m_makingSelection
= false;
1198 // if m_selection=NULL, the user didn't move the mouse far enough from
1199 // starting point and the mouse up event is part of a click, the user
1200 // is not selecting text:
1203 CopySelection(Primary
);
1205 // we don't want mouse up event that ended selecting to be
1206 // handled as mouse click and e.g. follow hyperlink:
1210 #endif // wxUSE_CLIPBOARD
1212 wxPoint pos
= CalcUnscrolledPosition(event
.GetPosition());
1213 wxHtmlWindowMouseHelper::HandleMouseClick(m_Cell
, pos
, event
);
1217 void wxHtmlWindow::OnMouseCaptureLost(wxMouseCaptureLostEvent
& WXUNUSED(event
))
1219 if ( !m_makingSelection
)
1222 // discard the selecting operation
1223 m_makingSelection
= false;
1224 wxDELETE(m_selection
);
1225 m_tmpSelFromCell
= NULL
;
1228 #endif // wxUSE_CLIPBOARD
1231 void wxHtmlWindow::OnInternalIdle()
1233 wxWindow::OnInternalIdle();
1235 if (m_Cell
!= NULL
&& DidMouseMove())
1237 #ifdef DEBUG_HTML_SELECTION
1241 wxGetMousePosition(&xc
, &yc
);
1242 ScreenToClient(&xc
, &yc
);
1243 CalcUnscrolledPosition(xc
, yc
, &x
, &y
);
1245 wxHtmlCell
*cell
= m_Cell
->FindCellByPos(x
, y
);
1247 // handle selection update:
1248 if ( m_makingSelection
)
1250 if ( !m_tmpSelFromCell
)
1251 m_tmpSelFromCell
= m_Cell
->FindCellByPos(
1252 m_tmpSelFromPos
.x
,m_tmpSelFromPos
.y
);
1254 // NB: a trick - we adjust selFromPos to be upper left or bottom
1255 // right corner of the first cell of the selection depending
1256 // on whether the mouse is moving to the right or to the left.
1257 // This gives us more "natural" behaviour when selecting
1258 // a line (specifically, first cell of the next line is not
1259 // included if you drag selection from left to right over
1262 if ( !m_tmpSelFromCell
)
1264 dirFromPos
= m_tmpSelFromPos
;
1268 dirFromPos
= m_tmpSelFromCell
->GetAbsPos();
1269 if ( x
< m_tmpSelFromPos
.x
)
1271 dirFromPos
.x
+= m_tmpSelFromCell
->GetWidth();
1272 dirFromPos
.y
+= m_tmpSelFromCell
->GetHeight();
1275 bool goingDown
= dirFromPos
.y
< y
||
1276 (dirFromPos
.y
== y
&& dirFromPos
.x
< x
);
1278 // determine selection span:
1279 if ( /*still*/ !m_tmpSelFromCell
)
1283 m_tmpSelFromCell
= m_Cell
->FindCellByPos(
1284 m_tmpSelFromPos
.x
,m_tmpSelFromPos
.y
,
1285 wxHTML_FIND_NEAREST_AFTER
);
1286 if (!m_tmpSelFromCell
)
1287 m_tmpSelFromCell
= m_Cell
->GetFirstTerminal();
1291 m_tmpSelFromCell
= m_Cell
->FindCellByPos(
1292 m_tmpSelFromPos
.x
,m_tmpSelFromPos
.y
,
1293 wxHTML_FIND_NEAREST_BEFORE
);
1294 if (!m_tmpSelFromCell
)
1295 m_tmpSelFromCell
= m_Cell
->GetLastTerminal();
1299 wxHtmlCell
*selcell
= cell
;
1304 selcell
= m_Cell
->FindCellByPos(x
, y
,
1305 wxHTML_FIND_NEAREST_BEFORE
);
1307 selcell
= m_Cell
->GetLastTerminal();
1311 selcell
= m_Cell
->FindCellByPos(x
, y
,
1312 wxHTML_FIND_NEAREST_AFTER
);
1314 selcell
= m_Cell
->GetFirstTerminal();
1318 // NB: it may *rarely* happen that the code above didn't find one
1319 // of the cells, e.g. if wxHtmlWindow doesn't contain any
1321 if ( selcell
&& m_tmpSelFromCell
)
1325 // start selecting only if mouse movement was big enough
1326 // (otherwise it was meant as mouse click, not selection):
1327 const int PRECISION
= 2;
1328 wxPoint diff
= m_tmpSelFromPos
- wxPoint(x
,y
);
1329 if (abs(diff
.x
) > PRECISION
|| abs(diff
.y
) > PRECISION
)
1331 m_selection
= new wxHtmlSelection();
1336 if ( m_tmpSelFromCell
->IsBefore(selcell
) )
1338 m_selection
->Set(m_tmpSelFromPos
, m_tmpSelFromCell
,
1339 wxPoint(x
,y
), selcell
);
1343 m_selection
->Set(wxPoint(x
,y
), selcell
,
1344 m_tmpSelFromPos
, m_tmpSelFromCell
);
1346 m_selection
->ClearPrivPos();
1352 // handle cursor and status bar text changes:
1354 // NB: because we're passing in 'cell' and not 'm_Cell' (so that the
1355 // leaf cell lookup isn't done twice), we need to adjust the
1356 // position for the new root:
1357 wxPoint
posInCell(x
, y
);
1359 posInCell
-= cell
->GetAbsPos();
1360 wxHtmlWindowMouseHelper::HandleIdle(cell
, posInCell
);
1365 void wxHtmlWindow::StopAutoScrolling()
1367 if ( m_timerAutoScroll
)
1369 wxDELETE(m_timerAutoScroll
);
1373 void wxHtmlWindow::OnMouseEnter(wxMouseEvent
& event
)
1375 StopAutoScrolling();
1379 void wxHtmlWindow::OnMouseLeave(wxMouseEvent
& event
)
1381 // don't prevent the usual processing of the event from taking place
1384 // when a captured mouse leave a scrolled window we start generate
1385 // scrolling events to allow, for example, extending selection beyond the
1386 // visible area in some controls
1387 if ( wxWindow::GetCapture() == this )
1389 // where is the mouse leaving?
1391 wxPoint pt
= event
.GetPosition();
1394 orient
= wxHORIZONTAL
;
1397 else if ( pt
.y
< 0 )
1399 orient
= wxVERTICAL
;
1402 else // we're lower or to the right of the window
1404 wxSize size
= GetClientSize();
1405 if ( pt
.x
> size
.x
)
1407 orient
= wxHORIZONTAL
;
1408 pos
= GetVirtualSize().x
/ wxHTML_SCROLL_STEP
;
1410 else if ( pt
.y
> size
.y
)
1412 orient
= wxVERTICAL
;
1413 pos
= GetVirtualSize().y
/ wxHTML_SCROLL_STEP
;
1415 else // this should be impossible
1417 // but seems to happen sometimes under wxMSW - maybe it's a bug
1418 // there but for now just ignore it
1420 //wxFAIL_MSG( wxT("can't understand where has mouse gone") );
1426 // only start the auto scroll timer if the window can be scrolled in
1428 if ( !HasScrollbar(orient
) )
1431 delete m_timerAutoScroll
;
1432 m_timerAutoScroll
= new wxHtmlWinAutoScrollTimer
1435 pos
== 0 ? wxEVT_SCROLLWIN_LINEUP
1436 : wxEVT_SCROLLWIN_LINEDOWN
,
1440 m_timerAutoScroll
->Start(50); // FIXME: make configurable
1444 void wxHtmlWindow::OnKeyUp(wxKeyEvent
& event
)
1446 if ( IsSelectionEnabled() &&
1447 (event
.GetKeyCode() == 'C' && event
.CmdDown()) )
1449 wxClipboardTextEvent
evt(wxEVT_COMMAND_TEXT_COPY
, GetId());
1451 evt
.SetEventObject(this);
1453 GetEventHandler()->ProcessEvent(evt
);
1457 void wxHtmlWindow::OnCopy(wxCommandEvent
& WXUNUSED(event
))
1459 (void) CopySelection();
1462 void wxHtmlWindow::OnClipboardEvent(wxClipboardTextEvent
& WXUNUSED(event
))
1464 (void) CopySelection();
1467 void wxHtmlWindow::OnDoubleClick(wxMouseEvent
& event
)
1469 // select word under cursor:
1470 if ( IsSelectionEnabled() )
1472 SelectWord(CalcUnscrolledPosition(event
.GetPosition()));
1474 (void) CopySelection(Primary
);
1476 m_lastDoubleClick
= wxGetLocalTimeMillis();
1482 void wxHtmlWindow::SelectWord(const wxPoint
& pos
)
1486 wxHtmlCell
*cell
= m_Cell
->FindCellByPos(pos
.x
, pos
.y
);
1490 m_selection
= new wxHtmlSelection();
1491 m_selection
->Set(cell
, cell
);
1492 RefreshRect(wxRect(CalcScrolledPosition(cell
->GetAbsPos()),
1493 wxSize(cell
->GetWidth(), cell
->GetHeight())));
1498 void wxHtmlWindow::SelectLine(const wxPoint
& pos
)
1502 wxHtmlCell
*cell
= m_Cell
->FindCellByPos(pos
.x
, pos
.y
);
1505 // We use following heuristic to find a "line": let the line be all
1506 // cells in same container as the cell under mouse cursor that are
1507 // neither completely above nor completely bellow the clicked cell
1508 // (i.e. are likely to be words positioned on same line of text).
1510 int y1
= cell
->GetAbsPos().y
;
1511 int y2
= y1
+ cell
->GetHeight();
1513 const wxHtmlCell
*c
;
1514 const wxHtmlCell
*before
= NULL
;
1515 const wxHtmlCell
*after
= NULL
;
1517 // find last cell of line:
1518 for ( c
= cell
->GetNext(); c
; c
= c
->GetNext())
1520 y
= c
->GetAbsPos().y
;
1521 if ( y
+ c
->GetHeight() > y1
&& y
< y2
)
1529 // find first cell of line:
1530 for ( c
= cell
->GetParent()->GetFirstChild();
1531 c
&& c
!= cell
; c
= c
->GetNext())
1533 y
= c
->GetAbsPos().y
;
1534 if ( y
+ c
->GetHeight() > y1
&& y
< y2
)
1546 m_selection
= new wxHtmlSelection();
1547 m_selection
->Set(before
, after
);
1554 void wxHtmlWindow::SelectAll()
1559 m_selection
= new wxHtmlSelection();
1560 m_selection
->Set(m_Cell
->GetFirstTerminal(), m_Cell
->GetLastTerminal());
1565 #endif // wxUSE_CLIPBOARD
1569 IMPLEMENT_ABSTRACT_CLASS(wxHtmlProcessor
,wxObject
)
1571 #if wxUSE_EXTENDED_RTTI
1572 IMPLEMENT_DYNAMIC_CLASS_XTI(wxHtmlWindow
, wxScrolledWindow
,"wx/html/htmlwin.h")
1574 wxBEGIN_PROPERTIES_TABLE(wxHtmlWindow
)
1577 style , wxHW_SCROLLBAR_AUTO
1578 borders , (dimension)
1582 wxEND_PROPERTIES_TABLE()
1584 wxBEGIN_HANDLERS_TABLE(wxHtmlWindow
)
1585 wxEND_HANDLERS_TABLE()
1587 wxCONSTRUCTOR_5( wxHtmlWindow
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
1589 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow
,wxScrolledWindow
)
1592 BEGIN_EVENT_TABLE(wxHtmlWindow
, wxScrolledWindow
)
1593 EVT_SIZE(wxHtmlWindow::OnSize
)
1594 EVT_LEFT_DOWN(wxHtmlWindow::OnMouseDown
)
1595 EVT_LEFT_UP(wxHtmlWindow::OnMouseUp
)
1596 EVT_RIGHT_UP(wxHtmlWindow::OnMouseUp
)
1597 EVT_MOTION(wxHtmlWindow::OnMouseMove
)
1598 EVT_PAINT(wxHtmlWindow::OnPaint
)
1600 EVT_LEFT_DCLICK(wxHtmlWindow::OnDoubleClick
)
1601 EVT_ENTER_WINDOW(wxHtmlWindow::OnMouseEnter
)
1602 EVT_LEAVE_WINDOW(wxHtmlWindow::OnMouseLeave
)
1603 EVT_MOUSE_CAPTURE_LOST(wxHtmlWindow::OnMouseCaptureLost
)
1604 EVT_KEY_UP(wxHtmlWindow::OnKeyUp
)
1605 EVT_MENU(wxID_COPY
, wxHtmlWindow::OnCopy
)
1606 EVT_TEXT_COPY(wxID_ANY
, wxHtmlWindow::OnClipboardEvent
)
1607 #endif // wxUSE_CLIPBOARD
1610 //-----------------------------------------------------------------------------
1611 // wxHtmlWindowInterface implementation in wxHtmlWindow
1612 //-----------------------------------------------------------------------------
1614 void wxHtmlWindow::SetHTMLWindowTitle(const wxString
& title
)
1619 void wxHtmlWindow::OnHTMLLinkClicked(const wxHtmlLinkInfo
& link
)
1621 OnLinkClicked(link
);
1624 wxHtmlOpeningStatus
wxHtmlWindow::OnHTMLOpeningURL(wxHtmlURLType type
,
1625 const wxString
& url
,
1626 wxString
*redirect
) const
1628 return OnOpeningURL(type
, url
, redirect
);
1631 wxPoint
wxHtmlWindow::HTMLCoordsToWindow(wxHtmlCell
*WXUNUSED(cell
),
1632 const wxPoint
& pos
) const
1634 return CalcScrolledPosition(pos
);
1637 wxWindow
* wxHtmlWindow::GetHTMLWindow()
1642 wxColour
wxHtmlWindow::GetHTMLBackgroundColour() const
1644 return GetBackgroundColour();
1647 void wxHtmlWindow::SetHTMLBackgroundColour(const wxColour
& clr
)
1649 SetBackgroundColour(clr
);
1652 void wxHtmlWindow::SetHTMLBackgroundImage(const wxBitmap
& bmpBg
)
1654 SetBackgroundImage(bmpBg
);
1657 void wxHtmlWindow::SetHTMLStatusText(const wxString
& text
)
1660 if (m_RelatedStatusBarIndex
!= -1)
1662 if (m_RelatedStatusBar
)
1664 m_RelatedStatusBar
->SetStatusText(text
, m_RelatedStatusBarIndex
);
1666 else if (m_RelatedFrame
)
1668 m_RelatedFrame
->SetStatusText(text
, m_RelatedStatusBarIndex
);
1673 #endif // wxUSE_STATUSBAR
1677 wxCursor
wxHtmlWindow::GetDefaultHTMLCursor(HTMLCursor type
)
1681 case HTMLCursor_Link
:
1682 if ( !ms_cursorLink
)
1683 ms_cursorLink
= new wxCursor(wxCURSOR_HAND
);
1684 return *ms_cursorLink
;
1686 case HTMLCursor_Text
:
1687 if ( !ms_cursorText
)
1688 ms_cursorText
= new wxCursor(wxCURSOR_IBEAM
);
1689 return *ms_cursorText
;
1691 case HTMLCursor_Default
:
1693 return *wxSTANDARD_CURSOR
;
1697 wxCursor
wxHtmlWindow::GetHTMLCursor(HTMLCursor type
) const
1699 return GetDefaultHTMLCursor(type
);
1703 //-----------------------------------------------------------------------------
1705 //-----------------------------------------------------------------------------
1707 // A module to allow initialization/cleanup
1708 // without calling these functions from app.cpp or from
1709 // the user's application.
1711 class wxHtmlWinModule
: public wxModule
1713 DECLARE_DYNAMIC_CLASS(wxHtmlWinModule
)
1715 wxHtmlWinModule() : wxModule() {}
1716 bool OnInit() { return true; }
1717 void OnExit() { wxHtmlWindow::CleanUpStatics(); }
1720 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule
, wxModule
)
1723 // This hack forces the linker to always link in m_* files
1724 // (wxHTML doesn't work without handlers from these files)
1725 #include "wx/html/forcelnk.h"
1726 FORCE_WXHTML_MODULES()
1728 #endif // wxUSE_HTML