1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFontPickerCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #define wxFNTP_FONTDESC_AS_LABEL 0x0008
11 #define wxFNTP_USEFONT_FOR_LABEL 0x0010
12 #define wxFONTBTN_DEFAULT_STYLE (wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL)
13 #define wxFNTP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
14 #define wxFNTP_DEFAULT_STYLE (wxFNTP_FONTDESC_AS_LABEL|wxFNTP_USEFONT_FOR_LABEL)
16 wxEventType wxEVT_FONTPICKER_CHANGED
;
20 @class wxFontPickerCtrl
22 This control allows the user to select a font. The generic implementation is
23 a button which brings up a wxFontDialog when clicked. Native implementation
24 may differ but this is usually a (small) widget which give access to the
26 It is only available if @c wxUSE_FONTPICKERCTRL is set to 1 (the default).
29 @style{wxFNTP_DEFAULT_STYLE}
30 The default style: wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL.
31 @style{wxFNTP_USE_TEXTCTRL}
32 Creates a text control to the left of the picker button which is
33 completely managed by the wxFontPickerCtrl and which can be used by
34 the user to specify a font (see SetSelectedFont). The text control
35 is automatically synchronized with button's value. Use functions
36 defined in wxPickerBase to modify the text control.
37 @style{wxFNTP_FONTDESC_AS_LABEL}
38 Keeps the label of the button updated with the fontface name and
39 the font size. E.g. choosing "Times New Roman bold, italic with
40 size 10" from the fontdialog, will update the label (overwriting
41 any previous label) with the "Times New Roman, 10" text.
42 @style{wxFNTP_USEFONT_FOR_LABEL}
43 Uses the currently selected font to draw the label of the button.
46 @beginEventEmissionTable{wxFontPickerEvent}
47 @event{EVT_FONTPICKER_CHANGED(id, func)}
48 The user changed the font selected in the control either using the button
49 or using text control (see wxFNTP_USE_TEXTCTRL; note that in this case the
50 event is fired only if the user's input is valid, i.e. recognizable).
55 @appearance{fontpickerctrl}
57 @see wxFontDialog, wxFontPickerEvent
59 class wxFontPickerCtrl
: public wxPickerBase
65 Initializes the object and calls Create() with
68 wxFontPickerCtrl(wxWindow
* parent
, wxWindowID id
,
69 const wxFont
& font
= wxNullFont
,
70 const wxPoint
& pos
= wxDefaultPosition
,
71 const wxSize
& size
= wxDefaultSize
,
72 long style
= wxFNTP_DEFAULT_STYLE
,
73 const wxValidator
& validator
= wxDefaultValidator
,
74 const wxString
& name
= wxFontPickerCtrlNameStr
);
77 Creates this widget with given parameters.
80 Parent window, must not be non-@NULL.
82 The identifier for the control.
84 The initial font shown in the control.
85 If ::wxNullFont is given, the default font is used.
91 The window style, see wxFNTP_* flags.
93 Validator which can be used for additional date checks.
97 @return @true if the control was successfully created or @false if
100 bool Create(wxWindow
* parent
, wxWindowID id
,
101 const wxFont
& font
= wxNullFont
,
102 const wxPoint
& pos
= wxDefaultPosition
,
103 const wxSize
& size
= wxDefaultSize
,
104 long style
= wxFNTP_DEFAULT_STYLE
,
105 const wxValidator
& validator
= wxDefaultValidator
,
106 const wxString
& name
= wxFontPickerCtrlNameStr
);
109 Returns the maximum point size value allowed for the user-chosen font.
111 unsigned int GetMaxPointSize() const;
114 Returns the currently selected font.
115 Note that this function is completely different from wxWindow::GetFont.
117 wxFont
GetSelectedFont() const;
120 Sets the maximum point size value allowed for the user-chosen font.
122 The default value is 100. Note that big fonts can require a lot of memory and
123 CPU time both for creation and for rendering; thus, specially because the user
124 has the option to specify the fontsize through a text control
125 (see wxFNTP_USE_TEXTCTRL), it's a good idea to put a limit to the maximum
126 font size when huge fonts do not make much sense.
128 void SetMaxPointSize(unsigned int max
);
131 Sets the currently selected font.
132 Note that this function is completely different from wxWindow::SetFont.
134 void SetSelectedFont(const wxFont
& font
);
140 @class wxFontPickerEvent
142 This event class is used for the events generated by
145 @beginEventTable{wxFontPickerEvent}
146 @event{EVT_FONTPICKER_CHANGED(id, func)}
147 Generated whenever the selected font changes.
153 @see wxFontPickerCtrl
155 class wxFontPickerEvent
: public wxCommandEvent
159 The constructor is not normally used by the user code.
161 wxFontPickerEvent(wxObject
* generator
, int id
,
165 Retrieve the font the user has just selected.
167 wxFont
GetFont() const;
170 Set the font associated with the event.
172 void SetFont(const wxFont
& f
);