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 itemBoxSizer9
->Add(m_alignmentLeft
, 0, wxALIGN_LEFT
|wxALL
, 5);
150 m_alignmentRight
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
, _("&Right"), wxDefaultPosition
, wxDefaultSize
, 0 );
151 m_alignmentRight
->SetValue(false);
152 itemBoxSizer9
->Add(m_alignmentRight
, 0, wxALIGN_LEFT
|wxALL
, 5);
154 m_alignmentJustified
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
, _("&Justified"), wxDefaultPosition
, wxDefaultSize
, 0 );
155 m_alignmentJustified
->SetValue(false);
156 itemBoxSizer9
->Add(m_alignmentJustified
, 0, wxALIGN_LEFT
|wxALL
, 5);
158 m_alignmentCentred
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
, _("Cen&tred"), wxDefaultPosition
, wxDefaultSize
, 0 );
159 m_alignmentCentred
->SetValue(false);
160 itemBoxSizer9
->Add(m_alignmentCentred
, 0, wxALIGN_LEFT
|wxALL
, 5);
162 m_alignmentIndeterminate
= new wxRadioButton( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
, _("&Indeterminate"), wxDefaultPosition
, wxDefaultSize
, 0 );
163 m_alignmentIndeterminate
->SetValue(false);
164 itemBoxSizer9
->Add(m_alignmentIndeterminate
, 0, wxALIGN_LEFT
|wxALL
, 5);
166 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
168 wxStaticLine
* itemStaticLine16
= new wxStaticLine( itemPanel1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
169 itemBoxSizer4
->Add(itemStaticLine16
, 0, wxGROW
|wxLEFT
|wxBOTTOM
, 5);
171 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
173 wxBoxSizer
* itemBoxSizer18
= new wxBoxSizer(wxVERTICAL
);
174 itemBoxSizer4
->Add(itemBoxSizer18
, 0, wxGROW
, 5);
176 wxStaticText
* itemStaticText19
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Indentation (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
177 itemBoxSizer18
->Add(itemStaticText19
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
179 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
180 itemBoxSizer18
->Add(itemBoxSizer20
, 0, wxALIGN_LEFT
|wxALL
, 5);
182 itemBoxSizer20
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
184 wxFlexGridSizer
* itemFlexGridSizer22
= new wxFlexGridSizer(2, 2, 0, 0);
185 itemBoxSizer20
->Add(itemFlexGridSizer22
, 0, wxALIGN_CENTER_VERTICAL
, 5);
187 wxStaticText
* itemStaticText23
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Left:"), wxDefaultPosition
, wxDefaultSize
, 0 );
188 itemFlexGridSizer22
->Add(itemStaticText23
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
190 wxBoxSizer
* itemBoxSizer24
= new wxBoxSizer(wxHORIZONTAL
);
191 itemFlexGridSizer22
->Add(itemBoxSizer24
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
193 m_indentLeft
= new wxTextCtrl( itemPanel1
,
194 ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
,
197 wxSize(50, wxDefaultCoord
),
199 itemBoxSizer24
->Add(m_indentLeft
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
201 wxStaticText
* itemStaticText26
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Left (&first line):"), wxDefaultPosition
, wxDefaultSize
, 0 );
202 itemFlexGridSizer22
->Add(itemStaticText26
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
204 wxBoxSizer
* itemBoxSizer27
= new wxBoxSizer(wxHORIZONTAL
);
205 itemFlexGridSizer22
->Add(itemBoxSizer27
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
207 m_indentLeftFirst
= new wxTextCtrl( itemPanel1
,
208 ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
,
211 wxSize(50, wxDefaultCoord
),
213 itemBoxSizer27
->Add(m_indentLeftFirst
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
215 wxStaticText
* itemStaticText29
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Right:"), wxDefaultPosition
, wxDefaultSize
, 0 );
216 itemFlexGridSizer22
->Add(itemStaticText29
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
218 wxBoxSizer
* itemBoxSizer30
= new wxBoxSizer(wxHORIZONTAL
);
219 itemFlexGridSizer22
->Add(itemBoxSizer30
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
221 m_indentRight
= new wxTextCtrl( itemPanel1
,
222 ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
,
225 wxSize(50, wxDefaultCoord
),
227 itemBoxSizer30
->Add(m_indentRight
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
229 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
231 wxStaticLine
* itemStaticLine33
= new wxStaticLine( itemPanel1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_VERTICAL
);
232 itemBoxSizer4
->Add(itemStaticLine33
, 0, wxGROW
|wxTOP
|wxBOTTOM
, 5);
234 itemBoxSizer4
->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
, 5);
236 wxBoxSizer
* itemBoxSizer35
= new wxBoxSizer(wxVERTICAL
);
237 itemBoxSizer4
->Add(itemBoxSizer35
, 0, wxGROW
, 5);
239 wxStaticText
* itemStaticText36
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Spacing (tenths of a mm)"), wxDefaultPosition
, wxDefaultSize
, 0 );
240 itemBoxSizer35
->Add(itemStaticText36
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
242 wxBoxSizer
* itemBoxSizer37
= new wxBoxSizer(wxHORIZONTAL
);
243 itemBoxSizer35
->Add(itemBoxSizer37
, 0, wxALIGN_LEFT
|wxALL
, 5);
245 itemBoxSizer37
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
, 5);
247 wxFlexGridSizer
* itemFlexGridSizer39
= new wxFlexGridSizer(2, 2, 0, 0);
248 itemBoxSizer37
->Add(itemFlexGridSizer39
, 0, wxALIGN_CENTER_VERTICAL
, 5);
250 wxStaticText
* itemStaticText40
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Before a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
251 itemFlexGridSizer39
->Add(itemStaticText40
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
253 wxBoxSizer
* itemBoxSizer41
= new wxBoxSizer(wxHORIZONTAL
);
254 itemFlexGridSizer39
->Add(itemBoxSizer41
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
256 m_spacingBefore
= new wxTextCtrl( itemPanel1
,
257 ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
,
260 wxSize(50, wxDefaultCoord
),
262 itemBoxSizer41
->Add(m_spacingBefore
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
264 wxStaticText
* itemStaticText43
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("After a paragraph:"), wxDefaultPosition
, wxDefaultSize
, 0 );
265 itemFlexGridSizer39
->Add(itemStaticText43
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
267 wxBoxSizer
* itemBoxSizer44
= new wxBoxSizer(wxHORIZONTAL
);
268 itemFlexGridSizer39
->Add(itemBoxSizer44
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
270 m_spacingAfter
= new wxTextCtrl( itemPanel1
,
271 ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
,
274 wxSize(50, wxDefaultCoord
),
276 itemBoxSizer44
->Add(m_spacingAfter
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
278 wxStaticText
* itemStaticText46
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("Line spacing:"), wxDefaultPosition
, wxDefaultSize
, 0 );
279 itemFlexGridSizer39
->Add(itemStaticText46
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
|wxADJUST_MINSIZE
, 5);
281 wxBoxSizer
* itemBoxSizer47
= new wxBoxSizer(wxHORIZONTAL
);
282 itemFlexGridSizer39
->Add(itemBoxSizer47
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
, 5);
284 wxString m_spacingLineStrings
[] = {
289 m_spacingLine
= new wxComboBox( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
, _("Single"), wxDefaultPosition
, wxDefaultSize
, 3, m_spacingLineStrings
, wxCB_READONLY
);
290 m_spacingLine
->SetStringSelection(_("Single"));
291 itemBoxSizer47
->Add(m_spacingLine
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
293 itemBoxSizer3
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
295 m_previewCtrl
= new wxRichTextCtrl( itemPanel1
, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL
, wxEmptyString
, wxDefaultPosition
, wxSize(350, 180), wxSUNKEN_BORDER
);
296 m_previewCtrl
->SetHelpText(_("Shows a preview of the paragraph settings."));
298 m_previewCtrl
->SetToolTip(_("Shows a preview of the paragraph settings."));
299 itemBoxSizer3
->Add(m_previewCtrl
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
301 ////@end wxRichTextIndentsSpacingPage content construction
304 wxTextAttrEx
* wxRichTextIndentsSpacingPage::GetAttributes()
306 return wxRichTextFormattingDialog::GetDialogAttributes(this);
309 /// Updates the font preview
310 void wxRichTextIndentsSpacingPage::UpdatePreview()
312 static const wxChar
* s_para1
= wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
313 Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.");
315 static const wxChar
* s_para2
= wxT("\nDuis pharetra consequat dui. Cum sociis natoque penatibus \
316 et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.");
318 static const wxChar
* s_para3
= wxT("\nInteger convallis dolor at augue \
319 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
321 TransferDataFromWindow();
322 wxTextAttrEx
attr(*GetAttributes());
323 attr
.SetFlags(attr
.GetFlags() &
324 (wxTEXT_ATTR_ALIGNMENT
|wxTEXT_ATTR_LEFT_INDENT
|wxTEXT_ATTR_RIGHT_INDENT
|wxTEXT_ATTR_PARA_SPACING_BEFORE
|wxTEXT_ATTR_PARA_SPACING_AFTER
|
325 wxTEXT_ATTR_LINE_SPACING
|
326 wxTEXT_ATTR_BULLET_STYLE
|wxTEXT_ATTR_BULLET_NUMBER
|wxTEXT_ATTR_BULLET_SYMBOL
));
328 wxFont
font(m_previewCtrl
->GetFont());
329 font
.SetPointSize(9);
330 m_previewCtrl
->SetFont(font
);
332 font
.SetWeight(wxBOLD
);
335 m_previewCtrl
->Clear();
337 m_previewCtrl
->WriteText(s_para1
);
338 m_previewCtrl
->BeginStyle(attr
);
339 m_previewCtrl
->WriteText(s_para2
);
340 m_previewCtrl
->EndStyle();
341 m_previewCtrl
->WriteText(s_para3
);
344 /// Transfer data from/to window
345 bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
347 wxPanel::TransferDataFromWindow();
349 wxTextAttrEx
* attr
= GetAttributes();
351 if (m_alignmentLeft
->GetValue())
352 attr
->SetAlignment(wxTEXT_ALIGNMENT_LEFT
);
353 else if (m_alignmentCentred
->GetValue())
354 attr
->SetAlignment(wxTEXT_ALIGNMENT_CENTRE
);
355 else if (m_alignmentRight
->GetValue())
356 attr
->SetAlignment(wxTEXT_ALIGNMENT_RIGHT
);
357 else if (m_alignmentJustified
->GetValue())
358 attr
->SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED
);
361 attr
->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT
);
362 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT
));
365 wxString
leftIndent(m_indentLeft
->GetValue());
366 wxString
leftFirstIndent(m_indentLeftFirst
->GetValue());
367 if (!leftIndent
.empty())
369 int visualLeftIndent
= wxAtoi(leftIndent
);
370 int visualLeftFirstIndent
= wxAtoi(leftFirstIndent
);
371 int actualLeftIndent
= visualLeftFirstIndent
;
372 int actualLeftSubIndent
= visualLeftIndent
- visualLeftFirstIndent
;
374 attr
->SetLeftIndent(actualLeftIndent
, actualLeftSubIndent
);
377 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT
));
379 wxString
rightIndent(m_indentRight
->GetValue());
380 if (!rightIndent
.empty())
381 attr
->SetRightIndent(wxAtoi(rightIndent
));
383 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT
));
385 wxString
spacingAfter(m_spacingAfter
->GetValue());
386 if (!spacingAfter
.empty())
387 attr
->SetParagraphSpacingAfter(wxAtoi(spacingAfter
));
389 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER
));
391 wxString
spacingBefore(m_spacingBefore
->GetValue());
392 if (!spacingBefore
.empty())
393 attr
->SetParagraphSpacingBefore(wxAtoi(spacingBefore
));
395 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE
));
397 int spacingIndex
= m_spacingLine
->GetSelection();
399 if (spacingIndex
== 0)
401 else if (spacingIndex
== 1)
403 else if (spacingIndex
== 2)
406 if (lineSpacing
== 0)
407 attr
->SetFlags(attr
->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING
));
409 attr
->SetLineSpacing(lineSpacing
);
414 bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
418 wxPanel::TransferDataToWindow();
420 wxTextAttrEx
* attr
= GetAttributes();
422 if (attr
->HasAlignment())
424 if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_LEFT
)
425 m_alignmentLeft
->SetValue(true);
426 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_RIGHT
)
427 m_alignmentRight
->SetValue(true);
428 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_CENTRE
)
429 m_alignmentCentred
->SetValue(true);
430 else if (attr
->GetAlignment() == wxTEXT_ALIGNMENT_JUSTIFIED
)
431 m_alignmentJustified
->SetValue(true);
433 m_alignmentIndeterminate
->SetValue(true);
436 m_alignmentIndeterminate
->SetValue(true);
438 if (attr
->HasLeftIndent())
440 wxString
leftIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent() + attr
->GetLeftSubIndent()));
441 wxString
leftFirstIndent(wxString::Format(wxT("%ld"), attr
->GetLeftIndent()));
443 m_indentLeft
->SetValue(leftIndent
);
444 m_indentLeftFirst
->SetValue(leftFirstIndent
);
448 m_indentLeft
->SetValue(wxEmptyString
);
449 m_indentLeftFirst
->SetValue(wxEmptyString
);
452 if (attr
->HasRightIndent())
454 wxString
rightIndent(wxString::Format(wxT("%ld"), attr
->GetRightIndent()));
456 m_indentRight
->SetValue(rightIndent
);
459 m_indentRight
->SetValue(wxEmptyString
);
461 if (attr
->HasParagraphSpacingAfter())
463 wxString
spacingAfter(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingAfter()));
465 m_spacingAfter
->SetValue(spacingAfter
);
468 m_spacingAfter
->SetValue(wxEmptyString
);
470 if (attr
->HasParagraphSpacingBefore())
472 wxString
spacingBefore(wxString::Format(wxT("%d"), attr
->GetParagraphSpacingBefore()));
474 m_spacingBefore
->SetValue(spacingBefore
);
477 m_spacingBefore
->SetValue(wxEmptyString
);
479 if (attr
->HasLineSpacing())
483 int lineSpacing
= attr
->GetLineSpacing();
484 if (lineSpacing
== 10)
486 else if (lineSpacing
== 15)
488 else if (lineSpacing
== 20)
493 m_spacingLine
->SetSelection(index
);
496 m_spacingLine
->SetSelection(-1);
500 m_dontUpdate
= false;
507 * Should we show tooltips?
510 bool wxRichTextIndentsSpacingPage::ShowToolTips()
516 * Get bitmap resources
519 wxBitmap
wxRichTextIndentsSpacingPage::GetBitmapResource( const wxString
& name
)
522 ////@begin wxRichTextIndentsSpacingPage bitmap retrieval
525 ////@end wxRichTextIndentsSpacingPage bitmap retrieval
532 wxIcon
wxRichTextIndentsSpacingPage::GetIconResource( const wxString
& name
)
535 ////@begin wxRichTextIndentsSpacingPage icon retrieval
538 ////@end wxRichTextIndentsSpacingPage icon retrieval
541 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
544 void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent
& WXUNUSED(event
) )
552 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
555 void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent
& WXUNUSED(event
) )
563 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
566 void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent
& WXUNUSED(event
) )
574 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
577 void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent
& WXUNUSED(event
) )
585 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
588 void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent
& WXUNUSED(event
) )
596 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
599 void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent
& WXUNUSED(event
) )
607 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
610 void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent
& WXUNUSED(event
) )
618 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
621 void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent
& WXUNUSED(event
) )
629 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
632 void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent
& WXUNUSED(event
) )
640 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
643 void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent
& WXUNUSED(event
) )
650 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
653 void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent
& WXUNUSED(event
) )
659 #endif // wxUSE_RICHTEXT