]> git.saurik.com Git - wxWidgets.git/blame - src/richtext/richtextfontpage.cpp
update size hints when decoration size becomes known, and preserve size hint increments
[wxWidgets.git] / src / richtext / richtextfontpage.cpp
CommitLineData
97ff49b3 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/richtext/richtextfontpage.cpp
97ff49b3
JS
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
41a85215 12#include "wx/richtext/richtextfontpage.h"
97ff49b3 13
97ff49b3
JS
14/*!
15 * wxRichTextFontPage type definition
16 */
17
603f702b 18IMPLEMENT_DYNAMIC_CLASS( wxRichTextFontPage, wxRichTextDialogPage )
97ff49b3
JS
19
20/*!
21 * wxRichTextFontPage event table definition
22 */
23
603f702b 24BEGIN_EVENT_TABLE( wxRichTextFontPage, wxRichTextDialogPage )
97ff49b3
JS
25 EVT_LISTBOX( ID_RICHTEXTFONTPAGE_FACELISTBOX, wxRichTextFontPage::OnFaceListBoxSelected )
26 EVT_BUTTON( ID_RICHTEXTFONTPAGE_COLOURCTRL, wxRichTextFontPage::OnColourClicked )
50283a51 27 EVT_BUTTON( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxRichTextFontPage::OnColourClicked )
97ff49b3
JS
28
29////@begin wxRichTextFontPage event table entries
32423dd8
JS
30 EVT_IDLE( wxRichTextFontPage::OnIdle )
31
97ff49b3
JS
32 EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxRichTextFontPage::OnFaceTextCtrlUpdated )
33
34 EVT_TEXT( ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxRichTextFontPage::OnSizeTextCtrlUpdated )
35
32423dd8
JS
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
97ff49b3
JS
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
3c6cc330
JS
49 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected )
50
51 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected )
52
42688aea
JS
53 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, wxRichTextFontPage::OnStrikethroughctrlClick )
54
55 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL, wxRichTextFontPage::OnCapsctrlClick )
56
30bf7630
JS
57 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUPERSCRIPT, wxRichTextFontPage::OnRichtextfontpageSuperscriptClick )
58
59 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUBSCRIPT, wxRichTextFontPage::OnRichtextfontpageSubscriptClick )
60
97ff49b3
JS
61////@end wxRichTextFontPage event table entries
62
63END_EVENT_TABLE()
64
603f702b 65IMPLEMENT_HELP_PROVISION(wxRichTextFontPage)
97ff49b3
JS
66/*!
67 * wxRichTextFontPage constructors
68 */
69
70wxRichTextFontPage::wxRichTextFontPage( )
71{
72 Init();
73}
74
75wxRichTextFontPage::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 */
5778b3c8 84
97ff49b3
JS
85void wxRichTextFontPage::Init()
86{
87 m_dontUpdate = false;
88 m_colourPresent = false;
50283a51 89 m_bgColourPresent = false;
97ff49b3
JS
90
91////@begin wxRichTextFontPage member initialisation
92 m_faceTextCtrl = NULL;
97ff49b3 93 m_sizeTextCtrl = NULL;
32423dd8
JS
94 m_fontSizeSpinButtons = NULL;
95 m_sizeUnitsCtrl = NULL;
96 m_fontListBoxParent = NULL;
97 m_faceListBox = NULL;
97ff49b3
JS
98 m_sizeListBox = NULL;
99 m_styleCtrl = NULL;
100 m_weightCtrl = NULL;
101 m_underliningCtrl = NULL;
3c6cc330 102 m_textColourLabel = NULL;
97ff49b3 103 m_colourCtrl = NULL;
3c6cc330 104 m_bgColourLabel = NULL;
50283a51 105 m_bgColourCtrl = NULL;
42688aea
JS
106 m_strikethroughCtrl = NULL;
107 m_capitalsCtrl = NULL;
30bf7630
JS
108 m_superscriptCtrl = NULL;
109 m_subscriptCtrl = NULL;
97ff49b3
JS
110 m_previewCtrl = NULL;
111////@end wxRichTextFontPage member initialisation
112}
113
114/*!
115 * wxRichTextFontPage creator
116 */
117
118bool wxRichTextFontPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
119{
120////@begin wxRichTextFontPage creation
603f702b 121 wxRichTextDialogPage::Create( parent, id, pos, size, style );
97ff49b3
JS
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
137void wxRichTextFontPage::CreateControls()
138{
139////@begin wxRichTextFontPage content construction
603f702b 140 wxRichTextFontPage* itemRichTextDialogPage1 = this;
97ff49b3
JS
141
142 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
603f702b 143 itemRichTextDialogPage1->SetSizer(itemBoxSizer2);
97ff49b3
JS
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
603f702b 154 wxStaticText* itemStaticText6 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Font:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 155 itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3 156
603f702b 157 m_faceTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
97ff49b3 158 m_faceTextCtrl->SetHelpText(_("Type a font name."));
2fce6547 159 if (wxRichTextFontPage::ShowToolTips())
97ff49b3
JS
160 m_faceTextCtrl->SetToolTip(_("Type a font name."));
161 itemBoxSizer5->Add(m_faceTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
162
32423dd8
JS
163 wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL);
164 itemBoxSizer4->Add(itemBoxSizer8, 0, wxGROW, 5);
97ff49b3 165
32423dd8
JS
166 wxStaticText* itemStaticText9 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 );
167 itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3 168
32423dd8
JS
169 wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
170 itemBoxSizer8->Add(itemBoxSizer10, 0, wxGROW, 5);
97ff49b3 171
603f702b 172 m_sizeTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
97ff49b3 173 m_sizeTextCtrl->SetHelpText(_("Type a size in points."));
2fce6547 174 if (wxRichTextFontPage::ShowToolTips())
97ff49b3 175 m_sizeTextCtrl->SetToolTip(_("Type a size in points."));
32423dd8
JS
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);
97ff49b3 201
2fce6547 202 wxArrayString m_sizeListBoxStrings;
603f702b 203 m_sizeListBox = new wxListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), m_sizeListBoxStrings, wxLB_SINGLE );
97ff49b3 204 m_sizeListBox->SetHelpText(_("Lists font sizes in points."));
2fce6547 205 if (wxRichTextFontPage::ShowToolTips())
97ff49b3 206 m_sizeListBox->SetToolTip(_("Lists font sizes in points."));
32423dd8 207 m_fontListBoxParent->Add(m_sizeListBox, 0, wxGROW|wxALL|wxFIXED_MINSIZE, 5);
97ff49b3 208
32423dd8
JS
209 wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxHORIZONTAL);
210 itemBoxSizer3->Add(itemBoxSizer17, 0, wxGROW, 5);
97ff49b3 211
32423dd8
JS
212 wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL);
213 itemBoxSizer17->Add(itemBoxSizer18, 0, wxGROW, 5);
97ff49b3 214
32423dd8
JS
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);
97ff49b3 217
2fce6547 218 wxArrayString m_styleCtrlStrings;
603f702b 219 m_styleCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STYLECTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_styleCtrlStrings, wxCB_READONLY );
97ff49b3 220 m_styleCtrl->SetHelpText(_("Select regular or italic style."));
2fce6547 221 if (wxRichTextFontPage::ShowToolTips())
97ff49b3 222 m_styleCtrl->SetToolTip(_("Select regular or italic style."));
32423dd8 223 itemBoxSizer18->Add(m_styleCtrl, 0, wxGROW|wxALL, 5);
97ff49b3 224
32423dd8
JS
225 wxBoxSizer* itemBoxSizer21 = new wxBoxSizer(wxVERTICAL);
226 itemBoxSizer17->Add(itemBoxSizer21, 0, wxGROW, 5);
97ff49b3 227
32423dd8
JS
228 wxStaticText* itemStaticText22 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 );
229 itemBoxSizer21->Add(itemStaticText22, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3 230
2fce6547 231 wxArrayString m_weightCtrlStrings;
603f702b 232 m_weightCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_weightCtrlStrings, wxCB_READONLY );
97ff49b3 233 m_weightCtrl->SetHelpText(_("Select regular or bold."));
2fce6547 234 if (wxRichTextFontPage::ShowToolTips())
97ff49b3 235 m_weightCtrl->SetToolTip(_("Select regular or bold."));
32423dd8 236 itemBoxSizer21->Add(m_weightCtrl, 0, wxGROW|wxALL, 5);
97ff49b3 237
32423dd8
JS
238 wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL);
239 itemBoxSizer17->Add(itemBoxSizer24, 0, wxGROW, 5);
97ff49b3 240
32423dd8
JS
241 wxStaticText* itemStaticText25 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 );
242 itemBoxSizer24->Add(itemStaticText25, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3 243
2fce6547 244 wxArrayString m_underliningCtrlStrings;
603f702b 245 m_underliningCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_underliningCtrlStrings, wxCB_READONLY );
97ff49b3 246 m_underliningCtrl->SetHelpText(_("Select underlining or no underlining."));
2fce6547 247 if (wxRichTextFontPage::ShowToolTips())
97ff49b3 248 m_underliningCtrl->SetToolTip(_("Select underlining or no underlining."));
32423dd8 249 itemBoxSizer24->Add(m_underliningCtrl, 0, wxGROW|wxALL, 5);
97ff49b3 250
32423dd8 251 itemBoxSizer17->Add(0, 0, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
97ff49b3 252
32423dd8
JS
253 wxBoxSizer* itemBoxSizer28 = new wxBoxSizer(wxVERTICAL);
254 itemBoxSizer17->Add(itemBoxSizer28, 0, wxGROW, 5);
97ff49b3 255
3c6cc330
JS
256 m_textColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 );
257 m_textColourLabel->SetValue(false);
32423dd8 258 itemBoxSizer28->Add(m_textColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
50283a51 259
603f702b 260 m_colourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 );
97ff49b3 261 m_colourCtrl->SetHelpText(_("Click to change the text colour."));
2fce6547 262 if (wxRichTextFontPage::ShowToolTips())
97ff49b3 263 m_colourCtrl->SetToolTip(_("Click to change the text colour."));
32423dd8 264 itemBoxSizer28->Add(m_colourCtrl, 0, wxGROW|wxALL, 5);
50283a51 265
32423dd8
JS
266 wxBoxSizer* itemBoxSizer31 = new wxBoxSizer(wxVERTICAL);
267 itemBoxSizer17->Add(itemBoxSizer31, 0, wxGROW, 5);
97ff49b3 268
3c6cc330
JS
269 m_bgColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 );
270 m_bgColourLabel->SetValue(false);
32423dd8 271 itemBoxSizer31->Add(m_bgColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
50283a51 272
603f702b 273 m_bgColourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 );
50283a51
JS
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."));
32423dd8 277 itemBoxSizer31->Add(m_bgColourCtrl, 0, wxGROW|wxALL, 5);
50283a51 278
32423dd8
JS
279 wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxHORIZONTAL);
280 itemBoxSizer3->Add(itemBoxSizer34, 0, wxGROW, 5);
42688aea 281
23d11f0e 282 m_strikethroughCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, _("&Strikethrough"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
42688aea
JS
283 m_strikethroughCtrl->SetValue(false);
284 m_strikethroughCtrl->SetHelpText(_("Check to show a line through the text."));
2fce6547 285 if (wxRichTextFontPage::ShowToolTips())
42688aea 286 m_strikethroughCtrl->SetToolTip(_("Check to show a line through the text."));
32423dd8 287 itemBoxSizer34->Add(m_strikethroughCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
42688aea 288
23d11f0e 289 m_capitalsCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_CAPSCTRL, _("Ca&pitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
42688aea
JS
290 m_capitalsCtrl->SetValue(false);
291 m_capitalsCtrl->SetHelpText(_("Check to show the text in capitals."));
2fce6547 292 if (wxRichTextFontPage::ShowToolTips())
42688aea 293 m_capitalsCtrl->SetToolTip(_("Check to show the text in capitals."));
32423dd8 294 itemBoxSizer34->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
42688aea 295
23d11f0e 296 m_superscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUPERSCRIPT, _("Supe&rscript"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
30bf7630
JS
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."));
32423dd8 301 itemBoxSizer34->Add(m_superscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
30bf7630 302
23d11f0e 303 m_subscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUBSCRIPT, _("Subscrip&t"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
30bf7630
JS
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."));
32423dd8 308 itemBoxSizer34->Add(m_subscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
30bf7630 309
2fce6547 310 itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5);
97ff49b3 311
603f702b 312 m_previewCtrl = new wxRichTextFontPreviewCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 60), 0 );
97ff49b3 313 m_previewCtrl->SetHelpText(_("Shows a preview of the font settings."));
2fce6547 314 if (wxRichTextFontPage::ShowToolTips())
97ff49b3
JS
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
3c6cc330 322 m_styleCtrl->Append(_("(none)"));
97ff49b3
JS
323 m_styleCtrl->Append(_("Regular"));
324 m_styleCtrl->Append(_("Italic"));
325
3c6cc330 326 m_weightCtrl->Append(_("(none)"));
97ff49b3
JS
327 m_weightCtrl->Append(_("Regular"));
328 m_weightCtrl->Append(_("Bold"));
329
3c6cc330 330 m_underliningCtrl->Append(_("(none)"));
97ff49b3
JS
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
346bool wxRichTextFontPage::TransferDataFromWindow()
347{
348 wxPanel::TransferDataFromWindow();
349
24777478 350 wxRichTextAttr* attr = GetAttributes();
97ff49b3 351
603f702b 352 if (!m_faceTextCtrl->GetValue().IsEmpty())
97ff49b3 353 {
603f702b
JS
354 wxString faceName = m_faceTextCtrl->GetValue();
355 attr->SetFontFaceName(faceName);
97ff49b3
JS
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 {
32423dd8
JS
366 if (m_sizeUnitsCtrl->GetSelection() == 0)
367 attr->SetFontPointSize(sz);
368 else
369 attr->SetFontPixelSize(sz);
97ff49b3
JS
370 }
371 }
372 else
373 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE));
374
3c6cc330 375 if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0)
97ff49b3 376 {
7d76fbd5 377 wxFontStyle style;
3c6cc330 378 if (m_styleCtrl->GetSelection() == 2)
7d76fbd5 379 style = wxFONTSTYLE_ITALIC;
97ff49b3 380 else
7d76fbd5 381 style = wxFONTSTYLE_NORMAL;
97ff49b3 382
44cc96a8 383 attr->SetFontStyle(style);
97ff49b3
JS
384 }
385 else
386 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC));
387
3c6cc330 388 if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0)
97ff49b3 389 {
7d76fbd5 390 wxFontWeight weight;
3c6cc330 391 if (m_weightCtrl->GetSelection() == 2)
7d76fbd5 392 weight = wxFONTWEIGHT_BOLD;
97ff49b3 393 else
7d76fbd5 394 weight = wxFONTWEIGHT_NORMAL;
97ff49b3 395
44cc96a8 396 attr->SetFontWeight(weight);
97ff49b3
JS
397 }
398 else
399 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT));
400
3c6cc330 401 if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0)
97ff49b3
JS
402 {
403 bool underlined;
3c6cc330 404 if (m_underliningCtrl->GetSelection() == 2)
97ff49b3
JS
405 underlined = true;
406 else
407 underlined = false;
408
44cc96a8 409 attr->SetFontUnderlined(underlined);
97ff49b3
JS
410 }
411 else
412 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE));
413
3c6cc330 414 if (m_textColourLabel->GetValue())
97ff49b3 415 {
50283a51 416 attr->SetTextColour(m_colourCtrl->GetColour());
97ff49b3
JS
417 }
418 else
419 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR));
44cc96a8 420
3c6cc330 421 if (m_bgColourLabel->GetValue())
50283a51
JS
422 {
423 attr->SetBackgroundColour(m_bgColourCtrl->GetColour());
424 }
425 else
426 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_BACKGROUND_COLOUR));
427
42688aea
JS
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 }
a2c2fdc5
JS
437 else
438 {
439 attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH);
440 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH);
441 }
42688aea
JS
442
443 if (m_capitalsCtrl->Get3StateValue() != wxCHK_UNDETERMINED)
444 {
445 attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_CAPITALS);
44cc96a8 446
42688aea
JS
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 }
a2c2fdc5
JS
452 else
453 {
454 attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_CAPITALS);
455 attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS);
456 }
97ff49b3 457
30bf7630
JS
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 {
d1e5be0e
JS
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) );
a2c2fdc5 475 attr->SetTextEffects(attr->GetTextEffects() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT|wxTEXT_ATTR_EFFECT_SUPERSCRIPT) );
30bf7630
JS
476 }
477
97ff49b3
JS
478 return true;
479}
480
481bool wxRichTextFontPage::TransferDataToWindow()
482{
483 wxPanel::TransferDataToWindow();
484
485 m_dontUpdate = true;
24777478 486 wxRichTextAttr* attr = GetAttributes();
97ff49b3 487
44cc96a8 488 if (attr->HasFontFaceName())
97ff49b3 489 {
44cc96a8 490 m_faceTextCtrl->SetValue(attr->GetFontFaceName());
97ff49b3
JS
491 m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName());
492 }
493 else
494 {
495 m_faceTextCtrl->SetValue(wxEmptyString);
496 m_faceListBox->SetFaceNameSelection(wxEmptyString);
497 }
498
32423dd8 499 if (attr->HasFontPointSize())
97ff49b3 500 {
44cc96a8 501 wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize());
97ff49b3 502 m_sizeTextCtrl->SetValue(strSize);
32423dd8 503 m_sizeUnitsCtrl->SetSelection(0);
97ff49b3
JS
504 if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
505 m_sizeListBox->SetStringSelection(strSize);
506 }
32423dd8
JS
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 }
97ff49b3
JS
514 else
515 {
516 m_sizeTextCtrl->SetValue(wxEmptyString);
517 m_sizeListBox->SetSelection(wxNOT_FOUND);
518 }
519
44cc96a8 520 if (attr->HasFontWeight())
97ff49b3 521 {
44cc96a8 522 if (attr->GetFontWeight() == wxBOLD)
3c6cc330 523 m_weightCtrl->SetSelection(2);
97ff49b3 524 else
3c6cc330 525 m_weightCtrl->SetSelection(1);
97ff49b3
JS
526 }
527 else
528 {
3c6cc330 529 m_weightCtrl->SetSelection(0);
97ff49b3
JS
530 }
531
44cc96a8 532 if (attr->HasFontItalic())
97ff49b3 533 {
44cc96a8 534 if (attr->GetFontStyle() == wxITALIC)
3c6cc330 535 m_styleCtrl->SetSelection(2);
97ff49b3 536 else
3c6cc330 537 m_styleCtrl->SetSelection(1);
97ff49b3
JS
538 }
539 else
540 {
3c6cc330 541 m_styleCtrl->SetSelection(0);
97ff49b3
JS
542 }
543
44cc96a8 544 if (attr->HasFontUnderlined())
97ff49b3 545 {
44cc96a8 546 if (attr->GetFontUnderlined())
3c6cc330 547 m_underliningCtrl->SetSelection(2);
97ff49b3 548 else
3c6cc330 549 m_underliningCtrl->SetSelection(1);
97ff49b3
JS
550 }
551 else
552 {
3c6cc330 553 m_underliningCtrl->SetSelection(0);
97ff49b3
JS
554 }
555
556 if (attr->HasTextColour())
557 {
3638bb5c 558 m_colourCtrl->SetColour(attr->GetTextColour());
3c6cc330 559 m_textColourLabel->SetValue(true);
97ff49b3
JS
560 m_colourPresent = true;
561 }
3c6cc330
JS
562 else
563 {
564 m_colourCtrl->SetColour(*wxBLACK);
565 m_textColourLabel->SetValue(false);
566 }
97ff49b3 567
50283a51
JS
568 if (attr->HasBackgroundColour())
569 {
570 m_bgColourCtrl->SetColour(attr->GetBackgroundColour());
3c6cc330 571 m_bgColourLabel->SetValue(true);
50283a51
JS
572 m_bgColourPresent = true;
573 }
3c6cc330
JS
574 else
575 {
576 m_bgColourCtrl->SetColour(*wxWHITE);
577 m_bgColourLabel->SetValue(false);
578 }
50283a51 579
42688aea
JS
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);
30bf7630
JS
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 {
d1e5be0e
JS
622 m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
623 m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
30bf7630 624 }
42688aea
JS
625 }
626 else
627 {
628 m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED);
629 m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED);
d1e5be0e
JS
630 m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
631 m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
42688aea
JS
632 }
633
97ff49b3
JS
634 UpdatePreview();
635
636 m_dontUpdate = false;
637
638 return true;
639}
640
24777478 641wxRichTextAttr* wxRichTextFontPage::GetAttributes()
97ff49b3
JS
642{
643 return wxRichTextFormattingDialog::GetDialogAttributes(this);
644}
645
646/// Updates the font preview
647void wxRichTextFontPage::UpdatePreview()
648{
24777478 649 wxRichTextAttr attr;
97ff49b3 650
3c6cc330
JS
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);
97ff49b3 668
3c6cc330
JS
669 if (!(m_bgColourCtrl->GetColour() == *wxWHITE))
670 {
671 m_bgColourCtrl->SetColour(*wxWHITE);
672 m_bgColourCtrl->Refresh();
673 }
674 }
50283a51 675
97ff49b3
JS
676 if (m_faceListBox->GetSelection() != wxNOT_FOUND)
677 {
678 wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection());
713129f9 679 attr.SetFontFaceName(faceName);
97ff49b3
JS
680 }
681
682 wxString strSize = m_sizeTextCtrl->GetValue();
683 if (!strSize.IsEmpty())
684 {
685 int sz = wxAtoi(strSize);
686 if (sz > 0)
32423dd8
JS
687 {
688 if (m_sizeUnitsCtrl->GetSelection() == 1)
689 attr.SetFontPixelSize(sz);
690 else
691 attr.SetFontPointSize(sz);
692 }
97ff49b3
JS
693 }
694
3c6cc330 695 if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0)
97ff49b3 696 {
713129f9 697 wxFontStyle style;
3c6cc330 698 if (m_styleCtrl->GetSelection() == 2)
713129f9 699 style = wxFONTSTYLE_ITALIC;
97ff49b3 700 else
713129f9 701 style = wxFONTSTYLE_NORMAL;
97ff49b3 702
713129f9 703 attr.SetFontStyle(style);
97ff49b3
JS
704 }
705
3c6cc330 706 if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0)
97ff49b3 707 {
713129f9 708 wxFontWeight weight;
3c6cc330 709 if (m_weightCtrl->GetSelection() == 2)
713129f9 710 weight = wxFONTWEIGHT_BOLD;
97ff49b3 711 else
713129f9 712 weight = wxFONTWEIGHT_NORMAL;
97ff49b3 713
713129f9 714 attr.SetFontWeight(weight);
97ff49b3
JS
715 }
716
3c6cc330 717 if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0)
97ff49b3
JS
718 {
719 bool underlined;
3c6cc330 720 if (m_underliningCtrl->GetSelection() == 2)
97ff49b3
JS
721 underlined = true;
722 else
723 underlined = false;
724
713129f9 725 attr.SetFontUnderlined(underlined);
97ff49b3 726 }
44cc96a8 727
42688aea
JS
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 }
97ff49b3 739
30bf7630
JS
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
713129f9 745 wxFont font = attr.GetFont();
97ff49b3 746 m_previewCtrl->SetFont(font);
42688aea 747 m_previewCtrl->SetTextEffects(textEffects);
97ff49b3
JS
748 m_previewCtrl->Refresh();
749}
750
751/*!
752 * Should we show tooltips?
753 */
754
755bool wxRichTextFontPage::ShowToolTips()
756{
dadd4f55 757 return wxRichTextFormattingDialog::ShowToolTips();
97ff49b3
JS
758}
759
760/*!
761 * Get bitmap resources
762 */
763
764wxBitmap 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
777wxIcon 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
790void 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 {
f18eaf26 812 m_faceListBox->ScrollToRow(i);
97ff49b3
JS
813 break;
814 }
815 }
816 }
817 }
818}
819
820
821/*!
822 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
823 */
824
825void 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
841void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event )
842{
3c6cc330 843 bool oldDontUpdate = m_dontUpdate;
97ff49b3
JS
844 m_dontUpdate = true;
845
846 m_sizeTextCtrl->SetValue(event.GetString());
847
3c6cc330
JS
848 m_dontUpdate = oldDontUpdate;
849
850 if (m_dontUpdate)
851 return;
97ff49b3
JS
852
853 UpdatePreview();
854}
855
856/*!
857 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_FACELISTBOX
858 */
859
860void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) )
861{
3c6cc330 862 bool oldDontUpdate = m_dontUpdate;
97ff49b3
JS
863 m_dontUpdate = true;
864
865 m_faceTextCtrl->SetValue(m_faceListBox->GetFaceName(m_faceListBox->GetSelection()));
866
3c6cc330
JS
867 m_dontUpdate = oldDontUpdate;
868
869 if (m_dontUpdate)
870 return;
97ff49b3
JS
871
872 UpdatePreview();
873}
874
875/*!
876 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_STYLECTRL
877 */
878
879void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) )
880{
3c6cc330
JS
881 if (m_dontUpdate)
882 return;
883
97ff49b3
JS
884 UpdatePreview();
885}
886
887
888/*!
889 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
890 */
891
892void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(event) )
893{
3c6cc330
JS
894 if (m_dontUpdate)
895 return;
896
97ff49b3
JS
897 UpdatePreview();
898}
899
900
901/*!
902 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL
903 */
904
905void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent& WXUNUSED(event) )
906{
3c6cc330
JS
907 if (m_dontUpdate)
908 return;
909
97ff49b3
JS
910 UpdatePreview();
911}
912
50283a51 913void wxRichTextFontPage::OnColourClicked( wxCommandEvent& event )
97ff49b3 914{
50283a51
JS
915 if (event.GetId() == m_colourCtrl->GetId())
916 m_colourPresent = true;
917 else if (event.GetId() == m_bgColourCtrl->GetId())
918 m_bgColourPresent = true;
97ff49b3 919
3c6cc330
JS
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
97ff49b3
JS
933 UpdatePreview();
934}
42688aea
JS
935/*!
936 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL
937 */
938
939void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(event) )
940{
3c6cc330
JS
941 if (m_dontUpdate)
942 return;
943
42688aea
JS
944 UpdatePreview();
945}
946
947/*!
948 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_CAPSCTRL
949 */
950
951void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) )
952{
3c6cc330
JS
953 if (m_dontUpdate)
954 return;
955
42688aea
JS
956 UpdatePreview();
957}
958
30bf7630
JS
959/*!
960 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUPERSCRIPT
961 */
962
963void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) )
964{
3c6cc330
JS
965 if (m_dontUpdate)
966 return;
967
d1e5be0e 968 if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
30bf7630 969 m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED );
d1e5be0e 970
30bf7630
JS
971 UpdatePreview();
972}
973
974/*!
975 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUBSCRIPT
976 */
42688aea 977
30bf7630
JS
978void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) )
979{
3c6cc330
JS
980 if (m_dontUpdate)
981 return;
982
d1e5be0e 983 if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
30bf7630 984 m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED );
d1e5be0e 985
30bf7630
JS
986 UpdatePreview();
987}
32423dd8
JS
988
989/*!
990 * wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZE_UNITS
991 */
992
993void 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
1005void 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
1024void 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
1043void 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}