]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/richtext/richtextfontpage.cpp
fixing changing text colors
[wxWidgets.git] / src / richtext / richtextfontpage.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/richtext/richeditfontpage.cpp
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
12#include "../../include/wx/richtext/richtextfontpage.h"
13
14/*!
15 * wxRichTextFontPage type definition
16 */
17
18IMPLEMENT_DYNAMIC_CLASS( wxRichTextFontPage, wxPanel )
19
20/*!
21 * wxRichTextFontPage event table definition
22 */
23
24BEGIN_EVENT_TABLE( wxRichTextFontPage, wxPanel )
25 EVT_LISTBOX( ID_RICHTEXTFONTPAGE_FACELISTBOX, wxRichTextFontPage::OnFaceListBoxSelected )
26 EVT_BUTTON( ID_RICHTEXTFONTPAGE_COLOURCTRL, wxRichTextFontPage::OnColourClicked )
27
28////@begin wxRichTextFontPage event table entries
29 EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxRichTextFontPage::OnFaceTextCtrlUpdated )
30
31 EVT_TEXT( ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxRichTextFontPage::OnSizeTextCtrlUpdated )
32
33 EVT_LISTBOX( ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxRichTextFontPage::OnSizeListBoxSelected )
34
35 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_STYLECTRL, wxRichTextFontPage::OnStyleCtrlSelected )
36
37 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxRichTextFontPage::OnWeightCtrlSelected )
38
39 EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxRichTextFontPage::OnUnderliningCtrlSelected )
40
41////@end wxRichTextFontPage event table entries
42
43END_EVENT_TABLE()
44
45/*!
46 * wxRichTextFontPage constructors
47 */
48
49wxRichTextFontPage::wxRichTextFontPage( )
50{
51 Init();
52}
53
54wxRichTextFontPage::wxRichTextFontPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
55{
56 Init();
57 Create(parent, id, pos, size, style);
58}
59
60/*!
61 * Initialise members
62 */
63
64void wxRichTextFontPage::Init()
65{
66 m_dontUpdate = false;
67 m_colourPresent = false;
68
69////@begin wxRichTextFontPage member initialisation
70 m_faceTextCtrl = NULL;
71 m_faceListBox = NULL;
72 m_sizeTextCtrl = NULL;
73 m_sizeListBox = NULL;
74 m_styleCtrl = NULL;
75 m_weightCtrl = NULL;
76 m_underliningCtrl = NULL;
77 m_colourCtrl = NULL;
78 m_previewCtrl = NULL;
79////@end wxRichTextFontPage member initialisation
80}
81
82/*!
83 * wxRichTextFontPage creator
84 */
85
86bool wxRichTextFontPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
87{
88////@begin wxRichTextFontPage creation
89 wxPanel::Create( parent, id, pos, size, style );
90
91 CreateControls();
92 if (GetSizer())
93 {
94 GetSizer()->SetSizeHints(this);
95 }
96 Centre();
97////@end wxRichTextFontPage creation
98 return true;
99}
100
101/*!
102 * Control creation for wxRichTextFontPage
103 */
104
105void wxRichTextFontPage::CreateControls()
106{
107////@begin wxRichTextFontPage content construction
108 wxRichTextFontPage* itemPanel1 = this;
109
110 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
111 itemPanel1->SetSizer(itemBoxSizer2);
112
113 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
114 itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
115
116 wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
117 itemBoxSizer3->Add(itemBoxSizer4, 1, wxGROW, 5);
118
119 wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
120 itemBoxSizer4->Add(itemBoxSizer5, 1, wxGROW, 5);
121
122 wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Font:"), wxDefaultPosition, wxDefaultSize, 0 );
123 itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
124
125 m_faceTextCtrl = new wxTextCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_FACETEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
126 m_faceTextCtrl->SetHelpText(_("Type a font name."));
127 if (ShowToolTips())
128 m_faceTextCtrl->SetToolTip(_("Type a font name."));
129 itemBoxSizer5->Add(m_faceTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
130
131 m_faceListBox = new wxRichTextFontListBox( itemPanel1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 140), wxSIMPLE_BORDER );
132 m_faceListBox->SetHelpText(_("Lists the available fonts."));
133 if (ShowToolTips())
134 m_faceListBox->SetToolTip(_("Lists the available fonts."));
135 itemBoxSizer5->Add(m_faceListBox, 1, wxGROW|wxALL|wxFIXED_MINSIZE, 5);
136
137 wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL);
138 itemBoxSizer4->Add(itemBoxSizer9, 0, wxGROW, 5);
139
140 wxStaticText* itemStaticText10 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 );
141 itemBoxSizer9->Add(itemStaticText10, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
142
143 m_sizeTextCtrl = new wxTextCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
144 m_sizeTextCtrl->SetHelpText(_("Type a size in points."));
145 if (ShowToolTips())
146 m_sizeTextCtrl->SetToolTip(_("Type a size in points."));
147 itemBoxSizer9->Add(m_sizeTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
148
149 wxString* m_sizeListBoxStrings = NULL;
150 m_sizeListBox = new wxListBox( itemPanel1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), 0, m_sizeListBoxStrings, wxLB_SINGLE );
151 m_sizeListBox->SetHelpText(_("Lists font sizes in points."));
152 if (ShowToolTips())
153 m_sizeListBox->SetToolTip(_("Lists font sizes in points."));
154 itemBoxSizer9->Add(m_sizeListBox, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxFIXED_MINSIZE, 5);
155
156 wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
157 itemBoxSizer3->Add(itemBoxSizer13, 0, wxGROW, 5);
158
159 wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL);
160 itemBoxSizer13->Add(itemBoxSizer14, 1, wxGROW, 5);
161
162 wxStaticText* itemStaticText15 = new wxStaticText( itemPanel1, wxID_STATIC, _("Font st&yle:"), wxDefaultPosition, wxDefaultSize, 0 );
163 itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
164
165 wxString* m_styleCtrlStrings = NULL;
166 m_styleCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_STYLECTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_styleCtrlStrings, wxCB_READONLY );
167 m_styleCtrl->SetHelpText(_("Select regular or italic style."));
168 if (ShowToolTips())
169 m_styleCtrl->SetToolTip(_("Select regular or italic style."));
170 itemBoxSizer14->Add(m_styleCtrl, 0, wxGROW|wxALL, 5);
171
172 wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL);
173 itemBoxSizer13->Add(itemBoxSizer17, 1, wxGROW, 5);
174
175 wxStaticText* itemStaticText18 = new wxStaticText( itemPanel1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 );
176 itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
177
178 wxString* m_weightCtrlStrings = NULL;
179 m_weightCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_weightCtrlStrings, wxCB_READONLY );
180 m_weightCtrl->SetHelpText(_("Select regular or bold."));
181 if (ShowToolTips())
182 m_weightCtrl->SetToolTip(_("Select regular or bold."));
183 itemBoxSizer17->Add(m_weightCtrl, 0, wxGROW|wxALL, 5);
184
185 wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL);
186 itemBoxSizer13->Add(itemBoxSizer20, 1, wxGROW, 5);
187
188 wxStaticText* itemStaticText21 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 );
189 itemBoxSizer20->Add(itemStaticText21, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
190
191 wxString* m_underliningCtrlStrings = NULL;
192 m_underliningCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_underliningCtrlStrings, wxCB_READONLY );
193 m_underliningCtrl->SetHelpText(_("Select underlining or no underlining."));
194 if (ShowToolTips())
195 m_underliningCtrl->SetToolTip(_("Select underlining or no underlining."));
196 itemBoxSizer20->Add(m_underliningCtrl, 0, wxGROW|wxALL, 5);
197
198 wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL);
199 itemBoxSizer13->Add(itemBoxSizer23, 0, wxGROW, 5);
200
201 wxStaticText* itemStaticText24 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 );
202 itemBoxSizer23->Add(itemStaticText24, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
203
204 m_colourCtrl = new wxRichTextColourSwatchCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), wxSIMPLE_BORDER );
205 m_colourCtrl->SetHelpText(_("Click to change the text colour."));
206 if (ShowToolTips())
207 m_colourCtrl->SetToolTip(_("Click to change the text colour."));
208 itemBoxSizer23->Add(m_colourCtrl, 0, wxALIGN_LEFT|wxALL, 5);
209
210 itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
211
212 m_previewCtrl = new wxRichTextFontPreviewCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 80), wxSIMPLE_BORDER );
213 m_previewCtrl->SetHelpText(_("Shows a preview of the font settings."));
214 if (ShowToolTips())
215 m_previewCtrl->SetToolTip(_("Shows a preview of the font settings."));
216 itemBoxSizer3->Add(m_previewCtrl, 0, wxGROW|wxALL, 5);
217
218////@end wxRichTextFontPage content construction
219
220 m_faceListBox->UpdateFonts();
221
222 m_styleCtrl->Append(_("Regular"));
223 m_styleCtrl->Append(_("Italic"));
224
225 m_weightCtrl->Append(_("Regular"));
226 m_weightCtrl->Append(_("Bold"));
227
228 m_underliningCtrl->Append(_("Not underlined"));
229 m_underliningCtrl->Append(_("Underlined"));
230
231 wxString nStr;
232 int i;
233 for (i = 8; i < 40; i++)
234 {
235 nStr.Printf(wxT("%d"), i);
236 m_sizeListBox->Append(nStr);
237 }
238 m_sizeListBox->Append(wxT("48"));
239 m_sizeListBox->Append(wxT("72"));
240}
241
242/// Transfer data from/to window
243bool wxRichTextFontPage::TransferDataFromWindow()
244{
245 wxPanel::TransferDataFromWindow();
246
247 wxTextAttrEx* attr = GetAttributes();
248
249 if (m_faceListBox->GetSelection() != wxNOT_FOUND)
250 {
251 wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection());
252 if (!faceName.IsEmpty())
253 {
254 wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
255 font.SetFaceName(faceName);
256 wxSetFontPreservingStyles(*attr, font);
257 attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_FACE);
258 }
259 }
260 else
261 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_FACE));
262
263 wxString strSize = m_sizeTextCtrl->GetValue();
264 if (!strSize.IsEmpty())
265 {
266 int sz = wxAtoi(strSize);
267 if (sz > 0)
268 {
269 wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
270 font.SetPointSize(sz);
271 wxSetFontPreservingStyles(*attr, font);
272 attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_SIZE);
273 }
274 }
275 else
276 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE));
277
278 if (m_styleCtrl->GetSelection() != wxNOT_FOUND)
279 {
280 int style;
281 if (m_styleCtrl->GetStringSelection() == _("Italic"))
282 style = wxITALIC;
283 else
284 style = wxNORMAL;
285
286 wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
287 font.SetStyle(style);
288 wxSetFontPreservingStyles(*attr, font);
289 attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_ITALIC);
290 }
291 else
292 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC));
293
294 if (m_weightCtrl->GetSelection() != wxNOT_FOUND)
295 {
296 int weight;
297 if (m_weightCtrl->GetStringSelection() == _("Bold"))
298 weight = wxBOLD;
299 else
300 weight = wxNORMAL;
301
302 wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
303 font.SetWeight(weight);
304 wxSetFontPreservingStyles(*attr, font);
305 attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_WEIGHT);
306 }
307 else
308 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT));
309
310 if (m_underliningCtrl->GetSelection() != wxNOT_FOUND)
311 {
312 bool underlined;
313 if (m_underliningCtrl->GetStringSelection() == _("Underlined"))
314 underlined = true;
315 else
316 underlined = false;
317
318 wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
319 font.SetUnderlined(underlined);
320 wxSetFontPreservingStyles(*attr, font);
321 attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_UNDERLINE);
322 }
323 else
324 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE));
325
326 if (m_colourPresent)
327 {
328 attr->SetTextColour(m_colourCtrl->GetBackgroundColour());
329 }
330 else
331 attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR));
332
333 return true;
334}
335
336bool wxRichTextFontPage::TransferDataToWindow()
337{
338 wxPanel::TransferDataToWindow();
339
340 m_dontUpdate = true;
341 wxTextAttrEx* attr = GetAttributes();
342
343 if (attr->HasFont() && attr->HasFaceName())
344 {
345 m_faceTextCtrl->SetValue(attr->GetFont().GetFaceName());
346 m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName());
347 }
348 else
349 {
350 m_faceTextCtrl->SetValue(wxEmptyString);
351 m_faceListBox->SetFaceNameSelection(wxEmptyString);
352 }
353
354 if (attr->HasFont() && attr->HasSize())
355 {
356 wxString strSize = wxString::Format(wxT("%d"), attr->GetFont().GetPointSize());
357 m_sizeTextCtrl->SetValue(strSize);
358 if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
359 m_sizeListBox->SetStringSelection(strSize);
360 }
361 else
362 {
363 m_sizeTextCtrl->SetValue(wxEmptyString);
364 m_sizeListBox->SetSelection(wxNOT_FOUND);
365 }
366
367 if (attr->HasFont() && attr->HasWeight())
368 {
369 if (attr->GetFont().GetWeight() == wxBOLD)
370 m_weightCtrl->SetSelection(1);
371 else
372 m_weightCtrl->SetSelection(0);
373 }
374 else
375 {
376 m_weightCtrl->SetSelection(wxNOT_FOUND);
377 }
378
379 if (attr->HasFont() && attr->HasItalic())
380 {
381 if (attr->GetFont().GetStyle() == wxITALIC)
382 m_styleCtrl->SetSelection(1);
383 else
384 m_styleCtrl->SetSelection(0);
385 }
386 else
387 {
388 m_styleCtrl->SetSelection(wxNOT_FOUND);
389 }
390
391 if (attr->HasFont() && attr->HasUnderlined())
392 {
393 if (attr->GetFont().GetUnderlined())
394 m_underliningCtrl->SetSelection(1);
395 else
396 m_underliningCtrl->SetSelection(0);
397 }
398 else
399 {
400 m_underliningCtrl->SetSelection(wxNOT_FOUND);
401 }
402
403 if (attr->HasTextColour())
404 {
405 m_colourCtrl->SetBackgroundColour(attr->GetTextColour());
406 m_colourPresent = true;
407 }
408
409 UpdatePreview();
410
411 m_dontUpdate = false;
412
413 return true;
414}
415
416wxTextAttrEx* wxRichTextFontPage::GetAttributes()
417{
418 return wxRichTextFormattingDialog::GetDialogAttributes(this);
419}
420
421/// Updates the font preview
422void wxRichTextFontPage::UpdatePreview()
423{
424 wxFont font(*wxNORMAL_FONT);
425
426 if (m_colourPresent)
427 m_previewCtrl->SetForegroundColour(m_colourCtrl->GetBackgroundColour());
428
429 if (m_faceListBox->GetSelection() != wxNOT_FOUND)
430 {
431 wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection());
432 font.SetFaceName(faceName);
433 }
434
435 wxString strSize = m_sizeTextCtrl->GetValue();
436 if (!strSize.IsEmpty())
437 {
438 int sz = wxAtoi(strSize);
439 if (sz > 0)
440 font.SetPointSize(sz);
441 }
442
443 if (m_styleCtrl->GetSelection() != wxNOT_FOUND)
444 {
445 int style;
446 if (m_styleCtrl->GetStringSelection() == _("Italic"))
447 style = wxITALIC;
448 else
449 style = wxNORMAL;
450
451 font.SetStyle(style);
452 }
453
454 if (m_weightCtrl->GetSelection() != wxNOT_FOUND)
455 {
456 int weight;
457 if (m_weightCtrl->GetStringSelection() == _("Bold"))
458 weight = wxBOLD;
459 else
460 weight = wxNORMAL;
461
462 font.SetWeight(weight);
463 }
464
465 if (m_underliningCtrl->GetSelection() != wxNOT_FOUND)
466 {
467 bool underlined;
468 if (m_underliningCtrl->GetStringSelection() == _("Underlined"))
469 underlined = true;
470 else
471 underlined = false;
472
473 font.SetUnderlined(underlined);
474 }
475
476 m_previewCtrl->SetFont(font);
477 m_previewCtrl->Refresh();
478}
479
480/*!
481 * Should we show tooltips?
482 */
483
484bool wxRichTextFontPage::ShowToolTips()
485{
486 return true;
487}
488
489/*!
490 * Get bitmap resources
491 */
492
493wxBitmap wxRichTextFontPage::GetBitmapResource( const wxString& name )
494{
495 // Bitmap retrieval
496////@begin wxRichTextFontPage bitmap retrieval
497 wxUnusedVar(name);
498 return wxNullBitmap;
499////@end wxRichTextFontPage bitmap retrieval
500}
501
502/*!
503 * Get icon resources
504 */
505
506wxIcon wxRichTextFontPage::GetIconResource( const wxString& name )
507{
508 // Icon retrieval
509////@begin wxRichTextFontPage icon retrieval
510 wxUnusedVar(name);
511 return wxNullIcon;
512////@end wxRichTextFontPage icon retrieval
513}
514
515/*!
516 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL
517 */
518
519void wxRichTextFontPage::OnFaceTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) )
520{
521 if (m_dontUpdate)
522 return;
523
524 wxString facename = m_faceTextCtrl->GetValue();
525 if (!facename.IsEmpty())
526 {
527 if (m_faceListBox->HasFaceName(facename))
528 {
529 m_faceListBox->SetFaceNameSelection(facename);
530 UpdatePreview();
531 }
532 else
533 {
534 // Try to find a partial match
535 const wxArrayString& arr = m_faceListBox->GetFaceNames();
536 size_t i;
537 for (i = 0; i < arr.GetCount(); i++)
538 {
539 if (arr[i].Mid(0, facename.Length()).Lower() == facename.Lower())
540 {
541 m_faceListBox->ScrollToLine(i);
542 break;
543 }
544 }
545 }
546 }
547}
548
549
550/*!
551 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
552 */
553
554void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) )
555{
556 if (m_dontUpdate)
557 return;
558
559 wxString strSize = m_sizeTextCtrl->GetValue();
560 if (!strSize.IsEmpty() && m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
561 m_sizeListBox->SetStringSelection(strSize);
562 UpdatePreview();
563}
564
565
566/*!
567 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX
568 */
569
570void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event )
571{
572 m_dontUpdate = true;
573
574 m_sizeTextCtrl->SetValue(event.GetString());
575
576 m_dontUpdate = false;
577
578 UpdatePreview();
579}
580
581/*!
582 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_FACELISTBOX
583 */
584
585void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) )
586{
587 m_dontUpdate = true;
588
589 m_faceTextCtrl->SetValue(m_faceListBox->GetFaceName(m_faceListBox->GetSelection()));
590
591 m_dontUpdate = false;
592
593 UpdatePreview();
594}
595
596/*!
597 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_STYLECTRL
598 */
599
600void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) )
601{
602 UpdatePreview();
603}
604
605
606/*!
607 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
608 */
609
610void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(event) )
611{
612 UpdatePreview();
613}
614
615
616/*!
617 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL
618 */
619
620void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent& WXUNUSED(event) )
621{
622 UpdatePreview();
623}
624
625void wxRichTextFontPage::OnColourClicked( wxCommandEvent& WXUNUSED(event) )
626{
627 m_colourPresent = true;
628
629 UpdatePreview();
630}