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