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