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