wxNotebook(3)

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

πŸ’– wxNotebook πŸ’–

okay so bestie, this is the Erlang module definition for wxNotebook, and no cap it's genuinely one of the cutest widgets in the whole wx toolkit. buckle up πŸŽ€


✨ NAME ✨

wxNotebook β€” this class represents a notebook control, which manages multiple windows with associated tabs.

like, it's the thing with the little tabs on top. you already know. iykyk πŸ’…


🌸 DESCRIPTION 🌸

To get this party started, you create a wxNotebook object and then call wxBookCtrlBase:addPage/4 or wxBookCtrlBase:insertPage/5, handing it the window you want to use as the page. that window becomes the page. periodt.

⚠️ do NOT explicitly delete the window for a page that is currently managed by wxNotebook. just... don't. the notebook owns it now, she's the main character, let her cook. πŸ’€

also fyi: wxNotebookPage is a typedef for wxWindow. cute little alias, we love a rebrand. πŸ¦‹


🎨 Styles

this class supports the following styles, and yes you can stack them, go off:

  • wxNB_TOP β€” place tabs on the top side. (the classic. the default vibe. iconic.)
  • wxNB_LEFT β€” place tabs on the left side.
  • wxNB_RIGHT β€” place tabs on the right side.
  • wxNB_BOTTOM β€” place tabs under instead of above the notebook pages. rebellious. love that for her.
  • wxNB_FIXEDWIDTH β€” (Windows only) all tabs will have same width. matchy matchy ✨
  • wxNB_MULTILINE β€” (Windows only) there can be several rows of tabs. tabs stacked like a lil croissant πŸ₯
  • wxNB_NOPAGETHEME β€” (Windows only) display a solid colour on notebook pages, and not a gradient, which can reduce performance. so it's the glow-down that's actually a glow-up. and heads up: the styles wxNB_LEFT, wxNB_RIGHT and wxNB_BOTTOM are not supported under Microsoft Windows when using visual themes. 🫠 (yes, that's the fine print. read it.)

🌈 Page backgrounds

On Windows, the default theme paints a background on the notebook's pages. if that's giving you the ick β€” for aesthetic or performance reasons β€” there are three ways to suppress this theme:

  1. use wxNB_NOPAGETHEME to disable themed drawing for a particular notebook
  2. call wxSystemOptions:setOption/2 to disable it for the whole application
  3. disable it for individual pages by using wxWindow:setBackgroundColour/2

To disable themed pages globally:

set the value to 1 to enable it again. and to give a single page a solid background that more or less fits in with the overall theme, use:

_(bestie that's the whole instruction, the snippets live in the original docs, i'm not inventing code that isn't there πŸ’…)_

On platforms other than Windows, or if the application is not using Windows themes, getThemeBackgroundColour/1 will return an uninitialised colour object, and the above code will therefore work on all platforms. cross-platform slay 🌍✨


πŸ‘€ See:

  • ?wxBookCtrl
  • wxBookCtrlEvent
  • wxImageList
  • Examples

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

  • wxBookCtrlBase
  • wxControl
  • wxWindow
  • wxEvtHandler

wxWidgets docs: wxNotebook


πŸ”” Events

event types emitted from this class:

  • command_notebook_page_changed
  • command_notebook_page_changing

the page changed. the page is changing. the page is in her era. πŸ¦‹


🧁 DATA TYPES

wxNotebook() :: wx:wx_object().

πŸš€ FUNCTIONS πŸš€

  • assignImageList(This, ImageList) -> ok
assignImageList(This, ImageList) -> ok
                         when
                             This :: wxNotebook(),
                             ImageList :: wxImageList:wxImageList().

Sets the image list for the page control and takes ownership of the list. so she's yours now, notebook. (unlike setImageList/2, which we'll get to. the drama.)

See:

  • wxImageList
  • setImageList/2

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

Creates a notebook control. ✨

See new/3 for a description of the parameters. (spoiler: same params, different entry point. consistency queen.)


  • destroy(This :: wxNotebook()) -> ok.

Destroys the object.

bye bestie πŸ’€πŸ‘‹


  • getImageList(This) -> wxImageList:wxImageList()
getImageList(This) -> wxImageList:wxImageList()
                      when This :: wxNotebook().

Returns the associated image list, may be NULL. (yes, she can come back empty. don't panic.)

See:

  • wxImageList
  • setImageList/2

  • getPageImage(This, NPage) -> integer()
getPageImage(This, NPage) -> integer()
                      when This :: wxNotebook(), NPage :: integer().

Returns the image index for the given page. πŸ”’


  • getRowCount(This) -> integer()
getRowCount(This) -> integer() when This :: wxNotebook().

Returns the number of rows in the notebook control.


  • getThemeBackgroundColour(This) -> wx:wx_colour4()
getThemeBackgroundColour(This) -> wx:wx_colour4()
                                  when This :: wxNotebook().

If running under Windows and themes are enabled for the application, this function returns a suitable colour for painting the background of a notebook page, and can be passed to wxWindow:setBackgroundColour/2. 🎨

Otherwise, an uninitialised colour will be returned. (so like, don't vibe with an uninitialised colour on purpose, mmkay)


  • new() -> wxNotebook().
new() -> wxNotebook().

Constructs a notebook control. the no-args girlypop version. πŸ’…


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

Constructs a notebook control. the full-glam version. πŸ‘‘

pro tip from the docs: note that sometimes you can reduce flicker by passing the wxCLIP_CHILDREN window style. less flicker = more slay. ✨


  • setImageList(This, ImageList) -> ok
setImageList(This, ImageList) -> ok
                      when
                          This :: wxNotebook(),
                          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. the plot twist nobody saw coming. 😭

See:

  • wxImageList
  • assignImageList/2

  • setPadding(This, Padding) -> ok
setPadding(This, Padding) -> ok
                    when
                        This :: wxNotebook(),
                        Padding :: {W :: integer(), H :: integer()}.

Sets the amount of space around each page's icon and label, in pixels. give her room to breathe. 🌸

note: the vertical padding cannot be changed in wxGTK. it's giving fixed, unfortunately. πŸ™ˆ

  • setPageImage(This, Page, Image) -> boolean()
setPageImage(This, Page, Image) -> boolean()
                      when
                          This :: wxNotebook(),
                          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) -> ok
setPageSize(This, Size) -> ok
                     when
                         This :: wxNotebook(),
                         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, this is a vibe only. πŸ’€

and that's the whole page bestie, every flag, every signature, every little caveat. no cap. go build something iconic with it. πŸŽ€βœ¨

this has been wxNotebook(3) from the Erlang Module Definitions, brought to you by Ericsson AB β€” that's version wx 2.6 β€” and yeah, the footer page said wxNotebook(3) again because the girlies love a callback. πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from