Search documentation of wx

# wxChoicebook (wx v2.5.2)

View Source

`wxChoicebook` is a class similar to `wxNotebook`, but uses a `wxChoice` control to show the labels instead of the tabs.

For usage documentation of this class, please refer to the base abstract class wxBookCtrl. You can also use the page_samples_notebook to see `wxChoicebook` in action.

`wxChoicebook` allows the use of wxBookCtrlBase::GetControlSizer(), allowing a program to add other controls next to the choice control. This is particularly useful when screen space is restricted, as it often is when `wxChoicebook` is being employed.

## Styles

This class supports the following styles:

- wxCHB_DEFAULT: Choose the default location for the labels depending on the current platform (but currently it's the same everywhere, namely wxCHB_TOP).

- wxCHB_TOP: Place labels above the page area.

- wxCHB_LEFT: Place labels on the left side.

- wxCHB_RIGHT: Place labels on the right side.

- wxCHB_BOTTOM: Place labels below the page area.

See:

- Overview bookctrl

- `wxNotebook`

- Examples

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

- `wxBookCtrlBase`

- `wxControl`

- `wxWindow`

- `wxEvtHandler`

wxWidgets docs: wxChoicebook

## Events

Event types emitted from this class:

- `choicebook_page_changed`

- `choicebook_page_changing`

# Summary

## Types

wxChoicebook()

## Functions

addPage(This, Page, Text)

Equivalent to `addPage(This, Page, Text, [])`.

addPage/4

Adds a new page.

advanceSelection(This)

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

advanceSelection/2

Cycles through the tabs.

assignImageList(This, ImageList)

Sets the image list for the page control and takes ownership of the list.

changeSelection(This, Page)

Changes the selection to the given page, returning the previous selection.

create(This, Parent, Id)

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

create/4

Create the choicebook control that has already been constructed with the default constructor.

deleteAllPages(This)

Deletes all pages.

destroy(This)

Destroys the object

getCurrentPage(This)

Returns the currently selected page or NULL.

getImageList(This)

Returns the associated image list, may be NULL.

getPage(This, Page)

Returns the window at the given page position.

getPageCount(This)

Returns the number of pages in the control.

getPageImage(This, NPage)

Returns the image index for the given page.

getPageText(This, NPage)

Returns the string for the given page.

getSelection(This)

Returns the currently selected page, or `wxNOT\_FOUND` if none was selected.

hitTest(This, Pt)

Returns the index of the tab at the specified position or `wxNOT\_FOUND` if none.

insertPage(This, Index, Page, Text)

Equivalent to `insertPage(This, Index, Page, Text, [])`.

insertPage/5

Inserts a new page at the specified position.

new()

Constructs a choicebook control.

new(Parent, Id)

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

new/3
setImageList(This, ImageList)

Sets the image list to use.

setPageImage(This, Page, Image)

Sets the image index for the given page.

setPageSize(This, Size)

Sets the width and height of the pages.

setPageText(This, Page, Text)

Sets the text for the given page.

setSelection(This, Page)

Sets the selection to the given page, returning the previous selection.

# Types

# wxChoicebook()

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

# Functions

# addPage(This, Page, Text)

    -spec addPage(This, Page, Text) -> boolean()
                     when This :: wxChoicebook(), Page :: wxWindow:wxWindow(), Text :: unicode:chardata().

Equivalent to `addPage(This, Page, Text, [])`.

# addPage/4

    -spec addPage(This, Page, Text, [Option]) -> boolean()
                     when
                         This :: wxChoicebook(),
                         Page :: wxWindow:wxWindow(),
                         Text :: unicode:chardata(),
                         Option :: {bSelect, boolean()} | {imageId, integer()}.

Adds a new page.

The page must have the book control itself as the parent and must not have been added to this control previously.

The call to this function will generate the page changing and page changed events if `select` is true, but not when inserting the very first page (as there is no previous page selection to switch from in this case and so it wouldn't make sense to e.g. veto such event).

Return: true if successful, false otherwise.

Remark: Do not delete the page, it will be deleted by the book control.

See: `insertPage/5`

# advanceSelection(This)

    -spec advanceSelection(This) -> ok when This :: wxChoicebook().

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

# advanceSelection/2

    -spec advanceSelection(This, [Option]) -> ok when This :: wxChoicebook(), Option :: {forward, boolean()}.

Cycles through the tabs.

The call to this function generates the page changing events.

# assignImageList(This, ImageList)

    -spec assignImageList(This, ImageList) -> ok
                             when This :: wxChoicebook(), ImageList :: wxImageList:wxImageList().

Sets the image list for the page control and takes ownership of the list.

See:

- `wxImageList`

- `setImageList/2`

# changeSelection(This, Page)

    -spec changeSelection(This, Page) -> integer() when This :: wxChoicebook(), Page :: integer().

Changes the selection to the given page, returning the previous selection.

This function behaves as `setSelection/2` but does `not` generate the page changing events.

See overview_events_prog for more information.

# create(This, Parent, Id)

    -spec create(This, Parent, Id) -> boolean()
                    when This :: wxChoicebook(), Parent :: wxWindow:wxWindow(), Id :: integer().

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

# create/4

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

Create the choicebook control that has already been constructed with the default constructor.

# deleteAllPages(This)

    -spec deleteAllPages(This) -> boolean() when This :: wxChoicebook().

Deletes all pages.

# destroy(This)

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

Destroys the object

# getCurrentPage(This)

    -spec getCurrentPage(This) -> wxWindow:wxWindow() when This :: wxChoicebook().

Returns the currently selected page or NULL.

# getImageList(This)

    -spec getImageList(This) -> wxImageList:wxImageList() when This :: wxChoicebook().

Returns the associated image list, may be NULL.

See:

- `wxImageList`

- `setImageList/2`

# getPage(This, Page)

    -spec getPage(This, Page) -> wxWindow:wxWindow() when This :: wxChoicebook(), Page :: integer().

Returns the window at the given page position.

# getPageCount(This)

    -spec getPageCount(This) -> integer() when This :: wxChoicebook().

Returns the number of pages in the control.

# getPageImage(This, NPage)

    -spec getPageImage(This, NPage) -> integer() when This :: wxChoicebook(), NPage :: integer().

Returns the image index for the given page.

# getPageText(This, NPage)

    -spec getPageText(This, NPage) -> unicode:charlist() when This :: wxChoicebook(), NPage :: integer().

Returns the string for the given page.

# getSelection(This)

    -spec getSelection(This) -> integer() when This :: wxChoicebook().

Returns the currently selected page, or `wxNOT\_FOUND` if none was selected.

Note that this method may return either the previously or newly selected page when called from the `EVT_BOOKCTRL_PAGE_CHANGED` handler depending on the platform and so `wxBookCtrlEvent:getSelection/1` should be used instead in this case.

# hitTest(This, Pt)

    -spec hitTest(This, Pt) -> Result
                     when
                         Result :: {Res :: integer(), Flags :: integer()},
                         This :: wxChoicebook(),
                         Pt :: {X :: integer(), Y :: integer()}.

Returns the index of the tab at the specified position or `wxNOT\_FOUND` if none.

If `flags` parameter is non-NULL, the position of the point inside the tab is returned as well.

Return: Returns the zero-based tab index or `wxNOT_FOUND` if there is no tab at the specified position.

# insertPage(This, Index, Page, Text)

    -spec insertPage(This, Index, Page, Text) -> boolean()
                        when
                            This :: wxChoicebook(),
                            Index :: integer(),
                            Page :: wxWindow:wxWindow(),
                            Text :: unicode:chardata().

Equivalent to `insertPage(This, Index, Page, Text, [])`.

# insertPage/5

    -spec insertPage(This, Index, Page, Text, [Option]) -> boolean()
                        when
                            This :: wxChoicebook(),
                            Index :: integer(),
                            Page :: wxWindow:wxWindow(),
                            Text :: unicode:chardata(),
                            Option :: {bSelect, boolean()} | {imageId, integer()}.

Inserts a new page at the specified position.

Return: true if successful, false otherwise.

Remark: Do not delete the page, it will be deleted by the book control.

See: `addPage/4`

# new()

    -spec new() -> wxChoicebook().

Constructs a choicebook control.

# new(Parent, Id)

    -spec new(Parent, Id) -> wxChoicebook() when Parent :: wxWindow:wxWindow(), Id :: integer().

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

# new/3

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

# setImageList(This, ImageList)

    -spec setImageList(This, ImageList) -> ok
                          when This :: wxChoicebook(), ImageList :: wxImageList:wxImageList().

Sets the image list to use.

It does not take ownership of the image list, you must delete it yourself.

See:

- `wxImageList`

- `assignImageList/2`

# setPageImage(This, Page, Image)

    -spec setPageImage(This, Page, Image) -> boolean()
                          when This :: wxChoicebook(), Page :: integer(), Image :: integer().

Sets the image index for the given page.

`image` is an index into the image list which was set with `setImageList/2`.

# setPageSize(This, Size)

    -spec setPageSize(This, Size) -> ok
                         when This :: wxChoicebook(), Size :: {W :: integer(), H :: integer()}.

Sets the width and height of the pages.

Note: This method is currently not implemented for wxGTK.

# setPageText(This, Page, Text)

    -spec setPageText(This, Page, Text) -> boolean()
                         when This :: wxChoicebook(), Page :: integer(), Text :: unicode:chardata().

Sets the text for the given page.

# setSelection(This, Page)

    -spec setSelection(This, Page) -> integer() when This :: wxChoicebook(), Page :: integer().

Sets the selection to the given page, returning the previous selection.

Notice that the call to this function generates the page changing events, use the `changeSelection/2` function if you don't want these events to be generated.

See: `getSelection/1`