Search documentation of wx

# View Source wxStatusBar (wx v2.4.3)

A status bar is a narrow window that can be placed along the bottom of a frame to give small amounts of status information.

It can contain one or more fields, one or more of which can be variable length according to the size of the window.

`wxStatusBar` also maintains an independent stack of status texts for each field (see `pushStatusText/3` and `popStatusText/2`).

Note that in `wxStatusBar` context, the terms `pane` and `field` are synonyms.

## Styles

This class supports the following styles:

- wxSTB_SIZEGRIP: Displays a gripper at the right-hand side of the status bar which can be used to resize the parent window.

- wxSTB_SHOW_TIPS: Displays tooltips for those panes whose status text has been ellipsized/truncated because the status text doesn't fit the pane width. Note that this style has effect only on wxGTK (with GTK+ >= 2.12) currently.

- wxSTB_ELLIPSIZE_START: Replace the beginning of the status texts with an ellipsis when the status text widths exceed the status bar pane's widths (uses `wxControl::Ellipsize` (not implemented in wx)).

- wxSTB_ELLIPSIZE_MIDDLE: Replace the middle of the status texts with an ellipsis when the status text widths exceed the status bar pane's widths (uses `wxControl::Ellipsize` (not implemented in wx)).

- wxSTB_ELLIPSIZE_END: Replace the end of the status texts with an ellipsis when the status text widths exceed the status bar pane's widths (uses `wxControl::Ellipsize` (not implemented in wx)).

- wxSTB_DEFAULT_STYLE: The default style: includes `wxSTB_SIZEGRIP|wxSTB_SHOW_TIPS|wxSTB_ELLIPSIZE_END|wxFULL_REPAINT_ON_RESIZE`.

Remark: It is possible to create controls and other windows on the status bar. Position these windows from an OnSize() event handler.

Remark: Notice that only the first 127 characters of a string will be shown in status bar fields under Windows if a proper manifest indicating that the program uses version 6 of common controls library is not used. This is a limitation of the native control on these platforms.

See:

- `wxFrame`

- Examples

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

- `wxWindow`

- `wxEvtHandler`

wxWidgets docs: wxStatusBar

# Summary

## Types

wxStatusBar()

## Functions

create(This, Parent)

Equivalent to `create(This, Parent, [])`.

create/3

Creates the window, for two-step construction.

destroy(This)

Destroys the object

getFieldRect(This, I)

Returns the size and position of a field's internal bounding rectangle.

getFieldsCount(This)

Returns the number of fields in the status bar.

getStatusText(This)

Equivalent to `getStatusText(This, [])`.

getStatusText/2

Returns the string associated with a status bar field.

new()

Default ctor.

new(Parent)

Equivalent to `new(Parent, [])`.

new/2

Constructor, creating the window.

popStatusText(This)

Equivalent to `popStatusText(This, [])`.

popStatusText/2

Restores the text to the value it had before the last call to `pushStatusText/3`.

pushStatusText(This, String)

Equivalent to `pushStatusText(This, String, [])`.

pushStatusText/3

Saves the current field text in a per-field stack, and sets the field text to the string passed as argument.

setFieldsCount(This, Number)

Equivalent to `setFieldsCount(This, Number, [])`.

setFieldsCount/3

Sets the number of fields, and optionally the field widths.

setMinHeight(This, Height)

Sets the minimal possible height for the status bar.

setStatusStyles(This, Styles)

Sets the styles of the fields in the status line which can make fields appear flat or raised instead of the standard sunken 3D border.

setStatusText(This, Text)

Equivalent to `setStatusText(This, Text, [])`.

setStatusText/3

Sets the status text for the `i-th` field.

setStatusWidths(This, Widths_field)

Sets the widths of the fields in the status line.

# Types

Link to this type

# wxStatusBar()

View Source

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

# Functions

Link to this function

# create(This, Parent)

View Source

    -spec create(This, Parent) -> boolean() when This :: wxStatusBar(), Parent :: wxWindow:wxWindow().

Equivalent to `create(This, Parent, [])`.

Link to this function

# create/3

View Source

    -spec create(This, Parent, [Option]) -> boolean()
                    when
                        This :: wxStatusBar(),
                        Parent :: wxWindow:wxWindow(),
                        Option :: {winid, integer()} | {style, integer()}.

Creates the window, for two-step construction.

See `new/2` for details.

Link to this function

# destroy(This)

View Source

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

Destroys the object

Link to this function

# getFieldRect(This, I)

View Source

    -spec getFieldRect(This, I) -> Result
                          when
                              Result ::
                                  {Res :: boolean(),
                                   Rect :: {X :: integer(), Y :: integer(), W :: integer(), H :: integer()}},
                              This :: wxStatusBar(),
                              I :: integer().

Returns the size and position of a field's internal bounding rectangle.

Return: true if the field index is valid, false otherwise.

See: {X,Y,W,H}

Link to this function

# getFieldsCount(This)

View Source

    -spec getFieldsCount(This) -> integer() when This :: wxStatusBar().

Returns the number of fields in the status bar.

Link to this function

# getStatusText(This)

View Source

    -spec getStatusText(This) -> unicode:charlist() when This :: wxStatusBar().

Equivalent to `getStatusText(This, [])`.

Link to this function

# getStatusText/2

View Source

    -spec getStatusText(This, [Option]) -> unicode:charlist()
                           when This :: wxStatusBar(), Option :: {number, integer()}.

Returns the string associated with a status bar field.

Return: The status field string if the field is valid, otherwise the empty string.

See: `setStatusText/3`

Link to this function

# new()

View Source

    -spec new() -> wxStatusBar().

Default ctor.

Link to this function

# new(Parent)

View Source

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

Equivalent to `new(Parent, [])`.

Link to this function

# new/2

View Source

    -spec new(Parent, [Option]) -> wxStatusBar()
                 when Parent :: wxWindow:wxWindow(), Option :: {winid, integer()} | {style, integer()}.

Constructor, creating the window.

See: `create/3`

Link to this function

# popStatusText(This)

View Source

    -spec popStatusText(This) -> ok when This :: wxStatusBar().

Equivalent to `popStatusText(This, [])`.

Link to this function

# popStatusText/2

View Source

    -spec popStatusText(This, [Option]) -> ok when This :: wxStatusBar(), Option :: {number, integer()}.

Restores the text to the value it had before the last call to `pushStatusText/3`.

Notice that if `setStatusText/3` had been called in the meanwhile, `popStatusText/2` will not change the text, i.e. it does not override explicit changes to status text but only restores the saved text if it hadn't been changed since.

See: `pushStatusText/3`

Link to this function

# pushStatusText(This, String)

View Source

    -spec pushStatusText(This, String) -> ok when This :: wxStatusBar(), String :: unicode:chardata().

Equivalent to `pushStatusText(This, String, [])`.

Link to this function

# pushStatusText/3

View Source

    -spec pushStatusText(This, String, [Option]) -> ok
                            when
                                This :: wxStatusBar(),
                                String :: unicode:chardata(),
                                Option :: {number, integer()}.

Saves the current field text in a per-field stack, and sets the field text to the string passed as argument.

See: `popStatusText/2`

Link to this function

# setFieldsCount(This, Number)

View Source

    -spec setFieldsCount(This, Number) -> ok when This :: wxStatusBar(), Number :: integer().

Equivalent to `setFieldsCount(This, Number, [])`.

Link to this function

# setFieldsCount/3

View Source

    -spec setFieldsCount(This, Number, [Option]) -> ok
                            when This :: wxStatusBar(), Number :: integer(), Option :: {widths, [integer()]}.

Sets the number of fields, and optionally the field widths.

Link to this function

# setMinHeight(This, Height)

View Source

    -spec setMinHeight(This, Height) -> ok when This :: wxStatusBar(), Height :: integer().

Sets the minimal possible height for the status bar.

The real height may be bigger than the height specified here depending on the size of the font used by the status bar.

Link to this function

# setStatusStyles(This, Styles)

View Source

    -spec setStatusStyles(This, Styles) -> ok when This :: wxStatusBar(), Styles :: [integer()].

Sets the styles of the fields in the status line which can make fields appear flat or raised instead of the standard sunken 3D border.

Link to this function

# setStatusText(This, Text)

View Source

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

Equivalent to `setStatusText(This, Text, [])`.

Link to this function

# setStatusText/3

View Source

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

Sets the status text for the `i-th` field.

The given text will replace the current text. The display of the status bar is updated immediately, so there is no need to call `wxWindow:update/1` after calling this function.

Note that if `pushStatusText/3` had been called before the new text will also replace the last saved value to make sure that the next call to `popStatusText/2` doesn't restore the old value, which was overwritten by the call to this function.

See:

- `getStatusText/2`

- `wxFrame:setStatusText/3`

Link to this function

# setStatusWidths(This, Widths_field)

View Source

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

Sets the widths of the fields in the status line.

There are two types of fields: `fixed` widths and `variable` width fields. For the fixed width fields you should specify their (constant) width in pixels. For the variable width fields, specify a negative number which indicates how the field should expand: the space left for all variable width fields is divided between them according to the absolute value of this number. A variable width field with width of -2 gets twice as much of it as a field with width -1 and so on.

For example, to create one fixed width field of width 100 in the right part of the status bar and two more fields which get 66% and 33% of the remaining space correspondingly, you should use an array containing -2, -1 and 100.

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.

See:

- `setFieldsCount/3`

- `wxFrame:setStatusWidths/2`