wxHtmlWindow(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

✨ wxHtmlWindow(3) ✨

okay bestie, this is the Erlang module definition for wxHtmlWindow β€” and no, you're not reading the wrong manual, the manual name literally says Erlang Module Definition up top and the source is wx 2.6 from Ericsson AB. slay. let's get into it πŸ’…


🌸 NAME 🌸

wxHtmlWindow β€” okay so real talk, this is probably the only class you will directly use unless you wanna do something special (like adding new tag handlers or MIME filters). it's giving main character, and honestly? deserved. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

the whole purpose of this class is to show rich content pages β€” either a local file or something downloaded via HTTP β€” inside a window that's built on a subset of the HTML standard. not the whole thing, bestie, a subset. know the difference. ✨

the width of the window is constant, and you hand it over in the constructor. the virtual height, though? that changes dynamically depending on how big the page is. so it grows and shrinks like it's got a mind of its own, we love that for it. πŸŽ€

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
  • loadFile/2 β€” with a filename
Note: if you want complete HTML/CSS support and a Javascript engine, pls consider using wxWebView instead. wxHtmlWindow is the vibe, but wxWebView is the upgrade. πŸ™ˆ

also: 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. no skipping this step, fr fr. see ?wxInitAllImageHandlers and wxImage::AddHandler (not implemented in wx).


πŸŽ€ Styles πŸŽ€

this class supports the following styles, and they're all lowkey important:

  • wxHW_SCROLLBAR_NEVER β€” never display scrollbars, not even when the page is bigger than the window. bold choice, but it's yours.
  • wxHW_SCROLLBAR_AUTO β€” display scrollbars only if the page's size exceeds the window's size. the considerate option. 🫢
  • wxHW_NO_SELECTION β€” don't let the user select text. no copy-paste for them, sorry.

See: wxHtmlLinkEvent

this class is derived, and can use functions, from:

  • wxScrolledWindow
  • wxPanel
  • wxWindow
  • wxEvtHandler

wxWidgets docs: wxHtmlWindow


🌈 Events 🌈

event types emitted from this class, aka the things that go ping in the night:

  • html_cell_clicked
  • html_cell_hover
  • command_html_link_clicked

⭐ DATA TYPES ⭐

wxHtmlWindow() :: wx:wx_object().

that's it. that's the type. short and iconic. πŸ’œ


πŸ’– FUNCTIONS πŸ’–

appendToPage(This, Source) -> boolean()

when
    This :: wxHtmlWindow(),
    Source :: unicode:chardata().

appends an HTML fragment to the text that's currently being displayed, then refreshes the window. little glow-up for your page. ✨

Return: false if an error occurred, true otherwise.


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

destroys the object. rip boo, you had a good run. πŸ’€


getOpenedAnchor(This) -> unicode:charlist()

when This :: wxHtmlWindow().

returns the anchor within the currently opened page (see getOpenedPage/1).

if no page is opened, or if the displayed page wasn't produced by a call to loadPage/2, you get an empty string. so if you're getting nothing back, check ur methods bestie. 🫠


getOpenedPage(This) -> unicode:charlist()

when This :: wxHtmlWindow().

returns the full location of the opened page.

same deal as above: if no page is opened, or if the displayed page wasn't produced by a call to loadPage/2, empty string. 🌸


getOpenedPageTitle(This) -> unicode:charlist()

when This :: wxHtmlWindow().

returns the title of the opened page, or wxEmptyString if the current page doesn't contain a <TITLE> tag. no title, no drama. πŸ’…


getRelatedFrame(This) -> wxFrame:wxFrame()

when This :: wxHtmlWindow().

returns the related frame. that's the whole thing. πŸŽ€


historyBack(This) -> boolean()

when This :: wxHtmlWindow().

moves back to the previous page.

only pages displayed using loadPage/2 are stored in the history list. so setPage/2 pages? ghosted. not remembered. πŸ™ˆ

historyCanBack(This) -> boolean()

when This :: wxHtmlWindow().

returns true if it's possible to go back in the history, i.e. historyBack/1 won't fail.


historyCanForward(This) -> boolean()

when This :: wxHtmlWindow().

returns true if it's possible to go forward in the history, i.e. historyForward/1 won't fail.


historyClear(This) -> ok

when This :: wxHtmlWindow().

clears history. fresh start, clean slate, new me. πŸ¦‹


historyForward(This) -> boolean()

when This :: wxHtmlWindow().

moves to the next page in history.

again: only pages displayed using loadPage/2 are stored in the history list. πŸ’…

loadFile(This, Filename) -> boolean()

when
    This :: wxHtmlWindow(),
    Filename :: unicode:chardata().

loads an HTML page from a file and displays it. classic. πŸ“

Return: false if an error occurred, true otherwise

See: loadPage/2


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. two steps, one slay. ✨

Return: false if an error occurred, true otherwise

See: loadFile/2


new() -> wxHtmlWindow()

default ctor. no args, no notes, just vibes. πŸŽ€


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 the wxScrolled::wxScrolled() (not implemented in wx) constructor. iykyk.


selectAll(This) -> ok

when This :: wxHtmlWindow().

selects all text in the window. ctrl-A energy, but make it code. πŸ’…

See:

  • selectLine/2
  • selectWord/2

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 the displayed page, not to the window's origin. use wxScrolledWindow:calcUnscrolledPosition/3 to convert the physical coordinate. don't forget this part, it will humble you. 😭

See:

  • selectAll/1
  • selectWord/2

selectWord(This, Pos) -> ok

when
    This :: wxHtmlWindow(),
    Pos :: {X :: integer(), Y :: integer()}.

selects the word at position pos.

same warning as before bestie: pos is relative to the top of the displayed page, not to the window's origin. use wxScrolledWindow:calcUnscrolledPosition/3 to convert the physical coordinate. 🌸

See:

  • selectAll/1
  • selectLine/2

selectionToText(This) -> unicode:charlist()

when This :: wxHtmlWindow().

returns the current selection as plain text.

returns an empty string if no text is currently selected. so if it's empty, you didn't select anything, the code isn't broken. 🫠


setBorders(This, B) -> ok

when This :: wxHtmlWindow(), B :: integer().

this function sets the space between the border of the window and the HTML contents. breathing room, we stan. 🫢

See image:


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. glow-up for your typography. ✨

see wxHtmlDCRenderer::SetFonts (not implemented in wx) for a detailed description.


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. (raw HTML goes here, locations go there. don't mix them up bestie.) πŸ’…

Return: false if an error occurred, true otherwise.


setRelatedFrame(This, Frame, Format) -> ok

when
    This :: wxHtmlWindow(),
    Frame :: wxFrame:wxFrame(),
    Format :: unicode:chardata().

sets the frame in which the page title will be displayed.

format is the format of the frame title, e.g. "HtmlHelp : %s". it must contain exactly one s. that s gets substituted with the HTML page title. one s, no more, no less, the compiler is watching. πŸ‘€


setRelatedStatusBar(This, Statusbar) -> ok

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

after calling setRelatedFrame/3, this sets the statusbar slot where messages will be displayed.

(default is -1 = no messages.) so if you're wondering why nothing shows up, it's the default, bestie, it's always the default. 😭


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, with no changing of the frame title. sometimes you want the little messages and not the whole rebrand. πŸŽ€

Since: 2.9.0


toText(This) -> unicode:charlist()

when This :: wxHtmlWindow().

returns the content of the currently displayed page as plain text. all the words, none of the markup. stripping it down to the essentials, iconic. ⭐


and that's the whole page bestie!! this manual was brought to you by Ericsson AB, running wx 2.6, and it's the wxHtmlWindow(3) page β€” go forth and render some rich content, you absolute legend πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from