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_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
, wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated
)
47 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
, wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated
)
49 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, wxRichTextIndentsSpacingPage::OnSpacingLineSelected
)
51 ////@end wxRichTextIndentsSpacingPage event table entries
56 * wxRichTextIndentsSpacingPage constructors
59 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( )
64 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
67 Create(parent
, id
, pos
, size
, style
);
74 void wxRichTextIndentsSpacingPage::Init()
78 ////@begin wxRichTextIndentsSpacingPage member initialisation
79 m_alignmentLeft
= NULL
;
80 m_alignmentRight
= NULL
;
81 m_alignmentJustified
= NULL
;
82 m_alignmentCentred
= NULL
;
83 m_alignmentIndeterminate
= NULL
;
85 m_indentLeftFirst
= NULL
;
87 m_spacingBefore
= NULL
;
88 m_spacingAfter
= NULL
;
91 ////@end wxRichTextIndentsSpacingPage member initialisation
96 * wxRichTextIndentsSpacingPage creator
99 bool wxRichTextIndentsSpacingPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
101 ////@begin wxRichTextIndentsSpacingPage creation
102 wxPanel::Create( parent
, id
, pos
, size
, style
);
107 GetSizer()->SetSizeHints(this);
110 ////@end wxRichTextIndentsSpacingPage creation
115 * Control creation for wxRichTextIndentsSpacingPage
118 void wxRichTextIndentsSpacingPage::CreateControls()
120 ////@begin wxRichTextIndentsSpacingPage content construction
121 wxRichTextIndentsSpacingPage
* itemPanel1
= this;
123 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
124 itemPanel1
->SetSizer(itemBoxSizer2
);
126 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
127 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
129 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
130 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
132 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
133 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
135 wxStaticText
* itemStaticText6
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Alignment"), wxDefaultPosition
, wxDefaultSize
, 0 );
136 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
138 wxBoxSizer
* itemBoxSizer7
= new wxBoxSizer(wxHORIZONTAL
);
139 itemBoxSizer5
->Add(itemBoxSizer7
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
141 itemBoxSizer7
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
143 wxBoxSizer
* itemBoxSizer9
= new wxBoxSizer(wxVERTICAL
);
144 itemBoxSizer7
->Add(itemBoxSizer9
, 0, wxALIGN_CENTER_VERTICAL
|wxTOP
, 5);
146 m_alignmentLeft
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
, _("&Left"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
147 m_alignmentLeft
->SetValue(false);
148 m_alignmentLeft
->SetHelpText(_("Left-align text."));
150 m_alignmentLeft
->SetToolTip(_("Left-align text."));
151 itemBoxSizer9
->Add(m_alignmentLeft
, 0, wxALIGN_LEFT
|wxALL
, 5);
153 m_alignmentRight
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
, _("&Right"), wxDefaultPosition
, wxDefaultSize
, 0 );
154 m_alignmentRight
->SetValue(false);
155 m_alignmentRight
->SetHelpText(_("Right-align text."));
157 m_alignmentRight
->SetToolTip(_("Right-align text."));
158 itemBoxSizer9
->Add(m_alignmentRight
, 0, wxALIGN_LEFT
|wxALL
, 5);
160 m_alignmentJustified
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
, _("&Justified"), wxDefaultPosition
, wxDefaultSize
, 0 );
161 m_alignmentJustified
->SetValue(false);
162 m_alignmentJustified
->SetHelpText(_("Justify text left and right."));
164 m_alignmentJustified
->SetToolTip(_("Justify text left and right."));
165 itemBoxSizer9
->Add(m_alignmentJustified
, 0, wxALIGN_LEFT
|wxALL
, 5);
167 m_alignmentCentred
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
, _("Cen&tred"), wxDefaultPosition
, wxDefaultSize
, 0 );
168 m_alignmentCentred
->SetValue(false);
169 m_alignmentCentred
->SetHelpText(_("Centre text."));
171 m_alignmentCentred
->SetToolTip(_("Centre text."));
172 itemBoxSizer9
->Add(m_alignmentCentred
, 0, wxALIGN_LEFT
|wxALL
, 5);
174 m_alignmentIndeterminate
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
, _("&Indeterminate"), wxDefaultPosition
, wxDefaultSize
, 0 );
175 m_alignmentIndeterminate
->SetValue(false);
176 m_alignmentIndeterminate
->SetHelpText(_("Use the current alignment setting."));
178 m_alignmentIndeterminate
->SetToolTip(_("Use the current alignment setting."));
179 itemBoxSizer9
->Add(m_alignmentIndeterminate
, 0, wxALIGN_LEFT
|wxALL
, 5);
181 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
183 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemPanel1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
184 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxBOTTOM
, 5);
186 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
188 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
189 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
191 wxStaticText
* itemStaticText19
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Indentation (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
192 itemBoxSizer18
->Add(itemStaticText19
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
194 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
195 itemBoxSizer18
->Add(itemBoxSizer20
, 0, wxALIGN_LEFT
|wxALL
, 5);
197 itemBoxSizer20
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
199 wxFlexGridSizer
* itemFlexGridSizer22
= new wxFlexGridSizer(2, 2, 0, 0);
200 itemBoxSizer20
->Add(itemFlexGridSizer22
, 0, wxALIGN_CENTER_VERTICAL
, 5);
202 wxStaticText
* itemStaticText23
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Left:"), wxDefaultPosition
, wxDefaultSize
, 0 );
203 itemFlexGridSizer22
->Add(itemStaticText23
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
205 wxBoxSizer
* itemBoxSizer24
= new wxBoxSizer(wxHORIZONTAL
);
206 itemFlexGridSizer22
->Add(itemBoxSizer24
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
208 m_indentLeft
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
209 m_indentLeft
->SetHelpText(_("The left indent."));
211 m_indentLeft
->SetToolTip(_("The left indent."));
212 itemBoxSizer24
->Add(m_indentLeft
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
214 wxStaticText
* itemStaticText26
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Left (&first line):"), wxDefaultPosition
, wxDefaultSize
, 0 );
215 itemFlexGridSizer22
->Add(itemStaticText26
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
217 wxBoxSizer
* itemBoxSizer27
= new wxBoxSizer(wxHORIZONTAL
);
218 itemFlexGridSizer22
->Add(itemBoxSizer27
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
220 m_indentLeftFirst
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
221 m_indentLeftFirst
->SetHelpText(_("The first line indent."));
223 m_indentLeftFirst
->SetToolTip(_("The first line indent."));
224 itemBoxSizer27
->Add(m_indentLeftFirst
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
226 wxStaticText
* itemStaticText29
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Right:"), wxDefaultPosition
, wxDefaultSize
, 0 );
227 itemFlexGridSizer22
->Add(itemStaticText29
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
229 wxBoxSizer
* itemBoxSizer30
= new wxBoxSizer(wxHORIZONTAL
);
230 itemFlexGridSizer22
->Add(itemBoxSizer30
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
232 m_indentRight
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
233 m_indentRight
->SetHelpText(_("The right indent."));
235 m_indentRight
->SetToolTip(_("The right indent."));
236 itemBoxSizer30
->Add(m_indentRight
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
238 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
240 wxStaticLine
* itemStaticLine33
= new wxStaticLine( itemPanel1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
241 itemBoxSizer4
->Add(itemStaticLine33
, 0, wxGROW
|wxTOP
|wxBOTTOM
, 5);
243 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
245 wxBoxSizer
* itemBoxSizer35
= new wxBoxSizer(wxVERTICAL
);
246 itemBoxSizer4
->Add(itemBoxSizer35
, 0, wxGROW
, 5);
248 wxStaticText
* itemStaticText36
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Spacing (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
249 itemBoxSizer35
->Add(itemStaticText36
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
251 wxBoxSizer
* itemBoxSizer37
= new wxBoxSizer(wxHORIZONTAL
);
252 itemBoxSizer35
->Add(itemBoxSizer37
, 0, wxALIGN_LEFT
|wxALL
, 5);
254 itemBoxSizer37
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
256 wxFlexGridSizer
* itemFlexGridSizer39
= new wxFlexGridSizer(2, 2, 0, 0);
257 itemBoxSizer37
->Add(itemFlexGridSizer39
, 0, wxALIGN_CENTER_VERTICAL
, 5);
259 wxStaticText
* itemStaticText40
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Before a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
260 itemFlexGridSizer39
->Add(itemStaticText40
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
262 wxBoxSizer
* itemBoxSizer41
= new wxBoxSizer(wxHORIZONTAL
);
263 itemFlexGridSizer39
->Add(itemBoxSizer41
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
265 m_spacingBefore
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
266 m_spacingBefore
->SetHelpText(_("The spacing before the paragraph."));
268 m_spacingBefore
->SetToolTip(_("The spacing before the paragraph."));
269 itemBoxSizer41
->Add(m_spacingBefore
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
271 wxStaticText
* itemStaticText43
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("After a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
272 itemFlexGridSizer39
->Add(itemStaticText43
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
274 wxBoxSizer
* itemBoxSizer44
= new wxBoxSizer(wxHORIZONTAL
);
275 itemFlexGridSizer39
->Add(itemBoxSizer44
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
277 m_spacingAfter
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
, wxEmptyString
, wxDefaultPosition
, wxSize(50, -1), 0 );
279 m_spacingAfter
->SetToolTip(_("The spacing after the paragraph."));
280 itemBoxSizer44
->Add(m_spacingAfter
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
282 wxStaticText
* itemStaticText46
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Line spacing:"), wxDefaultPosition
, wxDefaultSize
, 0 );
283 itemFlexGridSizer39
->Add(itemStaticText46
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
285 wxBoxSizer
* itemBoxSizer47
= new wxBoxSizer(wxHORIZONTAL
);
286 itemFlexGridSizer39
->Add(itemBoxSizer47
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
288 wxString m_spacingLineStrings
[] = {
293 m_spacingLine
= new wxComboBox( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, _("Single"), wxDefaultPosition
, wxDefaultSize
, 3, m_spacingLineStrings
, wxCB_READONLY
);
294 m_spacingLine
->SetStringSelection(_("Single"));
295 m_spacingLine
->SetHelpText(_("The line spacing."));
297 m_spacingLine
->SetToolTip(_("The line spacing."));
298 itemBoxSizer47
->Add(m_spacingLine
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
300 itemBoxSizer3
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
302 m_previewCtrl
= new wxRichTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 180), wxSUNKEN_BORDER
);
303 m_previewCtrl
->SetHelpText(_("Shows a preview of the paragraph settings."));
305 m_previewCtrl
->SetToolTip(_("Shows a preview of the paragraph settings."));
306 itemBoxSizer3
->Add(m_previewCtrl
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
308 ////@end wxRichTextIndentsSpacingPage content construction
311 wxTextAttrEx
* wxRichTextIndentsSpacingPage::GetAttributes()
313 return wxRichTextFormattingDialog::GetDialogAttributes(this);
316 /// Updates the font preview
317 void wxRichTextIndentsSpacingPage::UpdatePreview()
319 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
320 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.");
322 static const wxChar
* s_para2
= wxT("\nDuis pharetra consequat dui. Cum sociis natoque penatibus \
323 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.");
325 static const wxChar
* s_para3
= wxT("\nInteger convallis dolor at augue \
326 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
328 TransferDataFromWindow();
329 wxTextAttrEx
attr(*GetAttributes());
330 attr
.SetFlags(attr
.GetFlags() &
331 (wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
332 wxTEXT_ATTR_LINE_SPACING
|
333 wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_SYMBOL
));
335 wxFont
font(m_previewCtrl
->GetFont());
336 font
.SetPointSize(9);
337 m_previewCtrl
->SetFont(font
);
339 wxTextAttrEx normalParaAttr
;
340 normalParaAttr
.SetFont(font
);
341 normalParaAttr
.SetTextColour(wxColour(wxT("LIGHT GREY")));
343 m_previewCtrl
->Freeze();
344 m_previewCtrl
->Clear();
346 m_previewCtrl
->BeginStyle(normalParaAttr
);
347 m_previewCtrl
->WriteText(s_para1
);
348 m_previewCtrl
->EndStyle();
350 m_previewCtrl
->BeginStyle(attr
);
351 m_previewCtrl
->WriteText(s_para2
);
352 m_previewCtrl
->EndStyle();
354 m_previewCtrl
->BeginStyle(normalParaAttr
);
355 m_previewCtrl
->WriteText(s_para3
);
356 m_previewCtrl
->EndStyle();
358 m_previewCtrl
->Thaw();
361 /// Transfer data from/to window
362 bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
364 wxPanel::TransferDataFromWindow();
366 wxTextAttrEx
* attr
= GetAttributes();
368 if (m_alignmentLeft
->GetValue())
369 attr
->SetAlignment(wxTEXT_ALIGNMENT_LEFT
);
370 else if (m_alignmentCentred
->GetValue())
371 attr
->SetAlignment(wxTEXT_ALIGNMENT_CENTRE
);
372 else if (m_alignmentRight
->GetValue())
373 attr
->SetAlignment(wxTEXT_ALIGNMENT_RIGHT
);
374 else if (m_alignmentJustified
->GetValue())
375 attr
->SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED
);
378 attr
->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT
);
379 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT
));
382 wxString
leftIndent(m_indentLeft
->GetValue());
383 wxString
leftFirstIndent(m_indentLeftFirst
->GetValue());
384 if (!leftIndent
.empty())
386 int visualLeftIndent
= wxAtoi(leftIndent
);
387 int visualLeftFirstIndent
= wxAtoi(leftFirstIndent
);
388 int actualLeftIndent
= visualLeftFirstIndent
;
389 int actualLeftSubIndent
= visualLeftIndent
- visualLeftFirstIndent
;
391 attr
->SetLeftIndent(actualLeftIndent
, actualLeftSubIndent
);
394 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT
));
396 wxString
rightIndent(m_indentRight
->GetValue());
397 if (!rightIndent
.empty())
398 attr
->SetRightIndent(wxAtoi(rightIndent
));
400 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT
));
402 wxString
spacingAfter(m_spacingAfter
->GetValue());
403 if (!spacingAfter
.empty())
404 attr
->SetParagraphSpacingAfter(wxAtoi(spacingAfter
));
406 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER
));
408 wxString
spacingBefore(m_spacingBefore
->GetValue());
409 if (!spacingBefore
.empty())
410 attr
->SetParagraphSpacingBefore(wxAtoi(spacingBefore
));
412 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE
));
414 int spacingIndex
= m_spacingLine
->GetSelection();
416 if (spacingIndex
== 0)
418 else if (spacingIndex
== 1)
420 else if (spacingIndex
== 2)
423 if (lineSpacing
== 0)
424 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING
));
426 attr
->SetLineSpacing(lineSpacing
);
431 bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
435 wxPanel::TransferDataToWindow();
437 wxTextAttrEx
* attr
= GetAttributes();
439 if (attr
->HasAlignment())
441 if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_LEFT
)
442 m_alignmentLeft
->SetValue(true);
443 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_RIGHT
)
444 m_alignmentRight
->SetValue(true);
445 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_CENTRE
)
446 m_alignmentCentred
->SetValue(true);
447 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_JUSTIFIED
)
448 m_alignmentJustified
->SetValue(true);
450 m_alignmentIndeterminate
->SetValue(true);
453 m_alignmentIndeterminate
->SetValue(true);
455 if (attr
->HasLeftIndent())
457 wxString
leftIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent() + attr
->GetLeftSubIndent()));
458 wxString
leftFirstIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent()));
460 m_indentLeft
->SetValue(leftIndent
);
461 m_indentLeftFirst
->SetValue(leftFirstIndent
);
465 m_indentLeft
->SetValue(wxEmptyString
);
466 m_indentLeftFirst
->SetValue(wxEmptyString
);
469 if (attr
->HasRightIndent())
471 wxString
rightIndent(wxString::Format(wxT("%ld"), attr
->GetRightIndent()));
473 m_indentRight
->SetValue(rightIndent
);
476 m_indentRight
->SetValue(wxEmptyString
);
478 if (attr
->HasParagraphSpacingAfter())
480 wxString
spacingAfter(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingAfter()));
482 m_spacingAfter
->SetValue(spacingAfter
);
485 m_spacingAfter
->SetValue(wxEmptyString
);
487 if (attr
->HasParagraphSpacingBefore())
489 wxString
spacingBefore(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingBefore()));
491 m_spacingBefore
->SetValue(spacingBefore
);
494 m_spacingBefore
->SetValue(wxEmptyString
);
496 if (attr
->HasLineSpacing())
500 int lineSpacing
= attr
->GetLineSpacing();
501 if (lineSpacing
== 10)
503 else if (lineSpacing
== 15)
505 else if (lineSpacing
== 20)
510 m_spacingLine
->SetSelection(index
);
513 m_spacingLine
->SetSelection(-1);
517 m_dontUpdate
= false;
524 * Should we show tooltips?
527 bool wxRichTextIndentsSpacingPage::ShowToolTips()
529 return wxRichTextFormattingDialog::ShowToolTips();
533 * Get bitmap resources
536 wxBitmap
wxRichTextIndentsSpacingPage::GetBitmapResource( const wxString
& name
)
539 ////@begin wxRichTextIndentsSpacingPage bitmap retrieval
542 ////@end wxRichTextIndentsSpacingPage bitmap retrieval
549 wxIcon
wxRichTextIndentsSpacingPage::GetIconResource( const wxString
& name
)
552 ////@begin wxRichTextIndentsSpacingPage icon retrieval
555 ////@end wxRichTextIndentsSpacingPage icon retrieval
558 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
561 void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent
& WXUNUSED(event
) )
569 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
572 void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent
& WXUNUSED(event
) )
580 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
583 void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent
& WXUNUSED(event
) )
591 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
594 void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent
& WXUNUSED(event
) )
602 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
605 void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent
& WXUNUSED(event
) )
613 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
616 void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent
& WXUNUSED(event
) )
624 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
627 void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent
& WXUNUSED(event
) )
635 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
638 void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent
& WXUNUSED(event
) )
646 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
649 void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent
& WXUNUSED(event
) )
657 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
660 void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent
& WXUNUSED(event
) )
667 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
670 void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent
& WXUNUSED(event
) )
676 #endif // wxUSE_RICHTEXT