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