]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: fontpicker.h | |
3 | // Purpose: interface of wxFontPickerCtrl | |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxFontPickerCtrl | |
11 | ||
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 | |
15 | font-chooser dialog. | |
16 | It is only available if @c wxUSE_FONTPICKERCTRL is set to 1 (the default). | |
17 | ||
18 | @beginStyleTable | |
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. | |
34 | @endStyleTable | |
35 | ||
36 | @beginEventEmissionTable{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). | |
41 | @endEventTable | |
42 | ||
43 | @library{wxcore} | |
44 | @category{pickers} | |
45 | @appearance{fontpickerctrl.png} | |
46 | ||
47 | @see wxFontDialog, wxFontPickerEvent | |
48 | */ | |
49 | class wxFontPickerCtrl : public wxPickerBase | |
50 | { | |
51 | public: | |
52 | /** | |
53 | Initializes the object and calls Create() with | |
54 | all the parameters. | |
55 | */ | |
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 = wxFontPickerCtrlNameStr); | |
63 | ||
64 | /** | |
65 | Creates this widget with given parameters. | |
66 | ||
67 | @param parent | |
68 | Parent window, must not be non-@NULL. | |
69 | @param id | |
70 | The identifier for the control. | |
71 | @param font | |
72 | The initial font shown in the control. | |
73 | If ::wxNullFont is given, the default font is used. | |
74 | @param pos | |
75 | Initial position. | |
76 | @param size | |
77 | Initial size. | |
78 | @param style | |
79 | The window style, see wxFNTP_* flags. | |
80 | @param validator | |
81 | Validator which can be used for additional date checks. | |
82 | @param name | |
83 | Control name. | |
84 | ||
85 | @return @true if the control was successfully created or @false if | |
86 | creation failed. | |
87 | */ | |
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); | |
95 | ||
96 | /** | |
97 | Returns the maximum point size value allowed for the user-chosen font. | |
98 | */ | |
99 | unsigned int GetMaxPointSize() const; | |
100 | ||
101 | /** | |
102 | Returns the currently selected font. | |
103 | Note that this function is completely different from wxWindow::GetFont. | |
104 | */ | |
105 | wxFont GetSelectedFont() const; | |
106 | ||
107 | /** | |
108 | Sets the maximum point size value allowed for the user-chosen font. | |
109 | ||
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. | |
115 | */ | |
116 | void SetMaxPointSize(unsigned int max); | |
117 | ||
118 | /** | |
119 | Sets the currently selected font. | |
120 | Note that this function is completely different from wxWindow::SetFont. | |
121 | */ | |
122 | void SetSelectedFont(const wxFont& font); | |
123 | }; | |
124 | ||
125 | ||
126 | ||
127 | /** | |
128 | @class wxFontPickerEvent | |
129 | ||
130 | This event class is used for the events generated by | |
131 | wxFontPickerCtrl. | |
132 | ||
133 | @beginEventTable{wxFontPickerEvent} | |
134 | @event{EVT_FONTPICKER_CHANGED(id, func)} | |
135 | Generated whenever the selected font changes. | |
136 | @endEventTable | |
137 | ||
138 | @library{wxcore} | |
139 | @category{events} | |
140 | ||
141 | @see wxFontPickerCtrl | |
142 | */ | |
143 | class wxFontPickerEvent : public wxCommandEvent | |
144 | { | |
145 | public: | |
146 | /** | |
147 | The constructor is not normally used by the user code. | |
148 | */ | |
149 | wxFontPickerEvent(wxObject* generator, int id, | |
150 | const wxFont& font); | |
151 | ||
152 | /** | |
153 | Retrieve the font the user has just selected. | |
154 | */ | |
155 | wxFont GetFont() const; | |
156 | ||
157 | /** | |
158 | Set the font associated with the event. | |
159 | */ | |
160 | void SetFont(const wxFont& f); | |
161 | }; | |
162 |