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"
17 #include "wx/richtext/richtextsymboldlg.h"
20 * wxRichTextBulletsPage type definition
23 IMPLEMENT_DYNAMIC_CLASS( wxRichTextBulletsPage
, wxRichTextDialogPage
)
26 * wxRichTextBulletsPage event table definition
29 BEGIN_EVENT_TABLE( wxRichTextBulletsPage
, wxRichTextDialogPage
)
31 ////@begin wxRichTextBulletsPage event table entries
32 EVT_LISTBOX( ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
, wxRichTextBulletsPage::OnStylelistboxSelected
)
34 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, wxRichTextBulletsPage::OnPeriodctrlClick
)
35 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, wxRichTextBulletsPage::OnPeriodctrlUpdate
)
37 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, wxRichTextBulletsPage::OnParenthesesctrlClick
)
38 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, wxRichTextBulletsPage::OnParenthesesctrlUpdate
)
40 EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, wxRichTextBulletsPage::OnRightParenthesisCtrlClick
)
41 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate
)
43 EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL
, wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected
)
45 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, wxRichTextBulletsPage::OnSymbolstaticUpdate
)
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
)
51 EVT_BUTTON( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, wxRichTextBulletsPage::OnChooseSymbolClick
)
52 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, wxRichTextBulletsPage::OnChooseSymbolUpdate
)
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
)
58 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NAMESTATIC
, wxRichTextBulletsPage::OnNamestaticUpdate
)
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
)
64 EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
, wxRichTextBulletsPage::OnNumberstaticUpdate
)
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
)
72 ////@end wxRichTextBulletsPage event table entries
76 IMPLEMENT_HELP_PROVISION(wxRichTextBulletsPage
)
79 * wxRichTextBulletsPage constructors
82 wxRichTextBulletsPage::wxRichTextBulletsPage( )
87 wxRichTextBulletsPage::wxRichTextBulletsPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
90 Create(parent
, id
, pos
, size
, style
);
97 void wxRichTextBulletsPage::Init()
99 m_hasBulletStyle
= false;
100 m_hasBulletNumber
= false;
101 m_hasBulletSymbol
= false;
102 m_dontUpdate
= false;
104 ////@begin wxRichTextBulletsPage member initialisation
105 m_styleListBox
= NULL
;
107 m_parenthesesCtrl
= NULL
;
108 m_rightParenthesisCtrl
= NULL
;
109 m_bulletAlignmentCtrl
= NULL
;
111 m_symbolFontCtrl
= NULL
;
112 m_bulletNameCtrl
= NULL
;
114 m_previewCtrl
= NULL
;
115 ////@end wxRichTextBulletsPage member initialisation
119 * wxRichTextBulletsPage creator
122 bool wxRichTextBulletsPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
124 ////@begin wxRichTextBulletsPage creation
125 wxRichTextDialogPage::Create( parent
, id
, pos
, size
, style
);
130 GetSizer()->SetSizeHints(this);
133 ////@end wxRichTextBulletsPage creation
138 * Control creation for wxRichTextBulletsPage
141 void wxRichTextBulletsPage::CreateControls()
143 ////@begin wxRichTextBulletsPage content construction
144 wxRichTextBulletsPage
* itemRichTextDialogPage1
= this;
146 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
147 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
149 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
150 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
152 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
153 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
155 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
156 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
158 wxStaticText
* itemStaticText6
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Bullet style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
159 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
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);
168 wxBoxSizer
* itemBoxSizer8
= new wxBoxSizer(wxHORIZONTAL
);
169 itemBoxSizer5
->Add(itemBoxSizer8
, 0, wxGROW
, 5);
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);
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);
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);
192 itemBoxSizer5
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
194 wxStaticText
* itemStaticText13
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Bullet &Alignment:"), wxDefaultPosition
, wxDefaultSize
, 0 );
195 itemBoxSizer5
->Add(itemStaticText13
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
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);
208 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
210 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
211 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
213 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
215 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
216 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
218 wxBoxSizer
* itemBoxSizer19
= new wxBoxSizer(wxHORIZONTAL
);
219 itemBoxSizer18
->Add(itemBoxSizer19
, 0, wxGROW
, 5);
221 wxStaticText
* itemStaticText20
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, _("&Symbol:"), wxDefaultPosition
, wxDefaultSize
, 0 );
222 itemBoxSizer19
->Add(itemStaticText20
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
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);
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);
237 itemBoxSizer18
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
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);
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);
249 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
, 5);
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);
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);
261 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
, 5);
263 wxStaticText
* itemStaticText30
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
, _("&Number:"), wxDefaultPosition
, wxDefaultSize
, 0 );
264 itemBoxSizer18
->Add(itemStaticText30
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
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);
272 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
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);
280 ////@end wxRichTextBulletsPage content construction
282 if (wxGetDisplaySize().y
< 600)
283 m_previewCtrl
->SetMinSize(wxSize(350, 50));
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"));
296 m_symbolCtrl
->Append(_("*"));
297 m_symbolCtrl
->Append(_("-"));
298 m_symbolCtrl
->Append(_(">"));
299 m_symbolCtrl
->Append(_("+"));
300 m_symbolCtrl
->Append(_("~"));
302 wxArrayString standardBulletNames
;
303 if (wxRichTextBuffer::GetRenderer())
304 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
307 for (i
= 0; i
< standardBulletNames
.GetCount(); i
++)
308 m_bulletNameCtrl
->Append(wxGetTranslation(standardBulletNames
[i
]));
310 wxArrayString facenames
= wxRichTextCtrl::GetAvailableFontNames();
313 m_symbolFontCtrl
->Append(facenames
);
316 /// Transfer data from/to window
317 bool wxRichTextBulletsPage::TransferDataFromWindow()
319 wxPanel::TransferDataFromWindow();
321 wxRichTextAttr
* attr
= GetAttributes();
323 int index
= m_styleListBox
->GetSelection();
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
));
334 m_hasBulletStyle
= true;
337 if (m_hasBulletStyle
)
339 long bulletStyle
= wxRICHTEXT_BULLETINDEX_NONE
;
341 if (index
== wxRICHTEXT_BULLETINDEX_ARABIC
)
342 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ARABIC
;
344 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE
)
345 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
;
347 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE
)
348 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
;
350 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
)
351 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
;
353 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
)
354 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
;
356 else if (index
== wxRICHTEXT_BULLETINDEX_OUTLINE
)
357 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_OUTLINE
;
359 else if (index
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
360 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
;
362 else if (index
== wxRICHTEXT_BULLETINDEX_BITMAP
)
363 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_BITMAP
;
365 else if (index
== wxRICHTEXT_BULLETINDEX_STANDARD
)
367 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_STANDARD
;
368 wxArrayString standardBulletNames
;
369 if (wxRichTextBuffer::GetRenderer() && m_bulletNameCtrl
->GetSelection() != wxNOT_FOUND
)
371 int sel
= m_bulletNameCtrl
->GetSelection();
372 wxString selName
= m_bulletNameCtrl
->GetString(sel
);
374 // Try to get the untranslated name using the current selection index of the combobox.
376 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
377 if (sel
< (int) standardBulletNames
.GetCount() && m_bulletNameCtrl
->GetValue() == selName
)
378 attr
->SetBulletName(standardBulletNames
[sel
]);
380 attr
->SetBulletName(m_bulletNameCtrl
->GetValue());
383 attr
->SetBulletName(m_bulletNameCtrl
->GetValue());
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
;
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
;
399 attr
->SetBulletStyle(bulletStyle
);
402 if (m_hasBulletNumber
)
404 attr
->SetBulletNumber(m_numberCtrl
->GetValue());
407 if (m_hasBulletSymbol
)
409 attr
->SetBulletText(m_symbolCtrl
->GetValue());
410 attr
->SetBulletFont(m_symbolFontCtrl
->GetValue());
416 bool wxRichTextBulletsPage::TransferDataToWindow()
420 wxPanel::TransferDataToWindow();
422 wxRichTextAttr
* attr
= GetAttributes();
424 if (attr
->HasBulletStyle())
426 m_hasBulletStyle
= true;
427 int index
= wxRICHTEXT_BULLETINDEX_NONE
;
429 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ARABIC
)
430 index
= wxRICHTEXT_BULLETINDEX_ARABIC
;
432 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
)
433 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE
;
435 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
)
436 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE
;
438 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
)
439 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
;
441 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
)
442 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
;
444 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE
)
445 index
= wxRICHTEXT_BULLETINDEX_OUTLINE
;
447 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL
)
448 index
= wxRICHTEXT_BULLETINDEX_SYMBOL
;
450 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_BITMAP
)
451 index
= wxRICHTEXT_BULLETINDEX_BITMAP
;
453 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD
)
454 index
= wxRICHTEXT_BULLETINDEX_STANDARD
;
456 m_styleListBox
->SetSelection(index
);
458 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PARENTHESES
)
459 m_parenthesesCtrl
->SetValue(true);
461 m_parenthesesCtrl
->SetValue(false);
463 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS
)
464 m_rightParenthesisCtrl
->SetValue(true);
466 m_rightParenthesisCtrl
->SetValue(false);
468 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PERIOD
)
469 m_periodCtrl
->SetValue(true);
471 m_periodCtrl
->SetValue(false);
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);
478 m_bulletAlignmentCtrl
->SetSelection(0);
482 m_hasBulletStyle
= false;
483 m_styleListBox
->SetSelection(-1);
484 m_bulletAlignmentCtrl
->SetSelection(-1);
487 if (attr
->HasBulletText())
489 m_symbolCtrl
->SetValue(attr
->GetBulletText());
490 m_symbolFontCtrl
->SetValue(attr
->GetBulletFont());
493 m_symbolCtrl
->SetValue(wxEmptyString
);
495 if (attr
->HasBulletNumber())
496 m_numberCtrl
->SetValue(attr
->GetBulletNumber());
498 m_numberCtrl
->SetValue(0);
500 if (attr
->HasBulletName())
502 wxArrayString standardBulletNames
;
503 if (wxRichTextBuffer::GetRenderer())
505 // Try to set the control by index in order to take translated combo control strings
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
);
512 m_bulletNameCtrl
->SetValue(attr
->GetBulletName());
515 m_bulletNameCtrl
->SetValue(attr
->GetBulletName());
518 m_bulletNameCtrl
->SetValue(wxEmptyString
);
522 m_dontUpdate
= false;
527 /// Updates the bullet preview
528 void wxRichTextBulletsPage::UpdatePreview()
530 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
531 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n");
533 static const wxChar
* s_para2
= wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \
534 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n");
536 static const wxChar
* s_para3
= wxT("Integer convallis dolor at augue \
537 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
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
));
546 wxFont
font(m_previewCtrl
->GetFont());
547 font
.SetPointSize(9);
548 m_previewCtrl
->SetFont(font
);
550 wxRichTextAttr normalParaAttr
;
551 normalParaAttr
.SetFont(font
);
552 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
554 m_previewCtrl
->Freeze();
555 m_previewCtrl
->Clear();
557 m_previewCtrl
->BeginStyle(normalParaAttr
);
558 m_previewCtrl
->WriteText(s_para1
);
559 m_previewCtrl
->EndStyle();
561 m_previewCtrl
->BeginStyle(attr
);
562 m_previewCtrl
->WriteText(s_para2
);
563 m_previewCtrl
->EndStyle();
565 m_previewCtrl
->BeginStyle(normalParaAttr
);
566 m_previewCtrl
->WriteText(s_para3
);
567 m_previewCtrl
->EndStyle();
569 m_previewCtrl
->NumberList(wxRichTextRange(0, m_previewCtrl
->GetLastPosition()+1));
571 m_previewCtrl
->Thaw();
574 wxRichTextAttr
* wxRichTextBulletsPage::GetAttributes()
576 return wxRichTextFormattingDialog::GetDialogAttributes(this);
580 * Should we show tooltips?
583 bool wxRichTextBulletsPage::ShowToolTips()
585 return wxRichTextFormattingDialog::ShowToolTips();
589 * Get bitmap resources
592 wxBitmap
wxRichTextBulletsPage::GetBitmapResource( const wxString
& name
)
595 ////@begin wxRichTextBulletsPage bitmap retrieval
598 ////@end wxRichTextBulletsPage bitmap retrieval
605 wxIcon
wxRichTextBulletsPage::GetIconResource( const wxString
& name
)
608 ////@begin wxRichTextBulletsPage icon retrieval
611 ////@end wxRichTextBulletsPage icon retrieval
615 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
618 void wxRichTextBulletsPage::OnStylelistboxSelected( wxCommandEvent
& WXUNUSED(event
) )
622 m_hasBulletStyle
= true;
624 if (m_styleListBox
->GetSelection() == wxRICHTEXT_BULLETINDEX_SYMBOL
)
625 m_hasBulletSymbol
= true;
632 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
635 void wxRichTextBulletsPage::OnSymbolctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
639 m_hasBulletSymbol
= true;
645 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
648 void wxRichTextBulletsPage::OnSymbolctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
652 m_hasBulletSymbol
= true;
658 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
661 void wxRichTextBulletsPage::OnSymbolctrlUpdate( wxUpdateUIEvent
& event
)
663 OnSymbolUpdate(event
);
667 * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
670 void wxRichTextBulletsPage::OnNumberctrlUpdated( wxSpinEvent
& WXUNUSED(event
) )
674 m_hasBulletNumber
= true;
680 * wxEVT_SCROLL_LINEUP event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
683 void wxRichTextBulletsPage::OnNumberctrlUp( wxSpinEvent
& WXUNUSED(event
) )
687 m_hasBulletNumber
= true;
693 * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
696 void wxRichTextBulletsPage::OnNumberctrlDown( wxSpinEvent
& WXUNUSED(event
) )
700 m_hasBulletNumber
= true;
706 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
709 void wxRichTextBulletsPage::OnNumberctrlTextUpdated( wxCommandEvent
& WXUNUSED(event
) )
713 m_hasBulletNumber
= true;
719 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
722 void wxRichTextBulletsPage::OnNumberctrlUpdate( wxUpdateUIEvent
& event
)
724 OnNumberUpdate(event
);
728 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
731 void wxRichTextBulletsPage::OnParenthesesctrlClick( wxCommandEvent
& WXUNUSED(event
) )
735 m_hasBulletStyle
= true;
741 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
744 void wxRichTextBulletsPage::OnParenthesesctrlUpdate( wxUpdateUIEvent
& event
)
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
));
753 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
756 void wxRichTextBulletsPage::OnPeriodctrlClick( wxCommandEvent
& WXUNUSED(event
) )
760 m_hasBulletStyle
= true;
766 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
769 void wxRichTextBulletsPage::OnPeriodctrlUpdate( wxUpdateUIEvent
& event
)
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
));
778 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
781 void wxRichTextBulletsPage::OnChooseSymbolClick( wxCommandEvent
& WXUNUSED(event
) )
783 int sel
= m_styleListBox
->GetSelection();
784 if (m_hasBulletStyle
&& sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
786 wxString symbol
= m_symbolCtrl
->GetValue();
787 wxString fontName
= m_symbolFontCtrl
->GetValue();
788 wxSymbolPickerDialog
dlg(symbol
, fontName
, fontName
, this);
790 if (dlg
.ShowModal() == wxID_OK
)
794 m_symbolCtrl
->SetValue(dlg
.GetSymbol());
795 m_symbolFontCtrl
->SetValue(dlg
.GetFontName());
799 m_dontUpdate
= false;
805 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
808 void wxRichTextBulletsPage::OnChooseSymbolUpdate( wxUpdateUIEvent
& event
)
810 OnSymbolUpdate(event
);
813 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
816 void wxRichTextBulletsPage::OnSymbolfontctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
824 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
827 void wxRichTextBulletsPage::OnSymbolfontctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
836 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
839 void wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate( wxUpdateUIEvent
& event
)
841 OnSymbolUpdate(event
);
844 /// Update for symbol-related controls
845 void wxRichTextBulletsPage::OnSymbolUpdate( wxUpdateUIEvent
& event
)
847 int sel
= m_styleListBox
->GetSelection();
848 event
.Enable(m_hasBulletStyle
&& (sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
));
851 /// Update for number-related controls
852 void wxRichTextBulletsPage::OnNumberUpdate( wxUpdateUIEvent
& event
)
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
));
861 /// Update for standard bullet-related controls
862 void wxRichTextBulletsPage::OnStandardBulletUpdate( wxUpdateUIEvent
& event
)
864 int sel
= m_styleListBox
->GetSelection();
865 event
.Enable( sel
== wxRICHTEXT_BULLETINDEX_STANDARD
);
870 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
873 void wxRichTextBulletsPage::OnSymbolstaticUpdate( wxUpdateUIEvent
& event
)
875 OnSymbolUpdate(event
);
880 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
883 void wxRichTextBulletsPage::OnNumberstaticUpdate( wxUpdateUIEvent
& event
)
885 OnNumberUpdate(event
);
889 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMESTATIC
892 void wxRichTextBulletsPage::OnNamestaticUpdate( wxUpdateUIEvent
& event
)
894 OnStandardBulletUpdate(event
);
899 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
902 void wxRichTextBulletsPage::OnNamectrlSelected( wxCommandEvent
& WXUNUSED(event
) )
910 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
913 void wxRichTextBulletsPage::OnNamectrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
921 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
924 void wxRichTextBulletsPage::OnNamectrlUIUpdate( wxUpdateUIEvent
& event
)
926 OnStandardBulletUpdate(event
);
929 #endif // wxUSE_RICHTEXT
931 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
934 void wxRichTextBulletsPage::OnRightParenthesisCtrlClick( wxCommandEvent
& WXUNUSED(event
) )
938 m_hasBulletStyle
= true;
944 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
947 void wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate( wxUpdateUIEvent
& event
)
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
));
956 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX
959 void wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )