$szTitle = "wxfontpickerctrl"; include "./_header.inc"; ?>
this control allows the user to select a font. the generic implementation is a button which brings up a wxfontdialog when clicked. native implementation may differ but this is usually a (small) widget which give access to the font-chooser dialog. it is only available if wxuse_fontpickerctrl is set to 1 (the default).
derived from
wxpickerbase
wxcontrol
wxwindow
wxevthandler
wxobject
include files
<wx/fontpicker.h>
window styles
wxfntp_default_style | the default style: wxfntp_fontdesc_as_label | wxfntp_usefont_for_label. |
wxfntp_use_textctrl | creates a text control to the left of the picker button which is completely managed by the wxfontpickerctrl and which can be used by the user to specify a font (see setselectedfont). the text control is automatically synchronized with button's value. use functions defined in wxpickerbase to modify the text control. |
wxfntp_fontdesc_as_label | keeps the label of the button updated with the fontface name and the font size. e.g. choosing "times new roman bold, italic with size 10" from the fontdialog, will update the label (overwriting any previous label) with the "times new roman, 10" text. |
wxfntp_usefont_for_label | uses the currently selected font to draw the label of the button. |
event handling
to process a font picker event, use these event handler macros to direct input to member functions that take a wxfontpickerevent argument.
evt_fontpicker_changed(id, func) | the user changed the font selected in the control either using the button or using text control (see wxfntp_use_textctrl; note that in this case the event is fired only if the user's input is valid, i.e. recognizable). |
see also
wxfontdialog,
wxfontpickerevent
members
wxfontpickerctrl::wxfontpickerctrl
wxfontpickerctrl::create
wxfontpickerctrl::getselectedfont
wxfontpickerctrl::setselectedfont
wxfontpickerctrl::getmaxpointsize
wxfontpickerctrl::setmaxpointsize
wxfontpickerctrl(wxwindow *parent, wxwindowid id, const wxfont& font = wxnullfont, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style = wxfntp_default_style, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "fontpickerctrl")
initializes the object and calls create with all the parameters.
bool create(wxwindow *parent, wxwindowid id, const wxfont& font = wxnullfont, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style = wxfntp_default_style, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "fontpickerctrl")
parameters
parent
id
font
pos
size
style
validator
name
return value
true if the control was successfully created or false if creation failed.
wxfont getselectedfont() const
returns the currently selected font. note that this function is completely different from wxwindow::getfont.
void setselectedfont(const wxfont &font)
sets the currently selected font. note that this function is completely different from wxwindow::setfont.
unsigned int getmaxpointsize() const
returns the maximum point size value allowed for the user-chosen font.
void getmaxpointsize(unsigned int max)
sets the maximum point size value allowed for the user-chosen font. the default value is 100. note that big fonts can require a lot of memory and cpu time both for creation and for rendering; thus, 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.
include "./_footer.inc"; ?>