]>
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:
64 @c text/html MIME type
66 Plain Text filter (this filter is used if no other filter matches)
68 static void AddFilter(wxHtmlFilter filter
);
71 Appends HTML fragment to currently displayed text and refreshes the window.
76 @returns @false if an error occurred, @true otherwise.
78 bool AppendToPage(const wxString
& source
);
81 Returns pointer to the top-level container.
82 See also: @ref overview_cells "Cells Overview",
83 @ref overview_printing
85 wxHtmlContainerCell
* GetInternalRepresentation() const;
88 Returns anchor within currently opened page
89 (see wxHtmlWindow::GetOpenedPage).
90 If no page is opened or if the displayed page wasn't
91 produced by call to LoadPage, empty string is returned.
93 wxString
GetOpenedAnchor();
96 Returns full location of the opened page. If no page is opened or if the
98 produced by call to LoadPage, empty string is returned.
100 wxString
GetOpenedPage();
103 Returns title of the opened page or wxEmptyString if current page does not
104 contain @c TITLE tag.
106 wxString
GetOpenedPageTitle();
109 Returns the related frame.
111 wxFrame
* GetRelatedFrame() const;
114 Moves back to the previous page. (each page displayed using
115 LoadPage() is stored in history list.)
120 Returns @true if it is possible to go back in the history (i.e. HistoryBack()
123 bool HistoryCanBack();
126 Returns @true if it is possible to go forward in the history (i.e. HistoryBack()
129 bool HistoryCanForward();
137 Moves to next page in history.
139 bool HistoryForward();
142 Loads HTML page from file and displays it.
144 @returns @false if an error occurred, @true otherwise
148 virtual bool LoadFile(const wxFileName
& filename
);
151 Unlike SetPage this function first loads HTML page from @a location
152 and then displays it. See example:
155 The address of document. See wxFileSystem for details on address format and
156 behaviour of "opener".
158 @returns @false if an error occurred, @true otherwise
162 virtual bool LoadPage(const wxString
& location
);
165 This method is called when a mouse button is clicked inside wxHtmlWindow.
166 The default behaviour is to emit a wxHtmlCellEvent
167 and, if the event was not processed or skipped, call
168 OnLinkClicked() if the cell contains an
170 Overloading this method is deprecated; intercept the event instead.
173 The cell inside which the mouse was clicked, always a simple
174 (i.e. non-container) cell
176 The logical coordinates of the click point
178 The mouse event containing other information about the click
180 @returns @true if a link was clicked, @false otherwise.
182 virtual bool OnCellClicked(wxHtmlCell cell
, wxCoord x
, wxCoord y
,
183 const wxMouseEvent
& event
);
186 This method is called when a mouse moves over an HTML cell.
187 Default behaviour is to emit a wxHtmlCellEvent.
188 Overloading this method is deprecated; intercept the event instead.
191 The cell inside which the mouse is currently, always a simple
192 (i.e. non-container) cell
194 The logical coordinates of the click point
196 virtual void OnCellMouseHover(wxHtmlCell cell
, wxCoord x
,
200 Called when user clicks on hypertext link. Default behaviour is to emit a
201 wxHtmlLinkEvent and, if the event was not processed
202 or skipped, call LoadPage() and do nothing else.
203 Overloading this method is deprecated; intercept the event instead.
204 Also see wxHtmlLinkInfo.
206 virtual void OnLinkClicked(const wxHtmlLinkInfo
& link
);
209 Called when an URL is being opened (either when the user clicks on a link or
210 an image is loaded). The URL will be opened only if OnOpeningURL returns
211 @c wxHTML_OPEN. This method is called by
212 wxHtmlParser::OpenURL.
213 You can override OnOpeningURL to selectively block some
214 URLs (e.g. for security reasons) or to redirect them elsewhere. Default
215 behaviour is to always return @c wxHTML_OPEN.
218 Indicates type of the resource. Is one of
252 Opening a resource that doesn't fall into
257 Pointer to wxString variable that must be filled with an
258 URL if OnOpeningURL returns wxHTML_REDIRECT.
260 virtual wxHtmlOpeningStatus
OnOpeningURL(wxHtmlURLType type
,
265 Called on parsing @c TITLE tag.
267 virtual void OnSetTitle(const wxString
& title
);
270 This reads custom settings from wxConfig. It uses the path 'path'
271 if given, otherwise it saves info into currently selected path.
272 The values are stored in sub-path @c wxHtmlWindow
273 Read values: all things set by SetFonts, SetBorders.
276 wxConfig from which you want to read the configuration.
278 Optional path in config tree. If not given current path is used.
280 virtual void ReadCustomization(wxConfigBase cfg
,
281 wxString path
= wxEmptyString
);
284 Selects all text in the window.
286 @see SelectLine(), SelectWord()
291 Selects the line of text that @a pos points at. Note that @e pos
292 is relative to the top of displayed page, not to window's origin, use
293 wxScrolledWindow::CalcUnscrolledPosition
294 to convert physical coordinate.
296 @see SelectAll(), SelectWord()
298 void SelectLine(const wxPoint
& pos
);
301 Selects the word at position @e pos. Note that @e pos
302 is relative to the top of displayed page, not to window's origin, use
303 wxScrolledWindow::CalcUnscrolledPosition
304 to convert physical coordinate.
306 @see SelectAll(), SelectLine()
308 void SelectWord(const wxPoint
& pos
);
311 Returns current selection as plain text. Returns empty string if no text
312 is currently selected.
314 wxString
SelectionToText();
317 This function sets the space between border of window and HTML contents. See
321 indentation from borders in pixels
323 void SetBorders(int b
);
326 This function sets font sizes and faces.
329 This is face name for normal (i.e. non-fixed) font.
330 It can be either empty string (then the default face is chosen) or
331 platform-specific face name. Examples are "helvetica" under Unix or
332 "Times New Roman" under Windows.
334 The same thing for fixed face ( TT../TT )
336 This is an array of 7 items of int type.
337 The values represent size of font with HTML size from -2 to +4
338 ( FONT SIZE=-2 to FONT SIZE=+4 ). Default sizes are used if sizes
341 void SetFonts(const wxString
& normal_face
,
342 const wxString
& fixed_face
,
343 const int sizes
= NULL
);
346 Sets HTML page and display it. This won't @b load the page!!
347 It will display the @e source. See example:
349 If you want to load a document from some location use
353 The HTML document source to be displayed.
355 @returns @false if an error occurred, @true otherwise.
357 bool SetPage(const wxString
& source
);
360 Sets the frame in which page title will be displayed. @a format is format of
361 frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s. This
362 %s is substituted with HTML page title.
364 void SetRelatedFrame(wxFrame
* frame
, const wxString
& format
);
367 @b After calling SetRelatedFrame(),
368 this sets statusbar slot where messages will be displayed.
369 (Default is -1 = no messages.)
372 statusbar slot number (0..n)
374 void SetRelatedStatusBar(int bar
);
377 Returns content of currently displayed page as plain text.
382 Saves custom settings into wxConfig. It uses the path 'path'
383 if given, otherwise it saves info into currently selected path.
384 Regardless of whether the path is given or not, the function creates sub-path
386 Saved values: all things set by SetFonts, SetBorders.
389 wxConfig to which you want to save the configuration.
391 Optional path in config tree. If not given, the current path is used.
393 virtual void WriteCustomization(wxConfigBase cfg
,
394 wxString path
= wxEmptyString
);
399 @class wxHtmlLinkEvent
400 @headerfile htmlwin.h wx/html/htmlwin.h
402 This event class is used for the events generated by wxHtmlWindow.
407 class wxHtmlLinkEvent
: public wxCommandEvent
411 The constructor is not normally used by the user code.
413 wxHyperlinkEvent(int id
, const wxHtmlLinkInfo
& linkinfo
);
416 Returns the wxHtmlLinkInfo which contains info about the cell clicked and the
417 hyperlink it contains.
419 const wxHtmlLinkInfo
GetLinkInfo() const;
424 @class wxHtmlCellEvent
425 @headerfile htmlwin.h wx/html/htmlwin.h
427 This event class is used for the events generated by wxHtmlWindow.
432 class wxHtmlCellEvent
: public wxCommandEvent
436 The constructor is not normally used by the user code.
438 wxHtmlCellEvent(wxEventType commandType
, int id
,
440 const wxPoint
& point
);
443 Returns the wxHtmlCellEvent associated with the event.
445 wxHtmlCell
* GetCell() const;
448 Returns @true if @ref setlinkclicked() SetLinkClicked(@true) has previously
452 bool GetLinkClicked() const;
455 Returns the wxPoint associated with the event.
457 wxPoint
GetPoint() const;
460 Call this function with @c linkclicked set to @true if the cell which has
461 been clicked contained a link or
462 @false otherwise (which is the default). With this function the event handler
463 can return info to the
464 wxHtmlWindow which sent the event.
466 bool SetLinkClicked(bool linkclicked
);