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
)
30 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
, wxRichTextIndentsSpacingPage::OnAlignmentRightSelected
)
31 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
, wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected
)
32 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
, wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected
)
33 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
, wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected
)
34 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
, wxRichTextIndentsSpacingPage::OnIndentLeftUpdated
)
35 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
, wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated
)
36 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
, wxRichTextIndentsSpacingPage::OnIndentRightUpdated
)
37 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
, wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected
)
38 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
, wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated
)
39 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
, wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated
)
40 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, wxRichTextIndentsSpacingPage::OnSpacingLineSelected
)
41 ////@end wxRichTextIndentsSpacingPage event table entries
45 IMPLEMENT_HELP_PROVISION(wxRichTextIndentsSpacingPage
)
48 * wxRichTextIndentsSpacingPage constructors
51 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( )
56 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
59 Create(parent
, id
, pos
, size
, style
);
66 void wxRichTextIndentsSpacingPage::Init()
70 ////@begin wxRichTextIndentsSpacingPage member initialisation
71 m_alignmentLeft
= NULL
;
72 m_alignmentRight
= NULL
;
73 m_alignmentJustified
= NULL
;
74 m_alignmentCentred
= NULL
;
75 m_alignmentIndeterminate
= NULL
;
77 m_indentLeftFirst
= NULL
;
79 m_outlineLevelCtrl
= NULL
;
80 m_spacingBefore
= NULL
;
81 m_spacingAfter
= NULL
;
83 m_pageBreakCtrl
= NULL
;
85 ////@end wxRichTextIndentsSpacingPage member initialisation
90 * wxRichTextIndentsSpacingPage creator
93 bool wxRichTextIndentsSpacingPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
95 ////@begin wxRichTextIndentsSpacingPage creation
96 wxRichTextDialogPage::Create( parent
, id
, pos
, size
, style
);
101 GetSizer()->SetSizeHints(this);
104 ////@end wxRichTextIndentsSpacingPage creation
109 * Control creation for wxRichTextIndentsSpacingPage
112 void wxRichTextIndentsSpacingPage::CreateControls()
114 ////@begin wxRichTextIndentsSpacingPage content construction
115 wxRichTextIndentsSpacingPage
* itemRichTextDialogPage1
= this;
117 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
118 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
120 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
121 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
123 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
124 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
126 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
127 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
129 wxStaticText
* itemStaticText6
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Alignment"), wxDefaultPosition
, wxDefaultSize
, 0 );
130 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
132 wxBoxSizer
* itemBoxSizer7
= new wxBoxSizer(wxHORIZONTAL
);
133 itemBoxSizer5
->Add(itemBoxSizer7
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
135 itemBoxSizer7
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
137 wxBoxSizer
* itemBoxSizer9
= new wxBoxSizer(wxVERTICAL
);
138 itemBoxSizer7
->Add(itemBoxSizer9
, 0, wxALIGN_CENTER_VERTICAL
|wxTOP
, 5);
140 m_alignmentLeft
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
, _("&Left"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
141 m_alignmentLeft
->SetValue(false);
142 m_alignmentLeft
->SetHelpText(_("Left-align text."));
143 if (wxRichTextIndentsSpacingPage::ShowToolTips())
144 m_alignmentLeft
->SetToolTip(_("Left-align text."));
145 itemBoxSizer9
->Add(m_alignmentLeft
, 0, wxALIGN_LEFT
|wxALL
, 5);
147 m_alignmentRight
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
, _("&Right"), wxDefaultPosition
, wxDefaultSize
, 0 );
148 m_alignmentRight
->SetValue(false);
149 m_alignmentRight
->SetHelpText(_("Right-align text."));
150 if (wxRichTextIndentsSpacingPage::ShowToolTips())
151 m_alignmentRight
->SetToolTip(_("Right-align text."));
152 itemBoxSizer9
->Add(m_alignmentRight
, 0, wxALIGN_LEFT
|wxALL
, 5);
154 m_alignmentJustified
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
, _("&Justified"), wxDefaultPosition
, wxDefaultSize
, 0 );
155 m_alignmentJustified
->SetValue(false);
156 m_alignmentJustified
->SetHelpText(_("Justify text left and right."));
157 if (wxRichTextIndentsSpacingPage::ShowToolTips())
158 m_alignmentJustified
->SetToolTip(_("Justify text left and right."));
159 itemBoxSizer9
->Add(m_alignmentJustified
, 0, wxALIGN_LEFT
|wxALL
, 5);
161 m_alignmentCentred
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
, _("Cen&tred"), wxDefaultPosition
, wxDefaultSize
, 0 );
162 m_alignmentCentred
->SetValue(false);
163 m_alignmentCentred
->SetHelpText(_("Centre text."));
164 if (wxRichTextIndentsSpacingPage::ShowToolTips())
165 m_alignmentCentred
->SetToolTip(_("Centre text."));
166 itemBoxSizer9
->Add(m_alignmentCentred
, 0, wxALIGN_LEFT
|wxALL
, 5);
168 m_alignmentIndeterminate
= new wxRadioButton( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
, _("&Indeterminate"), wxDefaultPosition
, wxDefaultSize
, 0 );
169 m_alignmentIndeterminate
->SetValue(false);
170 m_alignmentIndeterminate
->SetHelpText(_("Use the current alignment setting."));
171 if (wxRichTextIndentsSpacingPage::ShowToolTips())
172 m_alignmentIndeterminate
->SetToolTip(_("Use the current alignment setting."));
173 itemBoxSizer9
->Add(m_alignmentIndeterminate
, 0, wxALIGN_LEFT
|wxALL
, 5);
175 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
177 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
178 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxBOTTOM
, 5);
180 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
182 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
183 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
185 wxStaticText
* itemStaticText19
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Indentation (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
186 itemBoxSizer18
->Add(itemStaticText19
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
188 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
189 itemBoxSizer18
->Add(itemBoxSizer20
, 0, wxALIGN_LEFT
|wxALL
, 5);
191 itemBoxSizer20
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
193 wxFlexGridSizer
* itemFlexGridSizer22
= new wxFlexGridSizer(0, 2, 0, 0);
194 itemBoxSizer20
->Add(itemFlexGridSizer22
, 0, wxALIGN_CENTER_VERTICAL
, 5);
196 wxStaticText
* itemStaticText23
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Left:"), wxDefaultPosition
, wxDefaultSize
, 0 );
197 itemFlexGridSizer22
->Add(itemStaticText23
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
199 m_indentLeft
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
200 m_indentLeft
->SetHelpText(_("The left indent."));
201 if (wxRichTextIndentsSpacingPage::ShowToolTips())
202 m_indentLeft
->SetToolTip(_("The left indent."));
203 itemFlexGridSizer22
->Add(m_indentLeft
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
205 wxStaticText
* itemStaticText25
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Left (&first line):"), wxDefaultPosition
, wxDefaultSize
, 0 );
206 itemFlexGridSizer22
->Add(itemStaticText25
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
208 m_indentLeftFirst
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
209 m_indentLeftFirst
->SetHelpText(_("The first line indent."));
210 if (wxRichTextIndentsSpacingPage::ShowToolTips())
211 m_indentLeftFirst
->SetToolTip(_("The first line indent."));
212 itemFlexGridSizer22
->Add(m_indentLeftFirst
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
214 wxStaticText
* itemStaticText27
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Right:"), wxDefaultPosition
, wxDefaultSize
, 0 );
215 itemFlexGridSizer22
->Add(itemStaticText27
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
217 m_indentRight
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
218 m_indentRight
->SetHelpText(_("The right indent."));
219 if (wxRichTextIndentsSpacingPage::ShowToolTips())
220 m_indentRight
->SetToolTip(_("The right indent."));
221 itemFlexGridSizer22
->Add(m_indentRight
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
223 wxStaticText
* itemStaticText29
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Outline level:"), wxDefaultPosition
, wxDefaultSize
, 0 );
224 itemFlexGridSizer22
->Add(itemStaticText29
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
226 wxArrayString m_outlineLevelCtrlStrings
;
227 m_outlineLevelCtrl
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
, wxEmptyString
, wxDefaultPosition
, wxSize(85, -1), m_outlineLevelCtrlStrings
, wxCB_READONLY
);
228 m_outlineLevelCtrl
->SetHelpText(_("The outline level."));
229 if (wxRichTextIndentsSpacingPage::ShowToolTips())
230 m_outlineLevelCtrl
->SetToolTip(_("The outline level."));
231 itemFlexGridSizer22
->Add(m_outlineLevelCtrl
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
233 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
235 wxStaticLine
* itemStaticLine32
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
236 itemBoxSizer4
->Add(itemStaticLine32
, 0, wxGROW
|wxTOP
|wxBOTTOM
, 5);
238 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
240 wxBoxSizer
* itemBoxSizer34
= new wxBoxSizer(wxVERTICAL
);
241 itemBoxSizer4
->Add(itemBoxSizer34
, 0, wxGROW
, 5);
243 wxStaticText
* itemStaticText35
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Spacing (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
244 itemBoxSizer34
->Add(itemStaticText35
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
246 wxBoxSizer
* itemBoxSizer36
= new wxBoxSizer(wxHORIZONTAL
);
247 itemBoxSizer34
->Add(itemBoxSizer36
, 0, wxALIGN_LEFT
|wxALL
, 5);
249 itemBoxSizer36
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
251 wxFlexGridSizer
* itemFlexGridSizer38
= new wxFlexGridSizer(30, 2, 0, 0);
252 itemBoxSizer36
->Add(itemFlexGridSizer38
, 0, wxALIGN_CENTER_VERTICAL
, 5);
254 wxStaticText
* itemStaticText39
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Before a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
255 itemFlexGridSizer38
->Add(itemStaticText39
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
257 m_spacingBefore
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
258 m_spacingBefore
->SetHelpText(_("The spacing before the paragraph."));
259 if (wxRichTextIndentsSpacingPage::ShowToolTips())
260 m_spacingBefore
->SetToolTip(_("The spacing before the paragraph."));
261 itemFlexGridSizer38
->Add(m_spacingBefore
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
263 wxStaticText
* itemStaticText41
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&After a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
264 itemFlexGridSizer38
->Add(itemStaticText41
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
266 m_spacingAfter
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
267 if (wxRichTextIndentsSpacingPage::ShowToolTips())
268 m_spacingAfter
->SetToolTip(_("The spacing after the paragraph."));
269 itemFlexGridSizer38
->Add(m_spacingAfter
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
271 wxStaticText
* itemStaticText43
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("L&ine spacing:"), wxDefaultPosition
, wxDefaultSize
, 0 );
272 itemFlexGridSizer38
->Add(itemStaticText43
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
274 wxArrayString m_spacingLineStrings
;
275 m_spacingLineStrings
.Add(_("(none)"));
276 m_spacingLineStrings
.Add(_("Single"));
277 m_spacingLineStrings
.Add(_("1.1"));
278 m_spacingLineStrings
.Add(_("1.2"));
279 m_spacingLineStrings
.Add(_("1.3"));
280 m_spacingLineStrings
.Add(_("1.4"));
281 m_spacingLineStrings
.Add(_("1.5"));
282 m_spacingLineStrings
.Add(_("1.6"));
283 m_spacingLineStrings
.Add(_("1.7"));
284 m_spacingLineStrings
.Add(_("1.8"));
285 m_spacingLineStrings
.Add(_("1.9"));
286 m_spacingLineStrings
.Add(_("2"));
287 m_spacingLine
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, _("(none)"), wxDefaultPosition
, wxSize(85, -1), m_spacingLineStrings
, wxCB_READONLY
);
288 m_spacingLine
->SetStringSelection(_("(none)"));
289 m_spacingLine
->SetHelpText(_("The line spacing."));
290 if (wxRichTextIndentsSpacingPage::ShowToolTips())
291 m_spacingLine
->SetToolTip(_("The line spacing."));
292 itemFlexGridSizer38
->Add(m_spacingLine
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
294 m_pageBreakCtrl
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_PAGEBREAK
, _("&Page Break"), wxDefaultPosition
, wxDefaultSize
, 0 );
295 m_pageBreakCtrl
->SetValue(false);
296 m_pageBreakCtrl
->SetHelpText(_("Inserts a page break before the paragraph."));
297 if (wxRichTextIndentsSpacingPage::ShowToolTips())
298 m_pageBreakCtrl
->SetToolTip(_("Inserts a page break before the paragraph."));
299 itemBoxSizer34
->Add(m_pageBreakCtrl
, 0, wxALIGN_LEFT
|wxALL
, 5);
301 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
303 m_previewCtrl
= new wxRichTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 100), wxBORDER_THEME
|wxVSCROLL
|wxTE_READONLY
);
304 m_previewCtrl
->SetHelpText(_("Shows a preview of the paragraph settings."));
305 if (wxRichTextIndentsSpacingPage::ShowToolTips())
306 m_previewCtrl
->SetToolTip(_("Shows a preview of the paragraph settings."));
307 itemBoxSizer3
->Add(m_previewCtrl
, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
309 ////@end wxRichTextIndentsSpacingPage content construction
311 wxArrayString outlineLevelCtrlStrings
;
312 outlineLevelCtrlStrings
.Add(_("(none)"));
313 outlineLevelCtrlStrings
.Add("1");
314 outlineLevelCtrlStrings
.Add("2");
315 outlineLevelCtrlStrings
.Add("3");
316 outlineLevelCtrlStrings
.Add("4");
317 outlineLevelCtrlStrings
.Add("5");
318 outlineLevelCtrlStrings
.Add("6");
319 outlineLevelCtrlStrings
.Add("7");
320 outlineLevelCtrlStrings
.Add("8");
321 outlineLevelCtrlStrings
.Add("9");
322 outlineLevelCtrlStrings
.Add("10");
324 m_outlineLevelCtrl
->Freeze();
325 m_outlineLevelCtrl
->Append(outlineLevelCtrlStrings
);
326 m_outlineLevelCtrl
->Thaw();
327 m_outlineLevelCtrl
->SetStringSelection(_("(none)"));
330 wxRichTextAttr
* wxRichTextIndentsSpacingPage::GetAttributes()
332 return wxRichTextFormattingDialog::GetDialogAttributes(this);
335 /// Updates the font preview
336 void wxRichTextIndentsSpacingPage::UpdatePreview()
338 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
339 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n");
341 static const wxChar
* s_para2
= wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \
342 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n");
344 static const wxChar
* s_para3
= wxT("Integer convallis dolor at augue \
345 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
347 TransferDataFromWindow();
348 wxRichTextAttr
attr(*GetAttributes());
349 attr
.SetFlags(attr
.GetFlags() &
350 (wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
351 wxTEXT_ATTR_LINE_SPACING
|
352 wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
));
354 wxFont
font(m_previewCtrl
->GetFont());
355 font
.SetPointSize(9);
356 m_previewCtrl
->SetFont(font
);
358 wxRichTextAttr normalParaAttr
;
359 normalParaAttr
.SetFont(font
);
360 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
362 m_previewCtrl
->Freeze();
363 m_previewCtrl
->Clear();
365 m_previewCtrl
->BeginStyle(normalParaAttr
);
366 m_previewCtrl
->WriteText(s_para1
);
367 m_previewCtrl
->EndStyle();
369 m_previewCtrl
->BeginStyle(attr
);
370 m_previewCtrl
->WriteText(s_para2
);
371 m_previewCtrl
->EndStyle();
373 m_previewCtrl
->BeginStyle(normalParaAttr
);
374 m_previewCtrl
->WriteText(s_para3
);
375 m_previewCtrl
->EndStyle();
377 m_previewCtrl
->Thaw();
380 /// Transfer data from/to window
381 bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
383 wxPanel::TransferDataFromWindow();
385 wxRichTextAttr
* attr
= GetAttributes();
387 if (m_alignmentLeft
->GetValue())
388 attr
->SetAlignment(wxTEXT_ALIGNMENT_LEFT
);
389 else if (m_alignmentCentred
->GetValue())
390 attr
->SetAlignment(wxTEXT_ALIGNMENT_CENTRE
);
391 else if (m_alignmentRight
->GetValue())
392 attr
->SetAlignment(wxTEXT_ALIGNMENT_RIGHT
);
393 else if (m_alignmentJustified
->GetValue())
394 attr
->SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED
);
397 attr
->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT
);
398 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT
));
401 wxString
leftIndent(m_indentLeft
->GetValue());
402 wxString
leftFirstIndent(m_indentLeftFirst
->GetValue());
403 if (!leftIndent
.empty() || !leftFirstIndent
.empty())
405 int visualLeftIndent
= 0;
406 if (!leftIndent
.empty())
407 visualLeftIndent
= wxAtoi(leftIndent
);
409 int visualLeftFirstIndent
= wxAtoi(leftFirstIndent
);
410 int actualLeftIndent
= visualLeftFirstIndent
;
411 int actualLeftSubIndent
= visualLeftIndent
- visualLeftFirstIndent
;
413 attr
->SetLeftIndent(actualLeftIndent
, actualLeftSubIndent
);
416 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT
));
418 wxString
rightIndent(m_indentRight
->GetValue());
419 if (!rightIndent
.empty())
420 attr
->SetRightIndent(wxAtoi(rightIndent
));
422 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT
));
424 wxString
spacingAfter(m_spacingAfter
->GetValue());
425 if (!spacingAfter
.empty())
426 attr
->SetParagraphSpacingAfter(wxAtoi(spacingAfter
));
428 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER
));
430 wxString
spacingBefore(m_spacingBefore
->GetValue());
431 if (!spacingBefore
.empty())
432 attr
->SetParagraphSpacingBefore(wxAtoi(spacingBefore
));
434 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE
));
436 int spacingIndex
= m_spacingLine
->GetSelection() - 1;
438 if (spacingIndex
> -1)
439 lineSpacing
= 10 + spacingIndex
;
441 if (lineSpacing
== 0)
442 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING
));
444 attr
->SetLineSpacing(lineSpacing
);
446 int outlineLevel
= m_outlineLevelCtrl
->GetSelection();
447 if (outlineLevel
== wxNOT_FOUND
|| outlineLevel
== 0)
449 attr
->SetOutlineLevel(-1);
450 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_OUTLINE_LEVEL
));
453 attr
->SetOutlineLevel(outlineLevel
-1);
455 attr
->SetPageBreak(m_pageBreakCtrl
->GetValue());
460 bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
464 wxPanel::TransferDataToWindow();
466 wxRichTextAttr
* attr
= GetAttributes();
468 if (attr
->HasAlignment())
470 if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_LEFT
)
471 m_alignmentLeft
->SetValue(true);
472 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_RIGHT
)
473 m_alignmentRight
->SetValue(true);
474 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_CENTRE
)
475 m_alignmentCentred
->SetValue(true);
476 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_JUSTIFIED
)
477 m_alignmentJustified
->SetValue(true);
479 m_alignmentIndeterminate
->SetValue(true);
482 m_alignmentIndeterminate
->SetValue(true);
484 if (attr
->HasLeftIndent())
486 wxString
leftIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent() + attr
->GetLeftSubIndent()));
487 wxString
leftFirstIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent()));
489 m_indentLeft
->SetValue(leftIndent
);
490 m_indentLeftFirst
->SetValue(leftFirstIndent
);
494 m_indentLeft
->SetValue(wxEmptyString
);
495 m_indentLeftFirst
->SetValue(wxEmptyString
);
498 if (attr
->HasRightIndent())
500 wxString
rightIndent(wxString::Format(wxT("%ld"), attr
->GetRightIndent()));
502 m_indentRight
->SetValue(rightIndent
);
505 m_indentRight
->SetValue(wxEmptyString
);
507 if (attr
->HasParagraphSpacingAfter())
509 wxString
spacingAfter(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingAfter()));
511 m_spacingAfter
->SetValue(spacingAfter
);
514 m_spacingAfter
->SetValue(wxEmptyString
);
516 if (attr
->HasParagraphSpacingBefore())
518 wxString
spacingBefore(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingBefore()));
520 m_spacingBefore
->SetValue(spacingBefore
);
523 m_spacingBefore
->SetValue(wxEmptyString
);
525 if (attr
->HasLineSpacing())
529 int lineSpacing
= attr
->GetLineSpacing();
530 if (lineSpacing
>= 10 && lineSpacing
<= 20)
531 index
= (lineSpacing
- 10) + 1;
535 m_spacingLine
->SetSelection(index
);
538 m_spacingLine
->SetSelection(0);
540 if (attr
->HasOutlineLevel())
542 int outlineLevel
= attr
->GetOutlineLevel();
543 if (outlineLevel
< 0)
545 if (outlineLevel
> 9)
548 m_outlineLevelCtrl
->SetSelection(outlineLevel
+1);
551 m_outlineLevelCtrl
->SetSelection(0);
553 m_pageBreakCtrl
->SetValue(attr
->HasPageBreak());
557 m_dontUpdate
= false;
564 * Should we show tooltips?
567 bool wxRichTextIndentsSpacingPage::ShowToolTips()
569 return wxRichTextFormattingDialog::ShowToolTips();
573 * Get bitmap resources
576 wxBitmap
wxRichTextIndentsSpacingPage::GetBitmapResource( const wxString
& name
)
579 ////@begin wxRichTextIndentsSpacingPage bitmap retrieval
582 ////@end wxRichTextIndentsSpacingPage bitmap retrieval
589 wxIcon
wxRichTextIndentsSpacingPage::GetIconResource( const wxString
& name
)
592 ////@begin wxRichTextIndentsSpacingPage icon retrieval
595 ////@end wxRichTextIndentsSpacingPage icon retrieval
598 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
601 void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent
& WXUNUSED(event
) )
609 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
612 void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent
& WXUNUSED(event
) )
620 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
623 void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent
& WXUNUSED(event
) )
631 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
634 void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent
& WXUNUSED(event
) )
642 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
645 void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent
& WXUNUSED(event
) )
653 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
656 void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent
& WXUNUSED(event
) )
664 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
667 void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent
& WXUNUSED(event
) )
675 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
678 void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent
& WXUNUSED(event
) )
686 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
689 void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent
& WXUNUSED(event
) )
697 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
700 void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent
& WXUNUSED(event
) )
707 * wxEVT_COMBOBOX event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
710 void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent
& WXUNUSED(event
) )
717 * wxEVT_COMBOBOX event handler for ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
720 void wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected( wxCommandEvent
& WXUNUSED(event
) )
726 #endif // wxUSE_RICHTEXT