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