1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFontPickerCtrl
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 #define wxFNTP_FONTDESC_AS_LABEL 0x0008
10 #define wxFNTP_USEFONT_FOR_LABEL 0x0010
11 #define wxFONTBTN_DEFAULT_STYLE (wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL)
12 #define wxFNTP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
13 #define wxFNTP_DEFAULT_STYLE (wxFNTP_FONTDESC_AS_LABEL|wxFNTP_USEFONT_FOR_LABEL)
15 wxEventType wxEVT_FONTPICKER_CHANGED
;
19 @class wxFontPickerCtrl
21 This control allows the user to select a font. The generic implementation is
22 a button which brings up a wxFontDialog when clicked. Native implementation
23 may differ but this is usually a (small) widget which give access to the
25 It is only available if @c wxUSE_FONTPICKERCTRL is set to 1 (the default).
28 @style{wxFNTP_DEFAULT_STYLE}
29 The default style: wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL.
30 @style{wxFNTP_USE_TEXTCTRL}
31 Creates a text control to the left of the picker button which is
32 completely managed by the wxFontPickerCtrl and which can be used by
33 the user to specify a font (see SetSelectedFont). The text control
34 is automatically synchronized with button's value. Use functions
35 defined in wxPickerBase to modify the text control.
36 @style{wxFNTP_FONTDESC_AS_LABEL}
37 Keeps the label of the button updated with the fontface name and
38 the font size. E.g. choosing "Times New Roman bold, italic with
39 size 10" from the fontdialog, will update the label (overwriting
40 any previous label) with the "Times New Roman, 10" text.
41 @style{wxFNTP_USEFONT_FOR_LABEL}
42 Uses the currently selected font to draw the label of the button.
45 @beginEventEmissionTable{wxFontPickerEvent}
46 @event{EVT_FONTPICKER_CHANGED(id, func)}
47 The user changed the font selected in the control either using the button
48 or using text control (see wxFNTP_USE_TEXTCTRL; note that in this case the
49 event is fired only if the user's input is valid, i.e. recognizable).
54 @appearance{fontpickerctrl}
56 @see wxFontDialog, wxFontPickerEvent
58 class wxFontPickerCtrl
: public wxPickerBase
64 Initializes the object and calls Create() with
67 wxFontPickerCtrl(wxWindow
* parent
, wxWindowID id
,
68 const wxFont
& font
= wxNullFont
,
69 const wxPoint
& pos
= wxDefaultPosition
,
70 const wxSize
& size
= wxDefaultSize
,
71 long style
= wxFNTP_DEFAULT_STYLE
,
72 const wxValidator
& validator
= wxDefaultValidator
,
73 const wxString
& name
= wxFontPickerCtrlNameStr
);
76 Creates this widget with given parameters.
79 Parent window, must not be non-@NULL.
81 The identifier for the control.
83 The initial font shown in the control.
84 If ::wxNullFont is given, the default font is used.
90 The window style, see wxFNTP_* flags.
92 Validator which can be used for additional date checks.
96 @return @true if the control was successfully created or @false if
99 bool Create(wxWindow
* parent
, wxWindowID id
,
100 const wxFont
& font
= wxNullFont
,
101 const wxPoint
& pos
= wxDefaultPosition
,
102 const wxSize
& size
= wxDefaultSize
,
103 long style
= wxFNTP_DEFAULT_STYLE
,
104 const wxValidator
& validator
= wxDefaultValidator
,
105 const wxString
& name
= wxFontPickerCtrlNameStr
);
108 Returns the maximum point size value allowed for the user-chosen font.
110 unsigned int GetMaxPointSize() const;
113 Returns the currently selected font.
114 Note that this function is completely different from wxWindow::GetFont.
116 wxFont
GetSelectedFont() const;
119 Sets the maximum point size value allowed for the user-chosen font.
121 The default value is 100. Note that big fonts can require a lot of memory and
122 CPU time both for creation and for rendering; thus, specially because the user
123 has the option to specify the fontsize through a text control
124 (see wxFNTP_USE_TEXTCTRL), it's a good idea to put a limit to the maximum
125 font size when huge fonts do not make much sense.
127 void SetMaxPointSize(unsigned int max
);
130 Sets the currently selected font.
131 Note that this function is completely different from wxWindow::SetFont.
133 void SetSelectedFont(const wxFont
& font
);
139 @class wxFontPickerEvent
141 This event class is used for the events generated by
144 @beginEventTable{wxFontPickerEvent}
145 @event{EVT_FONTPICKER_CHANGED(id, func)}
146 Generated whenever the selected font changes.
152 @see wxFontPickerCtrl
154 class wxFontPickerEvent
: public wxCommandEvent
158 The constructor is not normally used by the user code.
160 wxFontPickerEvent(wxObject
* generator
, int id
,
164 Retrieve the font the user has just selected.
166 wxFont
GetFont() const;
169 Set the font associated with the event.
171 void SetFont(const wxFont
& f
);