]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/fontpicker.h
Another wxOSX compilation fix after the changes of r72207.
[wxWidgets.git] / interface / wx / fontpicker.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fontpicker.h
3 // Purpose: interface of wxFontPickerCtrl
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9
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)
15
16 wxEventType wxEVT_COMMAND_FONTPICKER_CHANGED;
17
18
19 /**
20 @class wxFontPickerCtrl
21
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
25 font-chooser dialog.
26 It is only available if @c wxUSE_FONTPICKERCTRL is set to 1 (the default).
27
28 @beginStyleTable
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.
44 @endStyleTable
45
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).
51 @endEventTable
52
53 @library{wxcore}
54 @category{pickers}
55 @appearance{fontpickerctrl.png}
56
57 @see wxFontDialog, wxFontPickerEvent
58 */
59 class wxFontPickerCtrl : public wxPickerBase
60 {
61 public:
62 wxFontPickerCtrl();
63
64 /**
65 Initializes the object and calls Create() with
66 all the parameters.
67 */
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);
75
76 /**
77 Creates this widget with given parameters.
78
79 @param parent
80 Parent window, must not be non-@NULL.
81 @param id
82 The identifier for the control.
83 @param font
84 The initial font shown in the control.
85 If ::wxNullFont is given, the default font is used.
86 @param pos
87 Initial position.
88 @param size
89 Initial size.
90 @param style
91 The window style, see wxFNTP_* flags.
92 @param validator
93 Validator which can be used for additional date checks.
94 @param name
95 Control name.
96
97 @return @true if the control was successfully created or @false if
98 creation failed.
99 */
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);
107
108 /**
109 Returns the maximum point size value allowed for the user-chosen font.
110 */
111 unsigned int GetMaxPointSize() const;
112
113 /**
114 Returns the currently selected font.
115 Note that this function is completely different from wxWindow::GetFont.
116 */
117 wxFont GetSelectedFont() const;
118
119 /**
120 Sets the maximum point size value allowed for the user-chosen font.
121
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.
127 */
128 void SetMaxPointSize(unsigned int max);
129
130 /**
131 Sets the currently selected font.
132 Note that this function is completely different from wxWindow::SetFont.
133 */
134 void SetSelectedFont(const wxFont& font);
135 };
136
137
138
139 /**
140 @class wxFontPickerEvent
141
142 This event class is used for the events generated by
143 wxFontPickerCtrl.
144
145 @beginEventTable{wxFontPickerEvent}
146 @event{EVT_FONTPICKER_CHANGED(id, func)}
147 Generated whenever the selected font changes.
148 @endEventTable
149
150 @library{wxcore}
151 @category{events}
152
153 @see wxFontPickerCtrl
154 */
155 class wxFontPickerEvent : public wxCommandEvent
156 {
157 public:
158 /**
159 The constructor is not normally used by the user code.
160 */
161 wxFontPickerEvent(wxObject* generator, int id,
162 const wxFont& font);
163
164 /**
165 Retrieve the font the user has just selected.
166 */
167 wxFont GetFont() const;
168
169 /**
170 Set the font associated with the event.
171 */
172 void SetFont(const wxFont& f);
173 };
174