1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextbulletspage.cpp
4 // Author: Julian Smart
6 // Created: 10/4/2006 10:32:31 AM
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
13 #include "wx/spinctrl.h"
15 #include "wx/richtext/richtextbulletspage.h"
16 #include "wx/richtext/richtextsymboldlg.h"
19 * wxRichTextBulletsPage type definition
22 IMPLEMENT_DYNAMIC_CLASS( wxRichTextBulletsPage
, wxRichTextDialogPage
)
25 * wxRichTextBulletsPage event table definition
28 BEGIN_EVENT_TABLE( wxRichTextBulletsPage
, wxRichTextDialogPage
)
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
75 IMPLEMENT_HELP_PROVISION(wxRichTextBulletsPage
)
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 wxRichTextDialogPage::Create( parent
, id
, pos
, size
, style
);
129 GetSizer()->SetSizeHints(this);
132 ////@end wxRichTextBulletsPage creation
137 * Control creation for wxRichTextBulletsPage
140 void wxRichTextBulletsPage::CreateControls()
144 ////@begin wxRichTextBulletsPage content construction
145 wxRichTextBulletsPage
* itemRichTextDialogPage1
= this;
147 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
148 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
150 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
151 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
153 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
154 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
156 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
157 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
159 wxStaticText
* itemStaticText6
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Bullet style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
160 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
162 wxArrayString m_styleListBoxStrings
;
163 m_styleListBox
= new wxListBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
, wxDefaultPosition
, wxSize(-1, 90), m_styleListBoxStrings
, wxLB_SINGLE
);
164 m_styleListBox
->SetHelpText(_("The available bullet styles."));
165 if (wxRichTextBulletsPage::ShowToolTips())
166 m_styleListBox
->SetToolTip(_("The available bullet styles."));
167 itemBoxSizer5
->Add(m_styleListBox
, 1, wxGROW
|wxALL
, 5);
169 wxBoxSizer
* itemBoxSizer8
= new wxBoxSizer(wxHORIZONTAL
);
170 itemBoxSizer5
->Add(itemBoxSizer8
, 0, wxGROW
, 5);
172 m_periodCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, _("Peri&od"), wxDefaultPosition
, wxDefaultSize
, 0 );
173 m_periodCtrl
->SetValue(false);
174 m_periodCtrl
->SetHelpText(_("Check to add a period after the bullet."));
175 if (wxRichTextBulletsPage::ShowToolTips())
176 m_periodCtrl
->SetToolTip(_("Check to add a period after the bullet."));
177 itemBoxSizer8
->Add(m_periodCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
179 m_parenthesesCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, _("(*)"), wxDefaultPosition
, wxDefaultSize
, 0 );
180 m_parenthesesCtrl
->SetValue(false);
181 m_parenthesesCtrl
->SetHelpText(_("Check to enclose the bullet in parentheses."));
182 if (wxRichTextBulletsPage::ShowToolTips())
183 m_parenthesesCtrl
->SetToolTip(_("Check to enclose the bullet in parentheses."));
184 itemBoxSizer8
->Add(m_parenthesesCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
186 m_rightParenthesisCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, _("*)"), wxDefaultPosition
, wxDefaultSize
, 0 );
187 m_rightParenthesisCtrl
->SetValue(false);
188 m_rightParenthesisCtrl
->SetHelpText(_("Check to add a right parenthesis."));
189 if (wxRichTextBulletsPage::ShowToolTips())
190 m_rightParenthesisCtrl
->SetToolTip(_("Check to add a right parenthesis."));
191 itemBoxSizer8
->Add(m_rightParenthesisCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
193 itemBoxSizer5
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
195 wxStaticText
* itemStaticText13
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Bullet &Alignment:"), wxDefaultPosition
, wxDefaultSize
, 0 );
196 itemBoxSizer5
->Add(itemStaticText13
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
198 wxArrayString m_bulletAlignmentCtrlStrings
;
199 m_bulletAlignmentCtrlStrings
.Add(_("Left"));
200 m_bulletAlignmentCtrlStrings
.Add(_("Centre"));
201 m_bulletAlignmentCtrlStrings
.Add(_("Right"));
202 m_bulletAlignmentCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL
, _("Left"), wxDefaultPosition
, wxSize(60, -1), m_bulletAlignmentCtrlStrings
, wxCB_READONLY
);
203 m_bulletAlignmentCtrl
->SetStringSelection(_("Left"));
204 m_bulletAlignmentCtrl
->SetHelpText(_("The bullet character."));
205 if (wxRichTextBulletsPage::ShowToolTips())
206 m_bulletAlignmentCtrl
->SetToolTip(_("The bullet character."));
207 itemBoxSizer5
->Add(m_bulletAlignmentCtrl
, 0, wxGROW
|wxALL
|wxFIXED_MINSIZE
, 5);
209 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
211 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
212 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
214 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
216 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
217 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
219 wxBoxSizer
* itemBoxSizer19
= new wxBoxSizer(wxHORIZONTAL
);
220 itemBoxSizer18
->Add(itemBoxSizer19
, 0, wxGROW
, 5);
222 wxStaticText
* itemStaticText20
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, _("&Symbol:"), wxDefaultPosition
, wxDefaultSize
, 0 );
223 itemBoxSizer19
->Add(itemStaticText20
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
225 wxArrayString m_symbolCtrlStrings
;
226 m_symbolCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(60, -1), m_symbolCtrlStrings
, wxCB_DROPDOWN
);
227 m_symbolCtrl
->SetHelpText(_("The bullet character."));
228 if (wxRichTextBulletsPage::ShowToolTips())
229 m_symbolCtrl
->SetToolTip(_("The bullet character."));
230 itemBoxSizer19
->Add(m_symbolCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
|wxFIXED_MINSIZE
, 5);
232 wxButton
* itemButton22
= new wxButton( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, _("Ch&oose..."), wxDefaultPosition
, wxDefaultSize
, 0 );
233 itemButton22
->SetHelpText(_("Click to browse for a symbol."));
234 if (wxRichTextBulletsPage::ShowToolTips())
235 itemButton22
->SetToolTip(_("Click to browse for a symbol."));
236 itemBoxSizer19
->Add(itemButton22
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
238 itemBoxSizer18
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
240 wxStaticText
* itemStaticText24
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, _("Symbol &font:"), wxDefaultPosition
, wxDefaultSize
, 0 );
241 itemBoxSizer18
->Add(itemStaticText24
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
243 wxArrayString m_symbolFontCtrlStrings
;
244 m_symbolFontCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, m_symbolFontCtrlStrings
, wxCB_DROPDOWN
);
245 m_symbolFontCtrl
->SetHelpText(_("Available fonts."));
246 if (wxRichTextBulletsPage::ShowToolTips())
247 m_symbolFontCtrl
->SetToolTip(_("Available fonts."));
248 itemBoxSizer18
->Add(m_symbolFontCtrl
, 0, wxGROW
|wxALL
, 5);
250 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
, 5);
252 wxStaticText
* itemStaticText27
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_NAMESTATIC
, _("S&tandard bullet name:"), wxDefaultPosition
, wxDefaultSize
, 0 );
253 itemBoxSizer18
->Add(itemStaticText27
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
255 wxArrayString m_bulletNameCtrlStrings
;
256 m_bulletNameCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_NAMECTRL
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, m_bulletNameCtrlStrings
, wxCB_DROPDOWN
);
257 m_bulletNameCtrl
->SetHelpText(_("A standard bullet name."));
258 if (wxRichTextBulletsPage::ShowToolTips())
259 m_bulletNameCtrl
->SetToolTip(_("A standard bullet name."));
260 itemBoxSizer18
->Add(m_bulletNameCtrl
, 0, wxGROW
|wxALL
, 5);
262 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
, 5);
264 wxStaticText
* itemStaticText30
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
, _("&Number:"), wxDefaultPosition
, wxDefaultSize
, 0 );
265 itemBoxSizer18
->Add(itemStaticText30
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
267 m_numberCtrl
= new wxSpinCtrl( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, wxT("0"), wxDefaultPosition
, wxSize(50, -1), wxSP_ARROW_KEYS
, 0, 100000, 0 );
268 m_numberCtrl
->SetHelpText(_("The list item number."));
269 if (wxRichTextBulletsPage::ShowToolTips())
270 m_numberCtrl
->SetToolTip(_("The list item number."));
271 itemBoxSizer18
->Add(m_numberCtrl
, 0, wxGROW
|wxALL
, 5);
273 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
275 m_previewCtrl
= new wxRichTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 100), wxBORDER_THEME
|wxVSCROLL
|wxTE_READONLY
);
276 m_previewCtrl
->SetHelpText(_("Shows a preview of the bullet settings."));
277 if (wxRichTextBulletsPage::ShowToolTips())
278 m_previewCtrl
->SetToolTip(_("Shows a preview of the bullet settings."));
279 itemBoxSizer3
->Add(m_previewCtrl
, 1, wxGROW
|wxALL
, 5);
281 ////@end wxRichTextBulletsPage content construction
283 if (wxGetDisplaySize().y
< 600)
284 m_previewCtrl
->SetMinSize(wxSize(350, 50));
286 m_styleListBox
->Append(_("(None)"));
287 m_styleListBox
->Append(_("Arabic"));
288 m_styleListBox
->Append(_("Upper case letters"));
289 m_styleListBox
->Append(_("Lower case letters"));
290 m_styleListBox
->Append(_("Upper case roman numerals"));
291 m_styleListBox
->Append(_("Lower case roman numerals"));
292 m_styleListBox
->Append(_("Numbered outline"));
293 m_styleListBox
->Append(_("Symbol"));
294 m_styleListBox
->Append(_("Bitmap"));
295 m_styleListBox
->Append(_("Standard"));
297 m_symbolCtrl
->Append(_("*"));
298 m_symbolCtrl
->Append(_("-"));
299 m_symbolCtrl
->Append(_(">"));
300 m_symbolCtrl
->Append(_("+"));
301 m_symbolCtrl
->Append(_("~"));
303 wxArrayString standardBulletNames
;
304 if (wxRichTextBuffer::GetRenderer())
305 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
308 for (i
= 0; i
< standardBulletNames
.GetCount(); i
++)
309 m_bulletNameCtrl
->Append(wxGetTranslation(standardBulletNames
[i
]));
311 wxArrayString facenames
= wxRichTextCtrl::GetAvailableFontNames();
314 m_symbolFontCtrl
->Append(facenames
);
316 m_dontUpdate
= false;
319 /// Transfer data from/to window
320 bool wxRichTextBulletsPage::TransferDataFromWindow()
322 wxPanel::TransferDataFromWindow();
324 wxRichTextAttr
* attr
= GetAttributes();
326 int index
= m_styleListBox
->GetSelection();
329 m_hasBulletStyle
= false;
330 m_hasBulletNumber
= false;
331 m_hasBulletSymbol
= false;
332 attr
->SetBulletStyle(wxTEXT_ATTR_BULLET_STYLE_NONE
);
333 attr
->SetFlags(attr
->GetFlags() & ~(wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
|wxTEXT_ATTR_BULLET_NAME
));
337 m_hasBulletStyle
= true;
340 if (m_hasBulletStyle
)
342 long bulletStyle
= wxRICHTEXT_BULLETINDEX_NONE
;
344 if (index
== wxRICHTEXT_BULLETINDEX_ARABIC
)
345 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ARABIC
;
347 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE
)
348 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
;
350 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE
)
351 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
;
353 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
)
354 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
;
356 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
)
357 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
;
359 else if (index
== wxRICHTEXT_BULLETINDEX_OUTLINE
)
360 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_OUTLINE
;
362 else if (index
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
363 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
;
365 else if (index
== wxRICHTEXT_BULLETINDEX_BITMAP
)
367 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_BITMAP
;
368 if (m_bulletNameCtrl
->GetValue().IsEmpty())
369 attr
->SetFlags(attr
->GetFlags() & ~wxTEXT_ATTR_BULLET_NAME
);
371 attr
->SetBulletName(m_bulletNameCtrl
->GetValue());
374 else if (index
== wxRICHTEXT_BULLETINDEX_STANDARD
)
376 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_STANDARD
;
377 wxArrayString standardBulletNames
;
378 if (wxRichTextBuffer::GetRenderer() && m_bulletNameCtrl
->GetSelection() != wxNOT_FOUND
)
380 int sel
= m_bulletNameCtrl
->GetSelection();
381 wxString selName
= m_bulletNameCtrl
->GetString(sel
);
383 // Try to get the untranslated name using the current selection index of the combobox.
385 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
386 if (sel
< (int) standardBulletNames
.GetCount() && m_bulletNameCtrl
->GetValue() == selName
)
387 attr
->SetBulletName(standardBulletNames
[sel
]);
389 attr
->SetBulletName(m_bulletNameCtrl
->GetValue());
392 attr
->SetBulletName(m_bulletNameCtrl
->GetValue());
395 if (m_parenthesesCtrl
->GetValue())
396 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_PARENTHESES
;
397 if (m_rightParenthesisCtrl
->GetValue())
398 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS
;
399 if (m_periodCtrl
->GetValue())
400 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_PERIOD
;
402 if (m_bulletAlignmentCtrl
->GetSelection() == 1)
403 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE
;
404 else if (m_bulletAlignmentCtrl
->GetSelection() == 2)
405 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
;
408 attr
->SetBulletStyle(bulletStyle
);
411 if (m_hasBulletNumber
)
413 attr
->SetBulletNumber(m_numberCtrl
->GetValue());
416 if (m_hasBulletSymbol
)
418 attr
->SetBulletText(m_symbolCtrl
->GetValue());
419 attr
->SetBulletFont(m_symbolFontCtrl
->GetValue());
425 bool wxRichTextBulletsPage::TransferDataToWindow()
429 wxPanel::TransferDataToWindow();
431 wxRichTextAttr
* attr
= GetAttributes();
433 if (attr
->HasBulletStyle())
435 m_hasBulletStyle
= true;
436 int index
= wxRICHTEXT_BULLETINDEX_NONE
;
438 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ARABIC
)
439 index
= wxRICHTEXT_BULLETINDEX_ARABIC
;
441 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
)
442 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE
;
444 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
)
445 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE
;
447 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
)
448 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
;
450 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
)
451 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
;
453 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE
)
454 index
= wxRICHTEXT_BULLETINDEX_OUTLINE
;
456 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL
)
457 index
= wxRICHTEXT_BULLETINDEX_SYMBOL
;
459 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_BITMAP
)
460 index
= wxRICHTEXT_BULLETINDEX_BITMAP
;
462 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD
)
463 index
= wxRICHTEXT_BULLETINDEX_STANDARD
;
465 m_styleListBox
->SetSelection(index
);
467 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PARENTHESES
)
468 m_parenthesesCtrl
->SetValue(true);
470 m_parenthesesCtrl
->SetValue(false);
472 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS
)
473 m_rightParenthesisCtrl
->SetValue(true);
475 m_rightParenthesisCtrl
->SetValue(false);
477 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PERIOD
)
478 m_periodCtrl
->SetValue(true);
480 m_periodCtrl
->SetValue(false);
482 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE
)
483 m_bulletAlignmentCtrl
->SetSelection(1);
484 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
)
485 m_bulletAlignmentCtrl
->SetSelection(2);
487 m_bulletAlignmentCtrl
->SetSelection(0);
491 m_hasBulletStyle
= false;
492 m_styleListBox
->SetSelection(-1);
493 m_bulletAlignmentCtrl
->SetSelection(-1);
496 if (attr
->HasBulletText())
498 m_symbolCtrl
->SetValue(attr
->GetBulletText());
499 m_symbolFontCtrl
->SetValue(attr
->GetBulletFont());
502 m_symbolCtrl
->SetValue(wxEmptyString
);
504 if (attr
->HasBulletNumber())
505 m_numberCtrl
->SetValue(attr
->GetBulletNumber());
507 m_numberCtrl
->SetValue(0);
509 if (attr
->HasBulletName())
511 wxArrayString standardBulletNames
;
512 if (wxRichTextBuffer::GetRenderer())
514 // Try to set the control by index in order to take translated combo control strings
516 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
517 int idx
= standardBulletNames
.Index(attr
->GetBulletName());
518 if (idx
!= -1 && idx
< (int) m_bulletNameCtrl
->GetCount())
519 m_bulletNameCtrl
->SetSelection(idx
);
521 m_bulletNameCtrl
->SetValue(attr
->GetBulletName());
524 m_bulletNameCtrl
->SetValue(attr
->GetBulletName());
527 m_bulletNameCtrl
->SetValue(wxEmptyString
);
531 m_dontUpdate
= false;
536 /// Updates the bullet preview
537 void wxRichTextBulletsPage::UpdatePreview()
539 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
540 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n");
542 static const wxChar
* s_para2
= wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \
543 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n");
545 static const wxChar
* s_para3
= wxT("Integer convallis dolor at augue \
546 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
548 TransferDataFromWindow();
549 wxRichTextAttr
attr(*GetAttributes());
550 attr
.SetFlags(attr
.GetFlags() &
551 (wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
|wxTEXT_ATTR_BULLET_NAME
|
552 wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
553 wxTEXT_ATTR_LINE_SPACING
));
555 wxFont
font(m_previewCtrl
->GetFont());
556 font
.SetPointSize(9);
557 m_previewCtrl
->SetFont(font
);
559 wxRichTextAttr normalParaAttr
;
560 normalParaAttr
.SetFont(font
);
561 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
563 m_previewCtrl
->Freeze();
564 m_previewCtrl
->Clear();
566 m_previewCtrl
->BeginStyle(normalParaAttr
);
567 m_previewCtrl
->WriteText(s_para1
);
568 m_previewCtrl
->EndStyle();
570 m_previewCtrl
->BeginStyle(attr
);
571 m_previewCtrl
->WriteText(s_para2
);
572 m_previewCtrl
->EndStyle();
574 m_previewCtrl
->BeginStyle(normalParaAttr
);
575 m_previewCtrl
->WriteText(s_para3
);
576 m_previewCtrl
->EndStyle();
578 m_previewCtrl
->NumberList(wxRichTextRange(0, m_previewCtrl
->GetLastPosition()+1));
580 m_previewCtrl
->Thaw();
583 wxRichTextAttr
* wxRichTextBulletsPage::GetAttributes()
585 return wxRichTextFormattingDialog::GetDialogAttributes(this);
589 * Should we show tooltips?
592 bool wxRichTextBulletsPage::ShowToolTips()
594 return wxRichTextFormattingDialog::ShowToolTips();
598 * Get bitmap resources
601 wxBitmap
wxRichTextBulletsPage::GetBitmapResource( const wxString
& name
)
604 ////@begin wxRichTextBulletsPage bitmap retrieval
607 ////@end wxRichTextBulletsPage bitmap retrieval
614 wxIcon
wxRichTextBulletsPage::GetIconResource( const wxString
& name
)
617 ////@begin wxRichTextBulletsPage icon retrieval
620 ////@end wxRichTextBulletsPage icon retrieval
624 * wxEVT_LISTBOX event handler for ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
627 void wxRichTextBulletsPage::OnStylelistboxSelected( wxCommandEvent
& WXUNUSED(event
) )
631 m_hasBulletStyle
= true;
633 if (m_styleListBox
->GetSelection() == wxRICHTEXT_BULLETINDEX_SYMBOL
)
634 m_hasBulletSymbol
= true;
641 * wxEVT_COMBOBOX event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
644 void wxRichTextBulletsPage::OnSymbolctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
648 m_hasBulletSymbol
= true;
654 * wxEVT_TEXT event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
657 void wxRichTextBulletsPage::OnSymbolctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
661 m_hasBulletSymbol
= true;
667 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
670 void wxRichTextBulletsPage::OnSymbolctrlUpdate( wxUpdateUIEvent
& event
)
672 OnSymbolUpdate(event
);
676 * wxEVT_SPINCTRL event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
679 void wxRichTextBulletsPage::OnNumberctrlUpdated( wxSpinEvent
& WXUNUSED(event
) )
683 m_hasBulletNumber
= true;
689 * wxEVT_SCROLL_LINEUP event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
692 void wxRichTextBulletsPage::OnNumberctrlUp( wxSpinEvent
& WXUNUSED(event
) )
696 m_hasBulletNumber
= true;
702 * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
705 void wxRichTextBulletsPage::OnNumberctrlDown( wxSpinEvent
& WXUNUSED(event
) )
709 m_hasBulletNumber
= true;
715 * wxEVT_TEXT event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
718 void wxRichTextBulletsPage::OnNumberctrlTextUpdated( wxCommandEvent
& WXUNUSED(event
) )
722 m_hasBulletNumber
= true;
728 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
731 void wxRichTextBulletsPage::OnNumberctrlUpdate( wxUpdateUIEvent
& event
)
733 OnNumberUpdate(event
);
737 * wxEVT_CHECKBOX event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
740 void wxRichTextBulletsPage::OnParenthesesctrlClick( wxCommandEvent
& WXUNUSED(event
) )
744 m_hasBulletStyle
= true;
750 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
753 void wxRichTextBulletsPage::OnParenthesesctrlUpdate( wxUpdateUIEvent
& event
)
755 int sel
= m_styleListBox
->GetSelection();
756 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
757 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
758 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
762 * wxEVT_CHECKBOX event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
765 void wxRichTextBulletsPage::OnPeriodctrlClick( wxCommandEvent
& WXUNUSED(event
) )
769 m_hasBulletStyle
= true;
775 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
778 void wxRichTextBulletsPage::OnPeriodctrlUpdate( wxUpdateUIEvent
& event
)
780 int sel
= m_styleListBox
->GetSelection();
781 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
782 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
783 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
787 * wxEVT_BUTTON event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
790 void wxRichTextBulletsPage::OnChooseSymbolClick( wxCommandEvent
& WXUNUSED(event
) )
792 int sel
= m_styleListBox
->GetSelection();
793 if (m_hasBulletStyle
&& sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
795 wxString symbol
= m_symbolCtrl
->GetValue();
796 wxString fontName
= m_symbolFontCtrl
->GetValue();
797 wxSymbolPickerDialog
dlg(symbol
, fontName
, fontName
, this);
799 if (dlg
.ShowModal() == wxID_OK
)
803 m_symbolCtrl
->SetValue(dlg
.GetSymbol());
804 m_symbolFontCtrl
->SetValue(dlg
.GetFontName());
808 m_dontUpdate
= false;
814 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
817 void wxRichTextBulletsPage::OnChooseSymbolUpdate( wxUpdateUIEvent
& event
)
819 OnSymbolUpdate(event
);
822 * wxEVT_COMBOBOX event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
825 void wxRichTextBulletsPage::OnSymbolfontctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
833 * wxEVT_TEXT event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
836 void wxRichTextBulletsPage::OnSymbolfontctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
845 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
848 void wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate( wxUpdateUIEvent
& event
)
850 OnSymbolUpdate(event
);
853 /// Update for symbol-related controls
854 void wxRichTextBulletsPage::OnSymbolUpdate( wxUpdateUIEvent
& event
)
856 int sel
= m_styleListBox
->GetSelection();
857 event
.Enable(m_hasBulletStyle
&& (sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
));
860 /// Update for number-related controls
861 void wxRichTextBulletsPage::OnNumberUpdate( wxUpdateUIEvent
& event
)
863 int sel
= m_styleListBox
->GetSelection();
864 event
.Enable( m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
865 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
866 sel
!= wxRICHTEXT_BULLETINDEX_STANDARD
&&
867 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
870 /// Update for standard bullet-related controls
871 void wxRichTextBulletsPage::OnStandardBulletUpdate( wxUpdateUIEvent
& event
)
873 int sel
= m_styleListBox
->GetSelection();
874 event
.Enable( sel
== wxRICHTEXT_BULLETINDEX_STANDARD
|| sel
== wxRICHTEXT_BULLETINDEX_BITMAP
);
879 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
882 void wxRichTextBulletsPage::OnSymbolstaticUpdate( wxUpdateUIEvent
& event
)
884 OnSymbolUpdate(event
);
889 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
892 void wxRichTextBulletsPage::OnNumberstaticUpdate( wxUpdateUIEvent
& event
)
894 OnNumberUpdate(event
);
898 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMESTATIC
901 void wxRichTextBulletsPage::OnNamestaticUpdate( wxUpdateUIEvent
& event
)
903 OnStandardBulletUpdate(event
);
908 * wxEVT_COMBOBOX event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
911 void wxRichTextBulletsPage::OnNamectrlSelected( wxCommandEvent
& WXUNUSED(event
) )
919 * wxEVT_TEXT event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
922 void wxRichTextBulletsPage::OnNamectrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
930 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
933 void wxRichTextBulletsPage::OnNamectrlUIUpdate( wxUpdateUIEvent
& event
)
935 OnStandardBulletUpdate(event
);
938 #endif // wxUSE_RICHTEXT
940 * wxEVT_CHECKBOX event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
943 void wxRichTextBulletsPage::OnRightParenthesisCtrlClick( wxCommandEvent
& WXUNUSED(event
) )
947 m_hasBulletStyle
= true;
953 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
956 void wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate( wxUpdateUIEvent
& event
)
958 int sel
= m_styleListBox
->GetSelection();
959 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
960 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
961 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
965 * wxEVT_COMBOBOX event handler for ID_COMBOBOX
968 void wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )