1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richeditfontpage.cpp
3 // Purpose: Font page for wxRichTextFormattingDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/richtext/richtextfontpage.h"
15 * wxRichTextFontPage type definition
18 IMPLEMENT_DYNAMIC_CLASS( wxRichTextFontPage
, wxPanel
)
21 * wxRichTextFontPage event table definition
24 BEGIN_EVENT_TABLE( wxRichTextFontPage
, wxPanel
)
25 EVT_LISTBOX( ID_RICHTEXTFONTPAGE_FACELISTBOX
, wxRichTextFontPage::OnFaceListBoxSelected
)
26 EVT_BUTTON( ID_RICHTEXTFONTPAGE_COLOURCTRL
, wxRichTextFontPage::OnColourClicked
)
28 ////@begin wxRichTextFontPage event table entries
29 EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL
, wxRichTextFontPage::OnFaceTextCtrlUpdated
)
31 EVT_TEXT( ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
, wxRichTextFontPage::OnSizeTextCtrlUpdated
)
33 EVT_LISTBOX( ID_RICHTEXTFONTPAGE_SIZELISTBOX
, wxRichTextFontPage::OnSizeListBoxSelected
)
35 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_STYLECTRL
, wxRichTextFontPage::OnStyleCtrlSelected
)
37 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_WEIGHTCTRL
, wxRichTextFontPage::OnWeightCtrlSelected
)
39 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
, wxRichTextFontPage::OnUnderliningCtrlSelected
)
41 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL
, wxRichTextFontPage::OnStrikethroughctrlClick
)
43 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL
, wxRichTextFontPage::OnCapsctrlClick
)
45 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUPERSCRIPT
, wxRichTextFontPage::OnRichtextfontpageSuperscriptClick
)
47 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUBSCRIPT
, wxRichTextFontPage::OnRichtextfontpageSubscriptClick
)
49 ////@end wxRichTextFontPage event table entries
54 * wxRichTextFontPage constructors
57 wxRichTextFontPage::wxRichTextFontPage( )
62 wxRichTextFontPage::wxRichTextFontPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
65 Create(parent
, id
, pos
, size
, style
);
72 void wxRichTextFontPage::Init()
75 m_colourPresent
= false;
77 ////@begin wxRichTextFontPage member initialisation
78 m_faceTextCtrl
= NULL
;
80 m_sizeTextCtrl
= NULL
;
84 m_underliningCtrl
= NULL
;
86 m_strikethroughCtrl
= NULL
;
87 m_capitalsCtrl
= NULL
;
88 m_superscriptCtrl
= NULL
;
89 m_subscriptCtrl
= NULL
;
91 ////@end wxRichTextFontPage member initialisation
95 * wxRichTextFontPage creator
98 bool wxRichTextFontPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
100 ////@begin wxRichTextFontPage creation
101 wxPanel::Create( parent
, id
, pos
, size
, style
);
106 GetSizer()->SetSizeHints(this);
109 ////@end wxRichTextFontPage creation
114 * Control creation for wxRichTextFontPage
117 void wxRichTextFontPage::CreateControls()
119 ////@begin wxRichTextFontPage content construction
120 wxRichTextFontPage
* itemPanel1
= this;
122 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
123 itemPanel1
->SetSizer(itemBoxSizer2
);
125 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
126 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
128 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
129 itemBoxSizer3
->Add(itemBoxSizer4
, 1, wxGROW
, 5);
131 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
132 itemBoxSizer4
->Add(itemBoxSizer5
, 1, wxGROW
, 5);
134 wxStaticText
* itemStaticText6
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Font:"), wxDefaultPosition
, wxDefaultSize
, 0 );
135 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
137 m_faceTextCtrl
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTFONTPAGE_FACETEXTCTRL
, _T(""), wxDefaultPosition
, wxDefaultSize
, 0 );
138 m_faceTextCtrl
->SetHelpText(_("Type a font name."));
139 if (wxRichTextFontPage::ShowToolTips())
140 m_faceTextCtrl
->SetToolTip(_("Type a font name."));
141 itemBoxSizer5
->Add(m_faceTextCtrl
, 0, wxGROW
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
143 m_faceListBox
= new wxRichTextFontListBox( itemPanel1
, ID_RICHTEXTFONTPAGE_FACELISTBOX
, wxDefaultPosition
, wxSize(200, 100), 0 );
144 m_faceListBox
->SetHelpText(_("Lists the available fonts."));
145 if (wxRichTextFontPage::ShowToolTips())
146 m_faceListBox
->SetToolTip(_("Lists the available fonts."));
147 itemBoxSizer5
->Add(m_faceListBox
, 1, wxGROW
|wxALL
|wxFIXED_MINSIZE
, 5);
149 wxBoxSizer
* itemBoxSizer9
= new wxBoxSizer(wxVERTICAL
);
150 itemBoxSizer4
->Add(itemBoxSizer9
, 0, wxGROW
, 5);
152 wxStaticText
* itemStaticText10
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Size:"), wxDefaultPosition
, wxDefaultSize
, 0 );
153 itemBoxSizer9
->Add(itemStaticText10
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
155 m_sizeTextCtrl
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
, _T(""), wxDefaultPosition
, wxSize(50, -1), 0 );
156 m_sizeTextCtrl
->SetHelpText(_("Type a size in points."));
157 if (wxRichTextFontPage::ShowToolTips())
158 m_sizeTextCtrl
->SetToolTip(_("Type a size in points."));
159 itemBoxSizer9
->Add(m_sizeTextCtrl
, 0, wxGROW
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
161 wxArrayString m_sizeListBoxStrings
;
162 m_sizeListBox
= new wxListBox( itemPanel1
, ID_RICHTEXTFONTPAGE_SIZELISTBOX
, wxDefaultPosition
, wxSize(50, -1), m_sizeListBoxStrings
, wxLB_SINGLE
);
163 m_sizeListBox
->SetHelpText(_("Lists font sizes in points."));
164 if (wxRichTextFontPage::ShowToolTips())
165 m_sizeListBox
->SetToolTip(_("Lists font sizes in points."));
166 itemBoxSizer9
->Add(m_sizeListBox
, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
|wxFIXED_MINSIZE
, 5);
168 wxBoxSizer
* itemBoxSizer13
= new wxBoxSizer(wxHORIZONTAL
);
169 itemBoxSizer3
->Add(itemBoxSizer13
, 0, wxGROW
, 5);
171 wxBoxSizer
* itemBoxSizer14
= new wxBoxSizer(wxVERTICAL
);
172 itemBoxSizer13
->Add(itemBoxSizer14
, 1, wxGROW
, 5);
174 wxStaticText
* itemStaticText15
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Font st&yle:"), wxDefaultPosition
, wxDefaultSize
, 0 );
175 itemBoxSizer14
->Add(itemStaticText15
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
177 wxArrayString m_styleCtrlStrings
;
178 m_styleCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTFONTPAGE_STYLECTRL
, _T(""), wxDefaultPosition
, wxDefaultSize
, m_styleCtrlStrings
, wxCB_READONLY
);
179 m_styleCtrl
->SetHelpText(_("Select regular or italic style."));
180 if (wxRichTextFontPage::ShowToolTips())
181 m_styleCtrl
->SetToolTip(_("Select regular or italic style."));
182 itemBoxSizer14
->Add(m_styleCtrl
, 0, wxGROW
|wxALL
, 5);
184 wxBoxSizer
* itemBoxSizer17
= new wxBoxSizer(wxVERTICAL
);
185 itemBoxSizer13
->Add(itemBoxSizer17
, 1, wxGROW
, 5);
187 wxStaticText
* itemStaticText18
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Font &weight:"), wxDefaultPosition
, wxDefaultSize
, 0 );
188 itemBoxSizer17
->Add(itemStaticText18
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
190 wxArrayString m_weightCtrlStrings
;
191 m_weightCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTFONTPAGE_WEIGHTCTRL
, _T(""), wxDefaultPosition
, wxDefaultSize
, m_weightCtrlStrings
, wxCB_READONLY
);
192 m_weightCtrl
->SetHelpText(_("Select regular or bold."));
193 if (wxRichTextFontPage::ShowToolTips())
194 m_weightCtrl
->SetToolTip(_("Select regular or bold."));
195 itemBoxSizer17
->Add(m_weightCtrl
, 0, wxGROW
|wxALL
, 5);
197 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxVERTICAL
);
198 itemBoxSizer13
->Add(itemBoxSizer20
, 1, wxGROW
, 5);
200 wxStaticText
* itemStaticText21
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Underlining:"), wxDefaultPosition
, wxDefaultSize
, 0 );
201 itemBoxSizer20
->Add(itemStaticText21
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
203 wxArrayString m_underliningCtrlStrings
;
204 m_underliningCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
, _T(""), wxDefaultPosition
, wxDefaultSize
, m_underliningCtrlStrings
, wxCB_READONLY
);
205 m_underliningCtrl
->SetHelpText(_("Select underlining or no underlining."));
206 if (wxRichTextFontPage::ShowToolTips())
207 m_underliningCtrl
->SetToolTip(_("Select underlining or no underlining."));
208 itemBoxSizer20
->Add(m_underliningCtrl
, 0, wxGROW
|wxALL
, 5);
210 wxBoxSizer
* itemBoxSizer23
= new wxBoxSizer(wxVERTICAL
);
211 itemBoxSizer13
->Add(itemBoxSizer23
, 0, wxGROW
, 5);
213 wxStaticText
* itemStaticText24
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Colour:"), wxDefaultPosition
, wxDefaultSize
, 0 );
214 itemBoxSizer23
->Add(itemStaticText24
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
216 m_colourCtrl
= new wxRichTextColourSwatchCtrl( itemPanel1
, ID_RICHTEXTFONTPAGE_COLOURCTRL
, wxDefaultPosition
, wxSize(40, 20), wxSIMPLE_BORDER
);
217 m_colourCtrl
->SetHelpText(_("Click to change the text colour."));
218 if (wxRichTextFontPage::ShowToolTips())
219 m_colourCtrl
->SetToolTip(_("Click to change the text colour."));
220 itemBoxSizer23
->Add(m_colourCtrl
, 0, wxALIGN_LEFT
|wxALL
, 5);
222 wxBoxSizer
* itemBoxSizer26
= new wxBoxSizer(wxHORIZONTAL
);
223 itemBoxSizer3
->Add(itemBoxSizer26
, 0, wxGROW
, 5);
225 m_strikethroughCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL
, _("&Strikethrough"), wxDefaultPosition
, wxDefaultSize
, wxCHK_3STATE
);
226 m_strikethroughCtrl
->SetValue(false);
227 m_strikethroughCtrl
->SetHelpText(_("Check to show a line through the text."));
228 if (wxRichTextFontPage::ShowToolTips())
229 m_strikethroughCtrl
->SetToolTip(_("Check to show a line through the text."));
230 itemBoxSizer26
->Add(m_strikethroughCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
232 m_capitalsCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTFONTPAGE_CAPSCTRL
, _("Ca&pitals"), wxDefaultPosition
, wxDefaultSize
, wxCHK_3STATE
);
233 m_capitalsCtrl
->SetValue(false);
234 m_capitalsCtrl
->SetHelpText(_("Check to show the text in capitals."));
235 if (wxRichTextFontPage::ShowToolTips())
236 m_capitalsCtrl
->SetToolTip(_("Check to show the text in capitals."));
237 itemBoxSizer26
->Add(m_capitalsCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
239 m_superscriptCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTFONTPAGE_SUPERSCRIPT
, _("Supe&rscript"), wxDefaultPosition
, wxDefaultSize
, wxCHK_3STATE
);
240 m_superscriptCtrl
->SetValue(false);
241 m_superscriptCtrl
->SetHelpText(_("Check to show the text in superscript."));
242 if (wxRichTextFontPage::ShowToolTips())
243 m_superscriptCtrl
->SetToolTip(_("Check to show the text in superscript."));
244 itemBoxSizer26
->Add(m_superscriptCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
246 m_subscriptCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTFONTPAGE_SUBSCRIPT
, _("Subscrip&t"), wxDefaultPosition
, wxDefaultSize
, wxCHK_3STATE
);
247 m_subscriptCtrl
->SetValue(false);
248 m_subscriptCtrl
->SetHelpText(_("Check to show the text in subscript."));
249 if (wxRichTextFontPage::ShowToolTips())
250 m_subscriptCtrl
->SetToolTip(_("Check to show the text in subscript."));
251 itemBoxSizer26
->Add(m_subscriptCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
253 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
255 m_previewCtrl
= new wxRichTextFontPreviewCtrl( itemPanel1
, ID_RICHTEXTFONTPAGE_PREVIEWCTRL
, wxDefaultPosition
, wxSize(100, 60), 0 );
256 m_previewCtrl
->SetHelpText(_("Shows a preview of the font settings."));
257 if (wxRichTextFontPage::ShowToolTips())
258 m_previewCtrl
->SetToolTip(_("Shows a preview of the font settings."));
259 itemBoxSizer3
->Add(m_previewCtrl
, 0, wxGROW
|wxALL
, 5);
261 ////@end wxRichTextFontPage content construction
263 m_faceListBox
->UpdateFonts();
265 m_styleCtrl
->Append(_("Regular"));
266 m_styleCtrl
->Append(_("Italic"));
268 m_weightCtrl
->Append(_("Regular"));
269 m_weightCtrl
->Append(_("Bold"));
271 m_underliningCtrl
->Append(_("Not underlined"));
272 m_underliningCtrl
->Append(_("Underlined"));
276 for (i
= 8; i
< 40; i
++)
278 nStr
.Printf(wxT("%d"), i
);
279 m_sizeListBox
->Append(nStr
);
281 m_sizeListBox
->Append(wxT("48"));
282 m_sizeListBox
->Append(wxT("72"));
285 /// Transfer data from/to window
286 bool wxRichTextFontPage::TransferDataFromWindow()
288 wxPanel::TransferDataFromWindow();
290 wxTextAttr
* attr
= GetAttributes();
292 if (m_faceListBox
->GetSelection() != wxNOT_FOUND
)
294 wxString faceName
= m_faceListBox
->GetFaceName(m_faceListBox
->GetSelection());
295 if (!faceName
.IsEmpty())
297 attr
->SetFontFaceName(faceName
);
301 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_FACE
));
303 wxString strSize
= m_sizeTextCtrl
->GetValue();
304 if (!strSize
.IsEmpty())
306 int sz
= wxAtoi(strSize
);
309 attr
->SetFontSize(sz
);
313 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE
));
315 if (m_styleCtrl
->GetSelection() != wxNOT_FOUND
)
318 if (m_styleCtrl
->GetStringSelection() == _("Italic"))
323 attr
->SetFontStyle(style
);
326 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC
));
328 if (m_weightCtrl
->GetSelection() != wxNOT_FOUND
)
331 if (m_weightCtrl
->GetStringSelection() == _("Bold"))
336 attr
->SetFontWeight(weight
);
339 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT
));
341 if (m_underliningCtrl
->GetSelection() != wxNOT_FOUND
)
344 if (m_underliningCtrl
->GetStringSelection() == _("Underlined"))
349 attr
->SetFontUnderlined(underlined
);
352 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE
));
356 attr
->SetTextColour(m_colourCtrl
->GetBackgroundColour());
359 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR
));
361 if (m_strikethroughCtrl
->Get3StateValue() != wxCHK_UNDETERMINED
)
363 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH
);
365 if (m_strikethroughCtrl
->Get3StateValue() == wxCHK_CHECKED
)
366 attr
->SetTextEffects(attr
->GetTextEffects() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH
);
368 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH
);
371 if (m_capitalsCtrl
->Get3StateValue() != wxCHK_UNDETERMINED
)
373 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_CAPITALS
);
375 if (m_capitalsCtrl
->Get3StateValue() == wxCHK_CHECKED
)
376 attr
->SetTextEffects(attr
->GetTextEffects() | wxTEXT_ATTR_EFFECT_CAPITALS
);
378 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS
);
381 if (m_superscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
383 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT
);
384 attr
->SetTextEffects(attr
->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT
);
385 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUBSCRIPT
);
387 else if (m_subscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
389 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUBSCRIPT
);
390 attr
->SetTextEffects(attr
->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUBSCRIPT
);
391 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUPERSCRIPT
);
395 // If they are undetermined, we don't want to include these flags in the text effects - the objects
396 // should retain their original style.
397 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT
|wxTEXT_ATTR_EFFECT_SUPERSCRIPT
) );
403 bool wxRichTextFontPage::TransferDataToWindow()
405 wxPanel::TransferDataToWindow();
408 wxTextAttr
* attr
= GetAttributes();
410 if (attr
->HasFontFaceName())
412 m_faceTextCtrl
->SetValue(attr
->GetFontFaceName());
413 m_faceListBox
->SetFaceNameSelection(attr
->GetFont().GetFaceName());
417 m_faceTextCtrl
->SetValue(wxEmptyString
);
418 m_faceListBox
->SetFaceNameSelection(wxEmptyString
);
421 if (attr
->HasFontSize())
423 wxString strSize
= wxString::Format(wxT("%d"), attr
->GetFontSize());
424 m_sizeTextCtrl
->SetValue(strSize
);
425 if (m_sizeListBox
->FindString(strSize
) != wxNOT_FOUND
)
426 m_sizeListBox
->SetStringSelection(strSize
);
430 m_sizeTextCtrl
->SetValue(wxEmptyString
);
431 m_sizeListBox
->SetSelection(wxNOT_FOUND
);
434 if (attr
->HasFontWeight())
436 if (attr
->GetFontWeight() == wxBOLD
)
437 m_weightCtrl
->SetSelection(1);
439 m_weightCtrl
->SetSelection(0);
443 m_weightCtrl
->SetSelection(wxNOT_FOUND
);
446 if (attr
->HasFontItalic())
448 if (attr
->GetFontStyle() == wxITALIC
)
449 m_styleCtrl
->SetSelection(1);
451 m_styleCtrl
->SetSelection(0);
455 m_styleCtrl
->SetSelection(wxNOT_FOUND
);
458 if (attr
->HasFontUnderlined())
460 if (attr
->GetFontUnderlined())
461 m_underliningCtrl
->SetSelection(1);
463 m_underliningCtrl
->SetSelection(0);
467 m_underliningCtrl
->SetSelection(wxNOT_FOUND
);
470 if (attr
->HasTextColour())
472 m_colourCtrl
->SetColour(attr
->GetTextColour());
473 m_colourPresent
= true;
476 if (attr
->HasTextEffects())
478 if (attr
->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH
)
480 if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH
)
481 m_strikethroughCtrl
->Set3StateValue(wxCHK_CHECKED
);
483 m_strikethroughCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
486 m_strikethroughCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
488 if (attr
->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_CAPITALS
)
490 if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS
)
491 m_capitalsCtrl
->Set3StateValue(wxCHK_CHECKED
);
493 m_capitalsCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
496 m_capitalsCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
498 if ( attr
->GetTextEffectFlags() & (wxTEXT_ATTR_EFFECT_SUPERSCRIPT
| wxTEXT_ATTR_EFFECT_SUBSCRIPT
) )
500 if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT
)
502 m_superscriptCtrl
->Set3StateValue(wxCHK_CHECKED
);
503 m_subscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
505 else if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT
)
507 m_superscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
508 m_subscriptCtrl
->Set3StateValue(wxCHK_CHECKED
);
512 m_superscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
513 m_subscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
518 m_superscriptCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
519 m_subscriptCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
524 m_strikethroughCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
525 m_capitalsCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
526 m_superscriptCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
527 m_subscriptCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
532 m_dontUpdate
= false;
537 wxTextAttr
* wxRichTextFontPage::GetAttributes()
539 return wxRichTextFormattingDialog::GetDialogAttributes(this);
542 /// Updates the font preview
543 void wxRichTextFontPage::UpdatePreview()
545 wxFont
font(*wxNORMAL_FONT
);
548 m_previewCtrl
->SetForegroundColour(m_colourCtrl
->GetBackgroundColour());
550 if (m_faceListBox
->GetSelection() != wxNOT_FOUND
)
552 wxString faceName
= m_faceListBox
->GetFaceName(m_faceListBox
->GetSelection());
553 font
.SetFaceName(faceName
);
556 wxString strSize
= m_sizeTextCtrl
->GetValue();
557 if (!strSize
.IsEmpty())
559 int sz
= wxAtoi(strSize
);
561 font
.SetPointSize(sz
);
564 if (m_styleCtrl
->GetSelection() != wxNOT_FOUND
)
567 if (m_styleCtrl
->GetStringSelection() == _("Italic"))
572 font
.SetStyle(style
);
575 if (m_weightCtrl
->GetSelection() != wxNOT_FOUND
)
578 if (m_weightCtrl
->GetStringSelection() == _("Bold"))
583 font
.SetWeight(weight
);
586 if (m_underliningCtrl
->GetSelection() != wxNOT_FOUND
)
589 if (m_underliningCtrl
->GetStringSelection() == _("Underlined"))
594 font
.SetUnderlined(underlined
);
599 if (m_strikethroughCtrl
->Get3StateValue() == wxCHK_CHECKED
)
601 textEffects
|= wxTEXT_ATTR_EFFECT_STRIKETHROUGH
;
604 if (m_capitalsCtrl
->Get3StateValue() == wxCHK_CHECKED
)
606 textEffects
|= wxTEXT_ATTR_EFFECT_CAPITALS
;
609 if ( m_superscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
610 textEffects
|= wxTEXT_ATTR_EFFECT_SUPERSCRIPT
;
611 else if ( m_subscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
612 textEffects
|= wxTEXT_ATTR_EFFECT_SUBSCRIPT
;
614 m_previewCtrl
->SetFont(font
);
615 m_previewCtrl
->SetTextEffects(textEffects
);
616 m_previewCtrl
->Refresh();
620 * Should we show tooltips?
623 bool wxRichTextFontPage::ShowToolTips()
625 return wxRichTextFormattingDialog::ShowToolTips();
629 * Get bitmap resources
632 wxBitmap
wxRichTextFontPage::GetBitmapResource( const wxString
& name
)
635 ////@begin wxRichTextFontPage bitmap retrieval
638 ////@end wxRichTextFontPage bitmap retrieval
645 wxIcon
wxRichTextFontPage::GetIconResource( const wxString
& name
)
648 ////@begin wxRichTextFontPage icon retrieval
651 ////@end wxRichTextFontPage icon retrieval
655 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL
658 void wxRichTextFontPage::OnFaceTextCtrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
663 wxString facename
= m_faceTextCtrl
->GetValue();
664 if (!facename
.IsEmpty())
666 if (m_faceListBox
->HasFaceName(facename
))
668 m_faceListBox
->SetFaceNameSelection(facename
);
673 // Try to find a partial match
674 const wxArrayString
& arr
= m_faceListBox
->GetFaceNames();
676 for (i
= 0; i
< arr
.GetCount(); i
++)
678 if (arr
[i
].Mid(0, facename
.Length()).Lower() == facename
.Lower())
680 m_faceListBox
->ScrollToRow(i
);
690 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
693 void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
698 wxString strSize
= m_sizeTextCtrl
->GetValue();
699 if (!strSize
.IsEmpty() && m_sizeListBox
->FindString(strSize
) != wxNOT_FOUND
)
700 m_sizeListBox
->SetStringSelection(strSize
);
706 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX
709 void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent
& event
)
713 m_sizeTextCtrl
->SetValue(event
.GetString());
715 m_dontUpdate
= false;
721 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_FACELISTBOX
724 void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent
& WXUNUSED(event
) )
728 m_faceTextCtrl
->SetValue(m_faceListBox
->GetFaceName(m_faceListBox
->GetSelection()));
730 m_dontUpdate
= false;
736 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_STYLECTRL
739 void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )
746 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
749 void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )
756 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL
759 void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )
764 void wxRichTextFontPage::OnColourClicked( wxCommandEvent
& WXUNUSED(event
) )
766 m_colourPresent
= true;
771 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL
774 void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent
& WXUNUSED(event
) )
780 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_CAPSCTRL
783 void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent
& WXUNUSED(event
) )
789 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUPERSCRIPT
792 void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent
& WXUNUSED(event
) )
794 if ( m_superscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
795 m_subscriptCtrl
->Set3StateValue( wxCHK_UNCHECKED
);
797 m_subscriptCtrl
->Set3StateValue( wxCHK_CHECKED
);
803 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUBSCRIPT
806 void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent
& WXUNUSED(event
) )
808 if ( m_subscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
809 m_superscriptCtrl
->Set3StateValue( wxCHK_UNCHECKED
);
811 m_superscriptCtrl
->Set3StateValue( wxCHK_CHECKED
);