1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextindentspage.cpp
4 // Author: Julian Smart
6 // Created: 10/3/2006 2:28:21 PM
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
13 #include "wx/richtext/richtextindentspage.h"
16 * wxRichTextIndentsSpacingPage type definition
19 IMPLEMENT_DYNAMIC_CLASS( wxRichTextIndentsSpacingPage
, wxRichTextDialogPage
)
22 * wxRichTextIndentsSpacingPage event table definition
25 BEGIN_EVENT_TABLE( wxRichTextIndentsSpacingPage
, wxRichTextDialogPage
)
27 ////@begin wxRichTextIndentsSpacingPage event table entries
28 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
, wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected
)
29 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
, wxRichTextIndentsSpacingPage::OnAlignmentRightSelected
)
30 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
, wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected
)
31 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
, wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected
)
32 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
, wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected
)
33 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
, wxRichTextIndentsSpacingPage::OnIndentLeftUpdated
)
34 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
, wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated
)
35 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
, wxRichTextIndentsSpacingPage::OnIndentRightUpdated
)
36 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
, wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected
)
37 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
, wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated
)
38 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
, wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated
)
39 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, wxRichTextIndentsSpacingPage::OnSpacingLineSelected
)
40 ////@end wxRichTextIndentsSpacingPage event table entries
44 IMPLEMENT_HELP_PROVISION(wxRichTextIndentsSpacingPage
)
47 * wxRichTextIndentsSpacingPage constructors
50 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( )
55 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
58 Create(parent
, id
, pos
, size
, style
);
65 void wxRichTextIndentsSpacingPage::Init()
69 ////@begin wxRichTextIndentsSpacingPage member initialisation
70 m_alignmentLeft
= NULL
;
71 m_alignmentRight
= NULL
;
72 m_alignmentJustified
= NULL
;
73 m_alignmentCentred
= NULL
;
74 m_alignmentIndeterminate
= NULL
;
76 m_indentLeftFirst
= NULL
;
78 m_outlineLevelCtrl
= NULL
;
79 m_spacingBefore
= NULL
;
80 m_spacingAfter
= NULL
;
82 m_pageBreakCtrl
= NULL
;
84 ////@end wxRichTextIndentsSpacingPage member initialisation
89 * wxRichTextIndentsSpacingPage creator
92 bool wxRichTextIndentsSpacingPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
94 ////@begin wxRichTextIndentsSpacingPage creation
95 wxRichTextDialogPage::Create( parent
, id
, pos
, size
, style
);
100 GetSizer()->SetSizeHints(this);
103 ////@end wxRichTextIndentsSpacingPage creation
108 * Control creation for wxRichTextIndentsSpacingPage
111 void wxRichTextIndentsSpacingPage::CreateControls()
113 ////@begin wxRichTextIndentsSpacingPage content construction
114 wxRichTextIndentsSpacingPage
* itemRichTextDialogPage1
= this;
116 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
117 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
119 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
120 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
122 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
123 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
125 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
126 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
128 wxStaticText
* itemStaticText6
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Alignment"), wxDefaultPosition
, wxDefaultSize
, 0 );
129 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
131 wxBoxSizer
* itemBoxSizer7
= new wxBoxSizer(wxHORIZONTAL
);
132 itemBoxSizer5
->Add(itemBoxSizer7
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
134 itemBoxSizer7
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
136 wxBoxSizer
* itemBoxSizer9
= new wxBoxSizer(wxVERTICAL
);
137 itemBoxSizer7
->Add(itemBoxSizer9
, 0, wxALIGN_CENTER_VERTICAL
|wxTOP
, 5);
139 m_alignmentLeft
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
, _("&Left"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
140 m_alignmentLeft
->SetValue(false);
141 m_alignmentLeft
->SetHelpText(_("Left-align text."));
142 if (wxRichTextIndentsSpacingPage::ShowToolTips())
143 m_alignmentLeft
->SetToolTip(_("Left-align text."));
144 itemBoxSizer9
->Add(m_alignmentLeft
, 0, wxALIGN_LEFT
|wxALL
, 5);
146 m_alignmentRight
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
, _("&Right"), wxDefaultPosition
, wxDefaultSize
, 0 );
147 m_alignmentRight
->SetValue(false);
148 m_alignmentRight
->SetHelpText(_("Right-align text."));
149 if (wxRichTextIndentsSpacingPage::ShowToolTips())
150 m_alignmentRight
->SetToolTip(_("Right-align text."));
151 itemBoxSizer9
->Add(m_alignmentRight
, 0, wxALIGN_LEFT
|wxALL
, 5);
153 m_alignmentJustified
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
, _("&Justified"), wxDefaultPosition
, wxDefaultSize
, 0 );
154 m_alignmentJustified
->SetValue(false);
155 m_alignmentJustified
->SetHelpText(_("Justify text left and right."));
156 if (wxRichTextIndentsSpacingPage::ShowToolTips())
157 m_alignmentJustified
->SetToolTip(_("Justify text left and right."));
158 itemBoxSizer9
->Add(m_alignmentJustified
, 0, wxALIGN_LEFT
|wxALL
, 5);
160 m_alignmentCentred
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
, _("Cen&tred"), wxDefaultPosition
, wxDefaultSize
, 0 );
161 m_alignmentCentred
->SetValue(false);
162 m_alignmentCentred
->SetHelpText(_("Centre text."));
163 if (wxRichTextIndentsSpacingPage::ShowToolTips())
164 m_alignmentCentred
->SetToolTip(_("Centre text."));
165 itemBoxSizer9
->Add(m_alignmentCentred
, 0, wxALIGN_LEFT
|wxALL
, 5);
167 m_alignmentIndeterminate
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
, _("&Indeterminate"), wxDefaultPosition
, wxDefaultSize
, 0 );
168 m_alignmentIndeterminate
->SetValue(false);
169 m_alignmentIndeterminate
->SetHelpText(_("Use the current alignment setting."));
170 if (wxRichTextIndentsSpacingPage::ShowToolTips())
171 m_alignmentIndeterminate
->SetToolTip(_("Use the current alignment setting."));
172 itemBoxSizer9
->Add(m_alignmentIndeterminate
, 0, wxALIGN_LEFT
|wxALL
, 5);
174 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
176 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
177 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxBOTTOM
, 5);
179 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
181 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
182 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
184 wxStaticText
* itemStaticText19
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Indentation (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
185 itemBoxSizer18
->Add(itemStaticText19
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
187 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
188 itemBoxSizer18
->Add(itemBoxSizer20
, 0, wxALIGN_LEFT
|wxALL
, 5);
190 itemBoxSizer20
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
192 wxFlexGridSizer
* itemFlexGridSizer22
= new wxFlexGridSizer(0, 2, 0, 0);
193 itemBoxSizer20
->Add(itemFlexGridSizer22
, 0, wxALIGN_CENTER_VERTICAL
, 5);
195 wxStaticText
* itemStaticText23
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Left:"), wxDefaultPosition
, wxDefaultSize
, 0 );
196 itemFlexGridSizer22
->Add(itemStaticText23
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
198 m_indentLeft
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
199 m_indentLeft
->SetHelpText(_("The left indent."));
200 if (wxRichTextIndentsSpacingPage::ShowToolTips())
201 m_indentLeft
->SetToolTip(_("The left indent."));
202 itemFlexGridSizer22
->Add(m_indentLeft
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
204 wxStaticText
* itemStaticText25
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Left (&first line):"), wxDefaultPosition
, wxDefaultSize
, 0 );
205 itemFlexGridSizer22
->Add(itemStaticText25
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
207 m_indentLeftFirst
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
208 m_indentLeftFirst
->SetHelpText(_("The first line indent."));
209 if (wxRichTextIndentsSpacingPage::ShowToolTips())
210 m_indentLeftFirst
->SetToolTip(_("The first line indent."));
211 itemFlexGridSizer22
->Add(m_indentLeftFirst
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
213 wxStaticText
* itemStaticText27
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Right:"), wxDefaultPosition
, wxDefaultSize
, 0 );
214 itemFlexGridSizer22
->Add(itemStaticText27
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
216 m_indentRight
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
217 m_indentRight
->SetHelpText(_("The right indent."));
218 if (wxRichTextIndentsSpacingPage::ShowToolTips())
219 m_indentRight
->SetToolTip(_("The right indent."));
220 itemFlexGridSizer22
->Add(m_indentRight
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
222 wxStaticText
* itemStaticText29
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Outline level:"), wxDefaultPosition
, wxDefaultSize
, 0 );
223 itemFlexGridSizer22
->Add(itemStaticText29
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
225 wxArrayString m_outlineLevelCtrlStrings
;
226 m_outlineLevelCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
, wxEmptyString
, wxDefaultPosition
, wxSize(85, -1), m_outlineLevelCtrlStrings
, wxCB_READONLY
);
227 m_outlineLevelCtrl
->SetHelpText(_("The outline level."));
228 if (wxRichTextIndentsSpacingPage::ShowToolTips())
229 m_outlineLevelCtrl
->SetToolTip(_("The outline level."));
230 itemFlexGridSizer22
->Add(m_outlineLevelCtrl
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
232 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
234 wxStaticLine
* itemStaticLine32
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
235 itemBoxSizer4
->Add(itemStaticLine32
, 0, wxGROW
|wxTOP
|wxBOTTOM
, 5);
237 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
239 wxBoxSizer
* itemBoxSizer34
= new wxBoxSizer(wxVERTICAL
);
240 itemBoxSizer4
->Add(itemBoxSizer34
, 0, wxGROW
, 5);
242 wxStaticText
* itemStaticText35
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Spacing (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
243 itemBoxSizer34
->Add(itemStaticText35
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
245 wxBoxSizer
* itemBoxSizer36
= new wxBoxSizer(wxHORIZONTAL
);
246 itemBoxSizer34
->Add(itemBoxSizer36
, 0, wxALIGN_LEFT
|wxALL
, 5);
248 itemBoxSizer36
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
250 wxFlexGridSizer
* itemFlexGridSizer38
= new wxFlexGridSizer(30, 2, 0, 0);
251 itemBoxSizer36
->Add(itemFlexGridSizer38
, 0, wxALIGN_CENTER_VERTICAL
, 5);
253 wxStaticText
* itemStaticText39
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Before a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
254 itemFlexGridSizer38
->Add(itemStaticText39
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
256 m_spacingBefore
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
257 m_spacingBefore
->SetHelpText(_("The spacing before the paragraph."));
258 if (wxRichTextIndentsSpacingPage::ShowToolTips())
259 m_spacingBefore
->SetToolTip(_("The spacing before the paragraph."));
260 itemFlexGridSizer38
->Add(m_spacingBefore
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
262 wxStaticText
* itemStaticText41
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&After a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
263 itemFlexGridSizer38
->Add(itemStaticText41
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
265 m_spacingAfter
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
266 if (wxRichTextIndentsSpacingPage::ShowToolTips())
267 m_spacingAfter
->SetToolTip(_("The spacing after the paragraph."));
268 itemFlexGridSizer38
->Add(m_spacingAfter
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
270 wxStaticText
* itemStaticText43
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("L&ine spacing:"), wxDefaultPosition
, wxDefaultSize
, 0 );
271 itemFlexGridSizer38
->Add(itemStaticText43
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
273 wxArrayString m_spacingLineStrings
;
274 m_spacingLineStrings
.Add(_("(none)"));
275 m_spacingLineStrings
.Add(_("Single"));
276 m_spacingLineStrings
.Add(_("1.1"));
277 m_spacingLineStrings
.Add(_("1.2"));
278 m_spacingLineStrings
.Add(_("1.3"));
279 m_spacingLineStrings
.Add(_("1.4"));
280 m_spacingLineStrings
.Add(_("1.5"));
281 m_spacingLineStrings
.Add(_("1.6"));
282 m_spacingLineStrings
.Add(_("1.7"));
283 m_spacingLineStrings
.Add(_("1.8"));
284 m_spacingLineStrings
.Add(_("1.9"));
285 m_spacingLineStrings
.Add(_("2"));
286 m_spacingLine
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, _("(none)"), wxDefaultPosition
, wxSize(85, -1), m_spacingLineStrings
, wxCB_READONLY
);
287 m_spacingLine
->SetStringSelection(_("(none)"));
288 m_spacingLine
->SetHelpText(_("The line spacing."));
289 if (wxRichTextIndentsSpacingPage::ShowToolTips())
290 m_spacingLine
->SetToolTip(_("The line spacing."));
291 itemFlexGridSizer38
->Add(m_spacingLine
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
293 m_pageBreakCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_PAGEBREAK
, _("&Page Break"), wxDefaultPosition
, wxDefaultSize
, 0 );
294 m_pageBreakCtrl
->SetValue(false);
295 m_pageBreakCtrl
->SetHelpText(_("Inserts a page break before the paragraph."));
296 if (wxRichTextIndentsSpacingPage::ShowToolTips())
297 m_pageBreakCtrl
->SetToolTip(_("Inserts a page break before the paragraph."));
298 itemBoxSizer34
->Add(m_pageBreakCtrl
, 0, wxALIGN_LEFT
|wxALL
, 5);
300 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
302 m_previewCtrl
= new wxRichTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 100), wxBORDER_THEME
|wxVSCROLL
|wxTE_READONLY
);
303 m_previewCtrl
->SetHelpText(_("Shows a preview of the paragraph settings."));
304 if (wxRichTextIndentsSpacingPage::ShowToolTips())
305 m_previewCtrl
->SetToolTip(_("Shows a preview of the paragraph settings."));
306 itemBoxSizer3
->Add(m_previewCtrl
, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
308 ////@end wxRichTextIndentsSpacingPage content construction
310 wxArrayString outlineLevelCtrlStrings
;
311 outlineLevelCtrlStrings
.Add(_("(none)"));
312 outlineLevelCtrlStrings
.Add("1");
313 outlineLevelCtrlStrings
.Add("2");
314 outlineLevelCtrlStrings
.Add("3");
315 outlineLevelCtrlStrings
.Add("4");
316 outlineLevelCtrlStrings
.Add("5");
317 outlineLevelCtrlStrings
.Add("6");
318 outlineLevelCtrlStrings
.Add("7");
319 outlineLevelCtrlStrings
.Add("8");
320 outlineLevelCtrlStrings
.Add("9");
321 outlineLevelCtrlStrings
.Add("10");
323 m_outlineLevelCtrl
->Freeze();
324 m_outlineLevelCtrl
->Append(outlineLevelCtrlStrings
);
325 m_outlineLevelCtrl
->Thaw();
326 m_outlineLevelCtrl
->SetStringSelection(_("(none)"));
329 wxRichTextAttr
* wxRichTextIndentsSpacingPage::GetAttributes()
331 return wxRichTextFormattingDialog::GetDialogAttributes(this);
334 /// Updates the font preview
335 void wxRichTextIndentsSpacingPage::UpdatePreview()
337 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
338 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n");
340 static const wxChar
* s_para2
= wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \
341 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n");
343 static const wxChar
* s_para3
= wxT("Integer convallis dolor at augue \
344 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
346 TransferDataFromWindow();
347 wxRichTextAttr
attr(*GetAttributes());
348 attr
.SetFlags(attr
.GetFlags() &
349 (wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
350 wxTEXT_ATTR_LINE_SPACING
|
351 wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
));
353 wxFont
font(m_previewCtrl
->GetFont());
354 font
.SetPointSize(9);
355 m_previewCtrl
->SetFont(font
);
357 wxRichTextAttr normalParaAttr
;
358 normalParaAttr
.SetFont(font
);
359 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
361 m_previewCtrl
->Freeze();
362 m_previewCtrl
->Clear();
364 m_previewCtrl
->BeginStyle(normalParaAttr
);
365 m_previewCtrl
->WriteText(s_para1
);
366 m_previewCtrl
->EndStyle();
368 m_previewCtrl
->BeginStyle(attr
);
369 m_previewCtrl
->WriteText(s_para2
);
370 m_previewCtrl
->EndStyle();
372 m_previewCtrl
->BeginStyle(normalParaAttr
);
373 m_previewCtrl
->WriteText(s_para3
);
374 m_previewCtrl
->EndStyle();
376 m_previewCtrl
->Thaw();
379 /// Transfer data from/to window
380 bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
382 wxPanel::TransferDataFromWindow();
384 wxRichTextAttr
* attr
= GetAttributes();
386 if (m_alignmentLeft
->GetValue())
387 attr
->SetAlignment(wxTEXT_ALIGNMENT_LEFT
);
388 else if (m_alignmentCentred
->GetValue())
389 attr
->SetAlignment(wxTEXT_ALIGNMENT_CENTRE
);
390 else if (m_alignmentRight
->GetValue())
391 attr
->SetAlignment(wxTEXT_ALIGNMENT_RIGHT
);
392 else if (m_alignmentJustified
->GetValue())
393 attr
->SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED
);
396 attr
->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT
);
397 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT
));
400 wxString
leftIndent(m_indentLeft
->GetValue());
401 wxString
leftFirstIndent(m_indentLeftFirst
->GetValue());
402 if (!leftIndent
.empty() || !leftFirstIndent
.empty())
404 int visualLeftIndent
= 0;
405 if (!leftIndent
.empty())
406 visualLeftIndent
= wxAtoi(leftIndent
);
408 int visualLeftFirstIndent
= wxAtoi(leftFirstIndent
);
409 int actualLeftIndent
= visualLeftFirstIndent
;
410 int actualLeftSubIndent
= visualLeftIndent
- visualLeftFirstIndent
;
412 attr
->SetLeftIndent(actualLeftIndent
, actualLeftSubIndent
);
415 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT
));
417 wxString
rightIndent(m_indentRight
->GetValue());
418 if (!rightIndent
.empty())
419 attr
->SetRightIndent(wxAtoi(rightIndent
));
421 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT
));
423 wxString
spacingAfter(m_spacingAfter
->GetValue());
424 if (!spacingAfter
.empty())
425 attr
->SetParagraphSpacingAfter(wxAtoi(spacingAfter
));
427 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER
));
429 wxString
spacingBefore(m_spacingBefore
->GetValue());
430 if (!spacingBefore
.empty())
431 attr
->SetParagraphSpacingBefore(wxAtoi(spacingBefore
));
433 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE
));
435 int spacingIndex
= m_spacingLine
->GetSelection() - 1;
437 if (spacingIndex
> -1)
438 lineSpacing
= 10 + spacingIndex
;
440 if (lineSpacing
== 0)
441 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING
));
443 attr
->SetLineSpacing(lineSpacing
);
445 int outlineLevel
= m_outlineLevelCtrl
->GetSelection();
446 if (outlineLevel
== wxNOT_FOUND
|| outlineLevel
== 0)
448 attr
->SetOutlineLevel(-1);
449 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_OUTLINE_LEVEL
));
452 attr
->SetOutlineLevel(outlineLevel
-1);
454 attr
->SetPageBreak(m_pageBreakCtrl
->GetValue());
459 bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
463 wxPanel::TransferDataToWindow();
465 wxRichTextAttr
* attr
= GetAttributes();
467 if (attr
->HasAlignment())
469 if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_LEFT
)
470 m_alignmentLeft
->SetValue(true);
471 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_RIGHT
)
472 m_alignmentRight
->SetValue(true);
473 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_CENTRE
)
474 m_alignmentCentred
->SetValue(true);
475 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_JUSTIFIED
)
476 m_alignmentJustified
->SetValue(true);
478 m_alignmentIndeterminate
->SetValue(true);
481 m_alignmentIndeterminate
->SetValue(true);
483 if (attr
->HasLeftIndent())
485 wxString
leftIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent() + attr
->GetLeftSubIndent()));
486 wxString
leftFirstIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent()));
488 m_indentLeft
->SetValue(leftIndent
);
489 m_indentLeftFirst
->SetValue(leftFirstIndent
);
493 m_indentLeft
->SetValue(wxEmptyString
);
494 m_indentLeftFirst
->SetValue(wxEmptyString
);
497 if (attr
->HasRightIndent())
499 wxString
rightIndent(wxString::Format(wxT("%ld"), attr
->GetRightIndent()));
501 m_indentRight
->SetValue(rightIndent
);
504 m_indentRight
->SetValue(wxEmptyString
);
506 if (attr
->HasParagraphSpacingAfter())
508 wxString
spacingAfter(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingAfter()));
510 m_spacingAfter
->SetValue(spacingAfter
);
513 m_spacingAfter
->SetValue(wxEmptyString
);
515 if (attr
->HasParagraphSpacingBefore())
517 wxString
spacingBefore(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingBefore()));
519 m_spacingBefore
->SetValue(spacingBefore
);
522 m_spacingBefore
->SetValue(wxEmptyString
);
524 if (attr
->HasLineSpacing())
528 int lineSpacing
= attr
->GetLineSpacing();
529 if (lineSpacing
>= 10 && lineSpacing
<= 20)
530 index
= (lineSpacing
- 10) + 1;
534 m_spacingLine
->SetSelection(index
);
537 m_spacingLine
->SetSelection(0);
539 if (attr
->HasOutlineLevel())
541 int outlineLevel
= attr
->GetOutlineLevel();
542 if (outlineLevel
< 0)
544 if (outlineLevel
> 9)
547 m_outlineLevelCtrl
->SetSelection(outlineLevel
+1);
550 m_outlineLevelCtrl
->SetSelection(0);
552 m_pageBreakCtrl
->SetValue(attr
->HasPageBreak());
556 m_dontUpdate
= false;
563 * Should we show tooltips?
566 bool wxRichTextIndentsSpacingPage::ShowToolTips()
568 return wxRichTextFormattingDialog::ShowToolTips();
572 * Get bitmap resources
575 wxBitmap
wxRichTextIndentsSpacingPage::GetBitmapResource( const wxString
& name
)
578 ////@begin wxRichTextIndentsSpacingPage bitmap retrieval
581 ////@end wxRichTextIndentsSpacingPage bitmap retrieval
588 wxIcon
wxRichTextIndentsSpacingPage::GetIconResource( const wxString
& name
)
591 ////@begin wxRichTextIndentsSpacingPage icon retrieval
594 ////@end wxRichTextIndentsSpacingPage icon retrieval
597 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
600 void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent
& WXUNUSED(event
) )
608 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
611 void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent
& WXUNUSED(event
) )
619 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
622 void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent
& WXUNUSED(event
) )
630 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
633 void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent
& WXUNUSED(event
) )
641 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
644 void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent
& WXUNUSED(event
) )
652 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
655 void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent
& WXUNUSED(event
) )
663 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
666 void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent
& WXUNUSED(event
) )
674 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
677 void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent
& WXUNUSED(event
) )
685 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
688 void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent
& WXUNUSED(event
) )
696 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
699 void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent
& WXUNUSED(event
) )
706 * wxEVT_COMBOBOX event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
709 void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent
& WXUNUSED(event
) )
716 * wxEVT_COMBOBOX event handler for ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
719 void wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected( wxCommandEvent
& WXUNUSED(event
) )
725 #endif // wxUSE_RICHTEXT