1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextbulletspage.cpp
4 // Author: Julian Smart
6 // Created: 10/4/2006 10:32:31 AM
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/richtext/richtextbulletspage.h"
16 #include "wx/richtext/richtextsymboldlg.h"
19 * wxRichTextBulletsPage type definition
22 IMPLEMENT_DYNAMIC_CLASS( wxRichTextBulletsPage
, wxPanel
)
25 * wxRichTextBulletsPage event table definition
28 BEGIN_EVENT_TABLE( wxRichTextBulletsPage
, wxPanel
)
30 ////@begin wxRichTextBulletsPage event table entries
31 EVT_LISTBOX( ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
, wxRichTextBulletsPage::OnStylelistboxSelected
)
33 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, wxRichTextBulletsPage::OnPeriodctrlClick
)
34 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, wxRichTextBulletsPage::OnPeriodctrlUpdate
)
36 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, wxRichTextBulletsPage::OnParenthesesctrlClick
)
37 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, wxRichTextBulletsPage::OnParenthesesctrlUpdate
)
39 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, wxRichTextBulletsPage::OnRightParenthesisCtrlClick
)
40 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate
)
42 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL
, wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected
)
44 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, wxRichTextBulletsPage::OnSymbolstaticUpdate
)
46 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, wxRichTextBulletsPage::OnSymbolctrlSelected
)
47 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, wxRichTextBulletsPage::OnSymbolctrlUpdated
)
48 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, wxRichTextBulletsPage::OnSymbolctrlUpdate
)
50 EVT_BUTTON( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, wxRichTextBulletsPage::OnChooseSymbolClick
)
51 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, wxRichTextBulletsPage::OnChooseSymbolUpdate
)
53 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, wxRichTextBulletsPage::OnSymbolfontctrlSelected
)
54 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, wxRichTextBulletsPage::OnSymbolfontctrlUpdated
)
55 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate
)
57 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NAMESTATIC
, wxRichTextBulletsPage::OnNamestaticUpdate
)
59 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_NAMECTRL
, wxRichTextBulletsPage::OnNamectrlSelected
)
60 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_NAMECTRL
, wxRichTextBulletsPage::OnNamectrlUpdated
)
61 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NAMECTRL
, wxRichTextBulletsPage::OnNamectrlUIUpdate
)
63 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
, wxRichTextBulletsPage::OnNumberstaticUpdate
)
65 EVT_SPINCTRL( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlUpdated
)
66 EVT_SPIN_UP( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlUp
)
67 EVT_SPIN_DOWN( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlDown
)
68 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlTextUpdated
)
69 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlUpdate
)
71 ////@end wxRichTextBulletsPage event table entries
76 * wxRichTextBulletsPage constructors
79 wxRichTextBulletsPage::wxRichTextBulletsPage( )
84 wxRichTextBulletsPage::wxRichTextBulletsPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
87 Create(parent
, id
, pos
, size
, style
);
94 void wxRichTextBulletsPage::Init()
96 m_hasBulletStyle
= false;
97 m_hasBulletNumber
= false;
98 m_hasBulletSymbol
= false;
101 ////@begin wxRichTextBulletsPage member initialisation
102 m_styleListBox
= NULL
;
104 m_parenthesesCtrl
= NULL
;
105 m_rightParenthesisCtrl
= NULL
;
106 m_bulletAlignmentCtrl
= NULL
;
108 m_symbolFontCtrl
= NULL
;
109 m_bulletNameCtrl
= NULL
;
111 m_previewCtrl
= NULL
;
112 ////@end wxRichTextBulletsPage member initialisation
116 * wxRichTextBulletsPage creator
119 bool wxRichTextBulletsPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
121 ////@begin wxRichTextBulletsPage creation
122 wxPanel::Create( parent
, id
, pos
, size
, style
);
127 GetSizer()->SetSizeHints(this);
130 ////@end wxRichTextBulletsPage creation
135 * Control creation for wxRichTextBulletsPage
138 void wxRichTextBulletsPage::CreateControls()
140 ////@begin wxRichTextBulletsPage content construction
141 wxRichTextBulletsPage
* itemPanel1
= this;
143 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
144 itemPanel1
->SetSizer(itemBoxSizer2
);
146 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
147 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
149 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
150 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
152 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
153 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
155 wxStaticText
* itemStaticText6
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Bullet style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
156 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
158 wxString
* m_styleListBoxStrings
= NULL
;
159 m_styleListBox
= new wxListBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
, wxDefaultPosition
, wxSize(-1, 140), 0, m_styleListBoxStrings
, wxLB_SINGLE
);
160 m_styleListBox
->SetHelpText(_("The available bullet styles."));
162 m_styleListBox
->SetToolTip(_("The available bullet styles."));
163 itemBoxSizer5
->Add(m_styleListBox
, 1, wxGROW
|wxALL
, 5);
165 wxBoxSizer
* itemBoxSizer8
= new wxBoxSizer(wxHORIZONTAL
);
166 itemBoxSizer5
->Add(itemBoxSizer8
, 0, wxGROW
, 5);
168 m_periodCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, _("Peri&od"), wxDefaultPosition
, wxDefaultSize
, 0 );
169 m_periodCtrl
->SetValue(false);
170 m_periodCtrl
->SetHelpText(_("Check to add a period after the bullet."));
172 m_periodCtrl
->SetToolTip(_("Check to add a period after the bullet."));
173 itemBoxSizer8
->Add(m_periodCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
175 m_parenthesesCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, _("(*)"), wxDefaultPosition
, wxDefaultSize
, 0 );
176 m_parenthesesCtrl
->SetValue(false);
177 m_parenthesesCtrl
->SetHelpText(_("Check to enclose the bullet in parentheses."));
179 m_parenthesesCtrl
->SetToolTip(_("Check to enclose the bullet in parentheses."));
180 itemBoxSizer8
->Add(m_parenthesesCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
182 m_rightParenthesisCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, _("*)"), wxDefaultPosition
, wxDefaultSize
, 0 );
183 m_rightParenthesisCtrl
->SetValue(false);
184 m_rightParenthesisCtrl
->SetHelpText(_("Check to add a right parenthesis."));
186 m_rightParenthesisCtrl
->SetToolTip(_("Check to add a right parenthesis."));
187 itemBoxSizer8
->Add(m_rightParenthesisCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
189 itemBoxSizer5
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
191 wxStaticText
* itemStaticText13
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Bullet &Alignment:"), wxDefaultPosition
, wxDefaultSize
, 0 );
192 itemBoxSizer5
->Add(itemStaticText13
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
194 wxString m_bulletAlignmentCtrlStrings
[] = {
199 m_bulletAlignmentCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL
, _("Left"), wxDefaultPosition
, wxSize(60, -1), 3, m_bulletAlignmentCtrlStrings
, wxCB_READONLY
);
200 m_bulletAlignmentCtrl
->SetStringSelection(_("Left"));
201 m_bulletAlignmentCtrl
->SetHelpText(_("The bullet character."));
203 m_bulletAlignmentCtrl
->SetToolTip(_("The bullet character."));
204 itemBoxSizer5
->Add(m_bulletAlignmentCtrl
, 0, wxGROW
|wxALL
|wxFIXED_MINSIZE
, 5);
206 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
208 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemPanel1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
209 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
211 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
213 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
214 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
216 wxStaticText
* itemStaticText19
= new wxStaticText( itemPanel1
, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, _("&Symbol:"), wxDefaultPosition
, wxDefaultSize
, 0 );
217 itemBoxSizer18
->Add(itemStaticText19
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
219 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
220 itemBoxSizer18
->Add(itemBoxSizer20
, 0, wxGROW
, 5);
222 wxString
* m_symbolCtrlStrings
= NULL
;
223 m_symbolCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, _T(""), wxDefaultPosition
, wxSize(60, -1), 0, m_symbolCtrlStrings
, wxCB_DROPDOWN
);
224 m_symbolCtrl
->SetHelpText(_("The bullet character."));
226 m_symbolCtrl
->SetToolTip(_("The bullet character."));
227 itemBoxSizer20
->Add(m_symbolCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
|wxFIXED_MINSIZE
, 5);
229 wxButton
* itemButton22
= new wxButton( itemPanel1
, ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, _("Ch&oose..."), wxDefaultPosition
, wxDefaultSize
, 0 );
230 itemButton22
->SetHelpText(_("Click to browse for a symbol."));
232 itemButton22
->SetToolTip(_("Click to browse for a symbol."));
233 itemBoxSizer20
->Add(itemButton22
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
235 itemBoxSizer18
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
237 wxStaticText
* itemStaticText24
= new wxStaticText( itemPanel1
, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, _("Symbol &font:"), wxDefaultPosition
, wxDefaultSize
, 0 );
238 itemBoxSizer18
->Add(itemStaticText24
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
240 wxString
* m_symbolFontCtrlStrings
= NULL
;
241 m_symbolFontCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, _T(""), wxDefaultPosition
, wxDefaultSize
, 0, m_symbolFontCtrlStrings
, wxCB_DROPDOWN
);
242 m_symbolFontCtrl
->SetHelpText(_("Available fonts."));
244 m_symbolFontCtrl
->SetToolTip(_("Available fonts."));
245 itemBoxSizer18
->Add(m_symbolFontCtrl
, 0, wxGROW
|wxALL
, 5);
247 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
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
|wxADJUST_MINSIZE
, 5);
252 wxString
* m_bulletNameCtrlStrings
= NULL
;
253 m_bulletNameCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_NAMECTRL
, _T(""), wxDefaultPosition
, wxDefaultSize
, 0, m_bulletNameCtrlStrings
, wxCB_DROPDOWN
);
254 m_bulletNameCtrl
->SetHelpText(_("A standard bullet name."));
256 m_bulletNameCtrl
->SetToolTip(_("A standard bullet name."));
257 itemBoxSizer18
->Add(m_bulletNameCtrl
, 0, wxGROW
|wxALL
, 5);
259 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
261 wxStaticText
* itemStaticText30
= new wxStaticText( itemPanel1
, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
, _("&Number:"), wxDefaultPosition
, wxDefaultSize
, 0 );
262 itemBoxSizer18
->Add(itemStaticText30
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
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."));
267 m_numberCtrl
->SetToolTip(_("The list item number."));
268 itemBoxSizer18
->Add(m_numberCtrl
, 0, wxGROW
|wxALL
, 5);
270 itemBoxSizer3
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
272 m_previewCtrl
= new wxRichTextCtrl( itemPanel1
, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 180), wxSUNKEN_BORDER
);
273 m_previewCtrl
->SetHelpText(_("Shows a preview of the bullet settings."));
275 m_previewCtrl
->SetToolTip(_("Shows a preview of the bullet settings."));
276 itemBoxSizer3
->Add(m_previewCtrl
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
278 ////@end wxRichTextBulletsPage content construction
280 m_styleListBox
->Append(_("(None)"));
281 m_styleListBox
->Append(_("Arabic"));
282 m_styleListBox
->Append(_("Upper case letters"));
283 m_styleListBox
->Append(_("Lower case letters"));
284 m_styleListBox
->Append(_("Upper case roman numerals"));
285 m_styleListBox
->Append(_("Lower case roman numerals"));
286 m_styleListBox
->Append(_("Numbered outline"));
287 m_styleListBox
->Append(_("Symbol"));
288 m_styleListBox
->Append(_("Bitmap"));
289 m_styleListBox
->Append(_("Standard"));
291 m_symbolCtrl
->Append(_("*"));
292 m_symbolCtrl
->Append(_("-"));
293 m_symbolCtrl
->Append(_(">"));
294 m_symbolCtrl
->Append(_("+"));
295 m_symbolCtrl
->Append(_("~"));
297 wxArrayString standardBulletNames
;
298 if (wxRichTextBuffer::GetRenderer())
299 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
301 m_bulletNameCtrl
->Append(standardBulletNames
);
303 wxArrayString facenames
= wxRichTextCtrl::GetAvailableFontNames();
306 m_symbolFontCtrl
->Append(facenames
);
309 /// Transfer data from/to window
310 bool wxRichTextBulletsPage::TransferDataFromWindow()
312 wxPanel::TransferDataFromWindow();
314 wxTextAttrEx
* attr
= GetAttributes();
316 if (m_hasBulletStyle
)
318 long bulletStyle
= wxRICHTEXT_BULLETINDEX_NONE
;
320 int index
= m_styleListBox
->GetSelection();
321 if (index
== wxRICHTEXT_BULLETINDEX_ARABIC
)
322 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ARABIC
;
324 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE
)
325 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
;
327 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE
)
328 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
;
330 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
)
331 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
;
333 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
)
334 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
;
336 else if (index
== wxRICHTEXT_BULLETINDEX_OUTLINE
)
337 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_OUTLINE
;
339 else if (index
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
340 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
;
342 else if (index
== wxRICHTEXT_BULLETINDEX_BITMAP
)
343 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_BITMAP
;
345 else if (index
== wxRICHTEXT_BULLETINDEX_STANDARD
)
347 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_STANDARD
;
348 attr
->SetBulletName(m_bulletNameCtrl
->GetValue());
351 if (m_parenthesesCtrl
->GetValue())
352 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_PARENTHESES
;
353 if (m_rightParenthesisCtrl
->GetValue())
354 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS
;
355 if (m_periodCtrl
->GetValue())
356 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_PERIOD
;
358 if (m_bulletAlignmentCtrl
->GetSelection() == 1)
359 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE
;
360 else if (m_bulletAlignmentCtrl
->GetSelection() == 2)
361 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
;
364 attr
->SetBulletStyle(bulletStyle
);
367 if (m_hasBulletNumber
)
369 attr
->SetBulletNumber(m_numberCtrl
->GetValue());
372 if (m_hasBulletSymbol
)
374 attr
->SetBulletText(m_symbolCtrl
->GetValue());
375 attr
->SetBulletFont(m_symbolFontCtrl
->GetValue());
381 bool wxRichTextBulletsPage::TransferDataToWindow()
385 wxPanel::TransferDataToWindow();
387 wxTextAttrEx
* attr
= GetAttributes();
389 if (attr
->HasBulletStyle())
391 m_hasBulletStyle
= true;
392 int index
= wxRICHTEXT_BULLETINDEX_NONE
;
394 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ARABIC
)
395 index
= wxRICHTEXT_BULLETINDEX_ARABIC
;
397 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
)
398 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE
;
400 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
)
401 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE
;
403 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
)
404 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
;
406 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
)
407 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
;
409 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE
)
410 index
= wxRICHTEXT_BULLETINDEX_OUTLINE
;
412 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL
)
413 index
= wxRICHTEXT_BULLETINDEX_SYMBOL
;
415 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_BITMAP
)
416 index
= wxRICHTEXT_BULLETINDEX_BITMAP
;
418 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD
)
419 index
= wxRICHTEXT_BULLETINDEX_STANDARD
;
421 m_styleListBox
->SetSelection(index
);
423 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PARENTHESES
)
424 m_parenthesesCtrl
->SetValue(true);
426 m_parenthesesCtrl
->SetValue(false);
428 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS
)
429 m_rightParenthesisCtrl
->SetValue(true);
431 m_rightParenthesisCtrl
->SetValue(false);
433 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PERIOD
)
434 m_periodCtrl
->SetValue(true);
436 m_periodCtrl
->SetValue(false);
438 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE
)
439 m_bulletAlignmentCtrl
->SetSelection(1);
440 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
)
441 m_bulletAlignmentCtrl
->SetSelection(2);
443 m_bulletAlignmentCtrl
->SetSelection(0);
447 m_hasBulletStyle
= false;
448 m_styleListBox
->SetSelection(-1);
449 m_bulletAlignmentCtrl
->SetSelection(-1);
452 if (attr
->HasBulletText())
454 m_symbolCtrl
->SetValue(attr
->GetBulletText());
455 m_symbolFontCtrl
->SetValue(attr
->GetBulletFont());
458 m_symbolCtrl
->SetValue(wxEmptyString
);
460 if (attr
->HasBulletNumber())
461 m_numberCtrl
->SetValue(attr
->GetBulletNumber());
463 m_numberCtrl
->SetValue(0);
465 if (attr
->HasBulletName())
466 m_bulletNameCtrl
->SetValue(attr
->GetBulletName());
468 m_bulletNameCtrl
->SetValue(wxEmptyString
);
472 m_dontUpdate
= false;
477 /// Updates the bullet preview
478 void wxRichTextBulletsPage::UpdatePreview()
480 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
481 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.");
483 static const wxChar
* s_para2
= wxT("\nDuis pharetra consequat dui. Cum sociis natoque penatibus \
484 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.");
486 static const wxChar
* s_para3
= wxT("\nInteger convallis dolor at augue \
487 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
489 TransferDataFromWindow();
490 wxTextAttrEx
attr(*GetAttributes());
491 attr
.SetFlags(attr
.GetFlags() &
492 (wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
|wxTEXT_ATTR_BULLET_NAME
|
493 wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
494 wxTEXT_ATTR_LINE_SPACING
));
496 wxFont
font(m_previewCtrl
->GetFont());
497 font
.SetPointSize(9);
498 m_previewCtrl
->SetFont(font
);
500 wxTextAttrEx normalParaAttr
;
501 normalParaAttr
.SetFont(font
);
502 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
504 m_previewCtrl
->Freeze();
505 m_previewCtrl
->Clear();
507 m_previewCtrl
->BeginStyle(normalParaAttr
);
508 m_previewCtrl
->WriteText(s_para1
);
509 m_previewCtrl
->EndStyle();
511 m_previewCtrl
->BeginStyle(attr
);
512 m_previewCtrl
->WriteText(s_para2
);
513 m_previewCtrl
->EndStyle();
515 m_previewCtrl
->BeginStyle(normalParaAttr
);
516 m_previewCtrl
->WriteText(s_para3
);
517 m_previewCtrl
->EndStyle();
519 m_previewCtrl
->NumberList(wxRichTextRange(0, m_previewCtrl
->GetLastPosition()+1));
521 m_previewCtrl
->Thaw();
524 wxTextAttrEx
* wxRichTextBulletsPage::GetAttributes()
526 return wxRichTextFormattingDialog::GetDialogAttributes(this);
530 * Should we show tooltips?
533 bool wxRichTextBulletsPage::ShowToolTips()
535 return wxRichTextFormattingDialog::ShowToolTips();
539 * Get bitmap resources
542 wxBitmap
wxRichTextBulletsPage::GetBitmapResource( const wxString
& name
)
545 ////@begin wxRichTextBulletsPage bitmap retrieval
548 ////@end wxRichTextBulletsPage bitmap retrieval
555 wxIcon
wxRichTextBulletsPage::GetIconResource( const wxString
& name
)
558 ////@begin wxRichTextBulletsPage icon retrieval
561 ////@end wxRichTextBulletsPage icon retrieval
565 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
568 void wxRichTextBulletsPage::OnStylelistboxSelected( wxCommandEvent
& WXUNUSED(event
) )
572 m_hasBulletStyle
= true;
574 if (m_styleListBox
->GetSelection() == wxRICHTEXT_BULLETINDEX_SYMBOL
)
575 m_hasBulletSymbol
= true;
582 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
585 void wxRichTextBulletsPage::OnSymbolctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
589 m_hasBulletSymbol
= true;
595 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
598 void wxRichTextBulletsPage::OnSymbolctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
602 m_hasBulletSymbol
= true;
608 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
611 void wxRichTextBulletsPage::OnSymbolctrlUpdate( wxUpdateUIEvent
& event
)
613 OnSymbolUpdate(event
);
617 * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
620 void wxRichTextBulletsPage::OnNumberctrlUpdated( wxSpinEvent
& WXUNUSED(event
) )
624 m_hasBulletNumber
= true;
630 * wxEVT_SCROLL_LINEUP event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
633 void wxRichTextBulletsPage::OnNumberctrlUp( wxSpinEvent
& WXUNUSED(event
) )
637 m_hasBulletNumber
= true;
643 * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
646 void wxRichTextBulletsPage::OnNumberctrlDown( wxSpinEvent
& WXUNUSED(event
) )
650 m_hasBulletNumber
= true;
656 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
659 void wxRichTextBulletsPage::OnNumberctrlTextUpdated( wxCommandEvent
& WXUNUSED(event
) )
663 m_hasBulletNumber
= true;
669 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
672 void wxRichTextBulletsPage::OnNumberctrlUpdate( wxUpdateUIEvent
& event
)
674 OnNumberUpdate(event
);
678 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
681 void wxRichTextBulletsPage::OnParenthesesctrlClick( wxCommandEvent
& WXUNUSED(event
) )
685 m_hasBulletStyle
= true;
691 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
694 void wxRichTextBulletsPage::OnParenthesesctrlUpdate( wxUpdateUIEvent
& event
)
696 int sel
= m_styleListBox
->GetSelection();
697 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
698 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
699 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
703 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
706 void wxRichTextBulletsPage::OnPeriodctrlClick( wxCommandEvent
& WXUNUSED(event
) )
710 m_hasBulletStyle
= true;
716 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
719 void wxRichTextBulletsPage::OnPeriodctrlUpdate( wxUpdateUIEvent
& event
)
721 int sel
= m_styleListBox
->GetSelection();
722 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
723 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
724 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
728 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
731 void wxRichTextBulletsPage::OnChooseSymbolClick( wxCommandEvent
& WXUNUSED(event
) )
733 int sel
= m_styleListBox
->GetSelection();
734 if (m_hasBulletStyle
&& sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
736 wxString symbol
= m_symbolCtrl
->GetValue();
737 wxString fontName
= m_symbolFontCtrl
->GetValue();
738 wxSymbolPickerDialog
dlg(symbol
, fontName
, fontName
, this);
740 if (dlg
.ShowModal() == wxID_OK
)
744 m_symbolCtrl
->SetValue(dlg
.GetSymbol());
745 m_symbolFontCtrl
->SetValue(dlg
.GetFontName());
749 m_dontUpdate
= false;
755 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
758 void wxRichTextBulletsPage::OnChooseSymbolUpdate( wxUpdateUIEvent
& event
)
760 OnSymbolUpdate(event
);
763 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
766 void wxRichTextBulletsPage::OnSymbolfontctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
774 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
777 void wxRichTextBulletsPage::OnSymbolfontctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
786 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
789 void wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate( wxUpdateUIEvent
& event
)
791 OnSymbolUpdate(event
);
794 /// Update for symbol-related controls
795 void wxRichTextBulletsPage::OnSymbolUpdate( wxUpdateUIEvent
& event
)
797 int sel
= m_styleListBox
->GetSelection();
798 event
.Enable(m_hasBulletStyle
&& (sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
));
801 /// Update for number-related controls
802 void wxRichTextBulletsPage::OnNumberUpdate( wxUpdateUIEvent
& event
)
804 int sel
= m_styleListBox
->GetSelection();
805 event
.Enable( m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
806 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
807 sel
!= wxRICHTEXT_BULLETINDEX_STANDARD
&&
808 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
811 /// Update for standard bullet-related controls
812 void wxRichTextBulletsPage::OnStandardBulletUpdate( wxUpdateUIEvent
& event
)
814 int sel
= m_styleListBox
->GetSelection();
815 event
.Enable( sel
== wxRICHTEXT_BULLETINDEX_STANDARD
);
820 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
823 void wxRichTextBulletsPage::OnSymbolstaticUpdate( wxUpdateUIEvent
& event
)
825 OnSymbolUpdate(event
);
830 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
833 void wxRichTextBulletsPage::OnNumberstaticUpdate( wxUpdateUIEvent
& event
)
835 OnNumberUpdate(event
);
839 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMESTATIC
842 void wxRichTextBulletsPage::OnNamestaticUpdate( wxUpdateUIEvent
& event
)
844 OnStandardBulletUpdate(event
);
849 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
852 void wxRichTextBulletsPage::OnNamectrlSelected( wxCommandEvent
& WXUNUSED(event
) )
860 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
863 void wxRichTextBulletsPage::OnNamectrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
871 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
874 void wxRichTextBulletsPage::OnNamectrlUIUpdate( wxUpdateUIEvent
& event
)
876 OnStandardBulletUpdate(event
);
879 #endif // wxUSE_RICHTEXT
881 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
884 void wxRichTextBulletsPage::OnRightParenthesisCtrlClick( wxCommandEvent
& WXUNUSED(event
) )
888 m_hasBulletStyle
= true;
894 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
897 void wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate( wxUpdateUIEvent
& event
)
899 int sel
= m_styleListBox
->GetSelection();
900 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
901 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
902 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
906 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX
909 void wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )