]> git.saurik.com Git - wxWidgets.git/blob - src/richtext/richtextbulletspage.cpp
updates from Andrea, plus some fixes
[wxWidgets.git] / src / richtext / richtextbulletspage.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextbulletspage.cpp
3 // Purpose:
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 10/4/2006 10:32:31 AM
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if wxUSE_RICHTEXT
13
14 #include "wx/richtext/richtextbulletspage.h"
15
16 #include "wx/richtext/richtextsymboldlg.h"
17 #include "wx/fontenum.h"
18
19 /*!
20 * wxRichTextBulletsPage type definition
21 */
22
23 IMPLEMENT_DYNAMIC_CLASS( wxRichTextBulletsPage, wxPanel )
24
25 /*!
26 * wxRichTextBulletsPage event table definition
27 */
28
29 BEGIN_EVENT_TABLE( wxRichTextBulletsPage, wxPanel )
30
31 ////@begin wxRichTextBulletsPage event table entries
32 EVT_LISTBOX( ID_RICHTEXTBULLETSPAGE_STYLELISTBOX, wxRichTextBulletsPage::OnStylelistboxSelected )
33
34 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, wxRichTextBulletsPage::OnSymbolstaticUpdate )
35
36 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, wxRichTextBulletsPage::OnSymbolctrlSelected )
37 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, wxRichTextBulletsPage::OnSymbolctrlUpdated )
38 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, wxRichTextBulletsPage::OnSymbolctrlUpdate )
39
40 EVT_BUTTON( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL, wxRichTextBulletsPage::OnChooseSymbolClick )
41 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL, wxRichTextBulletsPage::OnChooseSymbolUpdate )
42
43 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, wxRichTextBulletsPage::OnSymbolfontctrlSelected )
44 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, wxRichTextBulletsPage::OnSymbolfontctrlUpdated )
45 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate )
46
47 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC, wxRichTextBulletsPage::OnNumberstaticUpdate )
48
49 EVT_SPINCTRL( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlUpdated )
50 EVT_SPIN_UP( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlUp )
51 EVT_SPIN_DOWN( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlDown )
52 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlTextUpdated )
53 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlUpdate )
54
55 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, wxRichTextBulletsPage::OnParenthesesctrlClick )
56 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, wxRichTextBulletsPage::OnParenthesesctrlUpdate )
57
58 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PERIODCTRL, wxRichTextBulletsPage::OnPeriodctrlClick )
59 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PERIODCTRL, wxRichTextBulletsPage::OnPeriodctrlUpdate )
60
61 ////@end wxRichTextBulletsPage event table entries
62
63 END_EVENT_TABLE()
64
65 /*!
66 * wxRichTextBulletsPage constructors
67 */
68
69 wxRichTextBulletsPage::wxRichTextBulletsPage( )
70 {
71 Init();
72 }
73
74 wxRichTextBulletsPage::wxRichTextBulletsPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
75 {
76 Init();
77 Create(parent, id, pos, size, style);
78 }
79
80 /*!
81 * Initialise members
82 */
83
84 void wxRichTextBulletsPage::Init()
85 {
86 m_hasBulletStyle = false;
87 m_hasBulletNumber = false;
88 m_hasBulletSymbol = false;
89 m_dontUpdate = false;
90
91 ////@begin wxRichTextBulletsPage member initialisation
92 m_styleListBox = NULL;
93 m_symbolCtrl = NULL;
94 m_symbolFontCtrl = NULL;
95 m_numberCtrl = NULL;
96 m_parenthesesCtrl = NULL;
97 m_periodCtrl = NULL;
98 m_previewCtrl = NULL;
99 ////@end wxRichTextBulletsPage member initialisation
100 }
101
102 /*!
103 * wxRichTextBulletsPage creator
104 */
105
106 bool wxRichTextBulletsPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
107 {
108 ////@begin wxRichTextBulletsPage creation
109 wxPanel::Create( parent, id, pos, size, style );
110
111 CreateControls();
112 if (GetSizer())
113 {
114 GetSizer()->SetSizeHints(this);
115 }
116 Centre();
117 ////@end wxRichTextBulletsPage creation
118 return true;
119 }
120
121 /*!
122 * Control creation for wxRichTextBulletsPage
123 */
124
125 void wxRichTextBulletsPage::CreateControls()
126 {
127 ////@begin wxRichTextBulletsPage content construction
128 wxRichTextBulletsPage* itemPanel1 = this;
129
130 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
131 itemPanel1->SetSizer(itemBoxSizer2);
132
133 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
134 itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
135
136 wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
137 itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW, 5);
138
139 wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
140 itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5);
141
142 wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Bullet style:"), wxDefaultPosition, wxDefaultSize, 0 );
143 itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
144
145 wxString* m_styleListBoxStrings = NULL;
146 m_styleListBox = new wxListBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_STYLELISTBOX, wxDefaultPosition, wxDefaultSize, 0, m_styleListBoxStrings, wxLB_SINGLE );
147 itemBoxSizer5->Add(m_styleListBox, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
148
149 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
150
151 wxStaticLine* itemStaticLine9 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
152 itemBoxSizer4->Add(itemStaticLine9, 0, wxGROW|wxALL, 5);
153
154 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
155
156 wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL);
157 itemBoxSizer4->Add(itemBoxSizer11, 0, wxGROW, 5);
158
159 wxStaticText* itemStaticText12 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("&Symbol:"), wxDefaultPosition, wxDefaultSize, 0 );
160 itemBoxSizer11->Add(itemStaticText12, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
161
162 wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
163 itemBoxSizer11->Add(itemBoxSizer13, 0, wxGROW, 5);
164
165 wxString* m_symbolCtrlStrings = NULL;
166 m_symbolCtrl = new wxComboBox( itemPanel1,
167 ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL,
168 wxEmptyString,
169 wxDefaultPosition,
170 wxSize(60, wxDefaultCoord),
171 0,
172 m_symbolCtrlStrings,
173 wxCB_DROPDOWN );
174 itemBoxSizer13->Add(m_symbolCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 5);
175
176 wxButton* itemButton15 = new wxButton( itemPanel1, ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL, _("Ch&oose..."), wxDefaultPosition, wxDefaultSize, 0 );
177 itemBoxSizer13->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
178
179 itemBoxSizer11->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
180
181 wxStaticText* itemStaticText17 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("Symbol &font:"), wxDefaultPosition, wxDefaultSize, 0 );
182 itemBoxSizer11->Add(itemStaticText17, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
183
184 wxString* m_symbolFontCtrlStrings = NULL;
185 m_symbolFontCtrl = new wxComboBox( itemPanel1,
186 ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL,
187 wxEmptyString,
188 wxDefaultPosition,
189 wxDefaultSize,
190 0,
191 m_symbolFontCtrlStrings,
192 wxCB_DROPDOWN );
193 itemBoxSizer11->Add(m_symbolFontCtrl, 0, wxGROW|wxALL, 5);
194
195 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
196
197 wxStaticLine* itemStaticLine20 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
198 itemBoxSizer4->Add(itemStaticLine20, 0, wxGROW|wxALL, 5);
199
200 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
201
202 wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxVERTICAL);
203 itemBoxSizer4->Add(itemBoxSizer22, 0, wxGROW, 5);
204
205 wxStaticText* itemStaticText23 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC, _("&Number:"), wxDefaultPosition, wxDefaultSize, 0 );
206 itemBoxSizer22->Add(itemStaticText23, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
207
208 m_numberCtrl = new wxSpinCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, _T("0"), wxDefaultPosition, wxSize(50, wxDefaultCoord), wxSP_ARROW_KEYS, 0, 100000, 0 );
209 itemBoxSizer22->Add(m_numberCtrl, 0, wxGROW|wxALL, 5);
210
211 itemBoxSizer22->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
212
213 m_parenthesesCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, _("&Parentheses"), wxDefaultPosition, wxDefaultSize, 0 );
214 m_parenthesesCtrl->SetValue(false);
215 itemBoxSizer22->Add(m_parenthesesCtrl, 0, wxALIGN_LEFT|wxALL, 5);
216
217 m_periodCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_PERIODCTRL, _("Peri&od"), wxDefaultPosition, wxDefaultSize, 0 );
218 m_periodCtrl->SetValue(false);
219 itemBoxSizer22->Add(m_periodCtrl, 0, wxALIGN_LEFT|wxALL, 5);
220
221 itemBoxSizer3->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
222
223 m_previewCtrl = new wxRichTextCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 180), wxSUNKEN_BORDER );
224 m_previewCtrl->SetHelpText(_("Shows a preview of the bullet settings."));
225 if (ShowToolTips())
226 m_previewCtrl->SetToolTip(_("Shows a preview of the bullet settings."));
227 itemBoxSizer3->Add(m_previewCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
228
229 ////@end wxRichTextBulletsPage content construction
230
231 m_styleListBox->Append(_("(None)"));
232 m_styleListBox->Append(_("Arabic"));
233 m_styleListBox->Append(_("Upper case letters"));
234 m_styleListBox->Append(_("Lower case letters"));
235 m_styleListBox->Append(_("Upper case roman numerals"));
236 m_styleListBox->Append(_("Lower case roman numerals"));
237 m_styleListBox->Append(_("Symbol"));
238 m_styleListBox->Append(_("Bitmap"));
239
240 m_symbolCtrl->Append(_("*"));
241 m_symbolCtrl->Append(_("-"));
242 m_symbolCtrl->Append(_(">"));
243 m_symbolCtrl->Append(_("+"));
244 m_symbolCtrl->Append(_("~"));
245
246 wxFontEnumerator enumerator;
247 enumerator.EnumerateFacenames();
248 wxArrayString facenames = enumerator.GetFacenames();
249 facenames.Sort();
250
251 m_symbolFontCtrl->Append(facenames);
252 }
253
254 /// Transfer data from/to window
255 bool wxRichTextBulletsPage::TransferDataFromWindow()
256 {
257 wxPanel::TransferDataFromWindow();
258
259 wxTextAttrEx* attr = GetAttributes();
260
261 if (m_hasBulletStyle)
262 {
263 long bulletStyle = 0;
264
265 int index = m_styleListBox->GetSelection();
266 if (index == 1)
267 bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ARABIC;
268 else if (index == 2)
269 bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER;
270 else if (index == 3)
271 bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER;
272 else if (index == 4)
273 bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER;
274 else if (index == 5)
275 bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER;
276 else if (index == 6)
277 bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_SYMBOL;
278 else if (index == 7)
279 bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_BITMAP;
280
281 if (m_parenthesesCtrl->GetValue())
282 bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_PARENTHESES;
283 if (m_periodCtrl->GetValue())
284 bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_PERIOD;
285
286 attr->SetBulletStyle(bulletStyle);
287 }
288
289 if (m_hasBulletNumber)
290 {
291 attr->SetBulletNumber(m_numberCtrl->GetValue());
292 }
293
294 if (m_hasBulletSymbol)
295 {
296 wxChar c(wxT('*'));
297 if (m_symbolCtrl->GetValue().length() > 0)
298 c = m_symbolCtrl->GetValue()[0];
299 attr->SetBulletSymbol(c);
300 attr->SetBulletFont(m_symbolFontCtrl->GetValue());
301 }
302 return true;
303 }
304
305 bool wxRichTextBulletsPage::TransferDataToWindow()
306 {
307 m_dontUpdate = true;
308
309 wxPanel::TransferDataToWindow();
310
311 wxTextAttrEx* attr = GetAttributes();
312
313 if (attr->HasBulletStyle())
314 {
315 int index = -1;
316 if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ARABIC)
317 index = 1;
318 else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER)
319 index = 2;
320 else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER)
321 index = 3;
322 else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER)
323 index = 4;
324 else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER)
325 index = 5;
326 else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL)
327 index = 6;
328 else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_BITMAP)
329 index = 7;
330 m_styleListBox->SetSelection(index);
331
332 if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PARENTHESES)
333 m_parenthesesCtrl->SetValue(true);
334 else
335 m_parenthesesCtrl->SetValue(false);
336
337 if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PERIOD)
338 m_periodCtrl->SetValue(true);
339 else
340 m_periodCtrl->SetValue(false);
341 }
342 else
343 m_styleListBox->SetSelection(-1);
344
345 if (attr->HasBulletSymbol())
346 {
347 wxChar c = attr->GetBulletSymbol();
348 wxString s;
349 s << c;
350 m_symbolCtrl->SetValue(s);
351 m_symbolFontCtrl->SetValue(attr->GetBulletFont());
352 }
353 else
354 m_symbolCtrl->SetValue(wxEmptyString);
355
356 if (attr->HasBulletNumber())
357 m_numberCtrl->SetValue(attr->GetBulletNumber());
358 else
359 m_numberCtrl->SetValue(0);
360
361 UpdatePreview();
362
363 m_dontUpdate = false;
364
365 return true;
366 }
367
368 /// Updates the bullet preview
369 void wxRichTextBulletsPage::UpdatePreview()
370 {
371 static const wxChar* s_para1 = wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
372 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.");
373
374 static const wxChar* s_para2 = wxT("\nDuis pharetra consequat dui. Cum sociis natoque penatibus \
375 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.");
376
377 static const wxChar* s_para3 = wxT("\nInteger convallis dolor at augue \
378 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
379
380 TransferDataFromWindow();
381 wxTextAttrEx attr(*GetAttributes());
382 attr.SetFlags(attr.GetFlags() &
383 (wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_SYMBOL|
384 wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
385 wxTEXT_ATTR_LINE_SPACING));
386
387 wxFont font(m_previewCtrl->GetFont());
388 font.SetPointSize(9);
389 m_previewCtrl->SetFont(font);
390
391 font.SetWeight(wxBOLD);
392 attr.SetFont(font);
393
394 m_previewCtrl->Clear();
395
396 m_previewCtrl->WriteText(s_para1);
397 m_previewCtrl->BeginStyle(attr);
398 m_previewCtrl->WriteText(s_para2);
399 m_previewCtrl->EndStyle();
400 m_previewCtrl->WriteText(s_para3);
401 }
402
403 wxTextAttrEx* wxRichTextBulletsPage::GetAttributes()
404 {
405 return wxRichTextFormattingDialog::GetDialogAttributes(this);
406 }
407
408 /*!
409 * Should we show tooltips?
410 */
411
412 bool wxRichTextBulletsPage::ShowToolTips()
413 {
414 return true;
415 }
416
417 /*!
418 * Get bitmap resources
419 */
420
421 wxBitmap wxRichTextBulletsPage::GetBitmapResource( const wxString& name )
422 {
423 // Bitmap retrieval
424 ////@begin wxRichTextBulletsPage bitmap retrieval
425 wxUnusedVar(name);
426 return wxNullBitmap;
427 ////@end wxRichTextBulletsPage bitmap retrieval
428 }
429
430 /*!
431 * Get icon resources
432 */
433
434 wxIcon wxRichTextBulletsPage::GetIconResource( const wxString& name )
435 {
436 // Icon retrieval
437 ////@begin wxRichTextBulletsPage icon retrieval
438 wxUnusedVar(name);
439 return wxNullIcon;
440 ////@end wxRichTextBulletsPage icon retrieval
441 }
442
443 /*!
444 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
445 */
446
447 void wxRichTextBulletsPage::OnStylelistboxSelected( wxCommandEvent& WXUNUSED(event) )
448 {
449 if (!m_dontUpdate)
450 {
451 m_hasBulletStyle = true;
452
453 if (m_styleListBox->GetSelection() == 6)
454 m_hasBulletSymbol = true;
455
456 UpdatePreview();
457 }
458 }
459
460 /*!
461 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
462 */
463
464 void wxRichTextBulletsPage::OnSymbolctrlSelected( wxCommandEvent& WXUNUSED(event) )
465 {
466 if (!m_dontUpdate)
467 {
468 m_hasBulletSymbol = true;
469 UpdatePreview();
470 }
471 }
472
473 /*!
474 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
475 */
476
477 void wxRichTextBulletsPage::OnSymbolctrlUpdated( wxCommandEvent& WXUNUSED(event) )
478 {
479 if (!m_dontUpdate)
480 {
481 m_hasBulletSymbol = true;
482 UpdatePreview();
483 }
484 }
485
486 /*!
487 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
488 */
489
490 void wxRichTextBulletsPage::OnSymbolctrlUpdate( wxUpdateUIEvent& event )
491 {
492 OnSymbolUpdate(event);
493 }
494
495 /*!
496 * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
497 */
498
499 void wxRichTextBulletsPage::OnNumberctrlUpdated( wxSpinEvent& WXUNUSED(event) )
500 {
501 if (!m_dontUpdate)
502 {
503 m_hasBulletNumber = true;
504 UpdatePreview();
505 }
506 }
507
508 /*!
509 * wxEVT_SCROLL_LINEUP event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
510 */
511
512 void wxRichTextBulletsPage::OnNumberctrlUp( wxSpinEvent& WXUNUSED(event) )
513 {
514 if (!m_dontUpdate)
515 {
516 m_hasBulletNumber = true;
517 UpdatePreview();
518 }
519 }
520
521 /*!
522 * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
523 */
524
525 void wxRichTextBulletsPage::OnNumberctrlDown( wxSpinEvent& WXUNUSED(event) )
526 {
527 if (!m_dontUpdate)
528 {
529 m_hasBulletNumber = true;
530 UpdatePreview();
531 }
532 }
533
534 /*!
535 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
536 */
537
538 void wxRichTextBulletsPage::OnNumberctrlTextUpdated( wxCommandEvent& WXUNUSED(event) )
539 {
540 if (!m_dontUpdate)
541 {
542 m_hasBulletNumber = true;
543 UpdatePreview();
544 }
545 }
546
547 /*!
548 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
549 */
550
551 void wxRichTextBulletsPage::OnNumberctrlUpdate( wxUpdateUIEvent& event )
552 {
553 OnNumberUpdate(event);
554 }
555
556 /*!
557 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
558 */
559
560 void wxRichTextBulletsPage::OnParenthesesctrlClick( wxCommandEvent& WXUNUSED(event) )
561 {
562 if (!m_dontUpdate)
563 {
564 m_hasBulletStyle = true;
565 UpdatePreview();
566 }
567 }
568
569 /*!
570 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
571 */
572
573 void wxRichTextBulletsPage::OnParenthesesctrlUpdate( wxUpdateUIEvent& event )
574 {
575 int sel = m_styleListBox->GetSelection();
576 event.Enable(m_hasBulletStyle && (sel != 6 && sel != 7 && sel != 0));
577 }
578
579 /*!
580 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
581 */
582
583 void wxRichTextBulletsPage::OnPeriodctrlClick( wxCommandEvent& WXUNUSED(event) )
584 {
585 if (!m_dontUpdate)
586 {
587 m_hasBulletStyle = true;
588 UpdatePreview();
589 }
590 }
591
592 /*!
593 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
594 */
595
596 void wxRichTextBulletsPage::OnPeriodctrlUpdate( wxUpdateUIEvent& event )
597 {
598 int sel = m_styleListBox->GetSelection();
599 event.Enable(m_hasBulletStyle && (sel != 6 && sel != 7 && sel != 0));
600 }
601
602 /*!
603 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
604 */
605
606 void wxRichTextBulletsPage::OnChooseSymbolClick( wxCommandEvent& WXUNUSED(event) )
607 {
608 int sel = m_styleListBox->GetSelection();
609 if (m_hasBulletStyle && sel == 6)
610 {
611 wxString symbol = m_symbolCtrl->GetValue();
612 wxString fontName = m_symbolFontCtrl->GetValue();
613 wxSymbolPickerDialog dlg(symbol, fontName, fontName, this);
614
615 if (dlg.ShowModal() == wxID_OK)
616 {
617 m_dontUpdate = true;
618
619 m_symbolCtrl->SetValue(dlg.GetSymbol());
620 m_symbolFontCtrl->SetValue(dlg.GetFontName());
621
622 UpdatePreview();
623
624 m_dontUpdate = false;
625 }
626 }
627 }
628
629 /*!
630 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
631 */
632
633 void wxRichTextBulletsPage::OnChooseSymbolUpdate( wxUpdateUIEvent& event )
634 {
635 OnSymbolUpdate(event);
636 }
637 /*!
638 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
639 */
640
641 void wxRichTextBulletsPage::OnSymbolfontctrlSelected( wxCommandEvent& WXUNUSED(event) )
642 {
643 if (m_dontUpdate)
644 return;
645 UpdatePreview();
646 }
647
648 /*!
649 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
650 */
651
652 void wxRichTextBulletsPage::OnSymbolfontctrlUpdated( wxCommandEvent& WXUNUSED(event) )
653 {
654 if (m_dontUpdate)
655 return;
656 UpdatePreview();
657 }
658
659
660 /*!
661 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
662 */
663
664 void wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate( wxUpdateUIEvent& event )
665 {
666 OnSymbolUpdate(event);
667 }
668
669 /// Update for symbol-related controls
670 void wxRichTextBulletsPage::OnSymbolUpdate( wxUpdateUIEvent& event )
671 {
672 int sel = m_styleListBox->GetSelection();
673 event.Enable(m_hasBulletStyle && (sel == 6));
674 }
675
676 /// Update for number-related controls
677 void wxRichTextBulletsPage::OnNumberUpdate( wxUpdateUIEvent& event )
678 {
679 int sel = m_styleListBox->GetSelection();
680 event.Enable( m_hasBulletStyle && (sel != 6 && sel != 7 && sel != 0));
681 }
682
683 /*!
684 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
685 */
686
687 void wxRichTextBulletsPage::OnSymbolstaticUpdate( wxUpdateUIEvent& event )
688 {
689 OnSymbolUpdate(event);
690 }
691
692
693 /*!
694 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
695 */
696
697 void wxRichTextBulletsPage::OnNumberstaticUpdate( wxUpdateUIEvent& event )
698 {
699 OnNumberUpdate(event);
700 }
701
702 #endif // wxUSE_RICHTEXT