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