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