HtmlWindow is a widget for displaying simple HTML. IT supports key HTML features like links, images, tables and headings, but does not support all the features of modern browsers such as CSS and Javascript. It’s well suited for creating hypertext-based applications, but not for creating a complete web browser.
Once the window is created you can set its content by calling set_page, load_page or load_file. The width of the window is constant – given in the constructor – and virtual height is changed dynamically depending on page size.
HW_SCROLLBAR_NEVER |
Never display scrollbars, noteven when the page is larger than the window. |
HW_SCROLLBAR_AUTO |
Display scrollbars only ifpage’s size exceeds window’s size. |
HW_NO_SELECTION |
Don’t allow the user to selecttext. |
To process user interaction with an HtmlWindow, use these event handlers to direct input to blocks that take a HtmlCellEvent argument or a HtmlLinkEvent.
| evt_html_cell_clicked(id) { | event | ... } | A HtmlCell was clicked. |
| evt_html_cell_hover(id) { | event | ... } | The mouse passed over a HtmlCell. |
| evt_html_link_clicked(id) { | event | ... } | A HtmlCell which contains an hyperlink was clicked. |
HtmlWindow.new(Window parent, Integer id = -1,
Point pos = DEFAULT_POSITION,
Size size = DEFAULT_SIZE,
Integer style = HW_DEFAULT_STYLE,
String name = "htmlWindow")
Constructor. The parameters are the same as for the ScrolledWindow constructor.
add_filter(HtmlFilter filter)
Adds input filter to the static list of available filters. These filters are present by default:
text/html MIME typeimage/* MIME typesBoolean append_to_page(String source)
Appends HTML fragment to currently displayed text and refreshes the window.
false if an error occurred, true otherwise.
HtmlContainerCell get_internal_representation()
Returns pointer to the top-level container.
See also: Cells Overview, Printing Overview
String get_opened_anchor()
Returns anchor within currently opened page (see get_opened_page). If no page is opened or if the displayed page wasn’t produced by call to LoadPage, empty string is returned.
String get_opened_page()
Returns full location of the opened page. If no page is opened or if the displayed page wasn’t produced by call to LoadPage, empty string is returned.
String get_opened_page_title()
Returns title of the opened page or EmptyString if current page does not contain <TITLE> tag.
Frame get_related_frame()
Returns the related frame.
Boolean history_back()
Moves back to the previous page. (each page displayed using load_page is stored in history list.)
Boolean history_can_back()
Returns true if it is possible to go back in the history (i.e. HistoryBack() won’t fail).
Boolean history_can_forward()
Returns true if it is possible to go forward in the history (i.e. HistoryBack() won’t fail).
history_clear()
Clears history.
Boolean history_forward()
Moves to next page in history.
Boolean load_file(FileName filename)
Loads HTML page from file and displays it.
false if an error occurred, true otherwise
Boolean load_page(String location)
Unlike SetPage this function first loads HTML page from location and then displays it. See example:
htmlwin->LoadPage("help/myproject/index.htm");
false if an error occurred, true otherwise
Boolean or String on_opening_url(String url)
This method is called whenever the HtmlWindow attempts to open a URL,
either a page, or an image within a page. It can be used to block access
to certain URLs, or rewrite them. This method should return true, if
access to the URL should be allowed or false if it should be
blocked. It may also return a string containing a new URL to which the
request should be redirected.
Note that if redirecting, the method will immediately be called again with the new URL, so to avoid entering an endless loop, you should test for this and return true if no rewriting is to be done.
The default implementation in the standard Wx::HtmlWindow class always
returns true, ie allow the URL.
on_set_title(String title)
Called on parsing
read_customization(ConfigBase cfg, String path = '')
This reads custom settings from Config. It uses the path ‘path’
if given, otherwise it saves info into currently selected path.
The values are stored in sub-path HtmlWindow
Read values: all things set by SetFonts, SetBorders.
select_all()
Selects all text in the window.
String selection_to_text()
Returns current selection as plain text. Returns empty string if no text is currently selected.
select_line(Point pos)
Selects the line of text that pos points at. Note that pos is relative to the top of displayed page, not to window’s origin, use calc_unscrolled_position to convert physical coordinate.
select_word(Point pos)
Selects the word at position pos. Note that pos is relative to the top of displayed page, not to window’s origin, use calc_unscrolled_position to convert physical coordinate.
set_borders(Integer border_width)
This function sets the space between border of window and HTML contents.
set_fonts(String normal_face, String fixed_face,
Integer sizes = nil)
This function sets font sizes and faces.
Default font sizes are defined by constants HTML_FONT_SIZE_1, HTML_FONT_SIZE_2, ..., HTML_FONT_SIZE_7. Note that they differ among platforms. Default face names are empty strings.
Boolean set_page(String source)
Sets HTML page and display it. This doesn’t load the page! It parses and displays the HTML in the string source.
If you want to load a document from some location use load_page instead.
false if an error occurred, true otherwise.
set_related_frame(Frame frame, String format)
Sets the frame in which page title will be displayed. format is format of
frame title, e.g. “HtmlHelp : %s”. It must contain exactly one %s. This
%s is substituted with HTML page title.
set_related_status_bar(Integer bar)
After calling set_related_frame, this sets statusbar slot where messages will be displayed. (Default is -1 = no messages.)
String to_text()
Returns content of currently displayed page as plain text.
write_customization(ConfigBase cfg, String path = '')
Saves custom settings into Config. It uses the path ‘path’
if given, otherwise it saves info into currently selected path.
Regardless of whether the path is given or not, the function creates sub-path
HtmlWindow.
Saved values: all things set by SetFonts, SetBorders.
[This page automatically generated from the Textile source at Thu May 01 00:50:39 +0100 2008]