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/spinctrl.h"
16 #include "wx/richtext/richtextbulletspage.h"
18 #include "wx/richtext/richtextsymboldlg.h"
21 * wxRichTextBulletsPage type definition
24 IMPLEMENT_DYNAMIC_CLASS( wxRichTextBulletsPage
, wxPanel
)
27 * wxRichTextBulletsPage event table definition
30 BEGIN_EVENT_TABLE( wxRichTextBulletsPage
, wxPanel
)
32 ////@begin wxRichTextBulletsPage event table entries
33 EVT_LISTBOX( ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
, wxRichTextBulletsPage::OnStylelistboxSelected
)
35 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, wxRichTextBulletsPage::OnPeriodctrlClick
)
36 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, wxRichTextBulletsPage::OnPeriodctrlUpdate
)
38 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, wxRichTextBulletsPage::OnParenthesesctrlClick
)
39 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, wxRichTextBulletsPage::OnParenthesesctrlUpdate
)
41 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, wxRichTextBulletsPage::OnRightParenthesisCtrlClick
)
42 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate
)
44 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL
, wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected
)
46 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, wxRichTextBulletsPage::OnSymbolstaticUpdate
)
48 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, wxRichTextBulletsPage::OnSymbolctrlSelected
)
49 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, wxRichTextBulletsPage::OnSymbolctrlUpdated
)
50 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, wxRichTextBulletsPage::OnSymbolctrlUpdate
)
52 EVT_BUTTON( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, wxRichTextBulletsPage::OnChooseSymbolClick
)
53 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, wxRichTextBulletsPage::OnChooseSymbolUpdate
)
55 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, wxRichTextBulletsPage::OnSymbolfontctrlSelected
)
56 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, wxRichTextBulletsPage::OnSymbolfontctrlUpdated
)
57 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate
)
59 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NAMESTATIC
, wxRichTextBulletsPage::OnNamestaticUpdate
)
61 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_NAMECTRL
, wxRichTextBulletsPage::OnNamectrlSelected
)
62 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_NAMECTRL
, wxRichTextBulletsPage::OnNamectrlUpdated
)
63 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NAMECTRL
, wxRichTextBulletsPage::OnNamectrlUIUpdate
)
65 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
, wxRichTextBulletsPage::OnNumberstaticUpdate
)
67 EVT_SPINCTRL( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlUpdated
)
68 EVT_SPIN_UP( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlUp
)
69 EVT_SPIN_DOWN( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlDown
)
70 EVT_TEXT( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlTextUpdated
)
71 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxRichTextBulletsPage::OnNumberctrlUpdate
)
73 ////@end wxRichTextBulletsPage event table entries
78 * wxRichTextBulletsPage constructors
81 wxRichTextBulletsPage::wxRichTextBulletsPage( )
86 wxRichTextBulletsPage::wxRichTextBulletsPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
89 Create(parent
, id
, pos
, size
, style
);
96 void wxRichTextBulletsPage::Init()
98 m_hasBulletStyle
= false;
99 m_hasBulletNumber
= false;
100 m_hasBulletSymbol
= false;
101 m_dontUpdate
= false;
103 ////@begin wxRichTextBulletsPage member initialisation
104 m_styleListBox
= NULL
;
106 m_parenthesesCtrl
= NULL
;
107 m_rightParenthesisCtrl
= NULL
;
108 m_bulletAlignmentCtrl
= NULL
;
110 m_symbolFontCtrl
= NULL
;
111 m_bulletNameCtrl
= NULL
;
113 m_previewCtrl
= NULL
;
114 ////@end wxRichTextBulletsPage member initialisation
118 * wxRichTextBulletsPage creator
121 bool wxRichTextBulletsPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
123 ////@begin wxRichTextBulletsPage creation
124 wxPanel::Create( parent
, id
, pos
, size
, style
);
129 GetSizer()->SetSizeHints(this);
132 ////@end wxRichTextBulletsPage creation
137 * Control creation for wxRichTextBulletsPage
140 void wxRichTextBulletsPage::CreateControls()
142 ////@begin wxRichTextBulletsPage content construction
143 wxRichTextBulletsPage
* itemPanel1
= this;
145 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
146 itemPanel1
->SetSizer(itemBoxSizer2
);
148 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
149 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
151 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
152 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
154 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
155 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
157 wxStaticText
* itemStaticText6
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Bullet style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
158 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
160 wxArrayString m_styleListBoxStrings
;
161 m_styleListBox
= new wxListBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
, wxDefaultPosition
, wxSize(-1, 90), m_styleListBoxStrings
, wxLB_SINGLE
);
162 m_styleListBox
->SetHelpText(_("The available bullet styles."));
163 if (wxRichTextBulletsPage::ShowToolTips())
164 m_styleListBox
->SetToolTip(_("The available bullet styles."));
165 itemBoxSizer5
->Add(m_styleListBox
, 1, wxGROW
|wxALL
, 5);
167 wxBoxSizer
* itemBoxSizer8
= new wxBoxSizer(wxHORIZONTAL
);
168 itemBoxSizer5
->Add(itemBoxSizer8
, 0, wxGROW
, 5);
170 m_periodCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, _("Peri&od"), wxDefaultPosition
, wxDefaultSize
, 0 );
171 m_periodCtrl
->SetValue(false);
172 m_periodCtrl
->SetHelpText(_("Check to add a period after the bullet."));
173 if (wxRichTextBulletsPage::ShowToolTips())
174 m_periodCtrl
->SetToolTip(_("Check to add a period after the bullet."));
175 itemBoxSizer8
->Add(m_periodCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
177 m_parenthesesCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, _("(*)"), wxDefaultPosition
, wxDefaultSize
, 0 );
178 m_parenthesesCtrl
->SetValue(false);
179 m_parenthesesCtrl
->SetHelpText(_("Check to enclose the bullet in parentheses."));
180 if (wxRichTextBulletsPage::ShowToolTips())
181 m_parenthesesCtrl
->SetToolTip(_("Check to enclose the bullet in parentheses."));
182 itemBoxSizer8
->Add(m_parenthesesCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
184 m_rightParenthesisCtrl
= new wxCheckBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, _("*)"), wxDefaultPosition
, wxDefaultSize
, 0 );
185 m_rightParenthesisCtrl
->SetValue(false);
186 m_rightParenthesisCtrl
->SetHelpText(_("Check to add a right parenthesis."));
187 if (wxRichTextBulletsPage::ShowToolTips())
188 m_rightParenthesisCtrl
->SetToolTip(_("Check to add a right parenthesis."));
189 itemBoxSizer8
->Add(m_rightParenthesisCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
191 itemBoxSizer5
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
193 wxStaticText
* itemStaticText13
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Bullet &Alignment:"), wxDefaultPosition
, wxDefaultSize
, 0 );
194 itemBoxSizer5
->Add(itemStaticText13
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
196 wxArrayString m_bulletAlignmentCtrlStrings
;
197 m_bulletAlignmentCtrlStrings
.Add(_("Left"));
198 m_bulletAlignmentCtrlStrings
.Add(_("Centre"));
199 m_bulletAlignmentCtrlStrings
.Add(_("Right"));
200 m_bulletAlignmentCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL
, _("Left"), wxDefaultPosition
, wxSize(60, -1), m_bulletAlignmentCtrlStrings
, wxCB_READONLY
);
201 m_bulletAlignmentCtrl
->SetStringSelection(_("Left"));
202 m_bulletAlignmentCtrl
->SetHelpText(_("The bullet character."));
203 if (wxRichTextBulletsPage::ShowToolTips())
204 m_bulletAlignmentCtrl
->SetToolTip(_("The bullet character."));
205 itemBoxSizer5
->Add(m_bulletAlignmentCtrl
, 0, wxGROW
|wxALL
|wxFIXED_MINSIZE
, 5);
207 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
209 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemPanel1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
210 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
212 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
214 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
215 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
217 wxStaticText
* itemStaticText19
= new wxStaticText( itemPanel1
, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, _("&Symbol:"), wxDefaultPosition
, wxDefaultSize
, 0 );
218 itemBoxSizer18
->Add(itemStaticText19
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
220 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
221 itemBoxSizer18
->Add(itemBoxSizer20
, 0, wxGROW
, 5);
223 wxArrayString m_symbolCtrlStrings
;
224 m_symbolCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, _T(""), wxDefaultPosition
, wxSize(60, -1), m_symbolCtrlStrings
, wxCB_DROPDOWN
);
225 m_symbolCtrl
->SetHelpText(_("The bullet character."));
226 if (wxRichTextBulletsPage::ShowToolTips())
227 m_symbolCtrl
->SetToolTip(_("The bullet character."));
228 itemBoxSizer20
->Add(m_symbolCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
|wxFIXED_MINSIZE
, 5);
230 wxButton
* itemButton22
= new wxButton( itemPanel1
, ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, _("Ch&oose..."), wxDefaultPosition
, wxDefaultSize
, 0 );
231 itemButton22
->SetHelpText(_("Click to browse for a symbol."));
232 if (wxRichTextBulletsPage::ShowToolTips())
233 itemButton22
->SetToolTip(_("Click to browse for a symbol."));
234 itemBoxSizer20
->Add(itemButton22
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
236 itemBoxSizer18
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
238 wxStaticText
* itemStaticText24
= new wxStaticText( itemPanel1
, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, _("Symbol &font:"), wxDefaultPosition
, wxDefaultSize
, 0 );
239 itemBoxSizer18
->Add(itemStaticText24
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
241 wxArrayString m_symbolFontCtrlStrings
;
242 m_symbolFontCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, _T(""), wxDefaultPosition
, wxDefaultSize
, m_symbolFontCtrlStrings
, wxCB_DROPDOWN
);
243 m_symbolFontCtrl
->SetHelpText(_("Available fonts."));
244 if (wxRichTextBulletsPage::ShowToolTips())
245 m_symbolFontCtrl
->SetToolTip(_("Available fonts."));
246 itemBoxSizer18
->Add(m_symbolFontCtrl
, 0, wxGROW
|wxALL
, 5);
248 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
, 5);
250 wxStaticText
* itemStaticText27
= new wxStaticText( itemPanel1
, ID_RICHTEXTBULLETSPAGE_NAMESTATIC
, _("S&tandard bullet name:"), wxDefaultPosition
, wxDefaultSize
, 0 );
251 itemBoxSizer18
->Add(itemStaticText27
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
253 wxArrayString m_bulletNameCtrlStrings
;
254 m_bulletNameCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTBULLETSPAGE_NAMECTRL
, _T(""), wxDefaultPosition
, wxDefaultSize
, m_bulletNameCtrlStrings
, wxCB_DROPDOWN
);
255 m_bulletNameCtrl
->SetHelpText(_("A standard bullet name."));
256 if (wxRichTextBulletsPage::ShowToolTips())
257 m_bulletNameCtrl
->SetToolTip(_("A standard bullet name."));
258 itemBoxSizer18
->Add(m_bulletNameCtrl
, 0, wxGROW
|wxALL
, 5);
260 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
, 5);
262 wxStaticText
* itemStaticText30
= new wxStaticText( itemPanel1
, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
, _("&Number:"), wxDefaultPosition
, wxDefaultSize
, 0 );
263 itemBoxSizer18
->Add(itemStaticText30
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
265 m_numberCtrl
= new wxSpinCtrl( itemPanel1
, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, _T("0"), wxDefaultPosition
, wxSize(50, -1), wxSP_ARROW_KEYS
, 0, 100000, 0 );
266 m_numberCtrl
->SetHelpText(_("The list item number."));
267 if (wxRichTextBulletsPage::ShowToolTips())
268 m_numberCtrl
->SetToolTip(_("The list item number."));
269 itemBoxSizer18
->Add(m_numberCtrl
, 0, wxGROW
|wxALL
, 5);
271 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
273 m_previewCtrl
= new wxRichTextCtrl( itemPanel1
, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 100), wxVSCROLL
|wxTE_READONLY
);
274 m_previewCtrl
->SetHelpText(_("Shows a preview of the bullet settings."));
275 if (wxRichTextBulletsPage::ShowToolTips())
276 m_previewCtrl
->SetToolTip(_("Shows a preview of the bullet settings."));
277 itemBoxSizer3
->Add(m_previewCtrl
, 1, wxGROW
|wxALL
, 5);
279 ////@end wxRichTextBulletsPage content construction
281 m_styleListBox
->Append(_("(None)"));
282 m_styleListBox
->Append(_("Arabic"));
283 m_styleListBox
->Append(_("Upper case letters"));
284 m_styleListBox
->Append(_("Lower case letters"));
285 m_styleListBox
->Append(_("Upper case roman numerals"));
286 m_styleListBox
->Append(_("Lower case roman numerals"));
287 m_styleListBox
->Append(_("Numbered outline"));
288 m_styleListBox
->Append(_("Symbol"));
289 m_styleListBox
->Append(_("Bitmap"));
290 m_styleListBox
->Append(_("Standard"));
292 m_symbolCtrl
->Append(_("*"));
293 m_symbolCtrl
->Append(_("-"));
294 m_symbolCtrl
->Append(_(">"));
295 m_symbolCtrl
->Append(_("+"));
296 m_symbolCtrl
->Append(_("~"));
298 wxArrayString standardBulletNames
;
299 if (wxRichTextBuffer::GetRenderer())
300 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
302 m_bulletNameCtrl
->Append(standardBulletNames
);
304 wxArrayString facenames
= wxRichTextCtrl::GetAvailableFontNames();
307 m_symbolFontCtrl
->Append(facenames
);
310 /// Transfer data from/to window
311 bool wxRichTextBulletsPage::TransferDataFromWindow()
313 wxPanel::TransferDataFromWindow();
315 wxTextAttr
* attr
= GetAttributes();
317 if (m_hasBulletStyle
)
319 long bulletStyle
= wxRICHTEXT_BULLETINDEX_NONE
;
321 int index
= m_styleListBox
->GetSelection();
322 if (index
== wxRICHTEXT_BULLETINDEX_ARABIC
)
323 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ARABIC
;
325 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE
)
326 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
;
328 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE
)
329 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
;
331 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
)
332 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
;
334 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
)
335 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
;
337 else if (index
== wxRICHTEXT_BULLETINDEX_OUTLINE
)
338 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_OUTLINE
;
340 else if (index
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
341 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
;
343 else if (index
== wxRICHTEXT_BULLETINDEX_BITMAP
)
344 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_BITMAP
;
346 else if (index
== wxRICHTEXT_BULLETINDEX_STANDARD
)
348 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_STANDARD
;
349 attr
->SetBulletName(m_bulletNameCtrl
->GetValue());
352 if (m_parenthesesCtrl
->GetValue())
353 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_PARENTHESES
;
354 if (m_rightParenthesisCtrl
->GetValue())
355 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS
;
356 if (m_periodCtrl
->GetValue())
357 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_PERIOD
;
359 if (m_bulletAlignmentCtrl
->GetSelection() == 1)
360 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE
;
361 else if (m_bulletAlignmentCtrl
->GetSelection() == 2)
362 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
;
365 attr
->SetBulletStyle(bulletStyle
);
368 if (m_hasBulletNumber
)
370 attr
->SetBulletNumber(m_numberCtrl
->GetValue());
373 if (m_hasBulletSymbol
)
375 attr
->SetBulletText(m_symbolCtrl
->GetValue());
376 attr
->SetBulletFont(m_symbolFontCtrl
->GetValue());
382 bool wxRichTextBulletsPage::TransferDataToWindow()
386 wxPanel::TransferDataToWindow();
388 wxTextAttr
* attr
= GetAttributes();
390 if (attr
->HasBulletStyle())
392 m_hasBulletStyle
= true;
393 int index
= wxRICHTEXT_BULLETINDEX_NONE
;
395 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ARABIC
)
396 index
= wxRICHTEXT_BULLETINDEX_ARABIC
;
398 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
)
399 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE
;
401 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
)
402 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE
;
404 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
)
405 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
;
407 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
)
408 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
;
410 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE
)
411 index
= wxRICHTEXT_BULLETINDEX_OUTLINE
;
413 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL
)
414 index
= wxRICHTEXT_BULLETINDEX_SYMBOL
;
416 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_BITMAP
)
417 index
= wxRICHTEXT_BULLETINDEX_BITMAP
;
419 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD
)
420 index
= wxRICHTEXT_BULLETINDEX_STANDARD
;
422 m_styleListBox
->SetSelection(index
);
424 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PARENTHESES
)
425 m_parenthesesCtrl
->SetValue(true);
427 m_parenthesesCtrl
->SetValue(false);
429 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS
)
430 m_rightParenthesisCtrl
->SetValue(true);
432 m_rightParenthesisCtrl
->SetValue(false);
434 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PERIOD
)
435 m_periodCtrl
->SetValue(true);
437 m_periodCtrl
->SetValue(false);
439 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE
)
440 m_bulletAlignmentCtrl
->SetSelection(1);
441 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
)
442 m_bulletAlignmentCtrl
->SetSelection(2);
444 m_bulletAlignmentCtrl
->SetSelection(0);
448 m_hasBulletStyle
= false;
449 m_styleListBox
->SetSelection(-1);
450 m_bulletAlignmentCtrl
->SetSelection(-1);
453 if (attr
->HasBulletText())
455 m_symbolCtrl
->SetValue(attr
->GetBulletText());
456 m_symbolFontCtrl
->SetValue(attr
->GetBulletFont());
459 m_symbolCtrl
->SetValue(wxEmptyString
);
461 if (attr
->HasBulletNumber())
462 m_numberCtrl
->SetValue(attr
->GetBulletNumber());
464 m_numberCtrl
->SetValue(0);
466 if (attr
->HasBulletName())
467 m_bulletNameCtrl
->SetValue(attr
->GetBulletName());
469 m_bulletNameCtrl
->SetValue(wxEmptyString
);
473 m_dontUpdate
= false;
478 /// Updates the bullet preview
479 void wxRichTextBulletsPage::UpdatePreview()
481 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
482 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.");
484 static const wxChar
* s_para2
= wxT("\nDuis pharetra consequat dui. Cum sociis natoque penatibus \
485 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.");
487 static const wxChar
* s_para3
= wxT("\nInteger convallis dolor at augue \
488 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
490 TransferDataFromWindow();
491 wxTextAttr
attr(*GetAttributes());
492 attr
.SetFlags(attr
.GetFlags() &
493 (wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
|wxTEXT_ATTR_BULLET_NAME
|
494 wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
495 wxTEXT_ATTR_LINE_SPACING
));
497 wxFont
font(m_previewCtrl
->GetFont());
498 font
.SetPointSize(9);
499 m_previewCtrl
->SetFont(font
);
501 wxTextAttr normalParaAttr
;
502 normalParaAttr
.SetFont(font
);
503 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
505 m_previewCtrl
->Freeze();
506 m_previewCtrl
->Clear();
508 m_previewCtrl
->BeginStyle(normalParaAttr
);
509 m_previewCtrl
->WriteText(s_para1
);
510 m_previewCtrl
->EndStyle();
512 m_previewCtrl
->BeginStyle(attr
);
513 m_previewCtrl
->WriteText(s_para2
);
514 m_previewCtrl
->EndStyle();
516 m_previewCtrl
->BeginStyle(normalParaAttr
);
517 m_previewCtrl
->WriteText(s_para3
);
518 m_previewCtrl
->EndStyle();
520 m_previewCtrl
->NumberList(wxRichTextRange(0, m_previewCtrl
->GetLastPosition()+1));
522 m_previewCtrl
->Thaw();
525 wxTextAttr
* wxRichTextBulletsPage::GetAttributes()
527 return wxRichTextFormattingDialog::GetDialogAttributes(this);
531 * Should we show tooltips?
534 bool wxRichTextBulletsPage::ShowToolTips()
536 return wxRichTextFormattingDialog::ShowToolTips();
540 * Get bitmap resources
543 wxBitmap
wxRichTextBulletsPage::GetBitmapResource( const wxString
& name
)
546 ////@begin wxRichTextBulletsPage bitmap retrieval
549 ////@end wxRichTextBulletsPage bitmap retrieval
556 wxIcon
wxRichTextBulletsPage::GetIconResource( const wxString
& name
)
559 ////@begin wxRichTextBulletsPage icon retrieval
562 ////@end wxRichTextBulletsPage icon retrieval
566 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
569 void wxRichTextBulletsPage::OnStylelistboxSelected( wxCommandEvent
& WXUNUSED(event
) )
573 m_hasBulletStyle
= true;
575 if (m_styleListBox
->GetSelection() == wxRICHTEXT_BULLETINDEX_SYMBOL
)
576 m_hasBulletSymbol
= true;
583 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
586 void wxRichTextBulletsPage::OnSymbolctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
590 m_hasBulletSymbol
= true;
596 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
599 void wxRichTextBulletsPage::OnSymbolctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
603 m_hasBulletSymbol
= true;
609 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
612 void wxRichTextBulletsPage::OnSymbolctrlUpdate( wxUpdateUIEvent
& event
)
614 OnSymbolUpdate(event
);
618 * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
621 void wxRichTextBulletsPage::OnNumberctrlUpdated( wxSpinEvent
& WXUNUSED(event
) )
625 m_hasBulletNumber
= true;
631 * wxEVT_SCROLL_LINEUP event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
634 void wxRichTextBulletsPage::OnNumberctrlUp( wxSpinEvent
& WXUNUSED(event
) )
638 m_hasBulletNumber
= true;
644 * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
647 void wxRichTextBulletsPage::OnNumberctrlDown( wxSpinEvent
& WXUNUSED(event
) )
651 m_hasBulletNumber
= true;
657 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
660 void wxRichTextBulletsPage::OnNumberctrlTextUpdated( wxCommandEvent
& WXUNUSED(event
) )
664 m_hasBulletNumber
= true;
670 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
673 void wxRichTextBulletsPage::OnNumberctrlUpdate( wxUpdateUIEvent
& event
)
675 OnNumberUpdate(event
);
679 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
682 void wxRichTextBulletsPage::OnParenthesesctrlClick( wxCommandEvent
& WXUNUSED(event
) )
686 m_hasBulletStyle
= true;
692 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
695 void wxRichTextBulletsPage::OnParenthesesctrlUpdate( wxUpdateUIEvent
& event
)
697 int sel
= m_styleListBox
->GetSelection();
698 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
699 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
700 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
704 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
707 void wxRichTextBulletsPage::OnPeriodctrlClick( wxCommandEvent
& WXUNUSED(event
) )
711 m_hasBulletStyle
= true;
717 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
720 void wxRichTextBulletsPage::OnPeriodctrlUpdate( wxUpdateUIEvent
& event
)
722 int sel
= m_styleListBox
->GetSelection();
723 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
724 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
725 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
729 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
732 void wxRichTextBulletsPage::OnChooseSymbolClick( wxCommandEvent
& WXUNUSED(event
) )
734 int sel
= m_styleListBox
->GetSelection();
735 if (m_hasBulletStyle
&& sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
737 wxString symbol
= m_symbolCtrl
->GetValue();
738 wxString fontName
= m_symbolFontCtrl
->GetValue();
739 wxSymbolPickerDialog
dlg(symbol
, fontName
, fontName
, this);
741 if (dlg
.ShowModal() == wxID_OK
)
745 m_symbolCtrl
->SetValue(dlg
.GetSymbol());
746 m_symbolFontCtrl
->SetValue(dlg
.GetFontName());
750 m_dontUpdate
= false;
756 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
759 void wxRichTextBulletsPage::OnChooseSymbolUpdate( wxUpdateUIEvent
& event
)
761 OnSymbolUpdate(event
);
764 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
767 void wxRichTextBulletsPage::OnSymbolfontctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
775 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
778 void wxRichTextBulletsPage::OnSymbolfontctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
787 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
790 void wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate( wxUpdateUIEvent
& event
)
792 OnSymbolUpdate(event
);
795 /// Update for symbol-related controls
796 void wxRichTextBulletsPage::OnSymbolUpdate( wxUpdateUIEvent
& event
)
798 int sel
= m_styleListBox
->GetSelection();
799 event
.Enable(m_hasBulletStyle
&& (sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
));
802 /// Update for number-related controls
803 void wxRichTextBulletsPage::OnNumberUpdate( wxUpdateUIEvent
& event
)
805 int sel
= m_styleListBox
->GetSelection();
806 event
.Enable( m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
807 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
808 sel
!= wxRICHTEXT_BULLETINDEX_STANDARD
&&
809 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
812 /// Update for standard bullet-related controls
813 void wxRichTextBulletsPage::OnStandardBulletUpdate( wxUpdateUIEvent
& event
)
815 int sel
= m_styleListBox
->GetSelection();
816 event
.Enable( sel
== wxRICHTEXT_BULLETINDEX_STANDARD
);
821 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
824 void wxRichTextBulletsPage::OnSymbolstaticUpdate( wxUpdateUIEvent
& event
)
826 OnSymbolUpdate(event
);
831 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
834 void wxRichTextBulletsPage::OnNumberstaticUpdate( wxUpdateUIEvent
& event
)
836 OnNumberUpdate(event
);
840 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMESTATIC
843 void wxRichTextBulletsPage::OnNamestaticUpdate( wxUpdateUIEvent
& event
)
845 OnStandardBulletUpdate(event
);
850 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
853 void wxRichTextBulletsPage::OnNamectrlSelected( wxCommandEvent
& WXUNUSED(event
) )
861 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
864 void wxRichTextBulletsPage::OnNamectrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
872 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
875 void wxRichTextBulletsPage::OnNamectrlUIUpdate( wxUpdateUIEvent
& event
)
877 OnStandardBulletUpdate(event
);
880 #endif // wxUSE_RICHTEXT
882 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
885 void wxRichTextBulletsPage::OnRightParenthesisCtrlClick( wxCommandEvent
& WXUNUSED(event
) )
889 m_hasBulletStyle
= true;
895 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
898 void wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate( wxUpdateUIEvent
& event
)
900 int sel
= m_styleListBox
->GetSelection();
901 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
902 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
903 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
907 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX
910 void wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )