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
, wxPanel
)
23 * wxRichTextIndentsSpacingPage event table definition
26 BEGIN_EVENT_TABLE( wxRichTextIndentsSpacingPage
, wxPanel
)
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
58 * wxRichTextIndentsSpacingPage constructors
61 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( )
66 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
69 Create(parent
, id
, pos
, size
, style
);
76 void wxRichTextIndentsSpacingPage::Init()
80 ////@begin wxRichTextIndentsSpacingPage member initialisation
81 m_alignmentLeft
= NULL
;
82 m_alignmentRight
= NULL
;
83 m_alignmentJustified
= NULL
;
84 m_alignmentCentred
= NULL
;
85 m_alignmentIndeterminate
= NULL
;
87 m_indentLeftFirst
= NULL
;
89 m_outlineLevelCtrl
= NULL
;
90 m_spacingBefore
= NULL
;
91 m_spacingAfter
= NULL
;
94 ////@end wxRichTextIndentsSpacingPage member initialisation
99 * wxRichTextIndentsSpacingPage creator
102 bool wxRichTextIndentsSpacingPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
104 ////@begin wxRichTextIndentsSpacingPage creation
105 wxPanel::Create( parent
, id
, pos
, size
, style
);
110 GetSizer()->SetSizeHints(this);
113 ////@end wxRichTextIndentsSpacingPage creation
118 * Control creation for wxRichTextIndentsSpacingPage
121 void wxRichTextIndentsSpacingPage::CreateControls()
123 ////@begin wxRichTextIndentsSpacingPage content construction
124 wxRichTextIndentsSpacingPage
* itemPanel1
= this;
126 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
127 itemPanel1
->SetSizer(itemBoxSizer2
);
129 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
130 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
132 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
133 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
135 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
136 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
138 wxStaticText
* itemStaticText6
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Alignment"), wxDefaultPosition
, wxDefaultSize
, 0 );
139 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
141 wxBoxSizer
* itemBoxSizer7
= new wxBoxSizer(wxHORIZONTAL
);
142 itemBoxSizer5
->Add(itemBoxSizer7
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
144 itemBoxSizer7
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
146 wxBoxSizer
* itemBoxSizer9
= new wxBoxSizer(wxVERTICAL
);
147 itemBoxSizer7
->Add(itemBoxSizer9
, 0, wxALIGN_CENTER_VERTICAL
|wxTOP
, 5);
149 m_alignmentLeft
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
, _("&Left"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
150 m_alignmentLeft
->SetValue(false);
151 m_alignmentLeft
->SetHelpText(_("Left-align text."));
152 if (wxRichTextIndentsSpacingPage::ShowToolTips())
153 m_alignmentLeft
->SetToolTip(_("Left-align text."));
154 itemBoxSizer9
->Add(m_alignmentLeft
, 0, wxALIGN_LEFT
|wxALL
, 5);
156 m_alignmentRight
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
, _("&Right"), wxDefaultPosition
, wxDefaultSize
, 0 );
157 m_alignmentRight
->SetValue(false);
158 m_alignmentRight
->SetHelpText(_("Right-align text."));
159 if (wxRichTextIndentsSpacingPage::ShowToolTips())
160 m_alignmentRight
->SetToolTip(_("Right-align text."));
161 itemBoxSizer9
->Add(m_alignmentRight
, 0, wxALIGN_LEFT
|wxALL
, 5);
163 m_alignmentJustified
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
, _("&Justified"), wxDefaultPosition
, wxDefaultSize
, 0 );
164 m_alignmentJustified
->SetValue(false);
165 m_alignmentJustified
->SetHelpText(_("Justify text left and right."));
166 if (wxRichTextIndentsSpacingPage::ShowToolTips())
167 m_alignmentJustified
->SetToolTip(_("Justify text left and right."));
168 itemBoxSizer9
->Add(m_alignmentJustified
, 0, wxALIGN_LEFT
|wxALL
, 5);
170 m_alignmentCentred
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
, _("Cen&tred"), wxDefaultPosition
, wxDefaultSize
, 0 );
171 m_alignmentCentred
->SetValue(false);
172 m_alignmentCentred
->SetHelpText(_("Centre text."));
173 if (wxRichTextIndentsSpacingPage::ShowToolTips())
174 m_alignmentCentred
->SetToolTip(_("Centre text."));
175 itemBoxSizer9
->Add(m_alignmentCentred
, 0, wxALIGN_LEFT
|wxALL
, 5);
177 m_alignmentIndeterminate
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
, _("&Indeterminate"), wxDefaultPosition
, wxDefaultSize
, 0 );
178 m_alignmentIndeterminate
->SetValue(false);
179 m_alignmentIndeterminate
->SetHelpText(_("Use the current alignment setting."));
180 if (wxRichTextIndentsSpacingPage::ShowToolTips())
181 m_alignmentIndeterminate
->SetToolTip(_("Use the current alignment setting."));
182 itemBoxSizer9
->Add(m_alignmentIndeterminate
, 0, wxALIGN_LEFT
|wxALL
, 5);
184 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
186 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemPanel1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
187 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxBOTTOM
, 5);
189 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
191 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
192 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
194 wxStaticText
* itemStaticText19
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Indentation (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
195 itemBoxSizer18
->Add(itemStaticText19
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
197 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
198 itemBoxSizer18
->Add(itemBoxSizer20
, 0, wxALIGN_LEFT
|wxALL
, 5);
200 itemBoxSizer20
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
202 wxFlexGridSizer
* itemFlexGridSizer22
= new wxFlexGridSizer(4, 2, 0, 0);
203 itemBoxSizer20
->Add(itemFlexGridSizer22
, 0, wxALIGN_CENTER_VERTICAL
, 5);
205 wxStaticText
* itemStaticText23
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Left:"), wxDefaultPosition
, wxDefaultSize
, 0 );
206 itemFlexGridSizer22
->Add(itemStaticText23
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
208 wxBoxSizer
* itemBoxSizer24
= new wxBoxSizer(wxHORIZONTAL
);
209 itemFlexGridSizer22
->Add(itemBoxSizer24
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5);
211 m_indentLeft
= new wxTextCtrl( itemPanel1
, 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 itemBoxSizer24
->Add(m_indentLeft
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
217 wxStaticText
* itemStaticText26
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Left (&first line):"), wxDefaultPosition
, wxDefaultSize
, 0 );
218 itemFlexGridSizer22
->Add(itemStaticText26
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
220 wxBoxSizer
* itemBoxSizer27
= new wxBoxSizer(wxHORIZONTAL
);
221 itemFlexGridSizer22
->Add(itemBoxSizer27
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5);
223 m_indentLeftFirst
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
224 m_indentLeftFirst
->SetHelpText(_("The first line indent."));
225 if (wxRichTextIndentsSpacingPage::ShowToolTips())
226 m_indentLeftFirst
->SetToolTip(_("The first line indent."));
227 itemBoxSizer27
->Add(m_indentLeftFirst
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
229 wxStaticText
* itemStaticText29
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Right:"), wxDefaultPosition
, wxDefaultSize
, 0 );
230 itemFlexGridSizer22
->Add(itemStaticText29
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
232 wxBoxSizer
* itemBoxSizer30
= new wxBoxSizer(wxHORIZONTAL
);
233 itemFlexGridSizer22
->Add(itemBoxSizer30
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5);
235 m_indentRight
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
236 m_indentRight
->SetHelpText(_("The right indent."));
237 if (wxRichTextIndentsSpacingPage::ShowToolTips())
238 m_indentRight
->SetToolTip(_("The right indent."));
239 itemBoxSizer30
->Add(m_indentRight
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
241 wxStaticText
* itemStaticText32
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Outline level:"), wxDefaultPosition
, wxDefaultSize
, 0 );
242 itemFlexGridSizer22
->Add(itemStaticText32
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
244 wxArrayString m_outlineLevelCtrlStrings
;
245 m_outlineLevelCtrlStrings
.Add(_("Normal"));
246 m_outlineLevelCtrlStrings
.Add(_("1"));
247 m_outlineLevelCtrlStrings
.Add(_("2"));
248 m_outlineLevelCtrlStrings
.Add(_("3"));
249 m_outlineLevelCtrlStrings
.Add(_("4"));
250 m_outlineLevelCtrlStrings
.Add(_("5"));
251 m_outlineLevelCtrlStrings
.Add(_("6"));
252 m_outlineLevelCtrlStrings
.Add(_("7"));
253 m_outlineLevelCtrlStrings
.Add(_("8"));
254 m_outlineLevelCtrlStrings
.Add(_("9"));
255 m_outlineLevelCtrl
= new wxComboBox( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
, _("Normal"), wxDefaultPosition
, wxSize(90, -1), m_outlineLevelCtrlStrings
, wxCB_READONLY
);
256 m_outlineLevelCtrl
->SetStringSelection(_("Normal"));
257 m_outlineLevelCtrl
->SetHelpText(_("The outline level."));
258 if (wxRichTextIndentsSpacingPage::ShowToolTips())
259 m_outlineLevelCtrl
->SetToolTip(_("The outline level."));
260 itemFlexGridSizer22
->Add(m_outlineLevelCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
262 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
264 wxStaticLine
* itemStaticLine35
= new wxStaticLine( itemPanel1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
265 itemBoxSizer4
->Add(itemStaticLine35
, 0, wxGROW
|wxTOP
|wxBOTTOM
, 5);
267 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
269 wxBoxSizer
* itemBoxSizer37
= new wxBoxSizer(wxVERTICAL
);
270 itemBoxSizer4
->Add(itemBoxSizer37
, 0, wxGROW
, 5);
272 wxStaticText
* itemStaticText38
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Spacing (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
273 itemBoxSizer37
->Add(itemStaticText38
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
, 5);
275 wxBoxSizer
* itemBoxSizer39
= new wxBoxSizer(wxHORIZONTAL
);
276 itemBoxSizer37
->Add(itemBoxSizer39
, 0, wxALIGN_LEFT
|wxALL
, 5);
278 itemBoxSizer39
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
280 wxFlexGridSizer
* itemFlexGridSizer41
= new wxFlexGridSizer(3, 2, 0, 0);
281 itemFlexGridSizer41
->AddGrowableCol(1);
282 itemBoxSizer39
->Add(itemFlexGridSizer41
, 0, wxALIGN_CENTER_VERTICAL
, 5);
284 wxStaticText
* itemStaticText42
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Before a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
285 itemFlexGridSizer41
->Add(itemStaticText42
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
287 wxBoxSizer
* itemBoxSizer43
= new wxBoxSizer(wxHORIZONTAL
);
288 itemFlexGridSizer41
->Add(itemBoxSizer43
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5);
290 m_spacingBefore
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
291 m_spacingBefore
->SetHelpText(_("The spacing before the paragraph."));
292 if (wxRichTextIndentsSpacingPage::ShowToolTips())
293 m_spacingBefore
->SetToolTip(_("The spacing before the paragraph."));
294 itemBoxSizer43
->Add(m_spacingBefore
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
296 wxStaticText
* itemStaticText45
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&After a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
297 itemFlexGridSizer41
->Add(itemStaticText45
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
299 wxBoxSizer
* itemBoxSizer46
= new wxBoxSizer(wxHORIZONTAL
);
300 itemFlexGridSizer41
->Add(itemBoxSizer46
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5);
302 m_spacingAfter
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
303 if (wxRichTextIndentsSpacingPage::ShowToolTips())
304 m_spacingAfter
->SetToolTip(_("The spacing after the paragraph."));
305 itemBoxSizer46
->Add(m_spacingAfter
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
307 wxStaticText
* itemStaticText48
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("L&ine spacing:"), wxDefaultPosition
, wxDefaultSize
, 0 );
308 itemFlexGridSizer41
->Add(itemStaticText48
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
310 wxBoxSizer
* itemBoxSizer49
= new wxBoxSizer(wxHORIZONTAL
);
311 itemFlexGridSizer41
->Add(itemBoxSizer49
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5);
313 wxArrayString m_spacingLineStrings
;
314 m_spacingLineStrings
.Add(_("Single"));
315 m_spacingLineStrings
.Add(_("1.1"));
316 m_spacingLineStrings
.Add(_("1.2"));
317 m_spacingLineStrings
.Add(_("1.3"));
318 m_spacingLineStrings
.Add(_("1.4"));
319 m_spacingLineStrings
.Add(_("1.5"));
320 m_spacingLineStrings
.Add(_("1.6"));
321 m_spacingLineStrings
.Add(_("1.7"));
322 m_spacingLineStrings
.Add(_("1.8"));
323 m_spacingLineStrings
.Add(_("1.9"));
324 m_spacingLineStrings
.Add(_("2"));
325 m_spacingLine
= new wxComboBox( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, _("Single"), wxDefaultPosition
, wxSize(90, -1), m_spacingLineStrings
, wxCB_READONLY
);
326 m_spacingLine
->SetStringSelection(_("Single"));
327 m_spacingLine
->SetHelpText(_("The line spacing."));
328 if (wxRichTextIndentsSpacingPage::ShowToolTips())
329 m_spacingLine
->SetToolTip(_("The line spacing."));
330 itemBoxSizer49
->Add(m_spacingLine
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
332 itemBoxSizer3
->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
334 m_previewCtrl
= new wxRichTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 100), wxVSCROLL
|wxTE_READONLY
);
335 m_previewCtrl
->SetHelpText(_("Shows a preview of the paragraph settings."));
336 if (wxRichTextIndentsSpacingPage::ShowToolTips())
337 m_previewCtrl
->SetToolTip(_("Shows a preview of the paragraph settings."));
338 itemBoxSizer3
->Add(m_previewCtrl
, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
340 ////@end wxRichTextIndentsSpacingPage content construction
343 wxRichTextAttr
* wxRichTextIndentsSpacingPage::GetAttributes()
345 return wxRichTextFormattingDialog::GetDialogAttributes(this);
348 /// Updates the font preview
349 void wxRichTextIndentsSpacingPage::UpdatePreview()
351 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
352 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n");
354 static const wxChar
* s_para2
= wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \
355 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n");
357 static const wxChar
* s_para3
= wxT("Integer convallis dolor at augue \
358 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
360 TransferDataFromWindow();
361 wxRichTextAttr
attr(*GetAttributes());
362 attr
.SetFlags(attr
.GetFlags() &
363 (wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
364 wxTEXT_ATTR_LINE_SPACING
|
365 wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_TEXT
));
367 wxFont
font(m_previewCtrl
->GetFont());
368 font
.SetPointSize(9);
369 m_previewCtrl
->SetFont(font
);
371 wxRichTextAttr normalParaAttr
;
372 normalParaAttr
.SetFont(font
);
373 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
375 m_previewCtrl
->Freeze();
376 m_previewCtrl
->Clear();
378 m_previewCtrl
->BeginStyle(normalParaAttr
);
379 m_previewCtrl
->WriteText(s_para1
);
380 m_previewCtrl
->EndStyle();
382 m_previewCtrl
->BeginStyle(attr
);
383 m_previewCtrl
->WriteText(s_para2
);
384 m_previewCtrl
->EndStyle();
386 m_previewCtrl
->BeginStyle(normalParaAttr
);
387 m_previewCtrl
->WriteText(s_para3
);
388 m_previewCtrl
->EndStyle();
390 m_previewCtrl
->Thaw();
393 /// Transfer data from/to window
394 bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
396 wxPanel::TransferDataFromWindow();
398 wxRichTextAttr
* attr
= GetAttributes();
400 if (m_alignmentLeft
->GetValue())
401 attr
->SetAlignment(wxTEXT_ALIGNMENT_LEFT
);
402 else if (m_alignmentCentred
->GetValue())
403 attr
->SetAlignment(wxTEXT_ALIGNMENT_CENTRE
);
404 else if (m_alignmentRight
->GetValue())
405 attr
->SetAlignment(wxTEXT_ALIGNMENT_RIGHT
);
406 else if (m_alignmentJustified
->GetValue())
407 attr
->SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED
);
410 attr
->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT
);
411 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT
));
414 wxString
leftIndent(m_indentLeft
->GetValue());
415 wxString
leftFirstIndent(m_indentLeftFirst
->GetValue());
416 if (!leftIndent
.empty())
418 int visualLeftIndent
= wxAtoi(leftIndent
);
419 int visualLeftFirstIndent
= wxAtoi(leftFirstIndent
);
420 int actualLeftIndent
= visualLeftFirstIndent
;
421 int actualLeftSubIndent
= visualLeftIndent
- visualLeftFirstIndent
;
423 attr
->SetLeftIndent(actualLeftIndent
, actualLeftSubIndent
);
426 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT
));
428 wxString
rightIndent(m_indentRight
->GetValue());
429 if (!rightIndent
.empty())
430 attr
->SetRightIndent(wxAtoi(rightIndent
));
432 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT
));
434 wxString
spacingAfter(m_spacingAfter
->GetValue());
435 if (!spacingAfter
.empty())
436 attr
->SetParagraphSpacingAfter(wxAtoi(spacingAfter
));
438 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER
));
440 wxString
spacingBefore(m_spacingBefore
->GetValue());
441 if (!spacingBefore
.empty())
442 attr
->SetParagraphSpacingBefore(wxAtoi(spacingBefore
));
444 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE
));
446 int spacingIndex
= m_spacingLine
->GetSelection();
448 if (spacingIndex
!= -1)
449 lineSpacing
= 10 + spacingIndex
;
451 if (lineSpacing
== 0)
452 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING
));
454 attr
->SetLineSpacing(lineSpacing
);
456 int outlineLevel
= m_outlineLevelCtrl
->GetSelection();
457 if (outlineLevel
!= wxNOT_FOUND
)
458 attr
->SetOutlineLevel(outlineLevel
);
463 bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
467 wxPanel::TransferDataToWindow();
469 wxRichTextAttr
* attr
= GetAttributes();
471 if (attr
->HasAlignment())
473 if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_LEFT
)
474 m_alignmentLeft
->SetValue(true);
475 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_RIGHT
)
476 m_alignmentRight
->SetValue(true);
477 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_CENTRE
)
478 m_alignmentCentred
->SetValue(true);
479 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_JUSTIFIED
)
480 m_alignmentJustified
->SetValue(true);
482 m_alignmentIndeterminate
->SetValue(true);
485 m_alignmentIndeterminate
->SetValue(true);
487 if (attr
->HasLeftIndent())
489 wxString
leftIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent() + attr
->GetLeftSubIndent()));
490 wxString
leftFirstIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent()));
492 m_indentLeft
->SetValue(leftIndent
);
493 m_indentLeftFirst
->SetValue(leftFirstIndent
);
497 m_indentLeft
->SetValue(wxEmptyString
);
498 m_indentLeftFirst
->SetValue(wxEmptyString
);
501 if (attr
->HasRightIndent())
503 wxString
rightIndent(wxString::Format(wxT("%ld"), attr
->GetRightIndent()));
505 m_indentRight
->SetValue(rightIndent
);
508 m_indentRight
->SetValue(wxEmptyString
);
510 if (attr
->HasParagraphSpacingAfter())
512 wxString
spacingAfter(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingAfter()));
514 m_spacingAfter
->SetValue(spacingAfter
);
517 m_spacingAfter
->SetValue(wxEmptyString
);
519 if (attr
->HasParagraphSpacingBefore())
521 wxString
spacingBefore(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingBefore()));
523 m_spacingBefore
->SetValue(spacingBefore
);
526 m_spacingBefore
->SetValue(wxEmptyString
);
528 if (attr
->HasLineSpacing())
532 int lineSpacing
= attr
->GetLineSpacing();
533 if (lineSpacing
>= 10 && lineSpacing
<= 20)
534 index
= lineSpacing
- 10;
538 m_spacingLine
->SetSelection(index
);
541 m_spacingLine
->SetSelection(-1);
543 if (attr
->HasOutlineLevel())
545 int outlineLevel
= attr
->GetOutlineLevel();
546 if (outlineLevel
< 0)
548 if (outlineLevel
> 9)
551 m_outlineLevelCtrl
->SetSelection(outlineLevel
);
554 m_outlineLevelCtrl
->SetSelection(-1);
558 m_dontUpdate
= false;
565 * Should we show tooltips?
568 bool wxRichTextIndentsSpacingPage::ShowToolTips()
570 return wxRichTextFormattingDialog::ShowToolTips();
574 * Get bitmap resources
577 wxBitmap
wxRichTextIndentsSpacingPage::GetBitmapResource( const wxString
& name
)
580 ////@begin wxRichTextIndentsSpacingPage bitmap retrieval
583 ////@end wxRichTextIndentsSpacingPage bitmap retrieval
590 wxIcon
wxRichTextIndentsSpacingPage::GetIconResource( const wxString
& name
)
593 ////@begin wxRichTextIndentsSpacingPage icon retrieval
596 ////@end wxRichTextIndentsSpacingPage icon retrieval
599 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
602 void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent
& WXUNUSED(event
) )
610 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
613 void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent
& WXUNUSED(event
) )
621 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
624 void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent
& WXUNUSED(event
) )
632 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
635 void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent
& WXUNUSED(event
) )
643 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
646 void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent
& WXUNUSED(event
) )
654 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
657 void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent
& WXUNUSED(event
) )
665 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
668 void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent
& WXUNUSED(event
) )
676 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
679 void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent
& WXUNUSED(event
) )
687 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
690 void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent
& WXUNUSED(event
) )
698 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
701 void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent
& WXUNUSED(event
) )
708 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
711 void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent
& WXUNUSED(event
) )
718 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
721 void wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected( wxCommandEvent
& WXUNUSED(event
) )
727 #endif // wxUSE_RICHTEXT