Search documentation of wx

# View Source wxHtmlWindow (wx v2.4.2)

Functions for wxHtmlWindow class

`wxHtmlWindow` is probably the only class you will directly use unless you want to do something special (like adding new tag handlers or MIME filters).

The purpose of this class is to display rich content pages (either local file or downloaded via HTTP protocol) in a window based on a subset of the HTML standard. The width of the window is constant, given in the constructor and virtual height is changed dynamically depending on page size. Once the window is created you can set its content by calling `setPage/2` with raw HTML, `loadPage/2` with a `wxFileSystem` (not implemented in wx) location or `loadFile/2` with a filename.

Note: If you want complete HTML/CSS support as well as a Javascript engine, consider using `wxWebView` instead.

`wxHtmlWindow` uses the `wxImage` class for displaying images, so you need to initialize the handlers for any image formats you use before loading a page. See ?wxInitAllImageHandlers and `wxImage::AddHandler` (not implemented in wx).

Styles

This class supports the following styles:

See: `wxHtmlLinkEvent`, `wxHtmlCellEvent` (not implemented in wx)

This class is derived (and can use functions) from: `wxScrolledWindow` `wxPanel` `wxWindow` `wxEvtHandler`

wxWidgets docs: wxHtmlWindow

## Events

Event types emitted from this class: `html_cell_clicked`, `html_cell_hover`, `command_html_link_clicked`

# Summary

## Types

wxHtmlWindow()

## Functions

appendToPage(This, Source)

Appends HTML fragment to currently displayed text and refreshes the window.

destroy(This)

Destroys the object.

getOpenedAnchor(This)

Returns anchor within currently opened page (see `getOpenedPage/1`).

getOpenedPage(This)

Returns full location of the opened page.

getOpenedPageTitle(This)

Returns title of the opened page or wxEmptyString if the current page does not contain <TITLE> tag.

getRelatedFrame(This)

Returns the related frame.

historyBack(This)

Moves back to the previous page.

historyCanBack(This)

Returns true if it is possible to go back in the history i.e.

historyCanForward(This)

Returns true if it is possible to go forward in the history i.e.

historyClear(This)

Clears history.

historyForward(This)

Moves to next page in history.

loadFile(This, Filename)

Loads an HTML page from a file and displays it.

loadPage(This, Location)

Unlike `setPage/2` this function first loads the HTML page from `location` and then displays it.

new()

Default ctor.

new(Parent)
new/2

Constructor.

selectAll(This)

Selects all text in the window.

selectionToText(This)

Returns the current selection as plain text.

selectLine(This, Pos)

Selects the line of text that `pos` points at.

selectWord(This, Pos)

Selects the word at position `pos`.

setBorders(This, B)

This function sets the space between border of window and HTML contents.

setFonts(This, Normal_face, Fixed_face)
setFonts/4

This function sets font sizes and faces.

setPage(This, Source)

Sets the source of a page and displays it, for example

setRelatedFrame(This, Frame, Format)

Sets the frame in which page title will be displayed.

setRelatedStatusBar/2

`After` calling `setRelatedFrame/3`, this sets statusbar slot where messages will be displayed.

setRelatedStatusBar/3

`Sets` the associated statusbar where messages will be displayed.

toText(This)

Returns content of currently displayed page as plain text.

# Types

Link to this type

# wxHtmlWindow()

View Source

    -type wxHtmlWindow() :: wx:wx_object().

# Functions

Link to this function

# appendToPage(This, Source)

View Source

    -spec appendToPage(This, Source) -> boolean() when This :: wxHtmlWindow(), Source :: unicode:chardata().

Appends HTML fragment to currently displayed text and refreshes the window.

Return: false if an error occurred, true otherwise.

Link to this function

# destroy(This)

View Source

    -spec destroy(This :: wxHtmlWindow()) -> ok.

Destroys the object.

Link to this function

# getOpenedAnchor(This)

View Source

    -spec getOpenedAnchor(This) -> unicode:charlist() when This :: wxHtmlWindow().

Returns anchor within currently opened page (see `getOpenedPage/1`).

If no page is opened or if the displayed page wasn't produced by call to `loadPage/2`, empty string is returned.

Link to this function

# getOpenedPage(This)

View Source

    -spec getOpenedPage(This) -> unicode:charlist() when This :: wxHtmlWindow().

Returns full location of the opened page.

If no page is opened or if the displayed page wasn't produced by call to `loadPage/2`, empty string is returned.

Link to this function

# getOpenedPageTitle(This)

View Source

    -spec getOpenedPageTitle(This) -> unicode:charlist() when This :: wxHtmlWindow().

Returns title of the opened page or wxEmptyString if the current page does not contain <TITLE> tag.

Link to this function

# getRelatedFrame(This)

View Source

    -spec getRelatedFrame(This) -> wxFrame:wxFrame() when This :: wxHtmlWindow().

Returns the related frame.

Link to this function

# historyBack(This)

View Source

    -spec historyBack(This) -> boolean() when This :: wxHtmlWindow().

Moves back to the previous page.

Only pages displayed using `loadPage/2` are stored in history list.

Link to this function

# historyCanBack(This)

View Source

    -spec historyCanBack(This) -> boolean() when This :: wxHtmlWindow().

Returns true if it is possible to go back in the history i.e.

`historyBack/1` won't fail.

Link to this function

# historyCanForward(This)

View Source

    -spec historyCanForward(This) -> boolean() when This :: wxHtmlWindow().

Returns true if it is possible to go forward in the history i.e.

`historyForward/1` won't fail.

Link to this function

# historyClear(This)

View Source

    -spec historyClear(This) -> ok when This :: wxHtmlWindow().

Clears history.

Link to this function

# historyForward(This)

View Source

    -spec historyForward(This) -> boolean() when This :: wxHtmlWindow().

Moves to next page in history.

Only pages displayed using `loadPage/2` are stored in history list.

Link to this function

# loadFile(This, Filename)

View Source

    -spec loadFile(This, Filename) -> boolean() when This :: wxHtmlWindow(), Filename :: unicode:chardata().

Loads an HTML page from a file and displays it.

Return: false if an error occurred, true otherwise

See: `loadPage/2`

Link to this function

# loadPage(This, Location)

View Source

    -spec loadPage(This, Location) -> boolean() when This :: wxHtmlWindow(), Location :: unicode:chardata().

Unlike `setPage/2` this function first loads the HTML page from `location` and then displays it.

Return: false if an error occurred, true otherwise

See: `loadFile/2`

Link to this function

# new()

View Source

    -spec new() -> wxHtmlWindow().

Default ctor.

Link to this function

# new(Parent)

View Source

    -spec new(Parent) -> wxHtmlWindow() when Parent :: wxWindow:wxWindow().

Link to this function

# new/2

View Source

    -spec new(Parent, [Option]) -> wxHtmlWindow()
                 when
                     Parent :: wxWindow:wxWindow(),
                     Option ::
                         {id, integer()} |
                         {pos, {X :: integer(), Y :: integer()}} |
                         {size, {W :: integer(), H :: integer()}} |
                         {style, integer()}.

Constructor.

The parameters are the same as `wxScrolled::wxScrolled()` (not implemented in wx) constructor.

Link to this function

# selectAll(This)

View Source

    -spec selectAll(This) -> ok when This :: wxHtmlWindow().

Selects all text in the window.

See: `selectLine/2`, `selectWord/2`

Link to this function

# selectionToText(This)

View Source

    -spec selectionToText(This) -> unicode:charlist() when This :: wxHtmlWindow().

Returns the current selection as plain text.

Returns an empty string if no text is currently selected.

Link to this function

# selectLine(This, Pos)

View Source

    -spec selectLine(This, Pos) -> ok when This :: wxHtmlWindow(), Pos :: {X :: integer(), Y :: integer()}.

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 `wxScrolledWindow:calcUnscrolledPosition/3` to convert physical coordinate.

See: `selectAll/1`, `selectWord/2`

Link to this function

# selectWord(This, Pos)

View Source

    -spec selectWord(This, Pos) -> ok when This :: wxHtmlWindow(), Pos :: {X :: integer(), Y :: integer()}.

Selects the word at position `pos`.

Note that `pos` is relative to the top of displayed page, not to window's origin, use `wxScrolledWindow:calcUnscrolledPosition/3` to convert physical coordinate.

See: `selectAll/1`, `selectLine/2`

Link to this function

# setBorders(This, B)

View Source

    -spec setBorders(This, B) -> ok when This :: wxHtmlWindow(), B :: integer().

This function sets the space between border of window and HTML contents.

See image:

Link to this function

# setFonts(This, Normal_face, Fixed_face)

View Source

    -spec setFonts(This, Normal_face, Fixed_face) -> ok
                      when
                          This :: wxHtmlWindow(),
                          Normal_face :: unicode:chardata(),
                          Fixed_face :: unicode:chardata().

Link to this function

# setFonts/4

View Source

    -spec setFonts(This, Normal_face, Fixed_face, [Option]) -> ok
                      when
                          This :: wxHtmlWindow(),
                          Normal_face :: unicode:chardata(),
                          Fixed_face :: unicode:chardata(),
                          Option :: {sizes, [integer()]}.

This function sets font sizes and faces.

See `wxHtmlDCRenderer::SetFonts` (not implemented in wx) for detailed description.

See: SetSize()

Link to this function

# setPage(This, Source)

View Source

    -spec setPage(This, Source) -> boolean() when This :: wxHtmlWindow(), Source :: unicode:chardata().

Sets the source of a page and displays it, for example:

If you want to load a document from some location use `loadPage/2` instead.

Return: false if an error occurred, true otherwise.

Link to this function

# setRelatedFrame(This, Frame, Format)

View Source

    -spec setRelatedFrame(This, Frame, Format) -> ok
                             when
                                 This :: wxHtmlWindow(),
                                 Frame :: wxFrame:wxFrame(),
                                 Format :: unicode:chardata().

Sets the frame in which page title will be displayed.

`format` is the format of the frame title, e.g. "HtmlHelp : %s". It must contain exactly one s. This s is substituted with HTML page title.

Link to this function

# setRelatedStatusBar/2

View Source

    -spec setRelatedStatusBar(This, Statusbar) -> ok
                                 when This :: wxHtmlWindow(), Statusbar :: wxStatusBar:wxStatusBar();
                             (This, Index) -> ok when This :: wxHtmlWindow(), Index :: integer().

`After` calling `setRelatedFrame/3`, this sets statusbar slot where messages will be displayed.

(Default is -1 = no messages.)

Link to this function

# setRelatedStatusBar/3

View Source

    -spec setRelatedStatusBar(This, Statusbar, [Option]) -> ok
                                 when
                                     This :: wxHtmlWindow(),
                                     Statusbar :: wxStatusBar:wxStatusBar(),
                                     Option :: {index, integer()}.

`Sets` the associated statusbar where messages will be displayed.

Call this instead of `setRelatedFrame/3` if you want statusbar updates only, no changing of the frame title.

Since: 2.9.0

Link to this function

# toText(This)

View Source

    -spec toText(This) -> unicode:charlist() when This :: wxHtmlWindow().

Returns content of currently displayed page as plain text.