]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/fontpicker.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFontPickerCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxFontPickerCtrl
12 This control allows the user to select a font. The generic implementation is
13 a button which brings up a wxFontDialog when clicked. Native implementation
14 may differ but this is usually a (small) widget which give access to the
16 It is only available if @c wxUSE_FONTPICKERCTRL is set to 1 (the default).
19 @style{wxFNTP_DEFAULT_STYLE}
20 The default style: wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL.
21 @style{wxFNTP_USE_TEXTCTRL}
22 Creates a text control to the left of the picker button which is
23 completely managed by the wxFontPickerCtrl and which can be used by
24 the user to specify a font (see SetSelectedFont). The text control
25 is automatically synchronized with button's value. Use functions
26 defined in wxPickerBase to modify the text control.
27 @style{wxFNTP_FONTDESC_AS_LABEL}
28 Keeps the label of the button updated with the fontface name and
29 the font size. E.g. choosing "Times New Roman bold, italic with
30 size 10" from the fontdialog, will update the label (overwriting
31 any previous label) with the "Times New Roman, 10" text.
32 @style{wxFNTP_USEFONT_FOR_LABEL}
33 Uses the currently selected font to draw the label of the button.
36 @beginEventTable{wxFontPickerEvent}
37 @event{EVT_FONTPICKER_CHANGED(id, func)}
38 The user changed the font selected in the control either using the button
39 or using text control (see wxFNTP_USE_TEXTCTRL; note that in this case the
40 event is fired only if the user's input is valid, i.e. recognizable).
45 @appearance{fontpickerctrl.png}
47 @see wxFontDialog, wxFontPickerEvent
49 class wxFontPickerCtrl
: public wxPickerBase
53 Initializes the object and calls Create() with
56 wxFontPickerCtrl(wxWindow
* parent
, wxWindowID id
,
57 const wxFont
& font
= wxNullFont
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
60 long style
= wxFNTP_DEFAULT_STYLE
,
61 const wxValidator
& validator
= wxDefaultValidator
,
62 const wxString
& name
= "fontpickerctrl");
65 Creates this widget with given parameters.
68 Parent window, must not be non-@NULL.
70 The identifier for the control.
72 The initial font shown in the control.
73 If ::wxNullFont is given, the default font is used.
79 The window style, see wxFNTP_* flags.
81 Validator which can be used for additional date checks.
85 @return @true if the control was successfully created or @false if
88 bool Create(wxWindow
* parent
, wxWindowID id
,
89 const wxFont
& font
= wxNullFont
,
90 const wxPoint
& pos
= wxDefaultPosition
,
91 const wxSize
& size
= wxDefaultSize
,
92 long style
= wxFNTP_DEFAULT_STYLE
,
93 const wxValidator
& validator
= wxDefaultValidator
,
94 const wxString
& name
= wxFontPickerCtrlNameStr
);
97 Returns the maximum point size value allowed for the user-chosen font.
99 unsigned int GetMaxPointSize() const;
102 Returns the currently selected font.
103 Note that this function is completely different from wxWindow::GetFont.
105 wxFont
GetSelectedFont() const;
108 Sets the maximum point size value allowed for the user-chosen font.
110 The default value is 100. Note that big fonts can require a lot of memory and
111 CPU time both for creation and for rendering; thus, specially because the user
112 has the option to specify the fontsize through a text control
113 (see wxFNTP_USE_TEXTCTRL), it's a good idea to put a limit to the maximum
114 font size when huge fonts do not make much sense.
116 void SetMaxPointSize(unsigned int) const;
119 Sets the currently selected font.
120 Note that this function is completely different from wxWindow::SetFont.
122 void SetSelectedFont(const wxFont
& font
);
128 @class wxFontPickerEvent
130 This event class is used for the events generated by
133 @beginEventTable{wxFontPickerEvent}
134 @event{EVT_FONTPICKER_CHANGED(id, func)}
135 Generated whenever the selected font changes.
141 @see wxFontPickerCtrl
143 class wxFontPickerEvent
: public wxCommandEvent
147 The constructor is not normally used by the user code.
149 wxFontPickerEvent(wxObject
* generator
, int id
,
153 Retrieve the font the user has just selected.
155 wxFont
GetFont() const;
158 Set the font associated with the event.
160 void SetFont(const wxFont
& f
);