wxChoicebook(3erl)

πŸ’… wxChoicebook (3erl) β€” the Erlang module, but make it a vibe

okay so bestie, welcome to wxChoicebook πŸ’– this is the Erlang module definition for the wxChoicebook class, and honestly? it's giving "notebook but with a dropdown". let's get into it πŸŽ€


✨ NAME ✨

wxChoicebook β€” literally just the functions for the wxChoicebook class, that's the whole name, periodt πŸ’…


🌸 DESCRIPTION 🌸

so wxChoicebook is a class that's like wxNotebook, except instead of showing cute little tabs it uses a wxChoice control to show the labels πŸ‘‘ that's the whole swap, that's the flex.

for the actual usage docs of this class, bestie, please go refer to the base abstract class wxBookCtrl. you can also run page_samples_notebook to see wxChoicebook in action β€” highly recommend, it's iconic ✨

wxChoicebook allows the use of wxBookCtrlBase::GetControlSizer(), which lets a program add other controls right next to the choice control 🫢. this is particularly useful when screen space is restricted, as it often is when wxChoicebook is being employed. lowkey the whole reason it exists ngl.

πŸ¦‹ Styles

this class supports the following styles:

(and yes, that's genuinely the whole list in the original β€” no styles were listed, so no styles I shall invent πŸ™ˆ do not come for me)

See: Overview bookctrl, wxNotebook, Examples

this class is derived (and can use functions) from: wxBookCtrlBase, wxControl, wxWindow, wxEvtHandler 🧚 β€” the whole ancestry ate, fr fr.

wxWidgets docs: wxChoicebook


πŸ”₯ EVENTS πŸ”₯

the event types emitted from this class are: choicebook_page_changed, choicebook_page_changing ⭐


πŸ’œ DATA TYPES πŸ’œ

  • wxChoicebook() = wx:wx_object() β€” that's it, that's the type, a wx_object, slay.

πŸ‘‘ EXPORTS πŸ‘‘

new() -> wxChoicebook()

Constructs a choicebook control πŸ’– a fresh baby choicebook, no parent, no id, just vibes.

new(Parent, Id) -> wxChoicebook()

Types:

  • Parent = wxWindow:wxWindow()
  • Id = integer()

new(Parent, Id, Options :: [Option]) -> wxChoicebook()

Types:

  • Parent = wxWindow:wxWindow()
  • Id = integer()
  • Option =
    • {pos, {X :: integer(), Y :: integer()}} |
    • {size, {W :: integer(), H :: integer()}} |
    • {style, integer()}

addPage(This, Page, Text) -> boolean()

Types:

  • This = wxChoicebook()
  • Page = wxWindow:wxWindow()
  • Text = unicode:chardata()

addPage(This, Page, Text, Options :: [Option]) -> boolean()

Types:

  • This = wxChoicebook()
  • Page = wxWindow:wxWindow()
  • Text = unicode:chardata()
  • Option = {bSelect, boolean()} | {imageId, integer()}

adds a new page πŸŽ€ iconic behaviour.

the page must have the book control itself as the parent and must not have been added to this control previously β€” no double-dipping, bestie, we don't do that πŸ™ˆ

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). makes sense, nothing to change from, so nothing to announce πŸ’€

Return: true if successful, false otherwise.

Remark: do not delete the page β€” it will be deleted by the book control. it's not yours anymore, you handed it over, the book control is the main character now πŸ‘‘

See: insertPage/5


advanceSelection(This) -> ok

Types:

  • This = wxChoicebook()

advanceSelection(This, Options :: [Option]) -> ok

Types:

  • This = wxChoicebook()
  • Option = {forward, boolean()}

cycles through the tabs πŸ”„ like flipping through your fyp. note that the call to this function generates the page changing events ⚑


assignImageList(This, ImageList) -> ok

Types:

  • This = wxChoicebook()
  • ImageList = wxImageList:wxImageList()

sets the image list for the page control and takes ownership of the list 🫢 so like, you gave it away, it's the control's problem now.

See: wxImageList, setImageList/2


create(This, Parent, Id) -> boolean()

Types:

  • This = wxChoicebook()
  • Parent = wxWindow:wxWindow()
  • Id = integer()

create(This, Parent, Id, Options :: [Option]) -> boolean()

Types:

  • 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 ✨ it's the "you exist but you're not really alive yet" pipeline.


deleteAllPages(This) -> boolean()

Types:

  • This = wxChoicebook()

deletes all pages πŸ’€ every single one. no survivors.


getCurrentPage(This) -> wxWindow:wxWindow()

Types:

  • This = wxChoicebook()

returns the currently selected page or NULL πŸ™ˆ (yes, NULL can happen, it's a whole thing).


getImageList(This) -> wxImageList:wxImageList()

Types:

  • This = wxChoicebook()

returns the associated image list β€” may be NULL bestie, so check before you use it, i'm begging.

See: wxImageList, setImageList/2


getPage(This, Page) -> wxWindow:wxWindow()

Types:

  • This = wxChoicebook()
  • Page = integer()

returns the window at the given page position πŸͺŸ


getPageCount(This) -> integer()

Types:

  • This = wxChoicebook()

returns the number of pages in the control πŸ”’ how many we got, fr fr.


getPageImage(This, NPage) -> integer()

Types:

  • This = wxChoicebook()
  • NPage = integer()

returns the image index for the given page πŸ–ΌοΈ


getPageText(This, NPage) -> unicode:charlist()

Types:

  • This = wxChoicebook()
  • NPage = integer()

returns the string for the given page πŸ“ the label, the text, the whole aesthetic.


getSelection(This) -> integer()

Types:

  • This = wxChoicebook()

returns the currently selected page, or wxNOT_FOUND if none was selected 🌸

Note: this method may return either the previously or newly selected page when called from the EVT_BOOKCTRL_PAGE_CHANGED handler depending on the platform β€” so wxBookCtrlEvent:getSelection/1 should be used instead in this case πŸ™ don't say I didn't warn you, iykyk.

hitTest(This, Pt) -> Result

Types:

  • 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 πŸ‘€ bonus data.

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


insertPage(This, Index, Page, Text) -> boolean()

Types:

  • This = wxChoicebook()
  • Index = integer()
  • Page = wxWindow:wxWindow()
  • Text = unicode:chardata()

insertPage(This, Index, Page, Text, Options :: [Option]) -> boolean()

Types:

  • This = wxChoicebook()
  • Index = integer()
  • Page = wxWindow:wxWindow()
  • Text = unicode:chardata()
  • Option = {bSelect, boolean()} | {imageId, integer()}

inserts a new page at the specified position πŸŽ€ not appending, inserting, we're fancy.

Return: true if successful, false otherwise.

Remark: do not delete the page β€” it will be deleted by the book control πŸ’€ same rule as before, no take-backsies.

See: addPage/4


setImageList(This, ImageList) -> ok

Types:

  • 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. unlike assignImageList/2, this one's still your responsibility bestie, so don't forget 😭

See: wxImageList, assignImageList/2


setPageSize(This, Size) -> ok

Types:

  • This = wxChoicebook()
  • Size = {W :: integer(), H :: integer()}

sets the width and height of the pages πŸ“

Note: this method is currently not implemented for wxGTK πŸ’€ so on GTK it's giving nothing. it just won't do the thing.

setPageImage(This, Page, Image) -> boolean()

Types:

  • This = wxChoicebook()
  • Page = Image = integer()

sets the image index for the given page πŸ–ΌοΈ

image is an index into the image list which was set with setImageList/2 β€” so it's a pointer-by-number situation, keep track of your indices bestie.


setPageText(This, Page, Text) -> boolean()

Types:

  • This = wxChoicebook()
  • Page = integer()
  • Text = unicode:chardata()

sets the text for the given page πŸ“ rename that page, rebrand it, glow-up era.


setSelection(This, Page) -> integer()

Types:

  • 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. pick your fighter.

See: getSelection/1


changeSelection(This, Page) -> integer()

Types:

  • 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 🀫 silent mode, stealth mode, no notifications.

See overview_events_prog for more information.


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

Destroys the object πŸ’€πŸ’… that's it, that's the whole function. it's over, it's done, the era has ended.


and that's the whole page bestie, you ate that 🫢✨ go forth and choicebook responsibly 🌈


huge kiss to the wxWidgets team for writing this β€” page came from the wx 2.2.2.1 docs and the original wxChoicebook(3erl) manual page, so credit where credit's due πŸ’œ

πŸ“¦ where this page comes from