]>
Commit | Line | Data |
---|---|---|
97ff49b3 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: src/richtext/richtextfontpage.cpp |
97ff49b3 JS |
3 | // Purpose: Font page for wxRichTextFormattingDialog |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 2006-10-02 | |
97ff49b3 JS |
7 | // Copyright: (c) Julian Smart |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
41a85215 | 11 | #include "wx/richtext/richtextfontpage.h" |
97ff49b3 | 12 | |
97ff49b3 JS |
13 | /*! |
14 | * wxRichTextFontPage type definition | |
15 | */ | |
16 | ||
603f702b | 17 | IMPLEMENT_DYNAMIC_CLASS( wxRichTextFontPage, wxRichTextDialogPage ) |
97ff49b3 JS |
18 | |
19 | /*! | |
20 | * wxRichTextFontPage event table definition | |
21 | */ | |
22 | ||
603f702b | 23 | BEGIN_EVENT_TABLE( wxRichTextFontPage, wxRichTextDialogPage ) |
97ff49b3 JS |
24 | EVT_LISTBOX( ID_RICHTEXTFONTPAGE_FACELISTBOX, wxRichTextFontPage::OnFaceListBoxSelected ) |
25 | EVT_BUTTON( ID_RICHTEXTFONTPAGE_COLOURCTRL, wxRichTextFontPage::OnColourClicked ) | |
50283a51 | 26 | EVT_BUTTON( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxRichTextFontPage::OnColourClicked ) |
97ff49b3 JS |
27 | |
28 | ////@begin wxRichTextFontPage event table entries | |
32423dd8 JS |
29 | EVT_IDLE( wxRichTextFontPage::OnIdle ) |
30 | ||
97ff49b3 JS |
31 | EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxRichTextFontPage::OnFaceTextCtrlUpdated ) |
32 | ||
33 | EVT_TEXT( ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxRichTextFontPage::OnSizeTextCtrlUpdated ) | |
34 | ||
32423dd8 JS |
35 | EVT_SPIN_UP( ID_RICHTEXTFONTPAGE_SPINBUTTONS, wxRichTextFontPage::OnRichtextfontpageSpinbuttonsUp ) |
36 | EVT_SPIN_DOWN( ID_RICHTEXTFONTPAGE_SPINBUTTONS, wxRichTextFontPage::OnRichtextfontpageSpinbuttonsDown ) | |
37 | ||
38 | EVT_CHOICE( ID_RICHTEXTFONTPAGE_SIZE_UNITS, wxRichTextFontPage::OnRichtextfontpageSizeUnitsSelected ) | |
39 | ||
97ff49b3 JS |
40 | EVT_LISTBOX( ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxRichTextFontPage::OnSizeListBoxSelected ) |
41 | ||
42 | EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_STYLECTRL, wxRichTextFontPage::OnStyleCtrlSelected ) | |
43 | ||
44 | EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxRichTextFontPage::OnWeightCtrlSelected ) | |
45 | ||
46 | EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxRichTextFontPage::OnUnderliningCtrlSelected ) | |
47 | ||
3c6cc330 JS |
48 | EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected ) |
49 | ||
50 | EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected ) | |
51 | ||
42688aea JS |
52 | EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, wxRichTextFontPage::OnStrikethroughctrlClick ) |
53 | ||
54 | EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL, wxRichTextFontPage::OnCapsctrlClick ) | |
55 | ||
d07f2e19 JS |
56 | EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SMALLCAPSCTRL, wxRichTextFontPage::OnCapsctrlClick ) |
57 | ||
30bf7630 JS |
58 | EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUPERSCRIPT, wxRichTextFontPage::OnRichtextfontpageSuperscriptClick ) |
59 | ||
60 | EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUBSCRIPT, wxRichTextFontPage::OnRichtextfontpageSubscriptClick ) | |
61 | ||
97ff49b3 JS |
62 | ////@end wxRichTextFontPage event table entries |
63 | ||
64 | END_EVENT_TABLE() | |
65 | ||
603f702b | 66 | IMPLEMENT_HELP_PROVISION(wxRichTextFontPage) |
97ff49b3 JS |
67 | /*! |
68 | * wxRichTextFontPage constructors | |
69 | */ | |
70 | ||
71 | wxRichTextFontPage::wxRichTextFontPage( ) | |
72 | { | |
73 | Init(); | |
74 | } | |
75 | ||
76 | wxRichTextFontPage::wxRichTextFontPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) | |
77 | { | |
78 | Init(); | |
79 | Create(parent, id, pos, size, style); | |
80 | } | |
81 | ||
82 | /*! | |
83 | * Initialise members | |
84 | */ | |
5778b3c8 | 85 | |
97ff49b3 JS |
86 | void wxRichTextFontPage::Init() |
87 | { | |
88 | m_dontUpdate = false; | |
89 | m_colourPresent = false; | |
50283a51 | 90 | m_bgColourPresent = false; |
97ff49b3 JS |
91 | |
92 | ////@begin wxRichTextFontPage member initialisation | |
93 | m_faceTextCtrl = NULL; | |
97ff49b3 | 94 | m_sizeTextCtrl = NULL; |
32423dd8 JS |
95 | m_fontSizeSpinButtons = NULL; |
96 | m_sizeUnitsCtrl = NULL; | |
97 | m_fontListBoxParent = NULL; | |
98 | m_faceListBox = NULL; | |
97ff49b3 JS |
99 | m_sizeListBox = NULL; |
100 | m_styleCtrl = NULL; | |
101 | m_weightCtrl = NULL; | |
102 | m_underliningCtrl = NULL; | |
3c6cc330 | 103 | m_textColourLabel = NULL; |
97ff49b3 | 104 | m_colourCtrl = NULL; |
3c6cc330 | 105 | m_bgColourLabel = NULL; |
50283a51 | 106 | m_bgColourCtrl = NULL; |
42688aea JS |
107 | m_strikethroughCtrl = NULL; |
108 | m_capitalsCtrl = NULL; | |
d07f2e19 | 109 | m_smallCapitalsCtrl = NULL; |
30bf7630 JS |
110 | m_superscriptCtrl = NULL; |
111 | m_subscriptCtrl = NULL; | |
97ff49b3 JS |
112 | m_previewCtrl = NULL; |
113 | ////@end wxRichTextFontPage member initialisation | |
114 | } | |
115 | ||
116 | /*! | |
117 | * wxRichTextFontPage creator | |
118 | */ | |
119 | ||
120 | bool wxRichTextFontPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) | |
121 | { | |
122 | ////@begin wxRichTextFontPage creation | |
603f702b | 123 | wxRichTextDialogPage::Create( parent, id, pos, size, style ); |
97ff49b3 JS |
124 | |
125 | CreateControls(); | |
126 | if (GetSizer()) | |
127 | { | |
128 | GetSizer()->SetSizeHints(this); | |
129 | } | |
130 | Centre(); | |
131 | ////@end wxRichTextFontPage creation | |
132 | return true; | |
133 | } | |
134 | ||
135 | /*! | |
136 | * Control creation for wxRichTextFontPage | |
137 | */ | |
138 | ||
139 | void wxRichTextFontPage::CreateControls() | |
140 | { | |
141 | ////@begin wxRichTextFontPage content construction | |
603f702b | 142 | wxRichTextFontPage* itemRichTextDialogPage1 = this; |
97ff49b3 JS |
143 | |
144 | wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); | |
603f702b | 145 | itemRichTextDialogPage1->SetSizer(itemBoxSizer2); |
97ff49b3 JS |
146 | |
147 | wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); | |
148 | itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5); | |
149 | ||
150 | wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL); | |
151 | itemBoxSizer3->Add(itemBoxSizer4, 1, wxGROW, 5); | |
152 | ||
153 | wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL); | |
154 | itemBoxSizer4->Add(itemBoxSizer5, 1, wxGROW, 5); | |
155 | ||
603f702b | 156 | wxStaticText* itemStaticText6 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Font:"), wxDefaultPosition, wxDefaultSize, 0 ); |
69ce77e2 | 157 | itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); |
97ff49b3 | 158 | |
603f702b | 159 | m_faceTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); |
97ff49b3 | 160 | m_faceTextCtrl->SetHelpText(_("Type a font name.")); |
2fce6547 | 161 | if (wxRichTextFontPage::ShowToolTips()) |
97ff49b3 JS |
162 | m_faceTextCtrl->SetToolTip(_("Type a font name.")); |
163 | itemBoxSizer5->Add(m_faceTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); | |
164 | ||
32423dd8 JS |
165 | wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); |
166 | itemBoxSizer4->Add(itemBoxSizer8, 0, wxGROW, 5); | |
97ff49b3 | 167 | |
32423dd8 JS |
168 | wxStaticText* itemStaticText9 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 ); |
169 | itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); | |
97ff49b3 | 170 | |
32423dd8 JS |
171 | wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL); |
172 | itemBoxSizer8->Add(itemBoxSizer10, 0, wxGROW, 5); | |
97ff49b3 | 173 | |
603f702b | 174 | m_sizeTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); |
97ff49b3 | 175 | m_sizeTextCtrl->SetHelpText(_("Type a size in points.")); |
2fce6547 | 176 | if (wxRichTextFontPage::ShowToolTips()) |
97ff49b3 | 177 | m_sizeTextCtrl->SetToolTip(_("Type a size in points.")); |
32423dd8 JS |
178 | itemBoxSizer10->Add(m_sizeTextCtrl, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5); |
179 | ||
180 | m_fontSizeSpinButtons = new wxSpinButton( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SPINBUTTONS, wxDefaultPosition, wxSize(-1, 20), wxSP_VERTICAL ); | |
181 | m_fontSizeSpinButtons->SetRange(0, 100); | |
182 | m_fontSizeSpinButtons->SetValue(0); | |
183 | itemBoxSizer10->Add(m_fontSizeSpinButtons, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5); | |
184 | ||
185 | wxArrayString m_sizeUnitsCtrlStrings; | |
186 | m_sizeUnitsCtrlStrings.Add(_("pt")); | |
187 | m_sizeUnitsCtrlStrings.Add(_("px")); | |
188 | m_sizeUnitsCtrl = new wxChoice( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZE_UNITS, wxDefaultPosition, wxDefaultSize, m_sizeUnitsCtrlStrings, 0 ); | |
189 | m_sizeUnitsCtrl->SetStringSelection(_("pt")); | |
190 | m_sizeUnitsCtrl->SetHelpText(_("The font size units, points or pixels.")); | |
191 | if (wxRichTextFontPage::ShowToolTips()) | |
192 | m_sizeUnitsCtrl->SetToolTip(_("The font size units, points or pixels.")); | |
193 | itemBoxSizer10->Add(m_sizeUnitsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5); | |
194 | ||
195 | m_fontListBoxParent = new wxBoxSizer(wxHORIZONTAL); | |
196 | itemBoxSizer3->Add(m_fontListBoxParent, 0, wxGROW, 5); | |
197 | ||
198 | m_faceListBox = new wxRichTextFontListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 100), 0 ); | |
199 | m_faceListBox->SetHelpText(_("Lists the available fonts.")); | |
200 | if (wxRichTextFontPage::ShowToolTips()) | |
201 | m_faceListBox->SetToolTip(_("Lists the available fonts.")); | |
202 | m_fontListBoxParent->Add(m_faceListBox, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 5); | |
97ff49b3 | 203 | |
2fce6547 | 204 | wxArrayString m_sizeListBoxStrings; |
603f702b | 205 | m_sizeListBox = new wxListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), m_sizeListBoxStrings, wxLB_SINGLE ); |
97ff49b3 | 206 | m_sizeListBox->SetHelpText(_("Lists font sizes in points.")); |
2fce6547 | 207 | if (wxRichTextFontPage::ShowToolTips()) |
97ff49b3 | 208 | m_sizeListBox->SetToolTip(_("Lists font sizes in points.")); |
32423dd8 | 209 | m_fontListBoxParent->Add(m_sizeListBox, 0, wxGROW|wxALL|wxFIXED_MINSIZE, 5); |
97ff49b3 | 210 | |
32423dd8 JS |
211 | wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxHORIZONTAL); |
212 | itemBoxSizer3->Add(itemBoxSizer17, 0, wxGROW, 5); | |
97ff49b3 | 213 | |
32423dd8 JS |
214 | wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL); |
215 | itemBoxSizer17->Add(itemBoxSizer18, 0, wxGROW, 5); | |
97ff49b3 | 216 | |
32423dd8 JS |
217 | wxStaticText* itemStaticText19 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font st&yle:"), wxDefaultPosition, wxDefaultSize, 0 ); |
218 | itemBoxSizer18->Add(itemStaticText19, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); | |
97ff49b3 | 219 | |
2fce6547 | 220 | wxArrayString m_styleCtrlStrings; |
603f702b | 221 | m_styleCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STYLECTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_styleCtrlStrings, wxCB_READONLY ); |
97ff49b3 | 222 | m_styleCtrl->SetHelpText(_("Select regular or italic style.")); |
2fce6547 | 223 | if (wxRichTextFontPage::ShowToolTips()) |
97ff49b3 | 224 | m_styleCtrl->SetToolTip(_("Select regular or italic style.")); |
32423dd8 | 225 | itemBoxSizer18->Add(m_styleCtrl, 0, wxGROW|wxALL, 5); |
97ff49b3 | 226 | |
32423dd8 JS |
227 | wxBoxSizer* itemBoxSizer21 = new wxBoxSizer(wxVERTICAL); |
228 | itemBoxSizer17->Add(itemBoxSizer21, 0, wxGROW, 5); | |
97ff49b3 | 229 | |
32423dd8 JS |
230 | wxStaticText* itemStaticText22 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 ); |
231 | itemBoxSizer21->Add(itemStaticText22, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); | |
97ff49b3 | 232 | |
2fce6547 | 233 | wxArrayString m_weightCtrlStrings; |
603f702b | 234 | m_weightCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_weightCtrlStrings, wxCB_READONLY ); |
97ff49b3 | 235 | m_weightCtrl->SetHelpText(_("Select regular or bold.")); |
2fce6547 | 236 | if (wxRichTextFontPage::ShowToolTips()) |
97ff49b3 | 237 | m_weightCtrl->SetToolTip(_("Select regular or bold.")); |
32423dd8 | 238 | itemBoxSizer21->Add(m_weightCtrl, 0, wxGROW|wxALL, 5); |
97ff49b3 | 239 | |
32423dd8 JS |
240 | wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL); |
241 | itemBoxSizer17->Add(itemBoxSizer24, 0, wxGROW, 5); | |
97ff49b3 | 242 | |
32423dd8 JS |
243 | wxStaticText* itemStaticText25 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 ); |
244 | itemBoxSizer24->Add(itemStaticText25, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); | |
97ff49b3 | 245 | |
2fce6547 | 246 | wxArrayString m_underliningCtrlStrings; |
603f702b | 247 | m_underliningCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_underliningCtrlStrings, wxCB_READONLY ); |
97ff49b3 | 248 | m_underliningCtrl->SetHelpText(_("Select underlining or no underlining.")); |
2fce6547 | 249 | if (wxRichTextFontPage::ShowToolTips()) |
97ff49b3 | 250 | m_underliningCtrl->SetToolTip(_("Select underlining or no underlining.")); |
32423dd8 | 251 | itemBoxSizer24->Add(m_underliningCtrl, 0, wxGROW|wxALL, 5); |
97ff49b3 | 252 | |
32423dd8 | 253 | itemBoxSizer17->Add(0, 0, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5); |
97ff49b3 | 254 | |
32423dd8 JS |
255 | wxBoxSizer* itemBoxSizer28 = new wxBoxSizer(wxVERTICAL); |
256 | itemBoxSizer17->Add(itemBoxSizer28, 0, wxGROW, 5); | |
97ff49b3 | 257 | |
3c6cc330 JS |
258 | m_textColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 ); |
259 | m_textColourLabel->SetValue(false); | |
32423dd8 | 260 | itemBoxSizer28->Add(m_textColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5); |
50283a51 | 261 | |
603f702b | 262 | m_colourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 ); |
97ff49b3 | 263 | m_colourCtrl->SetHelpText(_("Click to change the text colour.")); |
2fce6547 | 264 | if (wxRichTextFontPage::ShowToolTips()) |
97ff49b3 | 265 | m_colourCtrl->SetToolTip(_("Click to change the text colour.")); |
32423dd8 | 266 | itemBoxSizer28->Add(m_colourCtrl, 0, wxGROW|wxALL, 5); |
50283a51 | 267 | |
32423dd8 JS |
268 | wxBoxSizer* itemBoxSizer31 = new wxBoxSizer(wxVERTICAL); |
269 | itemBoxSizer17->Add(itemBoxSizer31, 0, wxGROW, 5); | |
97ff49b3 | 270 | |
3c6cc330 JS |
271 | m_bgColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 ); |
272 | m_bgColourLabel->SetValue(false); | |
32423dd8 | 273 | itemBoxSizer31->Add(m_bgColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5); |
50283a51 | 274 | |
603f702b | 275 | m_bgColourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 ); |
50283a51 JS |
276 | m_bgColourCtrl->SetHelpText(_("Click to change the text background colour.")); |
277 | if (wxRichTextFontPage::ShowToolTips()) | |
278 | m_bgColourCtrl->SetToolTip(_("Click to change the text background colour.")); | |
32423dd8 | 279 | itemBoxSizer31->Add(m_bgColourCtrl, 0, wxGROW|wxALL, 5); |
50283a51 | 280 | |
32423dd8 JS |
281 | wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxHORIZONTAL); |
282 | itemBoxSizer3->Add(itemBoxSizer34, 0, wxGROW, 5); | |
42688aea | 283 | |
23d11f0e | 284 | m_strikethroughCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, _("&Strikethrough"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); |
42688aea JS |
285 | m_strikethroughCtrl->SetValue(false); |
286 | m_strikethroughCtrl->SetHelpText(_("Check to show a line through the text.")); | |
2fce6547 | 287 | if (wxRichTextFontPage::ShowToolTips()) |
42688aea | 288 | m_strikethroughCtrl->SetToolTip(_("Check to show a line through the text.")); |
32423dd8 | 289 | itemBoxSizer34->Add(m_strikethroughCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); |
42688aea | 290 | |
23d11f0e | 291 | m_capitalsCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_CAPSCTRL, _("Ca&pitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); |
42688aea JS |
292 | m_capitalsCtrl->SetValue(false); |
293 | m_capitalsCtrl->SetHelpText(_("Check to show the text in capitals.")); | |
2fce6547 | 294 | if (wxRichTextFontPage::ShowToolTips()) |
42688aea | 295 | m_capitalsCtrl->SetToolTip(_("Check to show the text in capitals.")); |
32423dd8 | 296 | itemBoxSizer34->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); |
42688aea | 297 | |
d07f2e19 JS |
298 | m_smallCapitalsCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SMALLCAPSCTRL, _("Small C&apitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); |
299 | m_smallCapitalsCtrl->SetValue(false); | |
300 | m_smallCapitalsCtrl->SetHelpText(_("Check to show the text in small capitals.")); | |
301 | if (wxRichTextFontPage::ShowToolTips()) | |
302 | m_smallCapitalsCtrl->SetToolTip(_("Check to show the text in small capitals.")); | |
303 | itemBoxSizer34->Add(m_smallCapitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | |
304 | ||
23d11f0e | 305 | m_superscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUPERSCRIPT, _("Supe&rscript"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); |
30bf7630 JS |
306 | m_superscriptCtrl->SetValue(false); |
307 | m_superscriptCtrl->SetHelpText(_("Check to show the text in superscript.")); | |
308 | if (wxRichTextFontPage::ShowToolTips()) | |
309 | m_superscriptCtrl->SetToolTip(_("Check to show the text in superscript.")); | |
32423dd8 | 310 | itemBoxSizer34->Add(m_superscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); |
30bf7630 | 311 | |
23d11f0e | 312 | m_subscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUBSCRIPT, _("Subscrip&t"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); |
30bf7630 JS |
313 | m_subscriptCtrl->SetValue(false); |
314 | m_subscriptCtrl->SetHelpText(_("Check to show the text in subscript.")); | |
315 | if (wxRichTextFontPage::ShowToolTips()) | |
316 | m_subscriptCtrl->SetToolTip(_("Check to show the text in subscript.")); | |
32423dd8 | 317 | itemBoxSizer34->Add(m_subscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); |
30bf7630 | 318 | |
2fce6547 | 319 | itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); |
97ff49b3 | 320 | |
603f702b | 321 | m_previewCtrl = new wxRichTextFontPreviewCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 60), 0 ); |
97ff49b3 | 322 | m_previewCtrl->SetHelpText(_("Shows a preview of the font settings.")); |
2fce6547 | 323 | if (wxRichTextFontPage::ShowToolTips()) |
97ff49b3 JS |
324 | m_previewCtrl->SetToolTip(_("Shows a preview of the font settings.")); |
325 | itemBoxSizer3->Add(m_previewCtrl, 0, wxGROW|wxALL, 5); | |
326 | ||
327 | ////@end wxRichTextFontPage content construction | |
328 | ||
329 | m_faceListBox->UpdateFonts(); | |
330 | ||
3c6cc330 | 331 | m_styleCtrl->Append(_("(none)")); |
97ff49b3 JS |
332 | m_styleCtrl->Append(_("Regular")); |
333 | m_styleCtrl->Append(_("Italic")); | |
334 | ||
3c6cc330 | 335 | m_weightCtrl->Append(_("(none)")); |
97ff49b3 JS |
336 | m_weightCtrl->Append(_("Regular")); |
337 | m_weightCtrl->Append(_("Bold")); | |
338 | ||
3c6cc330 | 339 | m_underliningCtrl->Append(_("(none)")); |
97ff49b3 JS |
340 | m_underliningCtrl->Append(_("Not underlined")); |
341 | m_underliningCtrl->Append(_("Underlined")); | |
342 | ||
343 | wxString nStr; | |
344 | int i; | |
345 | for (i = 8; i < 40; i++) | |
346 | { | |
347 | nStr.Printf(wxT("%d"), i); | |
348 | m_sizeListBox->Append(nStr); | |
349 | } | |
350 | m_sizeListBox->Append(wxT("48")); | |
351 | m_sizeListBox->Append(wxT("72")); | |
352 | } | |
353 | ||
354 | /// Transfer data from/to window | |
355 | bool wxRichTextFontPage::TransferDataFromWindow() | |
356 | { | |
357 | wxPanel::TransferDataFromWindow(); | |
358 | ||
24777478 | 359 | wxRichTextAttr* attr = GetAttributes(); |
97ff49b3 | 360 | |
603f702b | 361 | if (!m_faceTextCtrl->GetValue().IsEmpty()) |
97ff49b3 | 362 | { |
603f702b JS |
363 | wxString faceName = m_faceTextCtrl->GetValue(); |
364 | attr->SetFontFaceName(faceName); | |
97ff49b3 JS |
365 | } |
366 | else | |
367 | attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_FACE)); | |
368 | ||
369 | wxString strSize = m_sizeTextCtrl->GetValue(); | |
370 | if (!strSize.IsEmpty()) | |
371 | { | |
372 | int sz = wxAtoi(strSize); | |
373 | if (sz > 0) | |
374 | { | |
32423dd8 JS |
375 | if (m_sizeUnitsCtrl->GetSelection() == 0) |
376 | attr->SetFontPointSize(sz); | |
377 | else | |
378 | attr->SetFontPixelSize(sz); | |
97ff49b3 JS |
379 | } |
380 | } | |
381 | else | |
382 | attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE)); | |
383 | ||
3c6cc330 | 384 | if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0) |
97ff49b3 | 385 | { |
7d76fbd5 | 386 | wxFontStyle style; |
3c6cc330 | 387 | if (m_styleCtrl->GetSelection() == 2) |
7d76fbd5 | 388 | style = wxFONTSTYLE_ITALIC; |
97ff49b3 | 389 | else |
7d76fbd5 | 390 | style = wxFONTSTYLE_NORMAL; |
97ff49b3 | 391 | |
44cc96a8 | 392 | attr->SetFontStyle(style); |
97ff49b3 JS |
393 | } |
394 | else | |
395 | attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC)); | |
396 | ||
3c6cc330 | 397 | if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0) |
97ff49b3 | 398 | { |
7d76fbd5 | 399 | wxFontWeight weight; |
3c6cc330 | 400 | if (m_weightCtrl->GetSelection() == 2) |
7d76fbd5 | 401 | weight = wxFONTWEIGHT_BOLD; |
97ff49b3 | 402 | else |
7d76fbd5 | 403 | weight = wxFONTWEIGHT_NORMAL; |
97ff49b3 | 404 | |
44cc96a8 | 405 | attr->SetFontWeight(weight); |
97ff49b3 JS |
406 | } |
407 | else | |
408 | attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT)); | |
409 | ||
3c6cc330 | 410 | if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0) |
97ff49b3 JS |
411 | { |
412 | bool underlined; | |
3c6cc330 | 413 | if (m_underliningCtrl->GetSelection() == 2) |
97ff49b3 JS |
414 | underlined = true; |
415 | else | |
416 | underlined = false; | |
417 | ||
44cc96a8 | 418 | attr->SetFontUnderlined(underlined); |
97ff49b3 JS |
419 | } |
420 | else | |
421 | attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE)); | |
422 | ||
3c6cc330 | 423 | if (m_textColourLabel->GetValue()) |
97ff49b3 | 424 | { |
50283a51 | 425 | attr->SetTextColour(m_colourCtrl->GetColour()); |
97ff49b3 JS |
426 | } |
427 | else | |
428 | attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR)); | |
44cc96a8 | 429 | |
3c6cc330 | 430 | if (m_bgColourLabel->GetValue()) |
50283a51 JS |
431 | { |
432 | attr->SetBackgroundColour(m_bgColourCtrl->GetColour()); | |
433 | } | |
434 | else | |
435 | attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_BACKGROUND_COLOUR)); | |
436 | ||
42688aea JS |
437 | if (m_strikethroughCtrl->Get3StateValue() != wxCHK_UNDETERMINED) |
438 | { | |
439 | attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH); | |
440 | ||
441 | if (m_strikethroughCtrl->Get3StateValue() == wxCHK_CHECKED) | |
442 | attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH); | |
443 | else | |
444 | attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH); | |
445 | } | |
a2c2fdc5 JS |
446 | else |
447 | { | |
448 | attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH); | |
449 | attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_STRIKETHROUGH); | |
450 | } | |
42688aea JS |
451 | |
452 | if (m_capitalsCtrl->Get3StateValue() != wxCHK_UNDETERMINED) | |
453 | { | |
454 | attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_CAPITALS); | |
44cc96a8 | 455 | |
42688aea JS |
456 | if (m_capitalsCtrl->Get3StateValue() == wxCHK_CHECKED) |
457 | attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_CAPITALS); | |
458 | else | |
459 | attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS); | |
460 | } | |
a2c2fdc5 JS |
461 | else |
462 | { | |
463 | attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_CAPITALS); | |
464 | attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS); | |
465 | } | |
97ff49b3 | 466 | |
d07f2e19 JS |
467 | if (m_smallCapitalsCtrl->Get3StateValue() != wxCHK_UNDETERMINED) |
468 | { | |
469 | attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); | |
470 | ||
471 | if (m_smallCapitalsCtrl->Get3StateValue() == wxCHK_CHECKED) | |
472 | attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); | |
473 | else | |
474 | attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); | |
475 | } | |
476 | else | |
477 | { | |
478 | attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); | |
479 | attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); | |
480 | } | |
481 | ||
30bf7630 JS |
482 | if (m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED) |
483 | { | |
484 | attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT); | |
485 | attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT); | |
486 | attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUBSCRIPT); | |
487 | } | |
488 | else if (m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED) | |
489 | { | |
490 | attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUBSCRIPT); | |
491 | attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUBSCRIPT); | |
492 | attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUPERSCRIPT); | |
493 | } | |
494 | else | |
495 | { | |
d1e5be0e JS |
496 | // If they are undetermined, we don't want to include these flags in the text effects - the objects |
497 | // should retain their original style. | |
498 | attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT|wxTEXT_ATTR_EFFECT_SUPERSCRIPT) ); | |
a2c2fdc5 | 499 | attr->SetTextEffects(attr->GetTextEffects() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT|wxTEXT_ATTR_EFFECT_SUPERSCRIPT) ); |
30bf7630 JS |
500 | } |
501 | ||
31f95a7f JS |
502 | if (attr->GetTextEffectFlags() == 0) |
503 | attr->SetFlags(attr->GetFlags() & ~wxTEXT_ATTR_EFFECTS); | |
504 | ||
97ff49b3 JS |
505 | return true; |
506 | } | |
507 | ||
508 | bool wxRichTextFontPage::TransferDataToWindow() | |
509 | { | |
510 | wxPanel::TransferDataToWindow(); | |
511 | ||
512 | m_dontUpdate = true; | |
24777478 | 513 | wxRichTextAttr* attr = GetAttributes(); |
97ff49b3 | 514 | |
44cc96a8 | 515 | if (attr->HasFontFaceName()) |
97ff49b3 | 516 | { |
44cc96a8 | 517 | m_faceTextCtrl->SetValue(attr->GetFontFaceName()); |
97ff49b3 JS |
518 | m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName()); |
519 | } | |
520 | else | |
521 | { | |
522 | m_faceTextCtrl->SetValue(wxEmptyString); | |
523 | m_faceListBox->SetFaceNameSelection(wxEmptyString); | |
524 | } | |
525 | ||
32423dd8 | 526 | if (attr->HasFontPointSize()) |
97ff49b3 | 527 | { |
44cc96a8 | 528 | wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize()); |
97ff49b3 | 529 | m_sizeTextCtrl->SetValue(strSize); |
32423dd8 | 530 | m_sizeUnitsCtrl->SetSelection(0); |
97ff49b3 JS |
531 | if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND) |
532 | m_sizeListBox->SetStringSelection(strSize); | |
533 | } | |
32423dd8 JS |
534 | else if (attr->HasFontPixelSize()) |
535 | { | |
536 | wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize()); | |
537 | m_sizeTextCtrl->SetValue(strSize); | |
538 | m_sizeUnitsCtrl->SetSelection(1); | |
539 | m_sizeListBox->SetSelection(wxNOT_FOUND); | |
540 | } | |
97ff49b3 JS |
541 | else |
542 | { | |
543 | m_sizeTextCtrl->SetValue(wxEmptyString); | |
544 | m_sizeListBox->SetSelection(wxNOT_FOUND); | |
545 | } | |
546 | ||
44cc96a8 | 547 | if (attr->HasFontWeight()) |
97ff49b3 | 548 | { |
43f4e852 | 549 | if (attr->GetFontWeight() == wxFONTWEIGHT_BOLD) |
3c6cc330 | 550 | m_weightCtrl->SetSelection(2); |
97ff49b3 | 551 | else |
3c6cc330 | 552 | m_weightCtrl->SetSelection(1); |
97ff49b3 JS |
553 | } |
554 | else | |
555 | { | |
3c6cc330 | 556 | m_weightCtrl->SetSelection(0); |
97ff49b3 JS |
557 | } |
558 | ||
44cc96a8 | 559 | if (attr->HasFontItalic()) |
97ff49b3 | 560 | { |
43f4e852 | 561 | if (attr->GetFontStyle() == wxFONTSTYLE_ITALIC) |
3c6cc330 | 562 | m_styleCtrl->SetSelection(2); |
97ff49b3 | 563 | else |
3c6cc330 | 564 | m_styleCtrl->SetSelection(1); |
97ff49b3 JS |
565 | } |
566 | else | |
567 | { | |
3c6cc330 | 568 | m_styleCtrl->SetSelection(0); |
97ff49b3 JS |
569 | } |
570 | ||
44cc96a8 | 571 | if (attr->HasFontUnderlined()) |
97ff49b3 | 572 | { |
44cc96a8 | 573 | if (attr->GetFontUnderlined()) |
3c6cc330 | 574 | m_underliningCtrl->SetSelection(2); |
97ff49b3 | 575 | else |
3c6cc330 | 576 | m_underliningCtrl->SetSelection(1); |
97ff49b3 JS |
577 | } |
578 | else | |
579 | { | |
3c6cc330 | 580 | m_underliningCtrl->SetSelection(0); |
97ff49b3 JS |
581 | } |
582 | ||
583 | if (attr->HasTextColour()) | |
584 | { | |
3638bb5c | 585 | m_colourCtrl->SetColour(attr->GetTextColour()); |
3c6cc330 | 586 | m_textColourLabel->SetValue(true); |
97ff49b3 JS |
587 | m_colourPresent = true; |
588 | } | |
3c6cc330 JS |
589 | else |
590 | { | |
591 | m_colourCtrl->SetColour(*wxBLACK); | |
592 | m_textColourLabel->SetValue(false); | |
593 | } | |
97ff49b3 | 594 | |
50283a51 JS |
595 | if (attr->HasBackgroundColour()) |
596 | { | |
597 | m_bgColourCtrl->SetColour(attr->GetBackgroundColour()); | |
3c6cc330 | 598 | m_bgColourLabel->SetValue(true); |
50283a51 JS |
599 | m_bgColourPresent = true; |
600 | } | |
3c6cc330 JS |
601 | else |
602 | { | |
603 | m_bgColourCtrl->SetColour(*wxWHITE); | |
604 | m_bgColourLabel->SetValue(false); | |
605 | } | |
50283a51 | 606 | |
42688aea JS |
607 | if (attr->HasTextEffects()) |
608 | { | |
609 | if (attr->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH) | |
610 | { | |
611 | if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_STRIKETHROUGH) | |
612 | m_strikethroughCtrl->Set3StateValue(wxCHK_CHECKED); | |
613 | else | |
614 | m_strikethroughCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
615 | } | |
616 | else | |
617 | m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
618 | ||
619 | if (attr->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_CAPITALS) | |
620 | { | |
621 | if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS) | |
622 | m_capitalsCtrl->Set3StateValue(wxCHK_CHECKED); | |
623 | else | |
624 | m_capitalsCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
625 | } | |
626 | else | |
627 | m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
30bf7630 | 628 | |
d07f2e19 JS |
629 | if (attr->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS) |
630 | { | |
631 | if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS) | |
632 | m_smallCapitalsCtrl->Set3StateValue(wxCHK_CHECKED); | |
633 | else | |
634 | m_smallCapitalsCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
635 | } | |
636 | else | |
637 | m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
638 | ||
30bf7630 JS |
639 | if ( attr->GetTextEffectFlags() & (wxTEXT_ATTR_EFFECT_SUPERSCRIPT | wxTEXT_ATTR_EFFECT_SUBSCRIPT) ) |
640 | { | |
641 | if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) | |
642 | { | |
643 | m_superscriptCtrl->Set3StateValue(wxCHK_CHECKED); | |
644 | m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
645 | } | |
646 | else if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT) | |
647 | { | |
648 | m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
649 | m_subscriptCtrl->Set3StateValue(wxCHK_CHECKED); | |
650 | } | |
651 | else | |
652 | { | |
653 | m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
654 | m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); | |
655 | } | |
656 | } | |
657 | else | |
658 | { | |
d1e5be0e JS |
659 | m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); |
660 | m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
30bf7630 | 661 | } |
42688aea JS |
662 | } |
663 | else | |
664 | { | |
665 | m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
666 | m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
d07f2e19 | 667 | m_smallCapitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); |
d1e5be0e JS |
668 | m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); |
669 | m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); | |
42688aea JS |
670 | } |
671 | ||
97ff49b3 JS |
672 | UpdatePreview(); |
673 | ||
674 | m_dontUpdate = false; | |
675 | ||
676 | return true; | |
677 | } | |
678 | ||
24777478 | 679 | wxRichTextAttr* wxRichTextFontPage::GetAttributes() |
97ff49b3 JS |
680 | { |
681 | return wxRichTextFormattingDialog::GetDialogAttributes(this); | |
682 | } | |
683 | ||
684 | /// Updates the font preview | |
685 | void wxRichTextFontPage::UpdatePreview() | |
686 | { | |
24777478 | 687 | wxRichTextAttr attr; |
97ff49b3 | 688 | |
3c6cc330 JS |
689 | if (m_textColourLabel->GetValue()) |
690 | m_previewCtrl->SetForegroundColour(m_colourCtrl->GetColour()); | |
691 | else | |
692 | { | |
693 | m_previewCtrl->SetForegroundColour(*wxBLACK); | |
694 | if (!(m_colourCtrl->GetColour() == *wxBLACK)) | |
695 | { | |
696 | m_colourCtrl->SetColour(*wxBLACK); | |
697 | m_colourCtrl->Refresh(); | |
698 | } | |
699 | } | |
700 | ||
701 | if (m_bgColourLabel->GetValue()) | |
702 | m_previewCtrl->SetBackgroundColour(m_bgColourCtrl->GetColour()); | |
703 | else | |
704 | { | |
705 | m_previewCtrl->SetBackgroundColour(*wxWHITE); | |
97ff49b3 | 706 | |
3c6cc330 JS |
707 | if (!(m_bgColourCtrl->GetColour() == *wxWHITE)) |
708 | { | |
709 | m_bgColourCtrl->SetColour(*wxWHITE); | |
710 | m_bgColourCtrl->Refresh(); | |
711 | } | |
712 | } | |
50283a51 | 713 | |
97ff49b3 JS |
714 | if (m_faceListBox->GetSelection() != wxNOT_FOUND) |
715 | { | |
716 | wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection()); | |
713129f9 | 717 | attr.SetFontFaceName(faceName); |
97ff49b3 JS |
718 | } |
719 | ||
720 | wxString strSize = m_sizeTextCtrl->GetValue(); | |
721 | if (!strSize.IsEmpty()) | |
722 | { | |
723 | int sz = wxAtoi(strSize); | |
724 | if (sz > 0) | |
32423dd8 JS |
725 | { |
726 | if (m_sizeUnitsCtrl->GetSelection() == 1) | |
727 | attr.SetFontPixelSize(sz); | |
728 | else | |
729 | attr.SetFontPointSize(sz); | |
730 | } | |
97ff49b3 JS |
731 | } |
732 | ||
3c6cc330 | 733 | if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0) |
97ff49b3 | 734 | { |
713129f9 | 735 | wxFontStyle style; |
3c6cc330 | 736 | if (m_styleCtrl->GetSelection() == 2) |
713129f9 | 737 | style = wxFONTSTYLE_ITALIC; |
97ff49b3 | 738 | else |
713129f9 | 739 | style = wxFONTSTYLE_NORMAL; |
97ff49b3 | 740 | |
713129f9 | 741 | attr.SetFontStyle(style); |
97ff49b3 JS |
742 | } |
743 | ||
3c6cc330 | 744 | if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0) |
97ff49b3 | 745 | { |
713129f9 | 746 | wxFontWeight weight; |
3c6cc330 | 747 | if (m_weightCtrl->GetSelection() == 2) |
713129f9 | 748 | weight = wxFONTWEIGHT_BOLD; |
97ff49b3 | 749 | else |
713129f9 | 750 | weight = wxFONTWEIGHT_NORMAL; |
97ff49b3 | 751 | |
713129f9 | 752 | attr.SetFontWeight(weight); |
97ff49b3 JS |
753 | } |
754 | ||
3c6cc330 | 755 | if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0) |
97ff49b3 JS |
756 | { |
757 | bool underlined; | |
3c6cc330 | 758 | if (m_underliningCtrl->GetSelection() == 2) |
97ff49b3 JS |
759 | underlined = true; |
760 | else | |
761 | underlined = false; | |
762 | ||
713129f9 | 763 | attr.SetFontUnderlined(underlined); |
97ff49b3 | 764 | } |
44cc96a8 | 765 | |
42688aea JS |
766 | int textEffects = 0; |
767 | ||
768 | if (m_strikethroughCtrl->Get3StateValue() == wxCHK_CHECKED) | |
769 | { | |
770 | textEffects |= wxTEXT_ATTR_EFFECT_STRIKETHROUGH; | |
771 | } | |
772 | ||
773 | if (m_capitalsCtrl->Get3StateValue() == wxCHK_CHECKED) | |
774 | { | |
775 | textEffects |= wxTEXT_ATTR_EFFECT_CAPITALS; | |
776 | } | |
97ff49b3 | 777 | |
d07f2e19 JS |
778 | if (m_smallCapitalsCtrl->Get3StateValue() == wxCHK_CHECKED) |
779 | { | |
780 | textEffects |= wxTEXT_ATTR_EFFECT_SMALL_CAPITALS; | |
781 | } | |
782 | ||
30bf7630 JS |
783 | if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) |
784 | textEffects |= wxTEXT_ATTR_EFFECT_SUPERSCRIPT; | |
785 | else if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) | |
786 | textEffects |= wxTEXT_ATTR_EFFECT_SUBSCRIPT; | |
787 | ||
713129f9 | 788 | wxFont font = attr.GetFont(); |
97ff49b3 | 789 | m_previewCtrl->SetFont(font); |
42688aea | 790 | m_previewCtrl->SetTextEffects(textEffects); |
97ff49b3 JS |
791 | m_previewCtrl->Refresh(); |
792 | } | |
793 | ||
794 | /*! | |
795 | * Should we show tooltips? | |
796 | */ | |
797 | ||
798 | bool wxRichTextFontPage::ShowToolTips() | |
799 | { | |
dadd4f55 | 800 | return wxRichTextFormattingDialog::ShowToolTips(); |
97ff49b3 JS |
801 | } |
802 | ||
803 | /*! | |
804 | * Get bitmap resources | |
805 | */ | |
806 | ||
807 | wxBitmap wxRichTextFontPage::GetBitmapResource( const wxString& name ) | |
808 | { | |
809 | // Bitmap retrieval | |
810 | ////@begin wxRichTextFontPage bitmap retrieval | |
811 | wxUnusedVar(name); | |
812 | return wxNullBitmap; | |
813 | ////@end wxRichTextFontPage bitmap retrieval | |
814 | } | |
815 | ||
816 | /*! | |
817 | * Get icon resources | |
818 | */ | |
819 | ||
820 | wxIcon wxRichTextFontPage::GetIconResource( const wxString& name ) | |
821 | { | |
822 | // Icon retrieval | |
823 | ////@begin wxRichTextFontPage icon retrieval | |
824 | wxUnusedVar(name); | |
825 | return wxNullIcon; | |
826 | ////@end wxRichTextFontPage icon retrieval | |
827 | } | |
828 | ||
829 | /*! | |
ce7fe42e | 830 | * wxEVT_TEXT event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL |
97ff49b3 JS |
831 | */ |
832 | ||
833 | void wxRichTextFontPage::OnFaceTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) ) | |
834 | { | |
835 | if (m_dontUpdate) | |
836 | return; | |
837 | ||
838 | wxString facename = m_faceTextCtrl->GetValue(); | |
839 | if (!facename.IsEmpty()) | |
840 | { | |
841 | if (m_faceListBox->HasFaceName(facename)) | |
842 | { | |
843 | m_faceListBox->SetFaceNameSelection(facename); | |
844 | UpdatePreview(); | |
845 | } | |
846 | else | |
847 | { | |
848 | // Try to find a partial match | |
849 | const wxArrayString& arr = m_faceListBox->GetFaceNames(); | |
850 | size_t i; | |
851 | for (i = 0; i < arr.GetCount(); i++) | |
852 | { | |
853 | if (arr[i].Mid(0, facename.Length()).Lower() == facename.Lower()) | |
854 | { | |
f18eaf26 | 855 | m_faceListBox->ScrollToRow(i); |
97ff49b3 JS |
856 | break; |
857 | } | |
858 | } | |
859 | } | |
860 | } | |
861 | } | |
862 | ||
863 | ||
864 | /*! | |
ce7fe42e | 865 | * wxEVT_TEXT event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL |
97ff49b3 JS |
866 | */ |
867 | ||
868 | void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) ) | |
869 | { | |
870 | if (m_dontUpdate) | |
871 | return; | |
872 | ||
873 | wxString strSize = m_sizeTextCtrl->GetValue(); | |
874 | if (!strSize.IsEmpty() && m_sizeListBox->FindString(strSize) != wxNOT_FOUND) | |
875 | m_sizeListBox->SetStringSelection(strSize); | |
876 | UpdatePreview(); | |
877 | } | |
878 | ||
879 | ||
880 | /*! | |
ce7fe42e | 881 | * wxEVT_LISTBOX event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX |
97ff49b3 JS |
882 | */ |
883 | ||
884 | void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event ) | |
885 | { | |
3c6cc330 | 886 | bool oldDontUpdate = m_dontUpdate; |
97ff49b3 JS |
887 | m_dontUpdate = true; |
888 | ||
889 | m_sizeTextCtrl->SetValue(event.GetString()); | |
890 | ||
3c6cc330 JS |
891 | m_dontUpdate = oldDontUpdate; |
892 | ||
893 | if (m_dontUpdate) | |
894 | return; | |
97ff49b3 JS |
895 | |
896 | UpdatePreview(); | |
897 | } | |
898 | ||
899 | /*! | |
ce7fe42e | 900 | * wxEVT_LISTBOX event handler for ID_RICHTEXTFONTPAGE_FACELISTBOX |
97ff49b3 JS |
901 | */ |
902 | ||
903 | void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) ) | |
904 | { | |
3c6cc330 | 905 | bool oldDontUpdate = m_dontUpdate; |
97ff49b3 JS |
906 | m_dontUpdate = true; |
907 | ||
908 | m_faceTextCtrl->SetValue(m_faceListBox->GetFaceName(m_faceListBox->GetSelection())); | |
909 | ||
3c6cc330 JS |
910 | m_dontUpdate = oldDontUpdate; |
911 | ||
912 | if (m_dontUpdate) | |
913 | return; | |
97ff49b3 JS |
914 | |
915 | UpdatePreview(); | |
916 | } | |
917 | ||
918 | /*! | |
ce7fe42e | 919 | * wxEVT_COMBOBOX event handler for ID_RICHTEXTFONTPAGE_STYLECTRL |
97ff49b3 JS |
920 | */ |
921 | ||
922 | void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) ) | |
923 | { | |
3c6cc330 JS |
924 | if (m_dontUpdate) |
925 | return; | |
926 | ||
97ff49b3 JS |
927 | UpdatePreview(); |
928 | } | |
929 | ||
930 | ||
931 | /*! | |
ce7fe42e | 932 | * wxEVT_COMBOBOX event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL |
97ff49b3 JS |
933 | */ |
934 | ||
935 | void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(event) ) | |
936 | { | |
3c6cc330 JS |
937 | if (m_dontUpdate) |
938 | return; | |
939 | ||
97ff49b3 JS |
940 | UpdatePreview(); |
941 | } | |
942 | ||
943 | ||
944 | /*! | |
ce7fe42e | 945 | * wxEVT_COMBOBOX event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL |
97ff49b3 JS |
946 | */ |
947 | ||
948 | void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent& WXUNUSED(event) ) | |
949 | { | |
3c6cc330 JS |
950 | if (m_dontUpdate) |
951 | return; | |
952 | ||
97ff49b3 JS |
953 | UpdatePreview(); |
954 | } | |
955 | ||
50283a51 | 956 | void wxRichTextFontPage::OnColourClicked( wxCommandEvent& event ) |
97ff49b3 | 957 | { |
50283a51 JS |
958 | if (event.GetId() == m_colourCtrl->GetId()) |
959 | m_colourPresent = true; | |
960 | else if (event.GetId() == m_bgColourCtrl->GetId()) | |
961 | m_bgColourPresent = true; | |
97ff49b3 | 962 | |
3c6cc330 JS |
963 | m_dontUpdate = true; |
964 | ||
965 | if (event.GetId() == m_colourCtrl->GetId()) | |
966 | { | |
967 | m_textColourLabel->SetValue(true); | |
968 | } | |
969 | else if (event.GetId() == m_bgColourCtrl->GetId()) | |
970 | { | |
971 | m_bgColourLabel->SetValue(true); | |
972 | } | |
973 | ||
974 | m_dontUpdate = false; | |
975 | ||
97ff49b3 JS |
976 | UpdatePreview(); |
977 | } | |
42688aea | 978 | /*! |
ce7fe42e | 979 | * wxEVT_CHECKBOX event handler for ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL |
42688aea JS |
980 | */ |
981 | ||
982 | void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(event) ) | |
983 | { | |
3c6cc330 JS |
984 | if (m_dontUpdate) |
985 | return; | |
986 | ||
42688aea JS |
987 | UpdatePreview(); |
988 | } | |
989 | ||
990 | /*! | |
ce7fe42e | 991 | * wxEVT_CHECKBOX event handler for ID_RICHTEXTFONTPAGE_CAPSCTRL |
42688aea JS |
992 | */ |
993 | ||
994 | void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) ) | |
995 | { | |
3c6cc330 JS |
996 | if (m_dontUpdate) |
997 | return; | |
998 | ||
42688aea JS |
999 | UpdatePreview(); |
1000 | } | |
1001 | ||
30bf7630 | 1002 | /*! |
ce7fe42e | 1003 | * wxEVT_CHECKBOX event handler for ID_RICHTEXTFONTPAGE_SUPERSCRIPT |
30bf7630 JS |
1004 | */ |
1005 | ||
1006 | void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) ) | |
1007 | { | |
3c6cc330 JS |
1008 | if (m_dontUpdate) |
1009 | return; | |
1010 | ||
d1e5be0e | 1011 | if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED) |
30bf7630 | 1012 | m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); |
d1e5be0e | 1013 | |
30bf7630 JS |
1014 | UpdatePreview(); |
1015 | } | |
1016 | ||
1017 | /*! | |
ce7fe42e | 1018 | * wxEVT_CHECKBOX event handler for ID_RICHTEXTFONTPAGE_SUBSCRIPT |
30bf7630 | 1019 | */ |
42688aea | 1020 | |
30bf7630 JS |
1021 | void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) ) |
1022 | { | |
3c6cc330 JS |
1023 | if (m_dontUpdate) |
1024 | return; | |
1025 | ||
d1e5be0e | 1026 | if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED) |
30bf7630 | 1027 | m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); |
d1e5be0e | 1028 | |
30bf7630 JS |
1029 | UpdatePreview(); |
1030 | } | |
32423dd8 JS |
1031 | |
1032 | /*! | |
ce7fe42e | 1033 | * wxEVT_CHOICE event handler for ID_RICHTEXTFONTPAGE_SIZE_UNITS |
32423dd8 JS |
1034 | */ |
1035 | ||
1036 | void wxRichTextFontPage::OnRichtextfontpageSizeUnitsSelected( wxCommandEvent& WXUNUSED(event) ) | |
1037 | { | |
1038 | if (m_dontUpdate) | |
1039 | return; | |
1040 | ||
1041 | UpdatePreview(); | |
1042 | } | |
1043 | ||
1044 | /*! | |
ce7fe42e | 1045 | * wxEVT_SPINCTRL event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS |
32423dd8 JS |
1046 | */ |
1047 | ||
1048 | void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsUp( wxSpinEvent& WXUNUSED(event) ) | |
1049 | { | |
1050 | wxString text = m_sizeTextCtrl->GetValue(); | |
1051 | if (!text.IsEmpty()) | |
1052 | { | |
1053 | int size = wxAtoi(text); | |
1054 | if (size > 0) | |
1055 | { | |
1056 | size ++; | |
1057 | m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size)); | |
1058 | UpdatePreview(); | |
1059 | } | |
1060 | } | |
1061 | } | |
1062 | ||
1063 | /*! | |
1064 | * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS | |
1065 | */ | |
1066 | ||
1067 | void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsDown( wxSpinEvent& WXUNUSED(event) ) | |
1068 | { | |
1069 | wxString text = m_sizeTextCtrl->GetValue(); | |
1070 | if (!text.IsEmpty()) | |
1071 | { | |
1072 | int size = wxAtoi(text); | |
1073 | if (size > 0) | |
1074 | { | |
1075 | size --; | |
1076 | m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size)); | |
1077 | UpdatePreview(); | |
1078 | } | |
1079 | } | |
1080 | } | |
1081 | ||
1082 | /*! | |
1083 | * wxEVT_IDLE event handler for ID_RICHTEXTFONTPAGE | |
1084 | */ | |
1085 | ||
1086 | void wxRichTextFontPage::OnIdle( wxIdleEvent& WXUNUSED(event) ) | |
1087 | { | |
1088 | if (!m_sizeUnitsCtrl) | |
1089 | return; | |
31f95a7f | 1090 | |
32423dd8 JS |
1091 | if (m_sizeUnitsCtrl->GetSelection() == 1 && m_sizeListBox->IsShown()) |
1092 | { | |
1093 | m_fontListBoxParent->Show(m_sizeListBox, false); | |
1094 | Layout(); | |
1095 | } | |
1096 | else if (m_sizeUnitsCtrl->GetSelection() == 0 && !m_sizeListBox->IsShown()) | |
1097 | { | |
1098 | m_fontListBoxParent->Show(m_sizeListBox, true); | |
1099 | Layout(); | |
1100 | } | |
1101 | if (!wxRichTextFormattingDialog::GetDialog(this)->HasOption(wxRichTextFormattingDialog::Option_AllowPixelFontSize) && | |
1102 | m_sizeUnitsCtrl->IsEnabled()) | |
1103 | { | |
1104 | m_sizeUnitsCtrl->Disable(); | |
1105 | } | |
1106 | } |