]>
git.saurik.com Git - wxWidgets.git/blob - interface/html/htmlwin.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: html/htmlwin.h
3 // Purpose: documentation for wxHtmlWindow class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @headerfile htmlwin.h wx/html/htmlwin.h
13 wxHtmlWindow is probably the only class you will directly use
14 unless you want to do something special (like adding new tag
15 handlers or MIME filters).
17 The purpose of this class is to display HTML pages (either local
18 file or downloaded via HTTP protocol) in a window. The width
19 of the window is constant - given in the constructor - and virtual height
20 is changed dynamically depending on page size.
21 Once the window is created you can set its content by calling
22 @ref wxHtmlWindow::setpage SetPage(text),
23 @ref wxHtmlWindow::loadpage LoadPage(filename) or
24 wxHtmlWindow::LoadFile.
27 @style{wxHW_SCROLLBAR_NEVER}:
28 Never display scrollbars, not even when the page is larger than the
30 @style{wxHW_SCROLLBAR_AUTO}:
31 Display scrollbars only if page's size exceeds window's size.
32 @style{wxHW_NO_SELECTION}:
33 Don't allow the user to select text.
40 wxHtmlLinkEvent, wxHtmlCellEvent
42 class wxHtmlWindow
: public wxScrolledWindow
47 Constructor. The parameters are the same as for the wxScrolledWindow
51 Window style. See wxHtmlWindow.
54 wxHtmlWindow(wxWindow parent
, wxWindowID id
= -1,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
57 long style
= wxHW_DEFAULT_STYLE
,
58 const wxString
& name
= "htmlWindow");
62 Adds @ref overview_filters "input filter" to the static list of available
63 filters. These filters are present by default:
65 @c text/html MIME type
67 Plain Text filter (this filter is used if no other filter matches)
69 static void AddFilter(wxHtmlFilter filter
);
72 Appends HTML fragment to currently displayed text and refreshes the window.
77 @returns @false if an error occurred, @true otherwise.
79 bool AppendToPage(const wxString
& source
);
82 Returns pointer to the top-level container.
84 See also: @ref overview_cells "Cells Overview",
85 @ref overview_printing "Printing Overview"
87 wxHtmlContainerCell
* GetInternalRepresentation();
90 Returns anchor within currently opened page
91 (see wxHtmlWindow::GetOpenedPage).
92 If no page is opened or if the displayed page wasn't
93 produced by call to LoadPage, empty string is returned.
95 wxString
GetOpenedAnchor();
98 Returns full location of the opened page. If no page is opened or if the
100 produced by call to LoadPage, empty string is returned.
102 wxString
GetOpenedPage();
105 Returns title of the opened page or wxEmptyString if current page does not
106 contain @c TITLE tag.
108 wxString
GetOpenedPageTitle();
111 Returns the related frame.
113 wxFrame
* GetRelatedFrame();
116 Moves back to the previous page. (each page displayed using
117 LoadPage() is stored in history list.)
122 Returns @true if it is possible to go back in the history (i.e. HistoryBack()
125 bool HistoryCanBack();
128 Returns @true if it is possible to go forward in the history (i.e. HistoryBack()
131 bool HistoryCanForward();
139 Moves to next page in history.
141 bool HistoryForward();
144 Loads HTML page from file and displays it.
146 @returns @false if an error occurred, @true otherwise
150 virtual bool LoadFile(const wxFileName
& filename
);
153 Unlike SetPage this function first loads HTML page from @e location
154 and then displays it. See example:
157 The address of document. See wxFileSystem for details on address format and
158 behaviour of "opener".
160 @returns @false if an error occurred, @true otherwise
164 virtual bool LoadPage(const wxString
& location
);
167 This method is called when a mouse button is clicked inside wxHtmlWindow.
169 The default behaviour is to emit a wxHtmlCellEvent
170 and, if the event was not processed or skipped, call
171 OnLinkClicked() if the cell contains an
174 Overloading this method is deprecated; intercept the event instead.
177 The cell inside which the mouse was clicked, always a simple
178 (i.e. non-container) cell
181 The logical coordinates of the click point
184 The mouse event containing other information about the click
186 @returns @true if a link was clicked, @false otherwise.
188 virtual bool OnCellClicked(wxHtmlCell cell
, wxCoord x
, wxCoord y
,
189 const wxMouseEvent
& event
);
192 This method is called when a mouse moves over an HTML cell.
193 Default behaviour is to emit a wxHtmlCellEvent.
194 Overloading this method is deprecated; intercept the event instead.
197 The cell inside which the mouse is currently, always a simple
198 (i.e. non-container) cell
201 The logical coordinates of the click point
203 virtual void OnCellMouseHover(wxHtmlCell cell
, wxCoord x
,
207 Called when user clicks on hypertext link. Default behaviour is to emit a
208 wxHtmlLinkEvent and, if the event was not processed
209 or skipped, call LoadPage() and do nothing else.
210 Overloading this method is deprecated; intercept the event instead.
212 Also see wxHtmlLinkInfo.
214 virtual void OnLinkClicked(const wxHtmlLinkInfo
& link
);
217 Called when an URL is being opened (either when the user clicks on a link or
218 an image is loaded). The URL will be opened only if OnOpeningURL returns
219 @c wxHTML_OPEN. This method is called by
220 wxHtmlParser::OpenURL.
221 You can override OnOpeningURL to selectively block some
222 URLs (e.g. for security reasons) or to redirect them elsewhere. Default
223 behaviour is to always return @c wxHTML_OPEN.
226 Indicates type of the resource. Is one of
242 Opening a resource that doesn't fall into
249 Pointer to wxString variable that must be filled with an
250 URL if OnOpeningURL returns wxHTML_REDIRECT.
252 virtual wxHtmlOpeningStatus
OnOpeningURL(wxHtmlURLType type
,
254 wxString
* redirect
);
257 Called on parsing @c TITLE tag.
259 virtual void OnSetTitle(const wxString
& title
);
262 This reads custom settings from wxConfig. It uses the path 'path'
263 if given, otherwise it saves info into currently selected path.
264 The values are stored in sub-path @c wxHtmlWindow
266 Read values: all things set by SetFonts, SetBorders.
269 wxConfig from which you want to read the configuration.
272 Optional path in config tree. If not given current path is used.
274 virtual void ReadCustomization(wxConfigBase cfg
,
275 wxString path
= wxEmptyString
);
278 Selects all text in the window.
280 @sa SelectLine(), SelectWord()
285 Selects the line of text that @e pos points at. Note that @e pos
286 is relative to the top of displayed page, not to window's origin, use
287 wxScrolledWindow::CalcUnscrolledPosition
288 to convert physical coordinate.
290 @sa SelectAll(), SelectWord()
292 void SelectLine(const wxPoint
& pos
);
295 Selects the word at position @e pos. Note that @e pos
296 is relative to the top of displayed page, not to window's origin, use
297 wxScrolledWindow::CalcUnscrolledPosition
298 to convert physical coordinate.
300 @sa SelectAll(), SelectLine()
302 void SelectWord(const wxPoint
& pos
);
305 Returns current selection as plain text. Returns empty string if no text
306 is currently selected.
308 wxString
SelectionToText();
311 This function sets the space between border of window and HTML contents. See
315 indentation from borders in pixels
317 void SetBorders(int b
);
320 This function sets font sizes and faces.
323 This is face name for normal (i.e. non-fixed) font.
324 It can be either empty string (then the default face is chosen) or
325 platform-specific face name. Examples are "helvetica" under Unix or
326 "Times New Roman" under Windows.
329 The same thing for fixed face ( TT../TT )
332 This is an array of 7 items of int type.
333 The values represent size of font with HTML size from -2 to +4
334 ( FONT SIZE=-2 to FONT SIZE=+4 ). Default sizes are used if sizes
337 void SetFonts(const wxString
& normal_face
,
338 const wxString
& fixed_face
,
339 const int sizes
= @NULL
);
342 Sets HTML page and display it. This won't @b load the page!!
343 It will display the @e source. See example:
344 If you want to load a document from some location use
348 The HTML document source to be displayed.
350 @returns @false if an error occurred, @true otherwise.
352 bool SetPage(const wxString
& source
);
355 Sets the frame in which page title will be displayed. @e format is format of
356 frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s. This
357 %s is substituted with HTML page title.
359 void SetRelatedFrame(wxFrame
* frame
, const wxString
& format
);
362 @b After calling SetRelatedFrame(),
363 this sets statusbar slot where messages will be displayed.
364 (Default is -1 = no messages.)
367 statusbar slot number (0..n)
369 void SetRelatedStatusBar(int bar
);
372 Returns content of currently displayed page as plain text.
377 Saves custom settings into wxConfig. It uses the path 'path'
378 if given, otherwise it saves info into currently selected path.
379 Regardless of whether the path is given or not, the function creates sub-path
382 Saved values: all things set by SetFonts, SetBorders.
385 wxConfig to which you want to save the configuration.
388 Optional path in config tree. If not given, the current path is used.
390 virtual void WriteCustomization(wxConfigBase cfg
,
391 wxString path
= wxEmptyString
);
396 @class wxHtmlLinkEvent
397 @headerfile htmlwin.h wx/html/htmlwin.h
399 This event class is used for the events generated by wxHtmlWindow.
404 class wxHtmlLinkEvent
: public wxCommandEvent
408 The constructor is not normally used by the user code.
410 wxHyperlinkEvent(int id
, const wxHtmlLinkInfo
& linkinfo
);
413 Returns the wxHtmlLinkInfo which contains info about the cell clicked and the
414 hyperlink it contains.
416 const wxHtmlLinkInfo
GetLinkInfo();
421 @class wxHtmlCellEvent
422 @headerfile htmlwin.h wx/html/htmlwin.h
424 This event class is used for the events generated by wxHtmlWindow.
429 class wxHtmlCellEvent
: public wxCommandEvent
433 The constructor is not normally used by the user code.
435 wxHtmlCellEvent(wxEventType commandType
, int id
,
437 const wxPoint
& point
);
440 Returns the wxHtmlCellEvent associated with the event.
442 wxHtmlCell
* GetCell();
445 Returns @true if @ref setlinkclicked() SetLinkClicked(@true) has previously
449 bool GetLinkClicked();
452 Returns the wxPoint associated with the event.
457 Call this function with @c linkclicked set to @true if the cell which has
458 been clicked contained a link or
459 @false otherwise (which is the default). With this function the event handler
460 can return info to the
461 wxHtmlWindow which sent the event.
463 bool SetLinkClicked(bool linkclicked
);