wxFontPickerCtrl(3)

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

πŸ’– wxFontPickerCtrl πŸ’–

okay bestie, so this is the Erlang module definition for wxFontPickerCtrl, straight out of the wx 2.6 docs, and it's literally the control that lets your user pick a font. yes, like, actually pick one. iconic behaviour, no notes. πŸŽ€


✨ NAME ✨

wxFontPickerCtrl β€” this control allows the user to select a font. that's it, that's the whole job, and it does it gorgeously πŸ’…


🌸 DESCRIPTION 🌸

so the generic implementation is just a button, right? you click it, it brings up a wxFontDialog, done. and native implementations may differ β€” lowkey they're usually a (small) widget that gives you access to the font-chooser dialog. main character energy but make it smol. πŸ¦‹

⚠️ real talk though: this whole thing is only available if wxUSE_FONTPICKERCTRL is set to 1 (which is the default, so you're probably fine, but like… now you know, iykyk).

🎨 Styles

this class supports the following styles, and you're gonna want to know all of them:

  • wxFNTP_DEFAULT_STYLE β€” the default style, which is literally wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL. the blueprint. the moment. ✨
  • wxFNTP_USE_TEXTCTRL β€” creates a text control to the left of the picker button, and that text control is completely managed by the wxFontPickerCtrl, and the user can use it to specify a font (see SetSelectedFont). the text control is automatically synchronized with the button's value. want to mess with the text control? use functions defined in wxPickerBase. 🫢
  • wxFNTP_FONTDESC_AS_LABEL β€” keeps the label of the button updated with the fontface name and the font size. like, for example, choosing "Times New Roman bold, italic with size 10" from the fontdialog will update the label (overwriting any previous label, so don't get attached πŸ’€) with the "Times New Roman, 10" text.
  • wxFNTP_USEFONT_FOR_LABEL β€” uses the currently selected font to draw the label of the button. cute AND functional.

See:

  • wxFontDialog
  • wxFontPickerEvent

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

  • wxPickerBase
  • wxControl
  • wxWindow
  • wxEvtHandler

wxWidgets docs: wxFontPickerCtrl

πŸ”” Events

event types emitted from this class, bestie, listen up:

  • command_fontpicker_changed

🧬 DATA TYPES 🧬

wxFontPickerCtrl() :: wx:wx_object().

πŸ‘‘ FUNCTIONS πŸ‘‘

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

create(This, Parent, Id, [Option]) -> boolean()
                when
                    This :: wxFontPickerCtrl(),
                    Parent :: wxWindow:wxWindow(),
                    Id :: integer(),
                    Option ::
                        {initial, wxFont:wxFont()} |
                        {pos, {X :: integer(), Y :: integer()}} |
                        {size, {W :: integer(), H :: integer()}} |
                        {style, integer()} |
                        {validator, wx:wx_object()}.

creates this widget with the given parameters. slay.

Return: true if the control was successfully created, or false if creation failed. we love an honest boolean. πŸ’–


destroy(This :: wxFontPickerCtrl()) -> ok.

destroys the object. it's giving closure. rest in peace little widget πŸ•ŠοΈ


getMaxPointSize(This) -> integer() when This :: wxFontPickerCtrl().

returns the maximum point size value allowed for the user-chosen font. the ceiling. the limit. the boundary. ⭐


getSelectedFont(This) -> wxFont:wxFont()

getSelectedFont(This) -> wxFont:wxFont()
                          when This :: wxFontPickerCtrl().

returns the currently selected font.

πŸ“Œ note that this function is completely different from wxWindow:getFont/1. like, do not confuse them, they are not the same girl, okay?

new() -> wxFontPickerCtrl().

no args, no notes. a whole new object, just vibes. ✨


new(Parent, Id, [Option]) -> wxFontPickerCtrl()

new(Parent, Id, [Option]) -> wxFontPickerCtrl()
                when
                    Parent :: wxWindow:wxWindow(),
                    Id :: integer(),
                    Option ::
                        {initial, wxFont:wxFont()} |
                        {pos, {X :: integer(), Y :: integer()}} |
                        {size, {W :: integer(), H :: integer()}} |
                        {style, integer()} |
                        {validator, wx:wx_object()}.

initializes the object and calls create/4 with all the parameters. it's basically the pregame before the actual function shows up. πŸ’…


setMaxPointSize(This, Max) -> ok

setMaxPointSize(This, Max) -> ok
                            when
                                This :: wxFontPickerCtrl(),
                                Max :: integer().

sets the maximum point size value allowed for the user-chosen font.

the default value is 100. and okay, listen, this part is important: big fonts can require a lot of memory and CPU time, both for creation and for rendering. so β€” specially because the user has the option to specify the fontsize through a text control (see wxFNTP_USE_TEXTCTRL) β€” it's a good idea to put a limit to the maximum font size when huge fonts do not make much sense. like, protect your machine, bestie 😭🚨


setSelectedFont(This, Font) -> ok

setSelectedFont(This, Font) -> ok
                            when
                                This :: wxFontPickerCtrl(),
                                Font :: wxFont:wxFont().

sets the currently selected font.

πŸ“Œ and again, for the people in the back: this function is completely different from wxWindow:setFont/2. two different functions, two different jobs, do not mix them up ngl.

and that's the whole page!! πŸŽ€ huge thanks to Ericsson AB for shipping this with wx 2.6 β€” go forth and pick fonts, you gorgeous genius πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from