]>
Commit | Line | Data |
---|---|---|
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 | 18 | IMPLEMENT_DYNAMIC_CLASS( wxRichTextFontPage, wxRichTextDialogPage ) |
97ff49b3 JS |
19 | |
20 | /*! | |
21 | * wxRichTextFontPage event table definition | |
22 | */ | |
23 | ||
603f702b | 24 | BEGIN_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 | ||
63 | END_EVENT_TABLE() | |
64 | ||
603f702b | 65 | IMPLEMENT_HELP_PROVISION(wxRichTextFontPage) |
97ff49b3 JS |
66 | /*! |
67 | * wxRichTextFontPage constructors | |
68 | */ | |
69 | ||
70 | wxRichTextFontPage::wxRichTextFontPage( ) | |
71 | { | |
72 | Init(); | |
73 | } | |
74 | ||
75 | wxRichTextFontPage::wxRichTextFontPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) | |
76 | { | |
77 | Init(); | |
78 | Create(parent, id, pos, size, style); | |
79 | } | |
80 | ||
81 | /*! | |
82 | * Initialise members | |
83 | */ | |
5778b3c8 | 84 | |
97ff49b3 JS |
85 | void 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 | ||
118 | bool 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 | ||
137 | void 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 | |
346 | bool 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 | ||
31f95a7f JS |
478 | if (attr->GetTextEffectFlags() == 0) |
479 | attr->SetFlags(attr->GetFlags() & ~wxTEXT_ATTR_EFFECTS); | |
480 | ||
97ff49b3 JS |
481 | return true; |
482 | } | |
483 | ||
484 | bool wxRichTextFontPage::TransferDataToWindow() | |
485 | { | |
486 | wxPanel::TransferDataToWindow(); | |
487 | ||
488 | m_dontUpdate = true; | |
24777478 | 489 | wxRichTextAttr* attr = GetAttributes(); |
97ff49b3 | 490 | |
44cc96a8 | 491 | if (attr->HasFontFaceName()) |
97ff49b3 | 492 | { |
44cc96a8 | 493 | m_faceTextCtrl->SetValue(attr->GetFontFaceName()); |
97ff49b3 JS |
494 | m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName()); |
495 | } | |
496 | else | |
497 | { | |
498 | m_faceTextCtrl->SetValue(wxEmptyString); | |
499 | m_faceListBox->SetFaceNameSelection(wxEmptyString); | |
500 | } | |
501 | ||
32423dd8 | 502 | if (attr->HasFontPointSize()) |
97ff49b3 | 503 | { |
44cc96a8 | 504 | wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize()); |
97ff49b3 | 505 | m_sizeTextCtrl->SetValue(strSize); |
32423dd8 | 506 | m_sizeUnitsCtrl->SetSelection(0); |
97ff49b3 JS |
507 | if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND) |
508 | m_sizeListBox->SetStringSelection(strSize); | |
509 | } | |
32423dd8 JS |
510 | else if (attr->HasFontPixelSize()) |
511 | { | |
512 | wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize()); | |
513 | m_sizeTextCtrl->SetValue(strSize); | |
514 | m_sizeUnitsCtrl->SetSelection(1); | |
515 | m_sizeListBox->SetSelection(wxNOT_FOUND); | |
516 | } | |
97ff49b3 JS |
517 | else |
518 | { | |
519 | m_sizeTextCtrl->SetValue(wxEmptyString); | |
520 | m_sizeListBox->SetSelection(wxNOT_FOUND); | |
521 | } | |
522 | ||
44cc96a8 | 523 | if (attr->HasFontWeight()) |
97ff49b3 | 524 | { |
44cc96a8 | 525 | if (attr->GetFontWeight() == wxBOLD) |
3c6cc330 | 526 | m_weightCtrl->SetSelection(2); |
97ff49b3 | 527 | else |
3c6cc330 | 528 | m_weightCtrl->SetSelection(1); |
97ff49b3 JS |
529 | } |
530 | else | |
531 | { | |
3c6cc330 | 532 | m_weightCtrl->SetSelection(0); |
97ff49b3 JS |
533 | } |
534 | ||
44cc96a8 | 535 | if (attr->HasFontItalic()) |
97ff49b3 | 536 | { |
44cc96a8 | 537 | if (attr->GetFontStyle() == wxITALIC) |
3c6cc330 | 538 | m_styleCtrl->SetSelection(2); |
97ff49b3 | 539 | else |
3c6cc330 | 540 | m_styleCtrl->SetSelection(1); |
97ff49b3 JS |
541 | } |
542 | else | |
543 | { | |
3c6cc330 | 544 | m_styleCtrl->SetSelection(0); |
97ff49b3 JS |
545 | } |
546 | ||
44cc96a8 | 547 | if (attr->HasFontUnderlined()) |
97ff49b3 | 548 | { |
44cc96a8 | 549 | if (attr->GetFontUnderlined()) |
3c6cc330 | 550 | m_underliningCtrl->SetSelection(2); |
97ff49b3 | 551 | else |
3c6cc330 | 552 | m_underliningCtrl->SetSelection(1); |
97ff49b3 JS |
553 | } |
554 | else | |
555 | { | |
3c6cc330 | 556 | m_underliningCtrl->SetSelection(0); |
97ff49b3 JS |
557 | } |
558 | ||
559 | if (attr->HasTextColour()) | |
560 | { | |
3638bb5c | 561 | m_colourCtrl->SetColour(attr->GetTextColour()); |
3c6cc330 | 562 | m_textColourLabel->SetValue(true); |
97ff49b3 JS |
563 | m_colourPresent = true; |
564 | } | |
3c6cc330 JS |
565 | else |
566 | { | |
567 | m_colourCtrl->SetColour(*wxBLACK); | |
568 | m_textColourLabel->SetValue(false); | |
569 | } | |
97ff49b3 | 570 | |
50283a51 JS |
571 | if (attr->HasBackgroundColour()) |
572 | { | |
573 | m_bgColourCtrl->SetColour(attr->GetBackgroundColour()); | |
3c6cc330 | 574 | m_bgColourLabel->SetValue(true); |
50283a51 JS |
575 | m_bgColourPresent = true; |
576 | } | |
3c6cc330 JS |
577 | else |
578 | { | |
579 | m_bgColourCtrl->SetColour(*wxWHITE); | |
580 | m_bgColourLabel->SetValue(false); | |
581 | } | |
50283a51 | 582 | |
42688aea JS |
583 | if (attr->HasTextEffects()) |
584 | { | |
585 | if (attr->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH) | |
586 | { | |
587 | if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH) | |
588 | m_strikethroughCtrl->Set3StateValue(wxCHK_CHECKED); | |
589 | else | |
590 | m_strikethroughCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
591 | } | |
592 | else | |
593 | m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
594 | ||
595 | if (attr->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_CAPITALS) | |
596 | { | |
597 | if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS) | |
598 | m_capitalsCtrl->Set3StateValue(wxCHK_CHECKED); | |
599 | else | |
600 | m_capitalsCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
601 | } | |
602 | else | |
603 | m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
30bf7630 JS |
604 | |
605 | if ( attr->GetTextEffectFlags() & (wxTEXT_ATTR_EFFECT_SUPERSCRIPT | wxTEXT_ATTR_EFFECT_SUBSCRIPT) ) | |
606 | { | |
607 | if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) | |
608 | { | |
609 | m_superscriptCtrl->Set3StateValue(wxCHK_CHECKED); | |
610 | m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
611 | } | |
612 | else if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT) | |
613 | { | |
614 | m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
615 | m_subscriptCtrl->Set3StateValue(wxCHK_CHECKED); | |
616 | } | |
617 | else | |
618 | { | |
619 | m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
620 | m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
621 | } | |
622 | } | |
623 | else | |
624 | { | |
d1e5be0e JS |
625 | m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); |
626 | m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
30bf7630 | 627 | } |
42688aea JS |
628 | } |
629 | else | |
630 | { | |
631 | m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
632 | m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
d1e5be0e JS |
633 | m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); |
634 | m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
42688aea JS |
635 | } |
636 | ||
97ff49b3 JS |
637 | UpdatePreview(); |
638 | ||
639 | m_dontUpdate = false; | |
640 | ||
641 | return true; | |
642 | } | |
643 | ||
24777478 | 644 | wxRichTextAttr* wxRichTextFontPage::GetAttributes() |
97ff49b3 JS |
645 | { |
646 | return wxRichTextFormattingDialog::GetDialogAttributes(this); | |
647 | } | |
648 | ||
649 | /// Updates the font preview | |
650 | void wxRichTextFontPage::UpdatePreview() | |
651 | { | |
24777478 | 652 | wxRichTextAttr attr; |
97ff49b3 | 653 | |
3c6cc330 JS |
654 | if (m_textColourLabel->GetValue()) |
655 | m_previewCtrl->SetForegroundColour(m_colourCtrl->GetColour()); | |
656 | else | |
657 | { | |
658 | m_previewCtrl->SetForegroundColour(*wxBLACK); | |
659 | if (!(m_colourCtrl->GetColour() == *wxBLACK)) | |
660 | { | |
661 | m_colourCtrl->SetColour(*wxBLACK); | |
662 | m_colourCtrl->Refresh(); | |
663 | } | |
664 | } | |
665 | ||
666 | if (m_bgColourLabel->GetValue()) | |
667 | m_previewCtrl->SetBackgroundColour(m_bgColourCtrl->GetColour()); | |
668 | else | |
669 | { | |
670 | m_previewCtrl->SetBackgroundColour(*wxWHITE); | |
97ff49b3 | 671 | |
3c6cc330 JS |
672 | if (!(m_bgColourCtrl->GetColour() == *wxWHITE)) |
673 | { | |
674 | m_bgColourCtrl->SetColour(*wxWHITE); | |
675 | m_bgColourCtrl->Refresh(); | |
676 | } | |
677 | } | |
50283a51 | 678 | |
97ff49b3 JS |
679 | if (m_faceListBox->GetSelection() != wxNOT_FOUND) |
680 | { | |
681 | wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection()); | |
713129f9 | 682 | attr.SetFontFaceName(faceName); |
97ff49b3 JS |
683 | } |
684 | ||
685 | wxString strSize = m_sizeTextCtrl->GetValue(); | |
686 | if (!strSize.IsEmpty()) | |
687 | { | |
688 | int sz = wxAtoi(strSize); | |
689 | if (sz > 0) | |
32423dd8 JS |
690 | { |
691 | if (m_sizeUnitsCtrl->GetSelection() == 1) | |
692 | attr.SetFontPixelSize(sz); | |
693 | else | |
694 | attr.SetFontPointSize(sz); | |
695 | } | |
97ff49b3 JS |
696 | } |
697 | ||
3c6cc330 | 698 | if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0) |
97ff49b3 | 699 | { |
713129f9 | 700 | wxFontStyle style; |
3c6cc330 | 701 | if (m_styleCtrl->GetSelection() == 2) |
713129f9 | 702 | style = wxFONTSTYLE_ITALIC; |
97ff49b3 | 703 | else |
713129f9 | 704 | style = wxFONTSTYLE_NORMAL; |
97ff49b3 | 705 | |
713129f9 | 706 | attr.SetFontStyle(style); |
97ff49b3 JS |
707 | } |
708 | ||
3c6cc330 | 709 | if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0) |
97ff49b3 | 710 | { |
713129f9 | 711 | wxFontWeight weight; |
3c6cc330 | 712 | if (m_weightCtrl->GetSelection() == 2) |
713129f9 | 713 | weight = wxFONTWEIGHT_BOLD; |
97ff49b3 | 714 | else |
713129f9 | 715 | weight = wxFONTWEIGHT_NORMAL; |
97ff49b3 | 716 | |
713129f9 | 717 | attr.SetFontWeight(weight); |
97ff49b3 JS |
718 | } |
719 | ||
3c6cc330 | 720 | if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0) |
97ff49b3 JS |
721 | { |
722 | bool underlined; | |
3c6cc330 | 723 | if (m_underliningCtrl->GetSelection() == 2) |
97ff49b3 JS |
724 | underlined = true; |
725 | else | |
726 | underlined = false; | |
727 | ||
713129f9 | 728 | attr.SetFontUnderlined(underlined); |
97ff49b3 | 729 | } |
44cc96a8 | 730 | |
42688aea JS |
731 | int textEffects = 0; |
732 | ||
733 | if (m_strikethroughCtrl->Get3StateValue() == wxCHK_CHECKED) | |
734 | { | |
735 | textEffects |= wxTEXT_ATTR_EFFECT_STRIKETHROUGH; | |
736 | } | |
737 | ||
738 | if (m_capitalsCtrl->Get3StateValue() == wxCHK_CHECKED) | |
739 | { | |
740 | textEffects |= wxTEXT_ATTR_EFFECT_CAPITALS; | |
741 | } | |
97ff49b3 | 742 | |
30bf7630 JS |
743 | if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) |
744 | textEffects |= wxTEXT_ATTR_EFFECT_SUPERSCRIPT; | |
745 | else if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) | |
746 | textEffects |= wxTEXT_ATTR_EFFECT_SUBSCRIPT; | |
747 | ||
713129f9 | 748 | wxFont font = attr.GetFont(); |
97ff49b3 | 749 | m_previewCtrl->SetFont(font); |
42688aea | 750 | m_previewCtrl->SetTextEffects(textEffects); |
97ff49b3 JS |
751 | m_previewCtrl->Refresh(); |
752 | } | |
753 | ||
754 | /*! | |
755 | * Should we show tooltips? | |
756 | */ | |
757 | ||
758 | bool wxRichTextFontPage::ShowToolTips() | |
759 | { | |
dadd4f55 | 760 | return wxRichTextFormattingDialog::ShowToolTips(); |
97ff49b3 JS |
761 | } |
762 | ||
763 | /*! | |
764 | * Get bitmap resources | |
765 | */ | |
766 | ||
767 | wxBitmap wxRichTextFontPage::GetBitmapResource( const wxString& name ) | |
768 | { | |
769 | // Bitmap retrieval | |
770 | ////@begin wxRichTextFontPage bitmap retrieval | |
771 | wxUnusedVar(name); | |
772 | return wxNullBitmap; | |
773 | ////@end wxRichTextFontPage bitmap retrieval | |
774 | } | |
775 | ||
776 | /*! | |
777 | * Get icon resources | |
778 | */ | |
779 | ||
780 | wxIcon wxRichTextFontPage::GetIconResource( const wxString& name ) | |
781 | { | |
782 | // Icon retrieval | |
783 | ////@begin wxRichTextFontPage icon retrieval | |
784 | wxUnusedVar(name); | |
785 | return wxNullIcon; | |
786 | ////@end wxRichTextFontPage icon retrieval | |
787 | } | |
788 | ||
789 | /*! | |
790 | * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL | |
791 | */ | |
792 | ||
793 | void wxRichTextFontPage::OnFaceTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) ) | |
794 | { | |
795 | if (m_dontUpdate) | |
796 | return; | |
797 | ||
798 | wxString facename = m_faceTextCtrl->GetValue(); | |
799 | if (!facename.IsEmpty()) | |
800 | { | |
801 | if (m_faceListBox->HasFaceName(facename)) | |
802 | { | |
803 | m_faceListBox->SetFaceNameSelection(facename); | |
804 | UpdatePreview(); | |
805 | } | |
806 | else | |
807 | { | |
808 | // Try to find a partial match | |
809 | const wxArrayString& arr = m_faceListBox->GetFaceNames(); | |
810 | size_t i; | |
811 | for (i = 0; i < arr.GetCount(); i++) | |
812 | { | |
813 | if (arr[i].Mid(0, facename.Length()).Lower() == facename.Lower()) | |
814 | { | |
f18eaf26 | 815 | m_faceListBox->ScrollToRow(i); |
97ff49b3 JS |
816 | break; |
817 | } | |
818 | } | |
819 | } | |
820 | } | |
821 | } | |
822 | ||
823 | ||
824 | /*! | |
825 | * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL | |
826 | */ | |
827 | ||
828 | void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) ) | |
829 | { | |
830 | if (m_dontUpdate) | |
831 | return; | |
832 | ||
833 | wxString strSize = m_sizeTextCtrl->GetValue(); | |
834 | if (!strSize.IsEmpty() && m_sizeListBox->FindString(strSize) != wxNOT_FOUND) | |
835 | m_sizeListBox->SetStringSelection(strSize); | |
836 | UpdatePreview(); | |
837 | } | |
838 | ||
839 | ||
840 | /*! | |
841 | * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX | |
842 | */ | |
843 | ||
844 | void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event ) | |
845 | { | |
3c6cc330 | 846 | bool oldDontUpdate = m_dontUpdate; |
97ff49b3 JS |
847 | m_dontUpdate = true; |
848 | ||
849 | m_sizeTextCtrl->SetValue(event.GetString()); | |
850 | ||
3c6cc330 JS |
851 | m_dontUpdate = oldDontUpdate; |
852 | ||
853 | if (m_dontUpdate) | |
854 | return; | |
97ff49b3 JS |
855 | |
856 | UpdatePreview(); | |
857 | } | |
858 | ||
859 | /*! | |
860 | * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_FACELISTBOX | |
861 | */ | |
862 | ||
863 | void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) ) | |
864 | { | |
3c6cc330 | 865 | bool oldDontUpdate = m_dontUpdate; |
97ff49b3 JS |
866 | m_dontUpdate = true; |
867 | ||
868 | m_faceTextCtrl->SetValue(m_faceListBox->GetFaceName(m_faceListBox->GetSelection())); | |
869 | ||
3c6cc330 JS |
870 | m_dontUpdate = oldDontUpdate; |
871 | ||
872 | if (m_dontUpdate) | |
873 | return; | |
97ff49b3 JS |
874 | |
875 | UpdatePreview(); | |
876 | } | |
877 | ||
878 | /*! | |
879 | * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_STYLECTRL | |
880 | */ | |
881 | ||
882 | void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) ) | |
883 | { | |
3c6cc330 JS |
884 | if (m_dontUpdate) |
885 | return; | |
886 | ||
97ff49b3 JS |
887 | UpdatePreview(); |
888 | } | |
889 | ||
890 | ||
891 | /*! | |
892 | * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL | |
893 | */ | |
894 | ||
895 | void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(event) ) | |
896 | { | |
3c6cc330 JS |
897 | if (m_dontUpdate) |
898 | return; | |
899 | ||
97ff49b3 JS |
900 | UpdatePreview(); |
901 | } | |
902 | ||
903 | ||
904 | /*! | |
905 | * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL | |
906 | */ | |
907 | ||
908 | void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent& WXUNUSED(event) ) | |
909 | { | |
3c6cc330 JS |
910 | if (m_dontUpdate) |
911 | return; | |
912 | ||
97ff49b3 JS |
913 | UpdatePreview(); |
914 | } | |
915 | ||
50283a51 | 916 | void wxRichTextFontPage::OnColourClicked( wxCommandEvent& event ) |
97ff49b3 | 917 | { |
50283a51 JS |
918 | if (event.GetId() == m_colourCtrl->GetId()) |
919 | m_colourPresent = true; | |
920 | else if (event.GetId() == m_bgColourCtrl->GetId()) | |
921 | m_bgColourPresent = true; | |
97ff49b3 | 922 | |
3c6cc330 JS |
923 | m_dontUpdate = true; |
924 | ||
925 | if (event.GetId() == m_colourCtrl->GetId()) | |
926 | { | |
927 | m_textColourLabel->SetValue(true); | |
928 | } | |
929 | else if (event.GetId() == m_bgColourCtrl->GetId()) | |
930 | { | |
931 | m_bgColourLabel->SetValue(true); | |
932 | } | |
933 | ||
934 | m_dontUpdate = false; | |
935 | ||
97ff49b3 JS |
936 | UpdatePreview(); |
937 | } | |
42688aea JS |
938 | /*! |
939 | * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL | |
940 | */ | |
941 | ||
942 | void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(event) ) | |
943 | { | |
3c6cc330 JS |
944 | if (m_dontUpdate) |
945 | return; | |
946 | ||
42688aea JS |
947 | UpdatePreview(); |
948 | } | |
949 | ||
950 | /*! | |
951 | * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_CAPSCTRL | |
952 | */ | |
953 | ||
954 | void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) ) | |
955 | { | |
3c6cc330 JS |
956 | if (m_dontUpdate) |
957 | return; | |
958 | ||
42688aea JS |
959 | UpdatePreview(); |
960 | } | |
961 | ||
30bf7630 JS |
962 | /*! |
963 | * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUPERSCRIPT | |
964 | */ | |
965 | ||
966 | void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) ) | |
967 | { | |
3c6cc330 JS |
968 | if (m_dontUpdate) |
969 | return; | |
970 | ||
d1e5be0e | 971 | if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED) |
30bf7630 | 972 | m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); |
d1e5be0e | 973 | |
30bf7630 JS |
974 | UpdatePreview(); |
975 | } | |
976 | ||
977 | /*! | |
978 | * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUBSCRIPT | |
979 | */ | |
42688aea | 980 | |
30bf7630 JS |
981 | void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) ) |
982 | { | |
3c6cc330 JS |
983 | if (m_dontUpdate) |
984 | return; | |
985 | ||
d1e5be0e | 986 | if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED) |
30bf7630 | 987 | m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); |
d1e5be0e | 988 | |
30bf7630 JS |
989 | UpdatePreview(); |
990 | } | |
32423dd8 JS |
991 | |
992 | /*! | |
993 | * wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZE_UNITS | |
994 | */ | |
995 | ||
996 | void wxRichTextFontPage::OnRichtextfontpageSizeUnitsSelected( wxCommandEvent& WXUNUSED(event) ) | |
997 | { | |
998 | if (m_dontUpdate) | |
999 | return; | |
1000 | ||
1001 | UpdatePreview(); | |
1002 | } | |
1003 | ||
1004 | /*! | |
1005 | * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS | |
1006 | */ | |
1007 | ||
1008 | void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsUp( wxSpinEvent& WXUNUSED(event) ) | |
1009 | { | |
1010 | wxString text = m_sizeTextCtrl->GetValue(); | |
1011 | if (!text.IsEmpty()) | |
1012 | { | |
1013 | int size = wxAtoi(text); | |
1014 | if (size > 0) | |
1015 | { | |
1016 | size ++; | |
1017 | m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size)); | |
1018 | UpdatePreview(); | |
1019 | } | |
1020 | } | |
1021 | } | |
1022 | ||
1023 | /*! | |
1024 | * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS | |
1025 | */ | |
1026 | ||
1027 | void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsDown( wxSpinEvent& WXUNUSED(event) ) | |
1028 | { | |
1029 | wxString text = m_sizeTextCtrl->GetValue(); | |
1030 | if (!text.IsEmpty()) | |
1031 | { | |
1032 | int size = wxAtoi(text); | |
1033 | if (size > 0) | |
1034 | { | |
1035 | size --; | |
1036 | m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size)); | |
1037 | UpdatePreview(); | |
1038 | } | |
1039 | } | |
1040 | } | |
1041 | ||
1042 | /*! | |
1043 | * wxEVT_IDLE event handler for ID_RICHTEXTFONTPAGE | |
1044 | */ | |
1045 | ||
1046 | void wxRichTextFontPage::OnIdle( wxIdleEvent& WXUNUSED(event) ) | |
1047 | { | |
1048 | if (!m_sizeUnitsCtrl) | |
1049 | return; | |
31f95a7f | 1050 | |
32423dd8 JS |
1051 | if (m_sizeUnitsCtrl->GetSelection() == 1 && m_sizeListBox->IsShown()) |
1052 | { | |
1053 | m_fontListBoxParent->Show(m_sizeListBox, false); | |
1054 | Layout(); | |
1055 | } | |
1056 | else if (m_sizeUnitsCtrl->GetSelection() == 0 && !m_sizeListBox->IsShown()) | |
1057 | { | |
1058 | m_fontListBoxParent->Show(m_sizeListBox, true); | |
1059 | Layout(); | |
1060 | } | |
1061 | if (!wxRichTextFormattingDialog::GetDialog(this)->HasOption(wxRichTextFormattingDialog::Option_AllowPixelFontSize) && | |
1062 | m_sizeUnitsCtrl->IsEnabled()) | |
1063 | { | |
1064 | m_sizeUnitsCtrl->Disable(); | |
1065 | } | |
1066 | } |