]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/fontpicker.h
Add richtext event types.
[wxWidgets.git] / interface / wx / fontpicker.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: fontpicker.h
e54c96f1 3// Purpose: interface of wxFontPickerCtrl
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
575821fa
RD
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
ce7fe42e 16wxEventType wxEVT_FONTPICKER_CHANGED;
575821fa
RD
17
18
23324ae1
FM
19/**
20 @class wxFontPickerCtrl
7c913512 21
23324ae1
FM
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
674d80a7 25 font-chooser dialog.
23324ae1 26 It is only available if @c wxUSE_FONTPICKERCTRL is set to 1 (the default).
7c913512 27
23324ae1 28 @beginStyleTable
8c6791e4 29 @style{wxFNTP_DEFAULT_STYLE}
674d80a7 30 The default style: wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL.
8c6791e4 31 @style{wxFNTP_USE_TEXTCTRL}
23324ae1
FM
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.
8c6791e4 37 @style{wxFNTP_FONTDESC_AS_LABEL}
23324ae1
FM
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.
8c6791e4 42 @style{wxFNTP_USEFONT_FOR_LABEL}
23324ae1
FM
43 Uses the currently selected font to draw the label of the button.
44 @endStyleTable
7c913512 45
3051a44a 46 @beginEventEmissionTable{wxFontPickerEvent}
674d80a7
FM
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
23324ae1 53 @library{wxcore}
d18d9f60 54 @category{pickers}
ce154616 55 @appearance{fontpickerctrl}
7c913512 56
e54c96f1 57 @see wxFontDialog, wxFontPickerEvent
23324ae1
FM
58*/
59class wxFontPickerCtrl : public wxPickerBase
60{
61public:
575821fa
RD
62 wxFontPickerCtrl();
63
23324ae1
FM
64 /**
65 Initializes the object and calls Create() with
66 all the parameters.
67 */
4cc4bfaf 68 wxFontPickerCtrl(wxWindow* parent, wxWindowID id,
23324ae1
FM
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,
a44f3b5a 74 const wxString& name = wxFontPickerCtrlNameStr);
23324ae1
FM
75
76 /**
674d80a7
FM
77 Creates this widget with given parameters.
78
7c913512 79 @param parent
4cc4bfaf 80 Parent window, must not be non-@NULL.
7c913512 81 @param id
4cc4bfaf 82 The identifier for the control.
7c913512 83 @param font
674d80a7
FM
84 The initial font shown in the control.
85 If ::wxNullFont is given, the default font is used.
7c913512 86 @param pos
4cc4bfaf 87 Initial position.
7c913512 88 @param size
4cc4bfaf 89 Initial size.
7c913512 90 @param style
4cc4bfaf 91 The window style, see wxFNTP_* flags.
7c913512 92 @param validator
4cc4bfaf 93 Validator which can be used for additional date checks.
7c913512 94 @param name
4cc4bfaf 95 Control name.
3c4f71cc 96
d29a9a8a 97 @return @true if the control was successfully created or @false if
4cc4bfaf 98 creation failed.
23324ae1 99 */
4cc4bfaf 100 bool Create(wxWindow* parent, wxWindowID id,
23324ae1
FM
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,
5267aefd 106 const wxString& name = wxFontPickerCtrlNameStr);
23324ae1
FM
107
108 /**
109 Returns the maximum point size value allowed for the user-chosen font.
110 */
328f5751 111 unsigned int GetMaxPointSize() const;
23324ae1
FM
112
113 /**
114 Returns the currently selected font.
115 Note that this function is completely different from wxWindow::GetFont.
116 */
328f5751 117 wxFont GetSelectedFont() const;
23324ae1
FM
118
119 /**
120 Sets the maximum point size value allowed for the user-chosen font.
674d80a7 121
23324ae1 122 The default value is 100. Note that big fonts can require a lot of memory and
674d80a7
FM
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.
23324ae1 127 */
37220641 128 void SetMaxPointSize(unsigned int max);
23324ae1
FM
129
130 /**
131 Sets the currently selected font.
132 Note that this function is completely different from wxWindow::SetFont.
133 */
4cc4bfaf 134 void SetSelectedFont(const wxFont& font);
23324ae1
FM
135};
136
137
e54c96f1 138
23324ae1
FM
139/**
140 @class wxFontPickerEvent
7c913512 141
23324ae1
FM
142 This event class is used for the events generated by
143 wxFontPickerCtrl.
7c913512 144
674d80a7
FM
145 @beginEventTable{wxFontPickerEvent}
146 @event{EVT_FONTPICKER_CHANGED(id, func)}
147 Generated whenever the selected font changes.
148 @endEventTable
149
23324ae1 150 @library{wxcore}
674d80a7 151 @category{events}
7c913512 152
e54c96f1 153 @see wxFontPickerCtrl
23324ae1
FM
154*/
155class wxFontPickerEvent : public wxCommandEvent
156{
157public:
158 /**
159 The constructor is not normally used by the user code.
160 */
4cc4bfaf 161 wxFontPickerEvent(wxObject* generator, int id,
23324ae1
FM
162 const wxFont& font);
163
164 /**
165 Retrieve the font the user has just selected.
166 */
328f5751 167 wxFont GetFont() const;
23324ae1
FM
168
169 /**
170 Set the font associated with the event.
171 */
4cc4bfaf 172 void SetFont(const wxFont& f);
23324ae1 173};
e54c96f1 174