]> git.saurik.com Git - wxWidgets.git/blob - src/richtext/richtextfontpage.cpp
fix wxCHECK_MSG() return value
[wxWidgets.git] / src / richtext / richtextfontpage.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextfontpage.cpp
3 // Purpose: Font page for wxRichTextFormattingDialog
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 2006-10-02
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/richtext/richtextfontpage.h"
13
14 /*!
15 * wxRichTextFontPage type definition
16 */
17
18 IMPLEMENT_DYNAMIC_CLASS( wxRichTextFontPage, wxRichTextDialogPage )
19
20 /*!
21 * wxRichTextFontPage event table definition
22 */
23
24 BEGIN_EVENT_TABLE( wxRichTextFontPage, wxRichTextDialogPage )
25 EVT_LISTBOX( ID_RICHTEXTFONTPAGE_FACELISTBOX, wxRichTextFontPage::OnFaceListBoxSelected )
26 EVT_BUTTON( ID_RICHTEXTFONTPAGE_COLOURCTRL, wxRichTextFontPage::OnColourClicked )
27 EVT_BUTTON( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxRichTextFontPage::OnColourClicked )
28
29 ////@begin wxRichTextFontPage event table entries
30 EVT_IDLE( wxRichTextFontPage::OnIdle )
31
32 EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxRichTextFontPage::OnFaceTextCtrlUpdated )
33
34 EVT_TEXT( ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxRichTextFontPage::OnSizeTextCtrlUpdated )
35
36 EVT_SPIN_UP( ID_RICHTEXTFONTPAGE_SPINBUTTONS, wxRichTextFontPage::OnRichtextfontpageSpinbuttonsUp )
37 EVT_SPIN_DOWN( ID_RICHTEXTFONTPAGE_SPINBUTTONS, wxRichTextFontPage::OnRichtextfontpageSpinbuttonsDown )
38
39 EVT_CHOICE( ID_RICHTEXTFONTPAGE_SIZE_UNITS, wxRichTextFontPage::OnRichtextfontpageSizeUnitsSelected )
40
41 EVT_LISTBOX( ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxRichTextFontPage::OnSizeListBoxSelected )
42
43 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_STYLECTRL, wxRichTextFontPage::OnStyleCtrlSelected )
44
45 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxRichTextFontPage::OnWeightCtrlSelected )
46
47 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxRichTextFontPage::OnUnderliningCtrlSelected )
48
49 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected )
50
51 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected )
52
53 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, wxRichTextFontPage::OnStrikethroughctrlClick )
54
55 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL, wxRichTextFontPage::OnCapsctrlClick )
56
57 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SMALLCAPSCTRL, wxRichTextFontPage::OnCapsctrlClick )
58
59 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUPERSCRIPT, wxRichTextFontPage::OnRichtextfontpageSuperscriptClick )
60
61 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUBSCRIPT, wxRichTextFontPage::OnRichtextfontpageSubscriptClick )
62
63 ////@end wxRichTextFontPage event table entries
64
65 END_EVENT_TABLE()
66
67 IMPLEMENT_HELP_PROVISION(wxRichTextFontPage)
68 /*!
69 * wxRichTextFontPage constructors
70 */
71
72 wxRichTextFontPage::wxRichTextFontPage( )
73 {
74 Init();
75 }
76
77 wxRichTextFontPage::wxRichTextFontPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
78 {
79 Init();
80 Create(parent, id, pos, size, style);
81 }
82
83 /*!
84 * Initialise members
85 */
86
87 void wxRichTextFontPage::Init()
88 {
89 m_dontUpdate = false;
90 m_colourPresent = false;
91 m_bgColourPresent = false;
92
93 ////@begin wxRichTextFontPage member initialisation
94 m_faceTextCtrl = NULL;
95 m_sizeTextCtrl = NULL;
96 m_fontSizeSpinButtons = NULL;
97 m_sizeUnitsCtrl = NULL;
98 m_fontListBoxParent = NULL;
99 m_faceListBox = NULL;
100 m_sizeListBox = NULL;
101 m_styleCtrl = NULL;
102 m_weightCtrl = NULL;
103 m_underliningCtrl = NULL;
104 m_textColourLabel = NULL;
105 m_colourCtrl = NULL;
106 m_bgColourLabel = NULL;
107 m_bgColourCtrl = NULL;
108 m_strikethroughCtrl = NULL;
109 m_capitalsCtrl = NULL;
110 m_smallCapitalsCtrl = NULL;
111 m_superscriptCtrl = NULL;
112 m_subscriptCtrl = NULL;
113 m_previewCtrl = NULL;
114 ////@end wxRichTextFontPage member initialisation
115 }
116
117 /*!
118 * wxRichTextFontPage creator
119 */
120
121 bool wxRichTextFontPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
122 {
123 ////@begin wxRichTextFontPage creation
124 wxRichTextDialogPage::Create( parent, id, pos, size, style );
125
126 CreateControls();
127 if (GetSizer())
128 {
129 GetSizer()->SetSizeHints(this);
130 }
131 Centre();
132 ////@end wxRichTextFontPage creation
133 return true;
134 }
135
136 /*!
137 * Control creation for wxRichTextFontPage
138 */
139
140 void wxRichTextFontPage::CreateControls()
141 {
142 ////@begin wxRichTextFontPage content construction
143 wxRichTextFontPage* itemRichTextDialogPage1 = this;
144
145 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
146 itemRichTextDialogPage1->SetSizer(itemBoxSizer2);
147
148 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
149 itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
150
151 wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
152 itemBoxSizer3->Add(itemBoxSizer4, 1, wxGROW, 5);
153
154 wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
155 itemBoxSizer4->Add(itemBoxSizer5, 1, wxGROW, 5);
156
157 wxStaticText* itemStaticText6 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Font:"), wxDefaultPosition, wxDefaultSize, 0 );
158 itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
159
160 m_faceTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
161 m_faceTextCtrl->SetHelpText(_("Type a font name."));
162 if (wxRichTextFontPage::ShowToolTips())
163 m_faceTextCtrl->SetToolTip(_("Type a font name."));
164 itemBoxSizer5->Add(m_faceTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
165
166 wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL);
167 itemBoxSizer4->Add(itemBoxSizer8, 0, wxGROW, 5);
168
169 wxStaticText* itemStaticText9 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 );
170 itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
171
172 wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
173 itemBoxSizer8->Add(itemBoxSizer10, 0, wxGROW, 5);
174
175 m_sizeTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
176 m_sizeTextCtrl->SetHelpText(_("Type a size in points."));
177 if (wxRichTextFontPage::ShowToolTips())
178 m_sizeTextCtrl->SetToolTip(_("Type a size in points."));
179 itemBoxSizer10->Add(m_sizeTextCtrl, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5);
180
181 m_fontSizeSpinButtons = new wxSpinButton( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SPINBUTTONS, wxDefaultPosition, wxSize(-1, 20), wxSP_VERTICAL );
182 m_fontSizeSpinButtons->SetRange(0, 100);
183 m_fontSizeSpinButtons->SetValue(0);
184 itemBoxSizer10->Add(m_fontSizeSpinButtons, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5);
185
186 wxArrayString m_sizeUnitsCtrlStrings;
187 m_sizeUnitsCtrlStrings.Add(_("pt"));
188 m_sizeUnitsCtrlStrings.Add(_("px"));
189 m_sizeUnitsCtrl = new wxChoice( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZE_UNITS, wxDefaultPosition, wxDefaultSize, m_sizeUnitsCtrlStrings, 0 );
190 m_sizeUnitsCtrl->SetStringSelection(_("pt"));
191 m_sizeUnitsCtrl->SetHelpText(_("The font size units, points or pixels."));
192 if (wxRichTextFontPage::ShowToolTips())
193 m_sizeUnitsCtrl->SetToolTip(_("The font size units, points or pixels."));
194 itemBoxSizer10->Add(m_sizeUnitsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5);
195
196 m_fontListBoxParent = new wxBoxSizer(wxHORIZONTAL);
197 itemBoxSizer3->Add(m_fontListBoxParent, 0, wxGROW, 5);
198
199 m_faceListBox = new wxRichTextFontListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 100), 0 );
200 m_faceListBox->SetHelpText(_("Lists the available fonts."));
201 if (wxRichTextFontPage::ShowToolTips())
202 m_faceListBox->SetToolTip(_("Lists the available fonts."));
203 m_fontListBoxParent->Add(m_faceListBox, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 5);
204
205 wxArrayString m_sizeListBoxStrings;
206 m_sizeListBox = new wxListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), m_sizeListBoxStrings, wxLB_SINGLE );
207 m_sizeListBox->SetHelpText(_("Lists font sizes in points."));
208 if (wxRichTextFontPage::ShowToolTips())
209 m_sizeListBox->SetToolTip(_("Lists font sizes in points."));
210 m_fontListBoxParent->Add(m_sizeListBox, 0, wxGROW|wxALL|wxFIXED_MINSIZE, 5);
211
212 wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxHORIZONTAL);
213 itemBoxSizer3->Add(itemBoxSizer17, 0, wxGROW, 5);
214
215 wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL);
216 itemBoxSizer17->Add(itemBoxSizer18, 0, wxGROW, 5);
217
218 wxStaticText* itemStaticText19 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font st&yle:"), wxDefaultPosition, wxDefaultSize, 0 );
219 itemBoxSizer18->Add(itemStaticText19, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
220
221 wxArrayString m_styleCtrlStrings;
222 m_styleCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STYLECTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_styleCtrlStrings, wxCB_READONLY );
223 m_styleCtrl->SetHelpText(_("Select regular or italic style."));
224 if (wxRichTextFontPage::ShowToolTips())
225 m_styleCtrl->SetToolTip(_("Select regular or italic style."));
226 itemBoxSizer18->Add(m_styleCtrl, 0, wxGROW|wxALL, 5);
227
228 wxBoxSizer* itemBoxSizer21 = new wxBoxSizer(wxVERTICAL);
229 itemBoxSizer17->Add(itemBoxSizer21, 0, wxGROW, 5);
230
231 wxStaticText* itemStaticText22 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 );
232 itemBoxSizer21->Add(itemStaticText22, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
233
234 wxArrayString m_weightCtrlStrings;
235 m_weightCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_weightCtrlStrings, wxCB_READONLY );
236 m_weightCtrl->SetHelpText(_("Select regular or bold."));
237 if (wxRichTextFontPage::ShowToolTips())
238 m_weightCtrl->SetToolTip(_("Select regular or bold."));
239 itemBoxSizer21->Add(m_weightCtrl, 0, wxGROW|wxALL, 5);
240
241 wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL);
242 itemBoxSizer17->Add(itemBoxSizer24, 0, wxGROW, 5);
243
244 wxStaticText* itemStaticText25 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 );
245 itemBoxSizer24->Add(itemStaticText25, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
246
247 wxArrayString m_underliningCtrlStrings;
248 m_underliningCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_underliningCtrlStrings, wxCB_READONLY );
249 m_underliningCtrl->SetHelpText(_("Select underlining or no underlining."));
250 if (wxRichTextFontPage::ShowToolTips())
251 m_underliningCtrl->SetToolTip(_("Select underlining or no underlining."));
252 itemBoxSizer24->Add(m_underliningCtrl, 0, wxGROW|wxALL, 5);
253
254 itemBoxSizer17->Add(0, 0, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
255
256 wxBoxSizer* itemBoxSizer28 = new wxBoxSizer(wxVERTICAL);
257 itemBoxSizer17->Add(itemBoxSizer28, 0, wxGROW, 5);
258
259 m_textColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 );
260 m_textColourLabel->SetValue(false);
261 itemBoxSizer28->Add(m_textColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
262
263 m_colourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 );
264 m_colourCtrl->SetHelpText(_("Click to change the text colour."));
265 if (wxRichTextFontPage::ShowToolTips())
266 m_colourCtrl->SetToolTip(_("Click to change the text colour."));
267 itemBoxSizer28->Add(m_colourCtrl, 0, wxGROW|wxALL, 5);
268
269 wxBoxSizer* itemBoxSizer31 = new wxBoxSizer(wxVERTICAL);
270 itemBoxSizer17->Add(itemBoxSizer31, 0, wxGROW, 5);
271
272 m_bgColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 );
273 m_bgColourLabel->SetValue(false);
274 itemBoxSizer31->Add(m_bgColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
275
276 m_bgColourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 );
277 m_bgColourCtrl->SetHelpText(_("Click to change the text background colour."));
278 if (wxRichTextFontPage::ShowToolTips())
279 m_bgColourCtrl->SetToolTip(_("Click to change the text background colour."));
280 itemBoxSizer31->Add(m_bgColourCtrl, 0, wxGROW|wxALL, 5);
281
282 wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxHORIZONTAL);
283 itemBoxSizer3->Add(itemBoxSizer34, 0, wxGROW, 5);
284
285 m_strikethroughCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, _("&Strikethrough"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
286 m_strikethroughCtrl->SetValue(false);
287 m_strikethroughCtrl->SetHelpText(_("Check to show a line through the text."));
288 if (wxRichTextFontPage::ShowToolTips())
289 m_strikethroughCtrl->SetToolTip(_("Check to show a line through the text."));
290 itemBoxSizer34->Add(m_strikethroughCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
291
292 m_capitalsCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_CAPSCTRL, _("Ca&pitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
293 m_capitalsCtrl->SetValue(false);
294 m_capitalsCtrl->SetHelpText(_("Check to show the text in capitals."));
295 if (wxRichTextFontPage::ShowToolTips())
296 m_capitalsCtrl->SetToolTip(_("Check to show the text in capitals."));
297 itemBoxSizer34->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
298
299 m_smallCapitalsCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SMALLCAPSCTRL, _("Small C&apitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
300 m_smallCapitalsCtrl->SetValue(false);
301 m_smallCapitalsCtrl->SetHelpText(_("Check to show the text in small capitals."));
302 if (wxRichTextFontPage::ShowToolTips())
303 m_smallCapitalsCtrl->SetToolTip(_("Check to show the text in small capitals."));
304 itemBoxSizer34->Add(m_smallCapitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
305
306 m_superscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUPERSCRIPT, _("Supe&rscript"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
307 m_superscriptCtrl->SetValue(false);
308 m_superscriptCtrl->SetHelpText(_("Check to show the text in superscript."));
309 if (wxRichTextFontPage::ShowToolTips())
310 m_superscriptCtrl->SetToolTip(_("Check to show the text in superscript."));
311 itemBoxSizer34->Add(m_superscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
312
313 m_subscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUBSCRIPT, _("Subscrip&t"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
314 m_subscriptCtrl->SetValue(false);
315 m_subscriptCtrl->SetHelpText(_("Check to show the text in subscript."));
316 if (wxRichTextFontPage::ShowToolTips())
317 m_subscriptCtrl->SetToolTip(_("Check to show the text in subscript."));
318 itemBoxSizer34->Add(m_subscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
319
320 itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5);
321
322 m_previewCtrl = new wxRichTextFontPreviewCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 60), 0 );
323 m_previewCtrl->SetHelpText(_("Shows a preview of the font settings."));
324 if (wxRichTextFontPage::ShowToolTips())
325 m_previewCtrl->SetToolTip(_("Shows a preview of the font settings."));
326 itemBoxSizer3->Add(m_previewCtrl, 0, wxGROW|wxALL, 5);
327
328 ////@end wxRichTextFontPage content construction
329
330 m_faceListBox->UpdateFonts();
331
332 m_styleCtrl->Append(_("(none)"));
333 m_styleCtrl->Append(_("Regular"));
334 m_styleCtrl->Append(_("Italic"));
335
336 m_weightCtrl->Append(_("(none)"));
337 m_weightCtrl->Append(_("Regular"));
338 m_weightCtrl->Append(_("Bold"));
339
340 m_underliningCtrl->Append(_("(none)"));
341 m_underliningCtrl->Append(_("Not underlined"));
342 m_underliningCtrl->Append(_("Underlined"));
343
344 wxString nStr;
345 int i;
346 for (i = 8; i < 40; i++)
347 {
348 nStr.Printf(wxT("%d"), i);
349 m_sizeListBox->Append(nStr);
350 }
351 m_sizeListBox->Append(wxT("48"));
352 m_sizeListBox->Append(wxT("72"));
353 }
354
355 /// Transfer data from/to window
356 bool wxRichTextFontPage::TransferDataFromWindow()
357 {
358 wxPanel::TransferDataFromWindow();
359
360 wxRichTextAttr* attr = GetAttributes();
361
362 if (!m_faceTextCtrl->GetValue().IsEmpty())
363 {
364 wxString faceName = m_faceTextCtrl->GetValue();
365 attr->SetFontFaceName(faceName);
366 }
367 else
368 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_FACE));
369
370 wxString strSize = m_sizeTextCtrl->GetValue();
371 if (!strSize.IsEmpty())
372 {
373 int sz = wxAtoi(strSize);
374 if (sz > 0)
375 {
376 if (m_sizeUnitsCtrl->GetSelection() == 0)
377 attr->SetFontPointSize(sz);
378 else
379 attr->SetFontPixelSize(sz);
380 }
381 }
382 else
383 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE));
384
385 if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0)
386 {
387 wxFontStyle style;
388 if (m_styleCtrl->GetSelection() == 2)
389 style = wxFONTSTYLE_ITALIC;
390 else
391 style = wxFONTSTYLE_NORMAL;
392
393 attr->SetFontStyle(style);
394 }
395 else
396 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC));
397
398 if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0)
399 {
400 wxFontWeight weight;
401 if (m_weightCtrl->GetSelection() == 2)
402 weight = wxFONTWEIGHT_BOLD;
403 else
404 weight = wxFONTWEIGHT_NORMAL;
405
406 attr->SetFontWeight(weight);
407 }
408 else
409 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT));
410
411 if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0)
412 {
413 bool underlined;
414 if (m_underliningCtrl->GetSelection() == 2)
415 underlined = true;
416 else
417 underlined = false;
418
419 attr->SetFontUnderlined(underlined);
420 }
421 else
422 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE));
423
424 if (m_textColourLabel->GetValue())
425 {
426 attr->SetTextColour(m_colourCtrl->GetColour());
427 }
428 else
429 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR));
430
431 if (m_bgColourLabel->GetValue())
432 {
433 attr->SetBackgroundColour(m_bgColourCtrl->GetColour());
434 }
435 else
436 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_BACKGROUND_COLOUR));
437
438 if (m_strikethroughCtrl->Get3StateValue() != wxCHK_UNDETERMINED)
439 {
440 attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH);
441
442 if (m_strikethroughCtrl->Get3StateValue() == wxCHK_CHECKED)
443 attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH);
444 else
445 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH);
446 }
447 else
448 {
449 attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH);
450 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH);
451 }
452
453 if (m_capitalsCtrl->Get3StateValue() != wxCHK_UNDETERMINED)
454 {
455 attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_CAPITALS);
456
457 if (m_capitalsCtrl->Get3StateValue() == wxCHK_CHECKED)
458 attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_CAPITALS);
459 else
460 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS);
461 }
462 else
463 {
464 attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_CAPITALS);
465 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS);
466 }
467
468 if (m_smallCapitalsCtrl->Get3StateValue() != wxCHK_UNDETERMINED)
469 {
470 attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SMALL_CAPITALS);
471
472 if (m_smallCapitalsCtrl->Get3StateValue() == wxCHK_CHECKED)
473 attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_SMALL_CAPITALS);
474 else
475 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SMALL_CAPITALS);
476 }
477 else
478 {
479 attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_SMALL_CAPITALS);
480 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SMALL_CAPITALS);
481 }
482
483 if (m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
484 {
485 attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT);
486 attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT);
487 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUBSCRIPT);
488 }
489 else if (m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
490 {
491 attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUBSCRIPT);
492 attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUBSCRIPT);
493 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUPERSCRIPT);
494 }
495 else
496 {
497 // If they are undetermined, we don't want to include these flags in the text effects - the objects
498 // should retain their original style.
499 attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT|wxTEXT_ATTR_EFFECT_SUPERSCRIPT) );
500 attr->SetTextEffects(attr->GetTextEffects() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT|wxTEXT_ATTR_EFFECT_SUPERSCRIPT) );
501 }
502
503 if (attr->GetTextEffectFlags() == 0)
504 attr->SetFlags(attr->GetFlags() & ~wxTEXT_ATTR_EFFECTS);
505
506 return true;
507 }
508
509 bool wxRichTextFontPage::TransferDataToWindow()
510 {
511 wxPanel::TransferDataToWindow();
512
513 m_dontUpdate = true;
514 wxRichTextAttr* attr = GetAttributes();
515
516 if (attr->HasFontFaceName())
517 {
518 m_faceTextCtrl->SetValue(attr->GetFontFaceName());
519 m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName());
520 }
521 else
522 {
523 m_faceTextCtrl->SetValue(wxEmptyString);
524 m_faceListBox->SetFaceNameSelection(wxEmptyString);
525 }
526
527 if (attr->HasFontPointSize())
528 {
529 wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize());
530 m_sizeTextCtrl->SetValue(strSize);
531 m_sizeUnitsCtrl->SetSelection(0);
532 if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
533 m_sizeListBox->SetStringSelection(strSize);
534 }
535 else if (attr->HasFontPixelSize())
536 {
537 wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize());
538 m_sizeTextCtrl->SetValue(strSize);
539 m_sizeUnitsCtrl->SetSelection(1);
540 m_sizeListBox->SetSelection(wxNOT_FOUND);
541 }
542 else
543 {
544 m_sizeTextCtrl->SetValue(wxEmptyString);
545 m_sizeListBox->SetSelection(wxNOT_FOUND);
546 }
547
548 if (attr->HasFontWeight())
549 {
550 if (attr->GetFontWeight() == wxFONTWEIGHT_BOLD)
551 m_weightCtrl->SetSelection(2);
552 else
553 m_weightCtrl->SetSelection(1);
554 }
555 else
556 {
557 m_weightCtrl->SetSelection(0);
558 }
559
560 if (attr->HasFontItalic())
561 {
562 if (attr->GetFontStyle() == wxFONTSTYLE_ITALIC)
563 m_styleCtrl->SetSelection(2);
564 else
565 m_styleCtrl->SetSelection(1);
566 }
567 else
568 {
569 m_styleCtrl->SetSelection(0);
570 }
571
572 if (attr->HasFontUnderlined())
573 {
574 if (attr->GetFontUnderlined())
575 m_underliningCtrl->SetSelection(2);
576 else
577 m_underliningCtrl->SetSelection(1);
578 }
579 else
580 {
581 m_underliningCtrl->SetSelection(0);
582 }
583
584 if (attr->HasTextColour())
585 {
586 m_colourCtrl->SetColour(attr->GetTextColour());
587 m_textColourLabel->SetValue(true);
588 m_colourPresent = true;
589 }
590 else
591 {
592 m_colourCtrl->SetColour(*wxBLACK);
593 m_textColourLabel->SetValue(false);
594 }
595
596 if (attr->HasBackgroundColour())
597 {
598 m_bgColourCtrl->SetColour(attr->GetBackgroundColour());
599 m_bgColourLabel->SetValue(true);
600 m_bgColourPresent = true;
601 }
602 else
603 {
604 m_bgColourCtrl->SetColour(*wxWHITE);
605 m_bgColourLabel->SetValue(false);
606 }
607
608 if (attr->HasTextEffects())
609 {
610 if (attr->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH)
611 {
612 if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH)
613 m_strikethroughCtrl->Set3StateValue(wxCHK_CHECKED);
614 else
615 m_strikethroughCtrl->Set3StateValue(wxCHK_UNCHECKED);
616 }
617 else
618 m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED);
619
620 if (attr->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_CAPITALS)
621 {
622 if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS)
623 m_capitalsCtrl->Set3StateValue(wxCHK_CHECKED);
624 else
625 m_capitalsCtrl->Set3StateValue(wxCHK_UNCHECKED);
626 }
627 else
628 m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED);
629
630 if (attr->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS)
631 {
632 if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS)
633 m_smallCapitalsCtrl->Set3StateValue(wxCHK_CHECKED);
634 else
635 m_smallCapitalsCtrl->Set3StateValue(wxCHK_UNCHECKED);
636 }
637 else
638 m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED);
639
640 if ( attr->GetTextEffectFlags() & (wxTEXT_ATTR_EFFECT_SUPERSCRIPT | wxTEXT_ATTR_EFFECT_SUBSCRIPT) )
641 {
642 if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT)
643 {
644 m_superscriptCtrl->Set3StateValue(wxCHK_CHECKED);
645 m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED);
646 }
647 else if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT)
648 {
649 m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED);
650 m_subscriptCtrl->Set3StateValue(wxCHK_CHECKED);
651 }
652 else
653 {
654 m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED);
655 m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED);
656 }
657 }
658 else
659 {
660 m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
661 m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
662 }
663 }
664 else
665 {
666 m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED);
667 m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED);
668 m_smallCapitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED);
669 m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
670 m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
671 }
672
673 UpdatePreview();
674
675 m_dontUpdate = false;
676
677 return true;
678 }
679
680 wxRichTextAttr* wxRichTextFontPage::GetAttributes()
681 {
682 return wxRichTextFormattingDialog::GetDialogAttributes(this);
683 }
684
685 /// Updates the font preview
686 void wxRichTextFontPage::UpdatePreview()
687 {
688 wxRichTextAttr attr;
689
690 if (m_textColourLabel->GetValue())
691 m_previewCtrl->SetForegroundColour(m_colourCtrl->GetColour());
692 else
693 {
694 m_previewCtrl->SetForegroundColour(*wxBLACK);
695 if (!(m_colourCtrl->GetColour() == *wxBLACK))
696 {
697 m_colourCtrl->SetColour(*wxBLACK);
698 m_colourCtrl->Refresh();
699 }
700 }
701
702 if (m_bgColourLabel->GetValue())
703 m_previewCtrl->SetBackgroundColour(m_bgColourCtrl->GetColour());
704 else
705 {
706 m_previewCtrl->SetBackgroundColour(*wxWHITE);
707
708 if (!(m_bgColourCtrl->GetColour() == *wxWHITE))
709 {
710 m_bgColourCtrl->SetColour(*wxWHITE);
711 m_bgColourCtrl->Refresh();
712 }
713 }
714
715 if (m_faceListBox->GetSelection() != wxNOT_FOUND)
716 {
717 wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection());
718 attr.SetFontFaceName(faceName);
719 }
720
721 wxString strSize = m_sizeTextCtrl->GetValue();
722 if (!strSize.IsEmpty())
723 {
724 int sz = wxAtoi(strSize);
725 if (sz > 0)
726 {
727 if (m_sizeUnitsCtrl->GetSelection() == 1)
728 attr.SetFontPixelSize(sz);
729 else
730 attr.SetFontPointSize(sz);
731 }
732 }
733
734 if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0)
735 {
736 wxFontStyle style;
737 if (m_styleCtrl->GetSelection() == 2)
738 style = wxFONTSTYLE_ITALIC;
739 else
740 style = wxFONTSTYLE_NORMAL;
741
742 attr.SetFontStyle(style);
743 }
744
745 if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0)
746 {
747 wxFontWeight weight;
748 if (m_weightCtrl->GetSelection() == 2)
749 weight = wxFONTWEIGHT_BOLD;
750 else
751 weight = wxFONTWEIGHT_NORMAL;
752
753 attr.SetFontWeight(weight);
754 }
755
756 if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0)
757 {
758 bool underlined;
759 if (m_underliningCtrl->GetSelection() == 2)
760 underlined = true;
761 else
762 underlined = false;
763
764 attr.SetFontUnderlined(underlined);
765 }
766
767 int textEffects = 0;
768
769 if (m_strikethroughCtrl->Get3StateValue() == wxCHK_CHECKED)
770 {
771 textEffects |= wxTEXT_ATTR_EFFECT_STRIKETHROUGH;
772 }
773
774 if (m_capitalsCtrl->Get3StateValue() == wxCHK_CHECKED)
775 {
776 textEffects |= wxTEXT_ATTR_EFFECT_CAPITALS;
777 }
778
779 if (m_smallCapitalsCtrl->Get3StateValue() == wxCHK_CHECKED)
780 {
781 textEffects |= wxTEXT_ATTR_EFFECT_SMALL_CAPITALS;
782 }
783
784 if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED )
785 textEffects |= wxTEXT_ATTR_EFFECT_SUPERSCRIPT;
786 else if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED )
787 textEffects |= wxTEXT_ATTR_EFFECT_SUBSCRIPT;
788
789 wxFont font = attr.GetFont();
790 m_previewCtrl->SetFont(font);
791 m_previewCtrl->SetTextEffects(textEffects);
792 m_previewCtrl->Refresh();
793 }
794
795 /*!
796 * Should we show tooltips?
797 */
798
799 bool wxRichTextFontPage::ShowToolTips()
800 {
801 return wxRichTextFormattingDialog::ShowToolTips();
802 }
803
804 /*!
805 * Get bitmap resources
806 */
807
808 wxBitmap wxRichTextFontPage::GetBitmapResource( const wxString& name )
809 {
810 // Bitmap retrieval
811 ////@begin wxRichTextFontPage bitmap retrieval
812 wxUnusedVar(name);
813 return wxNullBitmap;
814 ////@end wxRichTextFontPage bitmap retrieval
815 }
816
817 /*!
818 * Get icon resources
819 */
820
821 wxIcon wxRichTextFontPage::GetIconResource( const wxString& name )
822 {
823 // Icon retrieval
824 ////@begin wxRichTextFontPage icon retrieval
825 wxUnusedVar(name);
826 return wxNullIcon;
827 ////@end wxRichTextFontPage icon retrieval
828 }
829
830 /*!
831 * wxEVT_TEXT event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL
832 */
833
834 void wxRichTextFontPage::OnFaceTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) )
835 {
836 if (m_dontUpdate)
837 return;
838
839 wxString facename = m_faceTextCtrl->GetValue();
840 if (!facename.IsEmpty())
841 {
842 if (m_faceListBox->HasFaceName(facename))
843 {
844 m_faceListBox->SetFaceNameSelection(facename);
845 UpdatePreview();
846 }
847 else
848 {
849 // Try to find a partial match
850 const wxArrayString& arr = m_faceListBox->GetFaceNames();
851 size_t i;
852 for (i = 0; i < arr.GetCount(); i++)
853 {
854 if (arr[i].Mid(0, facename.Length()).Lower() == facename.Lower())
855 {
856 m_faceListBox->ScrollToRow(i);
857 break;
858 }
859 }
860 }
861 }
862 }
863
864
865 /*!
866 * wxEVT_TEXT event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
867 */
868
869 void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) )
870 {
871 if (m_dontUpdate)
872 return;
873
874 wxString strSize = m_sizeTextCtrl->GetValue();
875 if (!strSize.IsEmpty() && m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
876 m_sizeListBox->SetStringSelection(strSize);
877 UpdatePreview();
878 }
879
880
881 /*!
882 * wxEVT_LISTBOX event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX
883 */
884
885 void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event )
886 {
887 bool oldDontUpdate = m_dontUpdate;
888 m_dontUpdate = true;
889
890 m_sizeTextCtrl->SetValue(event.GetString());
891
892 m_dontUpdate = oldDontUpdate;
893
894 if (m_dontUpdate)
895 return;
896
897 UpdatePreview();
898 }
899
900 /*!
901 * wxEVT_LISTBOX event handler for ID_RICHTEXTFONTPAGE_FACELISTBOX
902 */
903
904 void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) )
905 {
906 bool oldDontUpdate = m_dontUpdate;
907 m_dontUpdate = true;
908
909 m_faceTextCtrl->SetValue(m_faceListBox->GetFaceName(m_faceListBox->GetSelection()));
910
911 m_dontUpdate = oldDontUpdate;
912
913 if (m_dontUpdate)
914 return;
915
916 UpdatePreview();
917 }
918
919 /*!
920 * wxEVT_COMBOBOX event handler for ID_RICHTEXTFONTPAGE_STYLECTRL
921 */
922
923 void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) )
924 {
925 if (m_dontUpdate)
926 return;
927
928 UpdatePreview();
929 }
930
931
932 /*!
933 * wxEVT_COMBOBOX event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
934 */
935
936 void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(event) )
937 {
938 if (m_dontUpdate)
939 return;
940
941 UpdatePreview();
942 }
943
944
945 /*!
946 * wxEVT_COMBOBOX event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL
947 */
948
949 void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent& WXUNUSED(event) )
950 {
951 if (m_dontUpdate)
952 return;
953
954 UpdatePreview();
955 }
956
957 void wxRichTextFontPage::OnColourClicked( wxCommandEvent& event )
958 {
959 if (event.GetId() == m_colourCtrl->GetId())
960 m_colourPresent = true;
961 else if (event.GetId() == m_bgColourCtrl->GetId())
962 m_bgColourPresent = true;
963
964 m_dontUpdate = true;
965
966 if (event.GetId() == m_colourCtrl->GetId())
967 {
968 m_textColourLabel->SetValue(true);
969 }
970 else if (event.GetId() == m_bgColourCtrl->GetId())
971 {
972 m_bgColourLabel->SetValue(true);
973 }
974
975 m_dontUpdate = false;
976
977 UpdatePreview();
978 }
979 /*!
980 * wxEVT_CHECKBOX event handler for ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL
981 */
982
983 void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(event) )
984 {
985 if (m_dontUpdate)
986 return;
987
988 UpdatePreview();
989 }
990
991 /*!
992 * wxEVT_CHECKBOX event handler for ID_RICHTEXTFONTPAGE_CAPSCTRL
993 */
994
995 void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) )
996 {
997 if (m_dontUpdate)
998 return;
999
1000 UpdatePreview();
1001 }
1002
1003 /*!
1004 * wxEVT_CHECKBOX event handler for ID_RICHTEXTFONTPAGE_SUPERSCRIPT
1005 */
1006
1007 void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) )
1008 {
1009 if (m_dontUpdate)
1010 return;
1011
1012 if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
1013 m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED );
1014
1015 UpdatePreview();
1016 }
1017
1018 /*!
1019 * wxEVT_CHECKBOX event handler for ID_RICHTEXTFONTPAGE_SUBSCRIPT
1020 */
1021
1022 void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) )
1023 {
1024 if (m_dontUpdate)
1025 return;
1026
1027 if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
1028 m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED );
1029
1030 UpdatePreview();
1031 }
1032
1033 /*!
1034 * wxEVT_CHOICE event handler for ID_RICHTEXTFONTPAGE_SIZE_UNITS
1035 */
1036
1037 void wxRichTextFontPage::OnRichtextfontpageSizeUnitsSelected( wxCommandEvent& WXUNUSED(event) )
1038 {
1039 if (m_dontUpdate)
1040 return;
1041
1042 UpdatePreview();
1043 }
1044
1045 /*!
1046 * wxEVT_SPINCTRL event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS
1047 */
1048
1049 void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsUp( wxSpinEvent& WXUNUSED(event) )
1050 {
1051 wxString text = m_sizeTextCtrl->GetValue();
1052 if (!text.IsEmpty())
1053 {
1054 int size = wxAtoi(text);
1055 if (size > 0)
1056 {
1057 size ++;
1058 m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size));
1059 UpdatePreview();
1060 }
1061 }
1062 }
1063
1064 /*!
1065 * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS
1066 */
1067
1068 void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsDown( wxSpinEvent& WXUNUSED(event) )
1069 {
1070 wxString text = m_sizeTextCtrl->GetValue();
1071 if (!text.IsEmpty())
1072 {
1073 int size = wxAtoi(text);
1074 if (size > 0)
1075 {
1076 size --;
1077 m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size));
1078 UpdatePreview();
1079 }
1080 }
1081 }
1082
1083 /*!
1084 * wxEVT_IDLE event handler for ID_RICHTEXTFONTPAGE
1085 */
1086
1087 void wxRichTextFontPage::OnIdle( wxIdleEvent& WXUNUSED(event) )
1088 {
1089 if (!m_sizeUnitsCtrl)
1090 return;
1091
1092 if (m_sizeUnitsCtrl->GetSelection() == 1 && m_sizeListBox->IsShown())
1093 {
1094 m_fontListBoxParent->Show(m_sizeListBox, false);
1095 Layout();
1096 }
1097 else if (m_sizeUnitsCtrl->GetSelection() == 0 && !m_sizeListBox->IsShown())
1098 {
1099 m_fontListBoxParent->Show(m_sizeListBox, true);
1100 Layout();
1101 }
1102 if (!wxRichTextFormattingDialog::GetDialog(this)->HasOption(wxRichTextFormattingDialog::Option_AllowPixelFontSize) &&
1103 m_sizeUnitsCtrl->IsEnabled())
1104 {
1105 m_sizeUnitsCtrl->Disable();
1106 }
1107 }