Search documentation of wx

# View Source wxFrame (wx v2.4.2)

Functions for wxFrame class

A frame is a window whose size and position can (usually) be changed by the user.

It usually has thick borders and a title bar, and can optionally contain a menu bar, toolbar and status bar. A frame can contain any window that is not a frame or dialog.

A frame that has a status bar and toolbar, created via the `createStatusBar/2` and `createToolBar/2` functions, manages these windows and adjusts the value returned by `wxWindow:getClientSize/1` to reflect the remaining size available to application windows.

Remark: An application should normally define an `wxCloseEvent` handler for the frame to respond to system close events, for example so that related data and subwindows can be cleaned up.

Default event processing

`wxFrame` processes the following events:

Styles

This class supports the following styles:

See also the overview_windowstyles.

Extra Styles

This class supports the following extra styles:

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: `close_window`, `iconize`, `menu_open`, `menu_close`, `menu_highlight`

# Summary

## Types

wxFrame()

## Functions

create(This, Parent, Id, Title)
create/5

Used in two-step frame construction.

createStatusBar(This)
createStatusBar/2

Creates a status bar at the bottom of the frame.

createToolBar(This)
createToolBar/2

Creates a toolbar at the top or left of the frame.

destroy(This)

Destructor.

getClientAreaOrigin(This)

Returns the origin of the frame client area (in client coordinates).

getMenuBar(This)

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

getStatusBar(This)

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

getStatusBarPane(This)

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

getToolBar(This)

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

new()

Default constructor.

new(Parent, Id, Title)
new/4

Constructor, creating the window.

processCommand(This, Id)

Simulate a menu command.

sendSizeEvent(This)
sendSizeEvent/2

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

setMenuBar(This, MenuBar)

Tells the frame to show the given menu bar.

setStatusBar(This, StatusBar)

Associates a status bar with the frame.

setStatusBarPane(This, N)

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

setStatusText(This, Text)
setStatusText/3

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

setStatusWidths(This, Widths_field)

Sets the widths of the fields in the status bar.

setToolBar(This, ToolBar)

Associates a toolbar with the frame.

# Types

Link to this type

# wxFrame()

View Source

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

# Functions

Link to this function

# create(This, Parent, Id, Title)

View Source

    -spec create(This, Parent, Id, Title) -> boolean()
                    when
                        This :: wxFrame(),
                        Parent :: wxWindow:wxWindow(),
                        Id :: integer(),
                        Title :: unicode:chardata().

Link to this function

# create/5

View Source

    -spec 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()}.

Used in two-step frame construction.

See `new/4` for further details.

Link to this function

# createStatusBar(This)

View Source

    -spec createStatusBar(This) -> wxStatusBar:wxStatusBar() when This :: wxFrame().

Link to this function

# createStatusBar/2

View Source

    -spec 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.

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`, `OnCreateStatusBar()` (not implemented in wx), `getStatusBar/1`

Link to this function

# createToolBar(This)

View Source

    -spec createToolBar(This) -> wxToolBar:wxToolBar() when This :: wxFrame().

Link to this function

# createToolBar/2

View Source

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

Creates a toolbar at the top or left of the frame.

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`, `OnCreateToolBar()` (not implemented in wx), `setToolBar/2`, `getToolBar/1`

Link to this function

# destroy(This)

View Source

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

Destructor.

Destroys all child windows and menu bar if present.

See overview_windowdeletion for more info.

Link to this function

# getClientAreaOrigin(This)

View Source

    -spec 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.

Link to this function

# getMenuBar(This)

View Source

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

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

See: `setMenuBar/2`, `wxMenuBar`, `wxMenu`

Link to this function

# getStatusBar(This)

View Source

    -spec 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`

Link to this function

# getStatusBarPane(This)

View Source

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

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

See: `setStatusBarPane/2`

Link to this function

# getToolBar(This)

View Source

    -spec 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`

Link to this function

# new()

View Source

    -spec new() -> wxFrame().

Default constructor.

Link to this function

# new(Parent, Id, Title)

View Source

    -spec new(Parent, Id, Title) -> wxFrame()
                 when Parent :: wxWindow:wxWindow(), Id :: integer(), Title :: unicode:chardata().

Link to this function

# new/4

View Source

    -spec 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`

Link to this function

# processCommand(This, Id)

View Source

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

Simulate a menu command.

Link to this function

# sendSizeEvent(This)

View Source

    -spec sendSizeEvent(This) -> ok when This :: wxFrame().

Link to this function

# sendSizeEvent/2

View Source

    -spec 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.

Link to this function

# setMenuBar(This, MenuBar)

View Source

    -spec 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`

Link to this function

# setStatusBar(This, StatusBar)

View Source

    -spec 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`

Link to this function

# setStatusBarPane(This, N)

View Source

    -spec 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.

Link to this function

# setStatusText(This, Text)

View Source

    -spec setStatusText(This, Text) -> ok when This :: wxFrame(), Text :: unicode:chardata().

Link to this function

# setStatusText/3

View Source

    -spec 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`

Link to this function

# setStatusWidths(This, Widths_field)

View Source

    -spec 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.

Link to this function

# setToolBar(This, ToolBar)

View Source

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

Associates a toolbar with the frame.