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