1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextindentspage.cpp
4 // Author: Julian Smart
6 // Created: 10/3/2006 2:28:21 PM
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/richtext/richtextindentspage.h"
17 * wxRichTextIndentsSpacingPage type definition
20 IMPLEMENT_DYNAMIC_CLASS( wxRichTextIndentsSpacingPage
, wxRichTextDialogPage
)
23 * wxRichTextIndentsSpacingPage event table definition
26 BEGIN_EVENT_TABLE( wxRichTextIndentsSpacingPage
, wxRichTextDialogPage
)
28 ////@begin wxRichTextIndentsSpacingPage event table entries
29 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
, wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected
)
31 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
, wxRichTextIndentsSpacingPage::OnAlignmentRightSelected
)
33 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
, wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected
)
35 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
, wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected
)
37 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
, wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected
)
39 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
, wxRichTextIndentsSpacingPage::OnIndentLeftUpdated
)
41 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
, wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated
)
43 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
, wxRichTextIndentsSpacingPage::OnIndentRightUpdated
)
45 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
, wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected
)
47 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
, wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated
)
49 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
, wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated
)
51 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, wxRichTextIndentsSpacingPage::OnSpacingLineSelected
)
53 ////@end wxRichTextIndentsSpacingPage event table entries
57 IMPLEMENT_HELP_PROVISION(wxRichTextIndentsSpacingPage
)
60 * wxRichTextIndentsSpacingPage constructors
63 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( )
68 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
71 Create(parent
, id
, pos
, size
, style
);
78 void wxRichTextIndentsSpacingPage::Init()
82 ////@begin wxRichTextIndentsSpacingPage member initialisation
83 m_alignmentLeft
= NULL
;
84 m_alignmentRight
= NULL
;
85 m_alignmentJustified
= NULL
;
86 m_alignmentCentred
= NULL
;
87 m_alignmentIndeterminate
= NULL
;
89 m_indentLeftFirst
= NULL
;
91 m_outlineLevelCtrl
= NULL
;
92 m_spacingBefore
= NULL
;
93 m_spacingAfter
= NULL
;
95 m_pageBreakCtrl
= NULL
;
97 ////@end wxRichTextIndentsSpacingPage member initialisation
102 * wxRichTextIndentsSpacingPage creator
105 bool wxRichTextIndentsSpacingPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
107 ////@begin wxRichTextIndentsSpacingPage creation
108 wxRichTextDialogPage::Create( parent
, id
, pos
, size
, style
);
113 GetSizer()->SetSizeHints(this);
116 ////@end wxRichTextIndentsSpacingPage creation
121 * Control creation for wxRichTextIndentsSpacingPage
124 void wxRichTextIndentsSpacingPage::CreateControls()
126 ////@begin wxRichTextIndentsSpacingPage content construction
127 wxRichTextIndentsSpacingPage
* itemRichTextDialogPage1
= this;
129 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
130 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
132 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
133 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
135 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
136 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
138 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
139 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
141 wxStaticText
* itemStaticText6
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Alignment"), wxDefaultPosition
, wxDefaultSize
, 0 );
142 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
144 wxBoxSizer
* itemBoxSizer7
= new wxBoxSizer(wxHORIZONTAL
);
145 itemBoxSizer5
->Add(itemBoxSizer7
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
147 itemBoxSizer7
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
149 wxBoxSizer
* itemBoxSizer9
= new wxBoxSizer(wxVERTICAL
);
150 itemBoxSizer7
->Add(itemBoxSizer9
, 0, wxALIGN_CENTER_VERTICAL
|wxTOP
, 5);
152 m_alignmentLeft
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
, _("&Left"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
153 m_alignmentLeft
->SetValue(false);
154 m_alignmentLeft
->SetHelpText(_("Left-align text."));
155 if (wxRichTextIndentsSpacingPage::ShowToolTips())
156 m_alignmentLeft
->SetToolTip(_("Left-align text."));
157 itemBoxSizer9
->Add(m_alignmentLeft
, 0, wxALIGN_LEFT
|wxALL
, 5);
159 m_alignmentRight
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
, _("&Right"), wxDefaultPosition
, wxDefaultSize
, 0 );
160 m_alignmentRight
->SetValue(false);
161 m_alignmentRight
->SetHelpText(_("Right-align text."));
162 if (wxRichTextIndentsSpacingPage::ShowToolTips())
163 m_alignmentRight
->SetToolTip(_("Right-align text."));
164 itemBoxSizer9
->Add(m_alignmentRight
, 0, wxALIGN_LEFT
|wxALL
, 5);
166 m_alignmentJustified
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
, _("&Justified"), wxDefaultPosition
, wxDefaultSize
, 0 );
167 m_alignmentJustified
->SetValue(false);
168 m_alignmentJustified
->SetHelpText(_("Justify text left and right."));
169 if (wxRichTextIndentsSpacingPage::ShowToolTips())
170 m_alignmentJustified
->SetToolTip(_("Justify text left and right."));
171 itemBoxSizer9
->Add(m_alignmentJustified
, 0, wxALIGN_LEFT
|wxALL
, 5);
173 m_alignmentCentred
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
, _("Cen&tred"), wxDefaultPosition
, wxDefaultSize
, 0 );
174 m_alignmentCentred
->SetValue(false);
175 m_alignmentCentred
->SetHelpText(_("Centre text."));
176 if (wxRichTextIndentsSpacingPage::ShowToolTips())
177 m_alignmentCentred
->SetToolTip(_("Centre text."));
178 itemBoxSizer9
->Add(m_alignmentCentred
, 0, wxALIGN_LEFT
|wxALL
, 5);
180 m_alignmentIndeterminate
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
, _("&Indeterminate"), wxDefaultPosition
, wxDefaultSize
, 0 );
181 m_alignmentIndeterminate
->SetValue(false);
182 m_alignmentIndeterminate
->SetHelpText(_("Use the current alignment setting."));
183 if (wxRichTextIndentsSpacingPage::ShowToolTips())
184 m_alignmentIndeterminate
->SetToolTip(_("Use the current alignment setting."));
185 itemBoxSizer9
->Add(m_alignmentIndeterminate
, 0, wxALIGN_LEFT
|wxALL
, 5);
187 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
189 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
190 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxBOTTOM
, 5);
192 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
194 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
195 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
197 wxStaticText
* itemStaticText19
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Indentation (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
198 itemBoxSizer18
->Add(itemStaticText19
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
200 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
201 itemBoxSizer18
->Add(itemBoxSizer20
, 0, wxALIGN_LEFT
|wxALL
, 5);
203 itemBoxSizer20
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
205 wxFlexGridSizer
* itemFlexGridSizer22
= new wxFlexGridSizer(0, 2, 0, 0);
206 itemBoxSizer20
->Add(itemFlexGridSizer22
, 0, wxALIGN_CENTER_VERTICAL
, 5);
208 wxStaticText
* itemStaticText23
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Left:"), wxDefaultPosition
, wxDefaultSize
, 0 );
209 itemFlexGridSizer22
->Add(itemStaticText23
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
211 m_indentLeft
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
212 m_indentLeft
->SetHelpText(_("The left indent."));
213 if (wxRichTextIndentsSpacingPage::ShowToolTips())
214 m_indentLeft
->SetToolTip(_("The left indent."));
215 itemFlexGridSizer22
->Add(m_indentLeft
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
217 wxStaticText
* itemStaticText25
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Left (&first line):"), wxDefaultPosition
, wxDefaultSize
, 0 );
218 itemFlexGridSizer22
->Add(itemStaticText25
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
220 m_indentLeftFirst
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
221 m_indentLeftFirst
->SetHelpText(_("The first line indent."));
222 if (wxRichTextIndentsSpacingPage::ShowToolTips())
223 m_indentLeftFirst
->SetToolTip(_("The first line indent."));
224 itemFlexGridSizer22
->Add(m_indentLeftFirst
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
226 wxStaticText
* itemStaticText27
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Right:"), wxDefaultPosition
, wxDefaultSize
, 0 );
227 itemFlexGridSizer22
->Add(itemStaticText27
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
229 m_indentRight
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
230 m_indentRight
->SetHelpText(_("The right indent."));
231 if (wxRichTextIndentsSpacingPage::ShowToolTips())
232 m_indentRight
->SetToolTip(_("The right indent."));
233 itemFlexGridSizer22
->Add(m_indentRight
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
235 wxStaticText
* itemStaticText29
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Outline level:"), wxDefaultPosition
, wxDefaultSize
, 0 );
236 itemFlexGridSizer22
->Add(itemStaticText29
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
238 wxArrayString m_outlineLevelCtrlStrings
;
239 m_outlineLevelCtrlStrings
.Add(_("(none)"));
240 m_outlineLevelCtrlStrings
.Add(_("1"));
241 m_outlineLevelCtrlStrings
.Add(_("2"));
242 m_outlineLevelCtrlStrings
.Add(_("3"));
243 m_outlineLevelCtrlStrings
.Add(_("4"));
244 m_outlineLevelCtrlStrings
.Add(_("5"));
245 m_outlineLevelCtrlStrings
.Add(_("6"));
246 m_outlineLevelCtrlStrings
.Add(_("7"));
247 m_outlineLevelCtrlStrings
.Add(_("8"));
248 m_outlineLevelCtrlStrings
.Add(_("9"));
249 m_outlineLevelCtrlStrings
.Add(_("10"));
250 m_outlineLevelCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
, _("(none)"), wxDefaultPosition
, wxSize(85, -1), m_outlineLevelCtrlStrings
, wxCB_READONLY
);
251 m_outlineLevelCtrl
->SetStringSelection(_("(none)"));
252 m_outlineLevelCtrl
->SetHelpText(_("The outline level."));
253 if (wxRichTextIndentsSpacingPage::ShowToolTips())
254 m_outlineLevelCtrl
->SetToolTip(_("The outline level."));
255 itemFlexGridSizer22
->Add(m_outlineLevelCtrl
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
257 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
259 wxStaticLine
* itemStaticLine32
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
260 itemBoxSizer4
->Add(itemStaticLine32
, 0, wxGROW
|wxTOP
|wxBOTTOM
, 5);
262 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
264 wxBoxSizer
* itemBoxSizer34
= new wxBoxSizer(wxVERTICAL
);
265 itemBoxSizer4
->Add(itemBoxSizer34
, 0, wxGROW
, 5);
267 wxStaticText
* itemStaticText35
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Spacing (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
268 itemBoxSizer34
->Add(itemStaticText35
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
270 wxBoxSizer
* itemBoxSizer36
= new wxBoxSizer(wxHORIZONTAL
);
271 itemBoxSizer34
->Add(itemBoxSizer36
, 0, wxALIGN_LEFT
|wxALL
, 5);
273 itemBoxSizer36
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
275 wxFlexGridSizer
* itemFlexGridSizer38
= new wxFlexGridSizer(30, 2, 0, 0);
276 itemBoxSizer36
->Add(itemFlexGridSizer38
, 0, wxALIGN_CENTER_VERTICAL
, 5);
278 wxStaticText
* itemStaticText39
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Before a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
279 itemFlexGridSizer38
->Add(itemStaticText39
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
281 m_spacingBefore
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
282 m_spacingBefore
->SetHelpText(_("The spacing before the paragraph."));
283 if (wxRichTextIndentsSpacingPage::ShowToolTips())
284 m_spacingBefore
->SetToolTip(_("The spacing before the paragraph."));
285 itemFlexGridSizer38
->Add(m_spacingBefore
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
287 wxStaticText
* itemStaticText41
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&After a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
288 itemFlexGridSizer38
->Add(itemStaticText41
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
290 m_spacingAfter
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
291 if (wxRichTextIndentsSpacingPage::ShowToolTips())
292 m_spacingAfter
->SetToolTip(_("The spacing after the paragraph."));
293 itemFlexGridSizer38
->Add(m_spacingAfter
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
295 wxStaticText
* itemStaticText43
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("L&ine spacing:"), wxDefaultPosition
, wxDefaultSize
, 0 );
296 itemFlexGridSizer38
->Add(itemStaticText43
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
298 wxArrayString m_spacingLineStrings
;
299 m_spacingLineStrings
.Add(_("(none)"));
300 m_spacingLineStrings
.Add(_("Single"));
301 m_spacingLineStrings
.Add(_("1.1"));
302 m_spacingLineStrings
.Add(_("1.2"));
303 m_spacingLineStrings
.Add(_("1.3"));
304 m_spacingLineStrings
.Add(_("1.4"));
305 m_spacingLineStrings
.Add(_("1.5"));
306 m_spacingLineStrings
.Add(_("1.6"));
307 m_spacingLineStrings
.Add(_("1.7"));
308 m_spacingLineStrings
.Add(_("1.8"));
309 m_spacingLineStrings
.Add(_("1.9"));
310 m_spacingLineStrings
.Add(_("2"));
311 m_spacingLine
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, _("(none)"), wxDefaultPosition
, wxSize(85, -1), m_spacingLineStrings
, wxCB_READONLY
);
312 m_spacingLine
->SetStringSelection(_("(none)"));
313 m_spacingLine
->SetHelpText(_("The line spacing."));
314 if (wxRichTextIndentsSpacingPage::ShowToolTips())
315 m_spacingLine
->SetToolTip(_("The line spacing."));
316 itemFlexGridSizer38
->Add(m_spacingLine
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
318 m_pageBreakCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_PAGEBREAK
, _("&Page Break"), wxDefaultPosition
, wxDefaultSize
, 0 );
319 m_pageBreakCtrl
->SetValue(false);
320 m_pageBreakCtrl
->SetHelpText(_("Inserts a page break before the paragraph."));
321 if (wxRichTextIndentsSpacingPage::ShowToolTips())
322 m_pageBreakCtrl
->SetToolTip(_("Inserts a page break before the paragraph."));
323 itemBoxSizer34
->Add(m_pageBreakCtrl
, 0, wxALIGN_LEFT
|wxALL
, 5);
325 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
327 m_previewCtrl
= new wxRichTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 100), wxBORDER_THEME
|wxVSCROLL
|wxTE_READONLY
);
328 m_previewCtrl
->SetHelpText(_("Shows a preview of the paragraph settings."));
329 if (wxRichTextIndentsSpacingPage::ShowToolTips())
330 m_previewCtrl
->SetToolTip(_("Shows a preview of the paragraph settings."));
331 itemBoxSizer3
->Add(m_previewCtrl
, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
333 ////@end wxRichTextIndentsSpacingPage content construction
336 wxRichTextAttr
* wxRichTextIndentsSpacingPage::GetAttributes()
338 return wxRichTextFormattingDialog::GetDialogAttributes(this);
341 /// Updates the font preview
342 void wxRichTextIndentsSpacingPage::UpdatePreview()
344 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
345 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n");
347 static const wxChar
* s_para2
= wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \
348 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n");
350 static const wxChar
* s_para3
= wxT("Integer convallis dolor at augue \
351 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
353 TransferDataFromWindow();
354 wxRichTextAttr
attr(*GetAttributes());
355 attr
.SetFlags(attr
.GetFlags() &
356 (wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
357 wxTEXT_ATTR_LINE_SPACING
|
358 wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
));
360 wxFont
font(m_previewCtrl
->GetFont());
361 font
.SetPointSize(9);
362 m_previewCtrl
->SetFont(font
);
364 wxRichTextAttr normalParaAttr
;
365 normalParaAttr
.SetFont(font
);
366 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
368 m_previewCtrl
->Freeze();
369 m_previewCtrl
->Clear();
371 m_previewCtrl
->BeginStyle(normalParaAttr
);
372 m_previewCtrl
->WriteText(s_para1
);
373 m_previewCtrl
->EndStyle();
375 m_previewCtrl
->BeginStyle(attr
);
376 m_previewCtrl
->WriteText(s_para2
);
377 m_previewCtrl
->EndStyle();
379 m_previewCtrl
->BeginStyle(normalParaAttr
);
380 m_previewCtrl
->WriteText(s_para3
);
381 m_previewCtrl
->EndStyle();
383 m_previewCtrl
->Thaw();
386 /// Transfer data from/to window
387 bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
389 wxPanel::TransferDataFromWindow();
391 wxRichTextAttr
* attr
= GetAttributes();
393 if (m_alignmentLeft
->GetValue())
394 attr
->SetAlignment(wxTEXT_ALIGNMENT_LEFT
);
395 else if (m_alignmentCentred
->GetValue())
396 attr
->SetAlignment(wxTEXT_ALIGNMENT_CENTRE
);
397 else if (m_alignmentRight
->GetValue())
398 attr
->SetAlignment(wxTEXT_ALIGNMENT_RIGHT
);
399 else if (m_alignmentJustified
->GetValue())
400 attr
->SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED
);
403 attr
->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT
);
404 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT
));
407 wxString
leftIndent(m_indentLeft
->GetValue());
408 wxString
leftFirstIndent(m_indentLeftFirst
->GetValue());
409 if (!leftIndent
.empty() || !leftFirstIndent
.empty())
411 int visualLeftIndent
= 0;
412 if (!leftIndent
.empty())
413 visualLeftIndent
= wxAtoi(leftIndent
);
415 int visualLeftFirstIndent
= wxAtoi(leftFirstIndent
);
416 int actualLeftIndent
= visualLeftFirstIndent
;
417 int actualLeftSubIndent
= visualLeftIndent
- visualLeftFirstIndent
;
419 attr
->SetLeftIndent(actualLeftIndent
, actualLeftSubIndent
);
422 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT
));
424 wxString
rightIndent(m_indentRight
->GetValue());
425 if (!rightIndent
.empty())
426 attr
->SetRightIndent(wxAtoi(rightIndent
));
428 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT
));
430 wxString
spacingAfter(m_spacingAfter
->GetValue());
431 if (!spacingAfter
.empty())
432 attr
->SetParagraphSpacingAfter(wxAtoi(spacingAfter
));
434 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER
));
436 wxString
spacingBefore(m_spacingBefore
->GetValue());
437 if (!spacingBefore
.empty())
438 attr
->SetParagraphSpacingBefore(wxAtoi(spacingBefore
));
440 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE
));
442 int spacingIndex
= m_spacingLine
->GetSelection() - 1;
444 if (spacingIndex
> -1)
445 lineSpacing
= 10 + spacingIndex
;
447 if (lineSpacing
== 0)
448 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING
));
450 attr
->SetLineSpacing(lineSpacing
);
452 int outlineLevel
= m_outlineLevelCtrl
->GetSelection();
453 if (outlineLevel
== wxNOT_FOUND
|| outlineLevel
== 0)
455 attr
->SetOutlineLevel(-1);
456 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_OUTLINE_LEVEL
));
459 attr
->SetOutlineLevel(outlineLevel
-1);
461 attr
->SetPageBreak(m_pageBreakCtrl
->GetValue());
466 bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
470 wxPanel::TransferDataToWindow();
472 wxRichTextAttr
* attr
= GetAttributes();
474 if (attr
->HasAlignment())
476 if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_LEFT
)
477 m_alignmentLeft
->SetValue(true);
478 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_RIGHT
)
479 m_alignmentRight
->SetValue(true);
480 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_CENTRE
)
481 m_alignmentCentred
->SetValue(true);
482 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_JUSTIFIED
)
483 m_alignmentJustified
->SetValue(true);
485 m_alignmentIndeterminate
->SetValue(true);
488 m_alignmentIndeterminate
->SetValue(true);
490 if (attr
->HasLeftIndent())
492 wxString
leftIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent() + attr
->GetLeftSubIndent()));
493 wxString
leftFirstIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent()));
495 m_indentLeft
->SetValue(leftIndent
);
496 m_indentLeftFirst
->SetValue(leftFirstIndent
);
500 m_indentLeft
->SetValue(wxEmptyString
);
501 m_indentLeftFirst
->SetValue(wxEmptyString
);
504 if (attr
->HasRightIndent())
506 wxString
rightIndent(wxString::Format(wxT("%ld"), attr
->GetRightIndent()));
508 m_indentRight
->SetValue(rightIndent
);
511 m_indentRight
->SetValue(wxEmptyString
);
513 if (attr
->HasParagraphSpacingAfter())
515 wxString
spacingAfter(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingAfter()));
517 m_spacingAfter
->SetValue(spacingAfter
);
520 m_spacingAfter
->SetValue(wxEmptyString
);
522 if (attr
->HasParagraphSpacingBefore())
524 wxString
spacingBefore(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingBefore()));
526 m_spacingBefore
->SetValue(spacingBefore
);
529 m_spacingBefore
->SetValue(wxEmptyString
);
531 if (attr
->HasLineSpacing())
535 int lineSpacing
= attr
->GetLineSpacing();
536 if (lineSpacing
>= 10 && lineSpacing
<= 20)
537 index
= (lineSpacing
- 10) + 1;
541 m_spacingLine
->SetSelection(index
);
544 m_spacingLine
->SetSelection(0);
546 if (attr
->HasOutlineLevel())
548 int outlineLevel
= attr
->GetOutlineLevel();
549 if (outlineLevel
< 0)
551 if (outlineLevel
> 9)
554 m_outlineLevelCtrl
->SetSelection(outlineLevel
+1);
557 m_outlineLevelCtrl
->SetSelection(0);
559 m_pageBreakCtrl
->SetValue(attr
->HasPageBreak());
563 m_dontUpdate
= false;
570 * Should we show tooltips?
573 bool wxRichTextIndentsSpacingPage::ShowToolTips()
575 return wxRichTextFormattingDialog::ShowToolTips();
579 * Get bitmap resources
582 wxBitmap
wxRichTextIndentsSpacingPage::GetBitmapResource( const wxString
& name
)
585 ////@begin wxRichTextIndentsSpacingPage bitmap retrieval
588 ////@end wxRichTextIndentsSpacingPage bitmap retrieval
595 wxIcon
wxRichTextIndentsSpacingPage::GetIconResource( const wxString
& name
)
598 ////@begin wxRichTextIndentsSpacingPage icon retrieval
601 ////@end wxRichTextIndentsSpacingPage icon retrieval
604 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
607 void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent
& WXUNUSED(event
) )
615 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
618 void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent
& WXUNUSED(event
) )
626 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
629 void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent
& WXUNUSED(event
) )
637 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
640 void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent
& WXUNUSED(event
) )
648 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
651 void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent
& WXUNUSED(event
) )
659 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
662 void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent
& WXUNUSED(event
) )
670 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
673 void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent
& WXUNUSED(event
) )
681 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
684 void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent
& WXUNUSED(event
) )
692 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
695 void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent
& WXUNUSED(event
) )
703 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
706 void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent
& WXUNUSED(event
) )
713 * wxEVT_COMBOBOX event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
716 void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent
& WXUNUSED(event
) )
723 * wxEVT_COMBOBOX event handler for ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
726 void wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected( wxCommandEvent
& WXUNUSED(event
) )
732 #endif // wxUSE_RICHTEXT