1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextfontpage.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
, wxRichTextDialogPage
)
21 * wxRichTextFontPage event table definition
24 BEGIN_EVENT_TABLE( wxRichTextFontPage
, wxRichTextDialogPage
)
25 EVT_LISTBOX( ID_RICHTEXTFONTPAGE_FACELISTBOX
, wxRichTextFontPage::OnFaceListBoxSelected
)
26 EVT_BUTTON( ID_RICHTEXTFONTPAGE_COLOURCTRL
, wxRichTextFontPage::OnColourClicked
)
27 EVT_BUTTON( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL
, wxRichTextFontPage::OnColourClicked
)
29 ////@begin wxRichTextFontPage event table entries
30 EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL
, wxRichTextFontPage::OnFaceTextCtrlUpdated
)
32 EVT_TEXT( ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
, wxRichTextFontPage::OnSizeTextCtrlUpdated
)
34 EVT_LISTBOX( ID_RICHTEXTFONTPAGE_SIZELISTBOX
, wxRichTextFontPage::OnSizeListBoxSelected
)
36 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_STYLECTRL
, wxRichTextFontPage::OnStyleCtrlSelected
)
38 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_WEIGHTCTRL
, wxRichTextFontPage::OnWeightCtrlSelected
)
40 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
, wxRichTextFontPage::OnUnderliningCtrlSelected
)
42 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL
, wxRichTextFontPage::OnUnderliningCtrlSelected
)
44 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL
, wxRichTextFontPage::OnUnderliningCtrlSelected
)
46 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL
, wxRichTextFontPage::OnStrikethroughctrlClick
)
48 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL
, wxRichTextFontPage::OnCapsctrlClick
)
50 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUPERSCRIPT
, wxRichTextFontPage::OnRichtextfontpageSuperscriptClick
)
52 EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUBSCRIPT
, wxRichTextFontPage::OnRichtextfontpageSubscriptClick
)
54 ////@end wxRichTextFontPage event table entries
58 IMPLEMENT_HELP_PROVISION(wxRichTextFontPage
)
60 * wxRichTextFontPage constructors
63 wxRichTextFontPage::wxRichTextFontPage( )
68 wxRichTextFontPage::wxRichTextFontPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
71 Create(parent
, id
, pos
, size
, style
);
78 void wxRichTextFontPage::Init()
81 m_colourPresent
= false;
82 m_bgColourPresent
= false;
84 ////@begin wxRichTextFontPage member initialisation
85 m_faceTextCtrl
= NULL
;
87 m_sizeTextCtrl
= NULL
;
91 m_underliningCtrl
= NULL
;
92 m_textColourLabel
= NULL
;
94 m_bgColourLabel
= NULL
;
95 m_bgColourCtrl
= NULL
;
96 m_strikethroughCtrl
= NULL
;
97 m_capitalsCtrl
= NULL
;
98 m_superscriptCtrl
= NULL
;
99 m_subscriptCtrl
= NULL
;
100 m_previewCtrl
= NULL
;
101 ////@end wxRichTextFontPage member initialisation
105 * wxRichTextFontPage creator
108 bool wxRichTextFontPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
110 ////@begin wxRichTextFontPage creation
111 wxRichTextDialogPage::Create( parent
, id
, pos
, size
, style
);
116 GetSizer()->SetSizeHints(this);
119 ////@end wxRichTextFontPage creation
124 * Control creation for wxRichTextFontPage
127 void wxRichTextFontPage::CreateControls()
129 ////@begin wxRichTextFontPage content construction
130 wxRichTextFontPage
* itemRichTextDialogPage1
= this;
132 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
133 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
135 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
136 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
138 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
139 itemBoxSizer3
->Add(itemBoxSizer4
, 1, wxGROW
, 5);
141 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
142 itemBoxSizer4
->Add(itemBoxSizer5
, 1, wxGROW
, 5);
144 wxStaticText
* itemStaticText6
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Font:"), wxDefaultPosition
, wxDefaultSize
, 0 );
145 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
147 m_faceTextCtrl
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_FACETEXTCTRL
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, 0 );
148 m_faceTextCtrl
->SetHelpText(_("Type a font name."));
149 if (wxRichTextFontPage::ShowToolTips())
150 m_faceTextCtrl
->SetToolTip(_("Type a font name."));
151 itemBoxSizer5
->Add(m_faceTextCtrl
, 0, wxGROW
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
153 m_faceListBox
= new wxRichTextFontListBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_FACELISTBOX
, wxDefaultPosition
, wxSize(200, 100), 0 );
154 m_faceListBox
->SetHelpText(_("Lists the available fonts."));
155 if (wxRichTextFontPage::ShowToolTips())
156 m_faceListBox
->SetToolTip(_("Lists the available fonts."));
157 itemBoxSizer5
->Add(m_faceListBox
, 1, wxGROW
|wxALL
|wxFIXED_MINSIZE
, 5);
159 wxBoxSizer
* itemBoxSizer9
= new wxBoxSizer(wxVERTICAL
);
160 itemBoxSizer4
->Add(itemBoxSizer9
, 0, wxGROW
, 5);
162 wxStaticText
* itemStaticText10
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Size:"), wxDefaultPosition
, wxDefaultSize
, 0 );
163 itemBoxSizer9
->Add(itemStaticText10
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
165 m_sizeTextCtrl
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
166 m_sizeTextCtrl
->SetHelpText(_("Type a size in points."));
167 if (wxRichTextFontPage::ShowToolTips())
168 m_sizeTextCtrl
->SetToolTip(_("Type a size in points."));
169 itemBoxSizer9
->Add(m_sizeTextCtrl
, 0, wxGROW
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
171 wxArrayString m_sizeListBoxStrings
;
172 m_sizeListBox
= new wxListBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_SIZELISTBOX
, wxDefaultPosition
, wxSize(50, -1), m_sizeListBoxStrings
, wxLB_SINGLE
);
173 m_sizeListBox
->SetHelpText(_("Lists font sizes in points."));
174 if (wxRichTextFontPage::ShowToolTips())
175 m_sizeListBox
->SetToolTip(_("Lists font sizes in points."));
176 itemBoxSizer9
->Add(m_sizeListBox
, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
|wxFIXED_MINSIZE
, 5);
178 wxBoxSizer
* itemBoxSizer13
= new wxBoxSizer(wxHORIZONTAL
);
179 itemBoxSizer3
->Add(itemBoxSizer13
, 0, wxGROW
, 5);
181 wxBoxSizer
* itemBoxSizer14
= new wxBoxSizer(wxVERTICAL
);
182 itemBoxSizer13
->Add(itemBoxSizer14
, 0, wxGROW
, 5);
184 wxStaticText
* itemStaticText15
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Font st&yle:"), wxDefaultPosition
, wxDefaultSize
, 0 );
185 itemBoxSizer14
->Add(itemStaticText15
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
187 wxArrayString m_styleCtrlStrings
;
188 m_styleCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_STYLECTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(110, -1), m_styleCtrlStrings
, wxCB_READONLY
);
189 m_styleCtrl
->SetHelpText(_("Select regular or italic style."));
190 if (wxRichTextFontPage::ShowToolTips())
191 m_styleCtrl
->SetToolTip(_("Select regular or italic style."));
192 itemBoxSizer14
->Add(m_styleCtrl
, 0, wxGROW
|wxALL
, 5);
194 wxBoxSizer
* itemBoxSizer17
= new wxBoxSizer(wxVERTICAL
);
195 itemBoxSizer13
->Add(itemBoxSizer17
, 0, wxGROW
, 5);
197 wxStaticText
* itemStaticText18
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Font &weight:"), wxDefaultPosition
, wxDefaultSize
, 0 );
198 itemBoxSizer17
->Add(itemStaticText18
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
200 wxArrayString m_weightCtrlStrings
;
201 m_weightCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_WEIGHTCTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(110, -1), m_weightCtrlStrings
, wxCB_READONLY
);
202 m_weightCtrl
->SetHelpText(_("Select regular or bold."));
203 if (wxRichTextFontPage::ShowToolTips())
204 m_weightCtrl
->SetToolTip(_("Select regular or bold."));
205 itemBoxSizer17
->Add(m_weightCtrl
, 0, wxGROW
|wxALL
, 5);
207 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxVERTICAL
);
208 itemBoxSizer13
->Add(itemBoxSizer20
, 0, wxGROW
, 5);
210 wxStaticText
* itemStaticText21
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Underlining:"), wxDefaultPosition
, wxDefaultSize
, 0 );
211 itemBoxSizer20
->Add(itemStaticText21
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
213 wxArrayString m_underliningCtrlStrings
;
214 m_underliningCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(110, -1), m_underliningCtrlStrings
, wxCB_READONLY
);
215 m_underliningCtrl
->SetHelpText(_("Select underlining or no underlining."));
216 if (wxRichTextFontPage::ShowToolTips())
217 m_underliningCtrl
->SetToolTip(_("Select underlining or no underlining."));
218 itemBoxSizer20
->Add(m_underliningCtrl
, 0, wxGROW
|wxALL
, 5);
220 itemBoxSizer13
->Add(0, 0, 1, wxALIGN_CENTER_VERTICAL
|wxBOTTOM
, 5);
222 wxBoxSizer
* itemBoxSizer24
= new wxBoxSizer(wxVERTICAL
);
223 itemBoxSizer13
->Add(itemBoxSizer24
, 0, wxGROW
, 5);
225 m_textColourLabel
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL
, _("&Colour:"), wxDefaultPosition
, wxDefaultSize
, 0 );
226 m_textColourLabel
->SetValue(false);
227 itemBoxSizer24
->Add(m_textColourLabel
, 0, wxALIGN_CENTER_HORIZONTAL
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
229 m_colourCtrl
= new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_COLOURCTRL
, wxDefaultPosition
, wxSize(40, 20), 0 );
230 m_colourCtrl
->SetHelpText(_("Click to change the text colour."));
231 if (wxRichTextFontPage::ShowToolTips())
232 m_colourCtrl
->SetToolTip(_("Click to change the text colour."));
233 itemBoxSizer24
->Add(m_colourCtrl
, 0, wxGROW
|wxALL
, 5);
235 wxBoxSizer
* itemBoxSizer27
= new wxBoxSizer(wxVERTICAL
);
236 itemBoxSizer13
->Add(itemBoxSizer27
, 0, wxGROW
, 5);
238 m_bgColourLabel
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL
, _("&Bg colour:"), wxDefaultPosition
, wxDefaultSize
, 0 );
239 m_bgColourLabel
->SetValue(false);
240 itemBoxSizer27
->Add(m_bgColourLabel
, 0, wxALIGN_CENTER_HORIZONTAL
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
242 m_bgColourCtrl
= new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL
, wxDefaultPosition
, wxSize(40, 20), 0 );
243 m_bgColourCtrl
->SetHelpText(_("Click to change the text background colour."));
244 if (wxRichTextFontPage::ShowToolTips())
245 m_bgColourCtrl
->SetToolTip(_("Click to change the text background colour."));
246 itemBoxSizer27
->Add(m_bgColourCtrl
, 0, wxGROW
|wxALL
, 5);
248 wxBoxSizer
* itemBoxSizer30
= new wxBoxSizer(wxHORIZONTAL
);
249 itemBoxSizer3
->Add(itemBoxSizer30
, 0, wxGROW
, 5);
251 m_strikethroughCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL
, _("&Strikethrough"), wxDefaultPosition
, wxDefaultSize
, wxCHK_3STATE
|wxCHK_ALLOW_3RD_STATE_FOR_USER
);
252 m_strikethroughCtrl
->SetValue(false);
253 m_strikethroughCtrl
->SetHelpText(_("Check to show a line through the text."));
254 if (wxRichTextFontPage::ShowToolTips())
255 m_strikethroughCtrl
->SetToolTip(_("Check to show a line through the text."));
256 itemBoxSizer30
->Add(m_strikethroughCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
258 m_capitalsCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_CAPSCTRL
, _("Ca&pitals"), wxDefaultPosition
, wxDefaultSize
, wxCHK_3STATE
|wxCHK_ALLOW_3RD_STATE_FOR_USER
);
259 m_capitalsCtrl
->SetValue(false);
260 m_capitalsCtrl
->SetHelpText(_("Check to show the text in capitals."));
261 if (wxRichTextFontPage::ShowToolTips())
262 m_capitalsCtrl
->SetToolTip(_("Check to show the text in capitals."));
263 itemBoxSizer30
->Add(m_capitalsCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
265 m_superscriptCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_SUPERSCRIPT
, _("Supe&rscript"), wxDefaultPosition
, wxDefaultSize
, wxCHK_3STATE
|wxCHK_ALLOW_3RD_STATE_FOR_USER
);
266 m_superscriptCtrl
->SetValue(false);
267 m_superscriptCtrl
->SetHelpText(_("Check to show the text in superscript."));
268 if (wxRichTextFontPage::ShowToolTips())
269 m_superscriptCtrl
->SetToolTip(_("Check to show the text in superscript."));
270 itemBoxSizer30
->Add(m_superscriptCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
272 m_subscriptCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_SUBSCRIPT
, _("Subscrip&t"), wxDefaultPosition
, wxDefaultSize
, wxCHK_3STATE
|wxCHK_ALLOW_3RD_STATE_FOR_USER
);
273 m_subscriptCtrl
->SetValue(false);
274 m_subscriptCtrl
->SetHelpText(_("Check to show the text in subscript."));
275 if (wxRichTextFontPage::ShowToolTips())
276 m_subscriptCtrl
->SetToolTip(_("Check to show the text in subscript."));
277 itemBoxSizer30
->Add(m_subscriptCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
279 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
281 m_previewCtrl
= new wxRichTextFontPreviewCtrl( itemRichTextDialogPage1
, ID_RICHTEXTFONTPAGE_PREVIEWCTRL
, wxDefaultPosition
, wxSize(100, 60), 0 );
282 m_previewCtrl
->SetHelpText(_("Shows a preview of the font settings."));
283 if (wxRichTextFontPage::ShowToolTips())
284 m_previewCtrl
->SetToolTip(_("Shows a preview of the font settings."));
285 itemBoxSizer3
->Add(m_previewCtrl
, 0, wxGROW
|wxALL
, 5);
287 ////@end wxRichTextFontPage content construction
289 m_faceListBox
->UpdateFonts();
291 m_styleCtrl
->Append(_("(none)"));
292 m_styleCtrl
->Append(_("Regular"));
293 m_styleCtrl
->Append(_("Italic"));
295 m_weightCtrl
->Append(_("(none)"));
296 m_weightCtrl
->Append(_("Regular"));
297 m_weightCtrl
->Append(_("Bold"));
299 m_underliningCtrl
->Append(_("(none)"));
300 m_underliningCtrl
->Append(_("Not underlined"));
301 m_underliningCtrl
->Append(_("Underlined"));
305 for (i
= 8; i
< 40; i
++)
307 nStr
.Printf(wxT("%d"), i
);
308 m_sizeListBox
->Append(nStr
);
310 m_sizeListBox
->Append(wxT("48"));
311 m_sizeListBox
->Append(wxT("72"));
314 /// Transfer data from/to window
315 bool wxRichTextFontPage::TransferDataFromWindow()
317 wxPanel::TransferDataFromWindow();
319 wxRichTextAttr
* attr
= GetAttributes();
321 if (!m_faceTextCtrl
->GetValue().IsEmpty())
323 wxString faceName
= m_faceTextCtrl
->GetValue();
324 attr
->SetFontFaceName(faceName
);
327 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_FACE
));
329 wxString strSize
= m_sizeTextCtrl
->GetValue();
330 if (!strSize
.IsEmpty())
332 int sz
= wxAtoi(strSize
);
335 attr
->SetFontSize(sz
);
339 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE
));
341 if (m_styleCtrl
->GetSelection() != wxNOT_FOUND
&& m_styleCtrl
->GetSelection() != 0)
344 if (m_styleCtrl
->GetSelection() == 2)
345 style
= wxFONTSTYLE_ITALIC
;
347 style
= wxFONTSTYLE_NORMAL
;
349 attr
->SetFontStyle(style
);
352 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC
));
354 if (m_weightCtrl
->GetSelection() != wxNOT_FOUND
&& m_weightCtrl
->GetSelection() != 0)
357 if (m_weightCtrl
->GetSelection() == 2)
358 weight
= wxFONTWEIGHT_BOLD
;
360 weight
= wxFONTWEIGHT_NORMAL
;
362 attr
->SetFontWeight(weight
);
365 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT
));
367 if (m_underliningCtrl
->GetSelection() != wxNOT_FOUND
&& m_underliningCtrl
->GetSelection() != 0)
370 if (m_underliningCtrl
->GetSelection() == 2)
375 attr
->SetFontUnderlined(underlined
);
378 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE
));
380 if (m_textColourLabel
->GetValue())
382 attr
->SetTextColour(m_colourCtrl
->GetColour());
385 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR
));
387 if (m_bgColourLabel
->GetValue())
389 attr
->SetBackgroundColour(m_bgColourCtrl
->GetColour());
392 attr
->SetFlags(attr
->GetFlags() & (~ wxTEXT_ATTR_BACKGROUND_COLOUR
));
394 if (m_strikethroughCtrl
->Get3StateValue() != wxCHK_UNDETERMINED
)
396 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH
);
398 if (m_strikethroughCtrl
->Get3StateValue() == wxCHK_CHECKED
)
399 attr
->SetTextEffects(attr
->GetTextEffects() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH
);
401 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH
);
405 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH
);
406 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH
);
409 if (m_capitalsCtrl
->Get3StateValue() != wxCHK_UNDETERMINED
)
411 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_CAPITALS
);
413 if (m_capitalsCtrl
->Get3StateValue() == wxCHK_CHECKED
)
414 attr
->SetTextEffects(attr
->GetTextEffects() | wxTEXT_ATTR_EFFECT_CAPITALS
);
416 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS
);
420 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_CAPITALS
);
421 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS
);
424 if (m_superscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
426 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT
);
427 attr
->SetTextEffects(attr
->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT
);
428 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUBSCRIPT
);
430 else if (m_subscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
432 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUBSCRIPT
);
433 attr
->SetTextEffects(attr
->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUBSCRIPT
);
434 attr
->SetTextEffects(attr
->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUPERSCRIPT
);
438 // If they are undetermined, we don't want to include these flags in the text effects - the objects
439 // should retain their original style.
440 attr
->SetTextEffectFlags(attr
->GetTextEffectFlags() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT
|wxTEXT_ATTR_EFFECT_SUPERSCRIPT
) );
441 attr
->SetTextEffects(attr
->GetTextEffects() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT
|wxTEXT_ATTR_EFFECT_SUPERSCRIPT
) );
447 bool wxRichTextFontPage::TransferDataToWindow()
449 wxPanel::TransferDataToWindow();
452 wxRichTextAttr
* attr
= GetAttributes();
454 if (attr
->HasFontFaceName())
456 m_faceTextCtrl
->SetValue(attr
->GetFontFaceName());
457 m_faceListBox
->SetFaceNameSelection(attr
->GetFont().GetFaceName());
461 m_faceTextCtrl
->SetValue(wxEmptyString
);
462 m_faceListBox
->SetFaceNameSelection(wxEmptyString
);
465 if (attr
->HasFontSize())
467 wxString strSize
= wxString::Format(wxT("%d"), attr
->GetFontSize());
468 m_sizeTextCtrl
->SetValue(strSize
);
469 if (m_sizeListBox
->FindString(strSize
) != wxNOT_FOUND
)
470 m_sizeListBox
->SetStringSelection(strSize
);
474 m_sizeTextCtrl
->SetValue(wxEmptyString
);
475 m_sizeListBox
->SetSelection(wxNOT_FOUND
);
478 if (attr
->HasFontWeight())
480 if (attr
->GetFontWeight() == wxBOLD
)
481 m_weightCtrl
->SetSelection(2);
483 m_weightCtrl
->SetSelection(1);
487 m_weightCtrl
->SetSelection(0);
490 if (attr
->HasFontItalic())
492 if (attr
->GetFontStyle() == wxITALIC
)
493 m_styleCtrl
->SetSelection(2);
495 m_styleCtrl
->SetSelection(1);
499 m_styleCtrl
->SetSelection(0);
502 if (attr
->HasFontUnderlined())
504 if (attr
->GetFontUnderlined())
505 m_underliningCtrl
->SetSelection(2);
507 m_underliningCtrl
->SetSelection(1);
511 m_underliningCtrl
->SetSelection(0);
514 if (attr
->HasTextColour())
516 m_colourCtrl
->SetColour(attr
->GetTextColour());
517 m_textColourLabel
->SetValue(true);
518 m_colourPresent
= true;
522 m_colourCtrl
->SetColour(*wxBLACK
);
523 m_textColourLabel
->SetValue(false);
526 if (attr
->HasBackgroundColour())
528 m_bgColourCtrl
->SetColour(attr
->GetBackgroundColour());
529 m_bgColourLabel
->SetValue(true);
530 m_bgColourPresent
= true;
534 m_bgColourCtrl
->SetColour(*wxWHITE
);
535 m_bgColourLabel
->SetValue(false);
538 if (attr
->HasTextEffects())
540 if (attr
->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH
)
542 if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH
)
543 m_strikethroughCtrl
->Set3StateValue(wxCHK_CHECKED
);
545 m_strikethroughCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
548 m_strikethroughCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
550 if (attr
->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_CAPITALS
)
552 if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS
)
553 m_capitalsCtrl
->Set3StateValue(wxCHK_CHECKED
);
555 m_capitalsCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
558 m_capitalsCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
560 if ( attr
->GetTextEffectFlags() & (wxTEXT_ATTR_EFFECT_SUPERSCRIPT
| wxTEXT_ATTR_EFFECT_SUBSCRIPT
) )
562 if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT
)
564 m_superscriptCtrl
->Set3StateValue(wxCHK_CHECKED
);
565 m_subscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
567 else if (attr
->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT
)
569 m_superscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
570 m_subscriptCtrl
->Set3StateValue(wxCHK_CHECKED
);
574 m_superscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
575 m_subscriptCtrl
->Set3StateValue(wxCHK_UNCHECKED
);
580 m_superscriptCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
581 m_subscriptCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
586 m_strikethroughCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
587 m_capitalsCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
588 m_superscriptCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
589 m_subscriptCtrl
->Set3StateValue(wxCHK_UNDETERMINED
);
594 m_dontUpdate
= false;
599 wxRichTextAttr
* wxRichTextFontPage::GetAttributes()
601 return wxRichTextFormattingDialog::GetDialogAttributes(this);
604 /// Updates the font preview
605 void wxRichTextFontPage::UpdatePreview()
609 if (m_textColourLabel
->GetValue())
610 m_previewCtrl
->SetForegroundColour(m_colourCtrl
->GetColour());
613 m_previewCtrl
->SetForegroundColour(*wxBLACK
);
614 if (!(m_colourCtrl
->GetColour() == *wxBLACK
))
616 m_colourCtrl
->SetColour(*wxBLACK
);
617 m_colourCtrl
->Refresh();
621 if (m_bgColourLabel
->GetValue())
622 m_previewCtrl
->SetBackgroundColour(m_bgColourCtrl
->GetColour());
625 m_previewCtrl
->SetBackgroundColour(*wxWHITE
);
627 if (!(m_bgColourCtrl
->GetColour() == *wxWHITE
))
629 m_bgColourCtrl
->SetColour(*wxWHITE
);
630 m_bgColourCtrl
->Refresh();
634 if (m_faceListBox
->GetSelection() != wxNOT_FOUND
)
636 wxString faceName
= m_faceListBox
->GetFaceName(m_faceListBox
->GetSelection());
637 attr
.SetFontFaceName(faceName
);
640 wxString strSize
= m_sizeTextCtrl
->GetValue();
641 if (!strSize
.IsEmpty())
643 int sz
= wxAtoi(strSize
);
645 attr
.SetFontSize(sz
);
648 if (m_styleCtrl
->GetSelection() != wxNOT_FOUND
&& m_styleCtrl
->GetSelection() != 0)
651 if (m_styleCtrl
->GetSelection() == 2)
652 style
= wxFONTSTYLE_ITALIC
;
654 style
= wxFONTSTYLE_NORMAL
;
656 attr
.SetFontStyle(style
);
659 if (m_weightCtrl
->GetSelection() != wxNOT_FOUND
&& m_weightCtrl
->GetSelection() != 0)
662 if (m_weightCtrl
->GetSelection() == 2)
663 weight
= wxFONTWEIGHT_BOLD
;
665 weight
= wxFONTWEIGHT_NORMAL
;
667 attr
.SetFontWeight(weight
);
670 if (m_underliningCtrl
->GetSelection() != wxNOT_FOUND
&& m_underliningCtrl
->GetSelection() != 0)
673 if (m_underliningCtrl
->GetSelection() == 2)
678 attr
.SetFontUnderlined(underlined
);
683 if (m_strikethroughCtrl
->Get3StateValue() == wxCHK_CHECKED
)
685 textEffects
|= wxTEXT_ATTR_EFFECT_STRIKETHROUGH
;
688 if (m_capitalsCtrl
->Get3StateValue() == wxCHK_CHECKED
)
690 textEffects
|= wxTEXT_ATTR_EFFECT_CAPITALS
;
693 if ( m_superscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
694 textEffects
|= wxTEXT_ATTR_EFFECT_SUPERSCRIPT
;
695 else if ( m_subscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
696 textEffects
|= wxTEXT_ATTR_EFFECT_SUBSCRIPT
;
698 wxFont font
= attr
.GetFont();
699 m_previewCtrl
->SetFont(font
);
700 m_previewCtrl
->SetTextEffects(textEffects
);
701 m_previewCtrl
->Refresh();
705 * Should we show tooltips?
708 bool wxRichTextFontPage::ShowToolTips()
710 return wxRichTextFormattingDialog::ShowToolTips();
714 * Get bitmap resources
717 wxBitmap
wxRichTextFontPage::GetBitmapResource( const wxString
& name
)
720 ////@begin wxRichTextFontPage bitmap retrieval
723 ////@end wxRichTextFontPage bitmap retrieval
730 wxIcon
wxRichTextFontPage::GetIconResource( const wxString
& name
)
733 ////@begin wxRichTextFontPage icon retrieval
736 ////@end wxRichTextFontPage icon retrieval
740 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL
743 void wxRichTextFontPage::OnFaceTextCtrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
748 wxString facename
= m_faceTextCtrl
->GetValue();
749 if (!facename
.IsEmpty())
751 if (m_faceListBox
->HasFaceName(facename
))
753 m_faceListBox
->SetFaceNameSelection(facename
);
758 // Try to find a partial match
759 const wxArrayString
& arr
= m_faceListBox
->GetFaceNames();
761 for (i
= 0; i
< arr
.GetCount(); i
++)
763 if (arr
[i
].Mid(0, facename
.Length()).Lower() == facename
.Lower())
765 m_faceListBox
->ScrollToRow(i
);
775 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
778 void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
783 wxString strSize
= m_sizeTextCtrl
->GetValue();
784 if (!strSize
.IsEmpty() && m_sizeListBox
->FindString(strSize
) != wxNOT_FOUND
)
785 m_sizeListBox
->SetStringSelection(strSize
);
791 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX
794 void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent
& event
)
796 bool oldDontUpdate
= m_dontUpdate
;
799 m_sizeTextCtrl
->SetValue(event
.GetString());
801 m_dontUpdate
= oldDontUpdate
;
810 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_FACELISTBOX
813 void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent
& WXUNUSED(event
) )
815 bool oldDontUpdate
= m_dontUpdate
;
818 m_faceTextCtrl
->SetValue(m_faceListBox
->GetFaceName(m_faceListBox
->GetSelection()));
820 m_dontUpdate
= oldDontUpdate
;
829 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_STYLECTRL
832 void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )
842 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
845 void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )
855 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL
858 void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )
866 void wxRichTextFontPage::OnColourClicked( wxCommandEvent
& event
)
868 if (event
.GetId() == m_colourCtrl
->GetId())
869 m_colourPresent
= true;
870 else if (event
.GetId() == m_bgColourCtrl
->GetId())
871 m_bgColourPresent
= true;
875 if (event
.GetId() == m_colourCtrl
->GetId())
877 m_textColourLabel
->SetValue(true);
879 else if (event
.GetId() == m_bgColourCtrl
->GetId())
881 m_bgColourLabel
->SetValue(true);
884 m_dontUpdate
= false;
889 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL
892 void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent
& WXUNUSED(event
) )
901 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_CAPSCTRL
904 void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent
& WXUNUSED(event
) )
913 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUPERSCRIPT
916 void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent
& WXUNUSED(event
) )
921 if ( m_superscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
922 m_subscriptCtrl
->Set3StateValue( wxCHK_UNCHECKED
);
928 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUBSCRIPT
931 void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent
& WXUNUSED(event
) )
936 if ( m_subscriptCtrl
->Get3StateValue() == wxCHK_CHECKED
)
937 m_superscriptCtrl
->Set3StateValue( wxCHK_UNCHECKED
);