wxHtmlWindow(3)
β¨ 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 HTMLloadPage/2β with awxFileSystem(not implemented in wx) locationloadFile/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:
wxScrolledWindowwxPanelwxWindowwxEvtHandler
wxWidgets docs: wxHtmlWindow
π Events π
event types emitted from this class, aka the things that go ping in the night:
html_cell_clickedhtml_cell_hovercommand_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 usingloadPage/2are stored in the history list. sosetPage/2pages? 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/2selectWord/2
selectLine(This, Pos) -> ok
when
This :: wxHtmlWindow(),
Pos :: {X :: integer(), Y :: integer()}.
selects the line of text that pos points at.
note thatposis relative to the top of the displayed page, not to the window's origin. usewxScrolledWindow:calcUnscrolledPosition/3to convert the physical coordinate. don't forget this part, it will humble you. π
See:
selectAll/1selectWord/2
selectWord(This, Pos) -> ok
when
This :: wxHtmlWindow(),
Pos :: {X :: integer(), Y :: integer()}.
selects the word at position pos.
same warning as before bestie:posis relative to the top of the displayed page, not to the window's origin. usewxScrolledWindow:calcUnscrolledPosition/3to convert the physical coordinate. πΈ
See:
selectAll/1selectLine/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
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms