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()
145 ////@begin wxRichTextBulletsPage content construction
146 wxRichTextBulletsPage
* itemRichTextDialogPage1
= this;
148 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
149 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
151 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
152 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
154 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
155 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
157 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
158 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
160 wxStaticText
* itemStaticText6
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Bullet style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
161 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
163 wxArrayString m_styleListBoxStrings
;
164 m_styleListBox
= new wxListBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
, wxDefaultPosition
, wxSize(-1, 90), m_styleListBoxStrings
, wxLB_SINGLE
);
165 m_styleListBox
->SetHelpText(_("The available bullet styles."));
166 if (wxRichTextBulletsPage::ShowToolTips())
167 m_styleListBox
->SetToolTip(_("The available bullet styles."));
168 itemBoxSizer5
->Add(m_styleListBox
, 1, wxGROW
|wxALL
, 5);
170 wxBoxSizer
* itemBoxSizer8
= new wxBoxSizer(wxHORIZONTAL
);
171 itemBoxSizer5
->Add(itemBoxSizer8
, 0, wxGROW
, 5);
173 m_periodCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_PERIODCTRL
, _("Peri&od"), wxDefaultPosition
, wxDefaultSize
, 0 );
174 m_periodCtrl
->SetValue(false);
175 m_periodCtrl
->SetHelpText(_("Check to add a period after the bullet."));
176 if (wxRichTextBulletsPage::ShowToolTips())
177 m_periodCtrl
->SetToolTip(_("Check to add a period after the bullet."));
178 itemBoxSizer8
->Add(m_periodCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
180 m_parenthesesCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
, _("(*)"), wxDefaultPosition
, wxDefaultSize
, 0 );
181 m_parenthesesCtrl
->SetValue(false);
182 m_parenthesesCtrl
->SetHelpText(_("Check to enclose the bullet in parentheses."));
183 if (wxRichTextBulletsPage::ShowToolTips())
184 m_parenthesesCtrl
->SetToolTip(_("Check to enclose the bullet in parentheses."));
185 itemBoxSizer8
->Add(m_parenthesesCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
187 m_rightParenthesisCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL
, _("*)"), wxDefaultPosition
, wxDefaultSize
, 0 );
188 m_rightParenthesisCtrl
->SetValue(false);
189 m_rightParenthesisCtrl
->SetHelpText(_("Check to add a right parenthesis."));
190 if (wxRichTextBulletsPage::ShowToolTips())
191 m_rightParenthesisCtrl
->SetToolTip(_("Check to add a right parenthesis."));
192 itemBoxSizer8
->Add(m_rightParenthesisCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
194 itemBoxSizer5
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
196 wxStaticText
* itemStaticText13
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Bullet &Alignment:"), wxDefaultPosition
, wxDefaultSize
, 0 );
197 itemBoxSizer5
->Add(itemStaticText13
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
199 wxArrayString m_bulletAlignmentCtrlStrings
;
200 m_bulletAlignmentCtrlStrings
.Add(_("Left"));
201 m_bulletAlignmentCtrlStrings
.Add(_("Centre"));
202 m_bulletAlignmentCtrlStrings
.Add(_("Right"));
203 m_bulletAlignmentCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL
, _("Left"), wxDefaultPosition
, wxSize(60, -1), m_bulletAlignmentCtrlStrings
, wxCB_READONLY
);
204 m_bulletAlignmentCtrl
->SetStringSelection(_("Left"));
205 m_bulletAlignmentCtrl
->SetHelpText(_("The bullet character."));
206 if (wxRichTextBulletsPage::ShowToolTips())
207 m_bulletAlignmentCtrl
->SetToolTip(_("The bullet character."));
208 itemBoxSizer5
->Add(m_bulletAlignmentCtrl
, 0, wxGROW
|wxALL
|wxFIXED_MINSIZE
, 5);
210 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
212 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
213 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxRIGHT
, 5);
215 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
217 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
218 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
220 wxBoxSizer
* itemBoxSizer19
= new wxBoxSizer(wxHORIZONTAL
);
221 itemBoxSizer18
->Add(itemBoxSizer19
, 0, wxGROW
, 5);
223 wxStaticText
* itemStaticText20
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, _("&Symbol:"), wxDefaultPosition
, wxDefaultSize
, 0 );
224 itemBoxSizer19
->Add(itemStaticText20
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
226 wxArrayString m_symbolCtrlStrings
;
227 m_symbolCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(60, -1), m_symbolCtrlStrings
, wxCB_DROPDOWN
);
228 m_symbolCtrl
->SetHelpText(_("The bullet character."));
229 if (wxRichTextBulletsPage::ShowToolTips())
230 m_symbolCtrl
->SetToolTip(_("The bullet character."));
231 itemBoxSizer19
->Add(m_symbolCtrl
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
|wxFIXED_MINSIZE
, 5);
233 wxButton
* itemButton22
= new wxButton( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
, _("Ch&oose..."), wxDefaultPosition
, wxDefaultSize
, 0 );
234 itemButton22
->SetHelpText(_("Click to browse for a symbol."));
235 if (wxRichTextBulletsPage::ShowToolTips())
236 itemButton22
->SetToolTip(_("Click to browse for a symbol."));
237 itemBoxSizer19
->Add(itemButton22
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
239 itemBoxSizer18
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
241 wxStaticText
* itemStaticText24
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
, _("Symbol &font:"), wxDefaultPosition
, wxDefaultSize
, 0 );
242 itemBoxSizer18
->Add(itemStaticText24
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
244 wxArrayString m_symbolFontCtrlStrings
;
245 m_symbolFontCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, m_symbolFontCtrlStrings
, wxCB_DROPDOWN
);
246 m_symbolFontCtrl
->SetHelpText(_("Available fonts."));
247 if (wxRichTextBulletsPage::ShowToolTips())
248 m_symbolFontCtrl
->SetToolTip(_("Available fonts."));
249 itemBoxSizer18
->Add(m_symbolFontCtrl
, 0, wxGROW
|wxALL
, 5);
251 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
, 5);
253 wxStaticText
* itemStaticText27
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_NAMESTATIC
, _("S&tandard bullet name:"), wxDefaultPosition
, wxDefaultSize
, 0 );
254 itemBoxSizer18
->Add(itemStaticText27
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
256 wxArrayString m_bulletNameCtrlStrings
;
257 m_bulletNameCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_NAMECTRL
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, m_bulletNameCtrlStrings
, wxCB_DROPDOWN
);
258 m_bulletNameCtrl
->SetHelpText(_("A standard bullet name."));
259 if (wxRichTextBulletsPage::ShowToolTips())
260 m_bulletNameCtrl
->SetToolTip(_("A standard bullet name."));
261 itemBoxSizer18
->Add(m_bulletNameCtrl
, 0, wxGROW
|wxALL
, 5);
263 itemBoxSizer18
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
, 5);
265 wxStaticText
* itemStaticText30
= new wxStaticText( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
, _("&Number:"), wxDefaultPosition
, wxDefaultSize
, 0 );
266 itemBoxSizer18
->Add(itemStaticText30
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
268 m_numberCtrl
= new wxSpinCtrl( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
, _T("0"), wxDefaultPosition
, wxSize(50, -1), wxSP_ARROW_KEYS
, 0, 100000, 0 );
269 m_numberCtrl
->SetHelpText(_("The list item number."));
270 if (wxRichTextBulletsPage::ShowToolTips())
271 m_numberCtrl
->SetToolTip(_("The list item number."));
272 itemBoxSizer18
->Add(m_numberCtrl
, 0, wxGROW
|wxALL
, 5);
274 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
276 m_previewCtrl
= new wxRichTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 100), wxVSCROLL
|wxTE_READONLY
);
277 m_previewCtrl
->SetHelpText(_("Shows a preview of the bullet settings."));
278 if (wxRichTextBulletsPage::ShowToolTips())
279 m_previewCtrl
->SetToolTip(_("Shows a preview of the bullet settings."));
280 itemBoxSizer3
->Add(m_previewCtrl
, 1, wxGROW
|wxALL
, 5);
282 ////@end wxRichTextBulletsPage content construction
284 if (wxGetDisplaySize().y
< 600)
285 m_previewCtrl
->SetMinSize(wxSize(350, 50));
287 m_styleListBox
->Append(_("(None)"));
288 m_styleListBox
->Append(_("Arabic"));
289 m_styleListBox
->Append(_("Upper case letters"));
290 m_styleListBox
->Append(_("Lower case letters"));
291 m_styleListBox
->Append(_("Upper case roman numerals"));
292 m_styleListBox
->Append(_("Lower case roman numerals"));
293 m_styleListBox
->Append(_("Numbered outline"));
294 m_styleListBox
->Append(_("Symbol"));
295 m_styleListBox
->Append(_("Bitmap"));
296 m_styleListBox
->Append(_("Standard"));
298 m_symbolCtrl
->Append(_("*"));
299 m_symbolCtrl
->Append(_("-"));
300 m_symbolCtrl
->Append(_(">"));
301 m_symbolCtrl
->Append(_("+"));
302 m_symbolCtrl
->Append(_("~"));
304 wxArrayString standardBulletNames
;
305 if (wxRichTextBuffer::GetRenderer())
306 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
309 for (i
= 0; i
< standardBulletNames
.GetCount(); i
++)
310 m_bulletNameCtrl
->Append(wxGetTranslation(standardBulletNames
[i
]));
312 wxArrayString facenames
= wxRichTextCtrl::GetAvailableFontNames();
315 m_symbolFontCtrl
->Append(facenames
);
317 m_dontUpdate
= false;
320 /// Transfer data from/to window
321 bool wxRichTextBulletsPage::TransferDataFromWindow()
323 wxPanel::TransferDataFromWindow();
325 wxRichTextAttr
* attr
= GetAttributes();
327 int index
= m_styleListBox
->GetSelection();
330 m_hasBulletStyle
= false;
331 m_hasBulletNumber
= false;
332 m_hasBulletSymbol
= false;
333 attr
->SetBulletStyle(wxTEXT_ATTR_BULLET_STYLE_NONE
);
334 attr
->SetFlags(attr
->GetFlags() & ~(wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
|wxTEXT_ATTR_BULLET_NAME
));
338 m_hasBulletStyle
= true;
341 if (m_hasBulletStyle
)
343 long bulletStyle
= wxRICHTEXT_BULLETINDEX_NONE
;
345 if (index
== wxRICHTEXT_BULLETINDEX_ARABIC
)
346 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ARABIC
;
348 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE
)
349 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
;
351 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE
)
352 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
;
354 else if (index
== wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
)
355 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
;
357 else if (index
== wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
)
358 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
;
360 else if (index
== wxRICHTEXT_BULLETINDEX_OUTLINE
)
361 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_OUTLINE
;
363 else if (index
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
364 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
;
366 else if (index
== wxRICHTEXT_BULLETINDEX_BITMAP
)
367 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_BITMAP
;
369 else if (index
== wxRICHTEXT_BULLETINDEX_STANDARD
)
371 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_STANDARD
;
372 wxArrayString standardBulletNames
;
373 if (wxRichTextBuffer::GetRenderer() && m_bulletNameCtrl
->GetSelection() != wxNOT_FOUND
)
375 int sel
= m_bulletNameCtrl
->GetSelection();
376 wxString selName
= m_bulletNameCtrl
->GetString(sel
);
378 // Try to get the untranslated name using the current selection index of the combobox.
380 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
381 if (sel
< (int) standardBulletNames
.GetCount() && m_bulletNameCtrl
->GetValue() == selName
)
382 attr
->SetBulletName(standardBulletNames
[sel
]);
384 attr
->SetBulletName(m_bulletNameCtrl
->GetValue());
387 attr
->SetBulletName(m_bulletNameCtrl
->GetValue());
390 if (m_parenthesesCtrl
->GetValue())
391 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_PARENTHESES
;
392 if (m_rightParenthesisCtrl
->GetValue())
393 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS
;
394 if (m_periodCtrl
->GetValue())
395 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_PERIOD
;
397 if (m_bulletAlignmentCtrl
->GetSelection() == 1)
398 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE
;
399 else if (m_bulletAlignmentCtrl
->GetSelection() == 2)
400 bulletStyle
|= wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
;
403 attr
->SetBulletStyle(bulletStyle
);
406 if (m_hasBulletNumber
)
408 attr
->SetBulletNumber(m_numberCtrl
->GetValue());
411 if (m_hasBulletSymbol
)
413 attr
->SetBulletText(m_symbolCtrl
->GetValue());
414 attr
->SetBulletFont(m_symbolFontCtrl
->GetValue());
420 bool wxRichTextBulletsPage::TransferDataToWindow()
424 wxPanel::TransferDataToWindow();
426 wxRichTextAttr
* attr
= GetAttributes();
428 if (attr
->HasBulletStyle())
430 m_hasBulletStyle
= true;
431 int index
= wxRICHTEXT_BULLETINDEX_NONE
;
433 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ARABIC
)
434 index
= wxRICHTEXT_BULLETINDEX_ARABIC
;
436 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER
)
437 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE
;
439 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER
)
440 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE
;
442 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER
)
443 index
= wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN
;
445 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER
)
446 index
= wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN
;
448 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE
)
449 index
= wxRICHTEXT_BULLETINDEX_OUTLINE
;
451 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL
)
452 index
= wxRICHTEXT_BULLETINDEX_SYMBOL
;
454 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_BITMAP
)
455 index
= wxRICHTEXT_BULLETINDEX_BITMAP
;
457 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD
)
458 index
= wxRICHTEXT_BULLETINDEX_STANDARD
;
460 m_styleListBox
->SetSelection(index
);
462 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PARENTHESES
)
463 m_parenthesesCtrl
->SetValue(true);
465 m_parenthesesCtrl
->SetValue(false);
467 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS
)
468 m_rightParenthesisCtrl
->SetValue(true);
470 m_rightParenthesisCtrl
->SetValue(false);
472 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PERIOD
)
473 m_periodCtrl
->SetValue(true);
475 m_periodCtrl
->SetValue(false);
477 if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE
)
478 m_bulletAlignmentCtrl
->SetSelection(1);
479 else if (attr
->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
)
480 m_bulletAlignmentCtrl
->SetSelection(2);
482 m_bulletAlignmentCtrl
->SetSelection(0);
486 m_hasBulletStyle
= false;
487 m_styleListBox
->SetSelection(-1);
488 m_bulletAlignmentCtrl
->SetSelection(-1);
491 if (attr
->HasBulletText())
493 m_symbolCtrl
->SetValue(attr
->GetBulletText());
494 m_symbolFontCtrl
->SetValue(attr
->GetBulletFont());
497 m_symbolCtrl
->SetValue(wxEmptyString
);
499 if (attr
->HasBulletNumber())
500 m_numberCtrl
->SetValue(attr
->GetBulletNumber());
502 m_numberCtrl
->SetValue(0);
504 if (attr
->HasBulletName())
506 wxArrayString standardBulletNames
;
507 if (wxRichTextBuffer::GetRenderer())
509 // Try to set the control by index in order to take translated combo control strings
511 wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames
);
512 int idx
= standardBulletNames
.Index(attr
->GetBulletName());
513 if (idx
!= -1 && idx
< (int) m_bulletNameCtrl
->GetCount())
514 m_bulletNameCtrl
->SetSelection(idx
);
516 m_bulletNameCtrl
->SetValue(attr
->GetBulletName());
519 m_bulletNameCtrl
->SetValue(attr
->GetBulletName());
522 m_bulletNameCtrl
->SetValue(wxEmptyString
);
526 m_dontUpdate
= false;
531 /// Updates the bullet preview
532 void wxRichTextBulletsPage::UpdatePreview()
534 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
535 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n");
537 static const wxChar
* s_para2
= wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \
538 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n");
540 static const wxChar
* s_para3
= wxT("Integer convallis dolor at augue \
541 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
543 TransferDataFromWindow();
544 wxRichTextAttr
attr(*GetAttributes());
545 attr
.SetFlags(attr
.GetFlags() &
546 (wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
|wxTEXT_ATTR_BULLET_NAME
|
547 wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
548 wxTEXT_ATTR_LINE_SPACING
));
550 wxFont
font(m_previewCtrl
->GetFont());
551 font
.SetPointSize(9);
552 m_previewCtrl
->SetFont(font
);
554 wxRichTextAttr normalParaAttr
;
555 normalParaAttr
.SetFont(font
);
556 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
558 m_previewCtrl
->Freeze();
559 m_previewCtrl
->Clear();
561 m_previewCtrl
->BeginStyle(normalParaAttr
);
562 m_previewCtrl
->WriteText(s_para1
);
563 m_previewCtrl
->EndStyle();
565 m_previewCtrl
->BeginStyle(attr
);
566 m_previewCtrl
->WriteText(s_para2
);
567 m_previewCtrl
->EndStyle();
569 m_previewCtrl
->BeginStyle(normalParaAttr
);
570 m_previewCtrl
->WriteText(s_para3
);
571 m_previewCtrl
->EndStyle();
573 m_previewCtrl
->NumberList(wxRichTextRange(0, m_previewCtrl
->GetLastPosition()+1));
575 m_previewCtrl
->Thaw();
578 wxRichTextAttr
* wxRichTextBulletsPage::GetAttributes()
580 return wxRichTextFormattingDialog::GetDialogAttributes(this);
584 * Should we show tooltips?
587 bool wxRichTextBulletsPage::ShowToolTips()
589 return wxRichTextFormattingDialog::ShowToolTips();
593 * Get bitmap resources
596 wxBitmap
wxRichTextBulletsPage::GetBitmapResource( const wxString
& name
)
599 ////@begin wxRichTextBulletsPage bitmap retrieval
602 ////@end wxRichTextBulletsPage bitmap retrieval
609 wxIcon
wxRichTextBulletsPage::GetIconResource( const wxString
& name
)
612 ////@begin wxRichTextBulletsPage icon retrieval
615 ////@end wxRichTextBulletsPage icon retrieval
619 * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
622 void wxRichTextBulletsPage::OnStylelistboxSelected( wxCommandEvent
& WXUNUSED(event
) )
626 m_hasBulletStyle
= true;
628 if (m_styleListBox
->GetSelection() == wxRICHTEXT_BULLETINDEX_SYMBOL
)
629 m_hasBulletSymbol
= true;
636 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
639 void wxRichTextBulletsPage::OnSymbolctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
643 m_hasBulletSymbol
= true;
649 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
652 void wxRichTextBulletsPage::OnSymbolctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
656 m_hasBulletSymbol
= true;
662 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
665 void wxRichTextBulletsPage::OnSymbolctrlUpdate( wxUpdateUIEvent
& event
)
667 OnSymbolUpdate(event
);
671 * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
674 void wxRichTextBulletsPage::OnNumberctrlUpdated( wxSpinEvent
& WXUNUSED(event
) )
678 m_hasBulletNumber
= true;
684 * wxEVT_SCROLL_LINEUP event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
687 void wxRichTextBulletsPage::OnNumberctrlUp( wxSpinEvent
& WXUNUSED(event
) )
691 m_hasBulletNumber
= true;
697 * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
700 void wxRichTextBulletsPage::OnNumberctrlDown( wxSpinEvent
& WXUNUSED(event
) )
704 m_hasBulletNumber
= true;
710 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
713 void wxRichTextBulletsPage::OnNumberctrlTextUpdated( wxCommandEvent
& WXUNUSED(event
) )
717 m_hasBulletNumber
= true;
723 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
726 void wxRichTextBulletsPage::OnNumberctrlUpdate( wxUpdateUIEvent
& event
)
728 OnNumberUpdate(event
);
732 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
735 void wxRichTextBulletsPage::OnParenthesesctrlClick( wxCommandEvent
& WXUNUSED(event
) )
739 m_hasBulletStyle
= true;
745 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
748 void wxRichTextBulletsPage::OnParenthesesctrlUpdate( wxUpdateUIEvent
& event
)
750 int sel
= m_styleListBox
->GetSelection();
751 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
752 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
753 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
757 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
760 void wxRichTextBulletsPage::OnPeriodctrlClick( wxCommandEvent
& WXUNUSED(event
) )
764 m_hasBulletStyle
= true;
770 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
773 void wxRichTextBulletsPage::OnPeriodctrlUpdate( wxUpdateUIEvent
& event
)
775 int sel
= m_styleListBox
->GetSelection();
776 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
777 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
778 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
782 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
785 void wxRichTextBulletsPage::OnChooseSymbolClick( wxCommandEvent
& WXUNUSED(event
) )
787 int sel
= m_styleListBox
->GetSelection();
788 if (m_hasBulletStyle
&& sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
)
790 wxString symbol
= m_symbolCtrl
->GetValue();
791 wxString fontName
= m_symbolFontCtrl
->GetValue();
792 wxSymbolPickerDialog
dlg(symbol
, fontName
, fontName
, this);
794 if (dlg
.ShowModal() == wxID_OK
)
798 m_symbolCtrl
->SetValue(dlg
.GetSymbol());
799 m_symbolFontCtrl
->SetValue(dlg
.GetFontName());
803 m_dontUpdate
= false;
809 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
812 void wxRichTextBulletsPage::OnChooseSymbolUpdate( wxUpdateUIEvent
& event
)
814 OnSymbolUpdate(event
);
817 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
820 void wxRichTextBulletsPage::OnSymbolfontctrlSelected( wxCommandEvent
& WXUNUSED(event
) )
828 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
831 void wxRichTextBulletsPage::OnSymbolfontctrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
840 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
843 void wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate( wxUpdateUIEvent
& event
)
845 OnSymbolUpdate(event
);
848 /// Update for symbol-related controls
849 void wxRichTextBulletsPage::OnSymbolUpdate( wxUpdateUIEvent
& event
)
851 int sel
= m_styleListBox
->GetSelection();
852 event
.Enable(m_hasBulletStyle
&& (sel
== wxRICHTEXT_BULLETINDEX_SYMBOL
));
855 /// Update for number-related controls
856 void wxRichTextBulletsPage::OnNumberUpdate( wxUpdateUIEvent
& event
)
858 int sel
= m_styleListBox
->GetSelection();
859 event
.Enable( m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
860 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
861 sel
!= wxRICHTEXT_BULLETINDEX_STANDARD
&&
862 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
865 /// Update for standard bullet-related controls
866 void wxRichTextBulletsPage::OnStandardBulletUpdate( wxUpdateUIEvent
& event
)
868 int sel
= m_styleListBox
->GetSelection();
869 event
.Enable( sel
== wxRICHTEXT_BULLETINDEX_STANDARD
);
874 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
877 void wxRichTextBulletsPage::OnSymbolstaticUpdate( wxUpdateUIEvent
& event
)
879 OnSymbolUpdate(event
);
884 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
887 void wxRichTextBulletsPage::OnNumberstaticUpdate( wxUpdateUIEvent
& event
)
889 OnNumberUpdate(event
);
893 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMESTATIC
896 void wxRichTextBulletsPage::OnNamestaticUpdate( wxUpdateUIEvent
& event
)
898 OnStandardBulletUpdate(event
);
903 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
906 void wxRichTextBulletsPage::OnNamectrlSelected( wxCommandEvent
& WXUNUSED(event
) )
914 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
917 void wxRichTextBulletsPage::OnNamectrlUpdated( wxCommandEvent
& WXUNUSED(event
) )
925 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL
928 void wxRichTextBulletsPage::OnNamectrlUIUpdate( wxUpdateUIEvent
& event
)
930 OnStandardBulletUpdate(event
);
933 #endif // wxUSE_RICHTEXT
935 * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
938 void wxRichTextBulletsPage::OnRightParenthesisCtrlClick( wxCommandEvent
& WXUNUSED(event
) )
942 m_hasBulletStyle
= true;
948 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL
951 void wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate( wxUpdateUIEvent
& event
)
953 int sel
= m_styleListBox
->GetSelection();
954 event
.Enable(m_hasBulletStyle
&& (sel
!= wxRICHTEXT_BULLETINDEX_SYMBOL
&&
955 sel
!= wxRICHTEXT_BULLETINDEX_BITMAP
&&
956 sel
!= wxRICHTEXT_BULLETINDEX_NONE
));
960 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX
963 void wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected( wxCommandEvent
& WXUNUSED(event
) )