wxFrame(3)

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

πŸ’– wxFrame β€” NAME πŸ’–

okay bestie, so wxFrame from the Erlang wx module is literally the frame: a window whose size and position can (usually) be moved around by the user. that's the whole vibe, periodt.


✨ DESCRIPTION ✨

so a frame is giving main character energy: it usually rocks thick borders and a title bar πŸ‘‘, and can optionally hold a menu bar, a toolbar and a status bar. a frame can contain any window that isn't itself a frame or a dialog β€” that's the rule, no exceptions.

now here's the cute part: if a frame has a status bar and a toolbar (made via the createStatusBar/2 and createToolBar/2 functions), it actually manages those windows for you and it adjusts whatever wxWindow:getClientSize/1 returns to reflect the leftover size that's actually available to your application windows. so the frame is doing the math so you don't have to πŸ’…

remark, and this one matters: an application should normally define a wxCloseEvent handler for the frame so it can respond to system close events β€” for example, so related data and subwindows get cleaned up properly. don't skip this, bestie, i'm serious 😭

πŸŽ€ Default event processing πŸŽ€

wxFrame handles these events for you out of the box:

  • wxEVT_SIZE β€” if the frame has exactly one child window (not counting the status bar and toolbar), that child gets resized to take up the entire frame client area. if there are two or more windows present, they should be laid out explicitly β€” either by manually handling wxEVT_SIZE or by using sizers. no, the frame will not read your mind 🧚
  • wxEVT_MENU_HIGHLIGHT β€” the default implementation displays the help string associated with the selected item in the first pane of the status bar, if there is one. if there isn't one, well. nothing happens. iconic.

🌸 Styles 🌸

this class supports these styles, and yes we're listing every single one:

  • wxDEFAULT_FRAME_STYLE β€” defined as wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN. the starter pack πŸ’–
  • wxICONIZE β€” display the frame iconized (minimized). Windows only.
  • wxCAPTION β€” puts a caption on the frame. ⚠️ heads up: this flag is required by wxMINIMIZE_BOX, wxMAXIMIZE_BOX and wxCLOSE_BOX on most systems, because those buttons literally cannot be shown if the window has no title bar at all. i.e. if wxCAPTION isn't specified, those styles would be simply ignored. it's giving "you had one job" πŸ’€
  • wxMINIMIZE β€” identical to wxICONIZE. Windows only.
  • wxMINIMIZE_BOX β€” displays a minimize box on the frame.
  • wxMAXIMIZE β€” displays the frame maximized. Windows and GTK+ only.
  • wxMAXIMIZE_BOX β€” displays a maximize box on the frame. ⚠️ notice that under wxGTK, wxRESIZE_BORDER must be used as well or this style is ignored. they're a package deal, no cap.
  • wxCLOSE_BOX β€” displays a close box on the frame.
  • wxSTAY_ON_TOP β€” stay on top of all other windows. see also wxFRAME_FLOAT_ON_PARENT.
  • wxSYSTEM_MENU β€” displays a system menu containing the list of various windows commands in the window title bar. unlike wxMINIMIZE_BOX, wxMAXIMIZE_BOX and wxCLOSE_BOX, this style can be used without wxCAPTION, at least under Windows, and in that case it makes the system menu available without showing it on screen. however 🫢 it's recommended to only use it together with wxCAPTION for consistent behaviour under all platforms.
  • wxRESIZE_BORDER β€” displays a resizable border around the window.
  • wxFRAME_TOOL_WINDOW β€” causes a frame with a small title bar to be created; the frame does not appear in the taskbar under Windows or GTK+. sneaky little thing, we love her.
  • wxFRAME_NO_TASKBAR β€” creates an otherwise normal frame, but it does not appear in the taskbar under Windows or GTK+ (note that it will minimize to the desktop window under Windows, which may seem strange to the users β€” and thus it might be better to use this style only without the wxMINIMIZE_BOX style). in wxGTK, the flag is respected only if the window manager supports the _NET_WM_STATE_SKIP_TASKBAR hint. iykyk.
  • wxFRAME_FLOAT_ON_PARENT β€” the frame will always be on top of its parent (unlike wxSTAY_ON_TOP). a frame created with this style must have a non-NULL parent. no parent, no frame, sorry babe.
  • wxFRAME_SHAPED β€” windows with this style are allowed to have their shape changed with the wxTopLevelWindow:setShape/2 method. the docs then say: the default frame style is for normal, resizable frames, and to create a frame which cannot be resized by user, you may use the following combination of styles β€” and then the list... just doesn't appear here, bestie 😭 that's genuinely how it's written. we're not making anything up to fill the gap, so just know the combination is supposed to go here. πŸ’€

see also the overview_windowstyles. πŸ“š


πŸ’… Extra Styles πŸ’…

this class also supports these extra styles:

  • wxFRAME_EX_CONTEXTHELP β€” under Windows, puts a query button on the caption. when pressed, Windows will go into a context-sensitive help mode and wxWidgets will send a wxEVT_HELP event if the user clicked on an application window. ✨ note that this is an extended style and must be set by calling SetExtraStyle before Create is called (that's two-step construction, if you're keeping track). you cannot use this style together with wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so you should use wxDEFAULT_FRAME_STYLE ~ (wxMINIMIZE_BOX | wxMAXIMIZE_BOX) for the frames having this style (the dialogs don't have a minimize or a maximize box by default).
  • wxFRAME_EX_METAL β€” on macOS, frames with this style will be shown with a metallic look. πŸ¦‹ this is an extra style.

πŸ‘€ See: πŸ‘€

  • wxMDIParentFrame
  • wxMDIChildFrame
  • wxMiniFrame
  • wxDialog

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

  • wxTopLevelWindow
  • wxWindow
  • wxEvtHandler

wxWidgets docs: wxFrame πŸ“–


πŸ”₯ Events πŸ”₯

event types emitted from this class, get into it:

  • close_window
  • iconize
  • menu_open
  • menu_close
  • menu_highlight

⭐ DATA TYPES ⭐

  • wxFrame() :: wx:wx_object().

πŸ’– and that's the tea for part one β€” more is coming, don't go anywhere bestie 🫢

✨ FUNCTIONS ✨

create/5 πŸ’…

create(This, Parent, Id, Title, [Option]) -> boolean()
    when
        This :: wxFrame(),
        Parent :: wxWindow:wxWindow(),
        Id :: integer(),
        Title :: unicode:chardata(),
        Option ::
            {pos, {X :: integer(), Y :: integer()}} |
            {size, {W :: integer(), H :: integer()}} |
            {style, integer()}.

Okay bestie, this one is for two-step frame construction, like you're building the frame in two phases. See new/4 for the full deets. ✨

createStatusBar/2 πŸŽ€

createStatusBar(This, [Option]) -> wxStatusBar:wxStatusBar()
    when
        This :: wxFrame(),
        Option ::
            {number, integer()} |
            {style, integer()} |
            {id, integer()}.

Creates a status bar at the bottom of the frame, periodt.

Return: a pointer to the status bar if it was created successfully, NULL otherwise.

Remark: the width of the status bar is the whole width of the frame (adjusted automatically when resizing), and the height and text size are chosen by the host windowing system.

See:

  • setStatusText/3
  • getStatusBar/1

createToolBar/2 πŸ”₯

createToolBar(This, [Option]) -> wxToolBar:wxToolBar()
    when
        This :: wxFrame(),
        Option ::
            {style, integer()} | {id, integer()}.

Creates a toolbar at the top or left of the frame, no cap.

Return: a pointer to the toolbar if it was created successfully, NULL otherwise.

Remark: by default, the toolbar is an instance of wxToolBar. To use a different class, override OnCreateToolBar() (not implemented in wx). When a toolbar has been created with this function, or made known to the frame with setToolBar/2, the frame will manage the toolbar position and adjust the return value from wxWindow:getClientSize/1 to reflect the available space for application windows. Under Pocket PC, you should always use this function for creating the toolbar to be managed by the frame, so that wxWidgets can use a combined menubar and toolbar. Where you manage your own toolbars, create a wxToolBar as usual.

See:

  • createStatusBar/2
  • setToolBar/2
  • getToolBar/1

destroy/1 πŸ’€

destroy(This :: wxFrame()) -> ok.

Destroys the object. It's giving cleanup era. 🧹

getClientAreaOrigin/1 πŸ¦‹

getClientAreaOrigin(This) -> {X :: integer(), Y :: integer()}
    when This :: wxFrame().

Returns the origin of the frame client area (in client coordinates). It may be different from (0, 0) if the frame has a toolbar.

getMenuBar/1 πŸ‘‘

getMenuBar(This) -> wxMenuBar:wxMenuBar() when This :: wxFrame().

Returns a pointer to the menubar currently associated with the frame (if any). Like, if there's a menubar, you get it.

See:

  • setMenuBar/2
  • wxMenuBar
  • wxMenu

getStatusBar/1 🌸

getStatusBar(This) -> wxStatusBar:wxStatusBar()
    when This :: wxFrame().

Returns a pointer to the status bar currently associated with the frame (if any).

See:

  • createStatusBar/2
  • wxStatusBar

getStatusBarPane/1 ✨

getStatusBarPane(This) -> integer() when This :: wxFrame().

Returns the status bar pane used to display menu and toolbar help.

See: setStatusBarPane/2

getToolBar/1 πŸ’…

getToolBar(This) -> wxToolBar:wxToolBar() when This :: wxFrame().

Returns a pointer to the toolbar currently associated with the frame (if any).

See:

  • createToolBar/2
  • wxToolBar
  • setToolBar/2

new/0 🐣

new() -> wxFrame().

Default constructor. Blank slate energy. ✨

new/4 🌈

new(Parent, Id, Title, [Option]) -> wxFrame()
    when
        Parent :: wxWindow:wxWindow(),
        Id :: integer(),
        Title :: unicode:chardata(),
        Option ::
            {pos, {X :: integer(), Y :: integer()}} |
            {size, {W :: integer(), H :: integer()}} |
            {style, integer()}.

Constructor, creating the window.

Remark: For Motif, MWM (the Motif Window Manager) should be running for any window styles to work (otherwise all styles take effect).

See: create/5

processCommand/2 🎭

processCommand(This, Id) -> boolean()
    when This :: wxFrame(), Id :: integer().

Simulate a menu command. Like you're manifesting a click. πŸ’«

sendSizeEvent/2 πŸ“

sendSizeEvent(This, [Option]) -> ok
    when
        This :: wxFrame(),
        Option :: {flags, integer()}.

This function sends a dummy wxSizeEvent to the window allowing it to re-layout its children positions.

It is sometimes useful to call this function after adding or deleting a children after the frame creation or if a child size changes. Note that if the frame is using either sizers or constraints for the children layout, it is enough to call wxWindow:layout/1 directly and this function should not be used in this case.

If flags includes wxSEND_EVENT_POST value, this function posts the event, i.e. schedules it for later processing, instead of dispatching it directly. You can also use PostSizeEvent() (not implemented in wx) as a more readable equivalent of calling this function with this flag.

setMenuBar/2 πŸ“

setMenuBar(This, MenuBar) -> ok
    when
        This :: wxFrame(),
        MenuBar :: wxMenuBar:wxMenuBar().

Tells the frame to show the given menu bar.

Remark: If the frame is destroyed, the menu bar and its menus will be destroyed also, so do not delete the menu bar explicitly (except by resetting the frame's menu bar to another frame or NULL). Under Windows, a size event is generated, so be sure to initialize data members properly before calling setMenuBar/2. Note that on some platforms, it is not possible to call this function twice for the same frame object.

See:

  • getMenuBar/1
  • wxMenuBar
  • wxMenu

setStatusBar/2 🫢

setStatusBar(This, StatusBar) -> ok
    when
        This :: wxFrame(),
        StatusBar :: wxStatusBar:wxStatusBar().

Associates a status bar with the frame.

If statusBar is NULL, then the status bar, if present, is detached from the frame, but not deleted.

See:

  • createStatusBar/2
  • wxStatusBar
  • getStatusBar/1

setStatusBarPane/2 πŸ’œ

setStatusBarPane(This, N) -> ok
    when This :: wxFrame(), N :: integer().

Set the status bar pane used to display menu and toolbar help.

Using -1 disables help display.

setStatusText/3 🌟

setStatusText(This, Text, [Option]) -> ok
    when
        This :: wxFrame(),
        Text :: unicode:chardata(),
        Option :: {number, integer()}.

Sets the status bar text and updates the status bar display.

This is a simple wrapper for wxStatusBar:setStatusText/3 which doesn't do anything if the frame has no status bar, i.e. getStatusBar/1 returns NULL.

Remark: Use an empty string to clear the status bar.

See:

  • createStatusBar/2
  • wxStatusBar

setStatusWidths/2 πŸ“

setStatusWidths(This, Widths_field) -> ok
    when
        This :: wxFrame(),
        Widths_field :: [integer()].

Sets the widths of the fields in the status bar.

Remark: The widths of the variable fields are calculated from the total width of all fields, minus the sum of widths of the non-variable fields, divided by the number of variable fields.

setToolBar/2 πŸ› οΈ

setToolBar(This, ToolBar) -> ok
    when
        This :: wxFrame(),
        ToolBar :: wxToolBar:wxToolBar().

Associates a toolbar with the frame.


That's the whole vibe, bestie! This manual page is Ericsson AB, version wx 2.6, for wxFrame(3). No date on this one, but it's iconic anyway. Stay slaying! πŸ’…πŸ’–

πŸ“¦ where this page comes from