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 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUBSCRIPT
| wxTEXT_ATTR_EFFECT_SUPERSCRIPT
);
396 attr
->SetTextEffects(attr
->GetTextEffects() & ~( wxTEXT_ATTR_EFFECT_SUPERSCRIPT
| wxTEXT_ATTR_EFFECT_SUBSCRIPT
));
402 bool wxRichTextFontPage::TransferDataToWindow()
404 wxPanel::TransferDataToWindow();
407 wxTextAttr
* attr
= GetAttributes();
409 if (attr
->HasFontFaceName())
411 m_faceTextCtrl
->SetValue(attr
->GetFontFaceName());
412 m_faceListBox
->SetFaceNameSelection(attr
->GetFont().GetFaceName());
416 m_faceTextCtrl
->SetValue(wxEmptyString
);
417 m_faceListBox
->SetFaceNameSelection(wxEmptyString
);
420 if (attr
->HasFontSize())
422 wxString strSize
= wxString::Format(wxT("%d"), attr
->GetFontSize());
423 m_sizeTextCtrl
->SetValue(strSize
);
424 if (m_sizeListBox
->FindString(strSize
) != wxNOT_FOUND
)
425 m_sizeListBox
->SetStringSelection(strSize
);
429 m_sizeTextCtrl
->SetValue(wxEmptyString
);
430 m_sizeListBox
->SetSelection(wxNOT_FOUND
);
433 if (attr
->HasFontWeight())
435 if (attr
->GetFontWeight() == wxBOLD
)
436 m_weightCtrl
->SetSelection(1);
438 m_weightCtrl
->SetSelection(0);
442 m_weightCtrl
->SetSelection(wxNOT_FOUND
);
445 if (attr
->HasFontItalic())
447 if (attr
->GetFontStyle() == wxITALIC
)
448 m_styleCtrl
->SetSelection(1);
450 m_styleCtrl
->SetSelection(0);
454 m_styleCtrl
->SetSelection(wxNOT_FOUND
);
457 if (attr
->HasFontUnderlined())
459 if (attr
->GetFontUnderlined())
460 m_underliningCtrl
->SetSelection(1);
462 m_underliningCtrl
->SetSelection(0);
466 m_underliningCtrl
->SetSelection(wxNOT_FOUND
);
469 if (attr
->HasTextColour())
471 m_colourCtrl
->SetColour(attr
->GetTextColour());
472 m_colourPresent
= true;
475 if (attr
->HasTextEffects())
477 if (attr
->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH
)
479 if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH
)
480 m_strikethroughCtrl
->Set3StateValue(wxCHK_CHECKED
);
482 m_strikethroughCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
485 m_strikethroughCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
487 if (attr
->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_CAPITALS
)
489 if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS
)
490 m_capitalsCtrl
->Set3StateValue(wxCHK_CHECKED
);
492 m_capitalsCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
495 m_capitalsCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
497 if ( attr
->GetTextEffectFlags() & (wxTEXT_ATTR_EFFECT_SUPERSCRIPT
| wxTEXT_ATTR_EFFECT_SUBSCRIPT
) )
499 if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT
)
501 m_superscriptCtrl
->Set3StateValue(wxCHK_CHECKED
);
502 m_subscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
504 else if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT
)
506 m_superscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
507 m_subscriptCtrl
->Set3StateValue(wxCHK_CHECKED
);
511 m_superscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
512 m_subscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
517 m_superscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
518 m_subscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
523 m_strikethroughCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
524 m_capitalsCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
525 m_superscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
526 m_subscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
531 m_dontUpdate
= false;
536 wxTextAttr
* wxRichTextFontPage::GetAttributes()
538 return wxRichTextFormattingDialog::GetDialogAttributes(this);
541 /// Updates the font preview
542 void wxRichTextFontPage::UpdatePreview()
544 wxFont
font(*wxNORMAL_FONT
);
547 m_previewCtrl
->SetForegroundColour(m_colourCtrl
->GetBackgroundColour());
549 if (m_faceListBox
->GetSelection() != wxNOT_FOUND
)
551 wxString faceName
= m_faceListBox
->GetFaceName(m_faceListBox
->GetSelection());
552 font
.SetFaceName(faceName
);
555 wxString strSize
= m_sizeTextCtrl
->GetValue();
556 if (!strSize
.IsEmpty())
558 int sz
= wxAtoi(strSize
);
560 font
.SetPointSize(sz
);
563 if (m_styleCtrl
->GetSelection() != wxNOT_FOUND
)
566 if (m_styleCtrl
->GetStringSelection() == _("Italic"))
571 font
.SetStyle(style
);
574 if (m_weightCtrl
->GetSelection() != wxNOT_FOUND
)
577 if (m_weightCtrl
->GetStringSelection() == _("Bold"))
582 font
.SetWeight(weight
);
585 if (m_underliningCtrl
->GetSelection() != wxNOT_FOUND
)
588 if (m_underliningCtrl
->GetStringSelection() == _("Underlined"))
593 font
.SetUnderlined(underlined
);
598 if (m_strikethroughCtrl
->Get3StateValue() == wxCHK_CHECKED
)
600 textEffects
|= wxTEXT_ATTR_EFFECT_STRIKETHROUGH
;
603 if (m_capitalsCtrl
->Get3StateValue() == wxCHK_CHECKED
)
605 textEffects
|= wxTEXT_ATTR_EFFECT_CAPITALS
;
608 if ( m_superscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
609 textEffects
|= wxTEXT_ATTR_EFFECT_SUPERSCRIPT
;
610 else if ( m_subscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
611 textEffects
|= wxTEXT_ATTR_EFFECT_SUBSCRIPT
;
613 m_previewCtrl
->SetFont(font
);
614 m_previewCtrl
->SetTextEffects(textEffects
);
615 m_previewCtrl
->Refresh();
619 * Should we show tooltips?
622 bool wxRichTextFontPage::ShowToolTips()
624 return wxRichTextFormattingDialog::ShowToolTips();
628 * Get bitmap resources
631 wxBitmap
wxRichTextFontPage::GetBitmapResource( const wxString
& name
)
634 ////@begin wxRichTextFontPage bitmap retrieval
637 ////@end wxRichTextFontPage bitmap retrieval
644 wxIcon
wxRichTextFontPage::GetIconResource( const wxString
& name
)
647 ////@begin wxRichTextFontPage icon retrieval
650 ////@end wxRichTextFontPage icon retrieval
654 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL
657 void wxRichTextFontPage::OnFaceTextCtrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
662 wxString facename
= m_faceTextCtrl
->GetValue();
663 if (!facename
.IsEmpty())
665 if (m_faceListBox
->HasFaceName(facename
))
667 m_faceListBox
->SetFaceNameSelection(facename
);
672 // Try to find a partial match
673 const wxArrayString
& arr
= m_faceListBox
->GetFaceNames();
675 for (i
= 0; i
< arr
.GetCount(); i
++)
677 if (arr
[i
].Mid(0, facename
.Length()).Lower() == facename
.Lower())
679 m_faceListBox
->ScrollToRow(i
);
689 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
692 void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
697 wxString strSize
= m_sizeTextCtrl
->GetValue();
698 if (!strSize
.IsEmpty() && m_sizeListBox
->FindString(strSize
) != wxNOT_FOUND
)
699 m_sizeListBox
->SetStringSelection(strSize
);
705 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX
708 void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent
& event
)
712 m_sizeTextCtrl
->SetValue(event
.GetString());
714 m_dontUpdate
= false;
720 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_FACELISTBOX
723 void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent
& WXUNUSED(event
) )
727 m_faceTextCtrl
->SetValue(m_faceListBox
->GetFaceName(m_faceListBox
->GetSelection()));
729 m_dontUpdate
= false;
735 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_STYLECTRL
738 void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )
745 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
748 void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )
755 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL
758 void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )
763 void wxRichTextFontPage::OnColourClicked( wxCommandEvent
& WXUNUSED(event
) )
765 m_colourPresent
= true;
770 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL
773 void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent
& WXUNUSED(event
) )
779 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_CAPSCTRL
782 void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent
& WXUNUSED(event
) )
788 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUPERSCRIPT
791 void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent
& WXUNUSED(event
) )
793 if ( m_superscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
&& m_subscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
794 m_subscriptCtrl
->Set3StateValue( wxCHK_UNCHECKED
);
799 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUBSCRIPT
802 void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent
& WXUNUSED(event
) )
804 if ( m_superscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
&& m_subscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
805 m_superscriptCtrl
->Set3StateValue( wxCHK_UNCHECKED
);