]> git.saurik.com Git - wxWidgets.git/blob - src/richtext/richtextindentspage.cpp
Mention GetC and wxFileSystem in incompatible changes.
[wxWidgets.git] / src / richtext / richtextindentspage.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextindentspage.cpp
3 // Purpose:
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 10/3/2006 2:28:21 PM
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if wxUSE_RICHTEXT
13
14 #include "wx/richtext/richtextindentspage.h"
15
16 /*!
17 * wxRichTextIndentsSpacingPage type definition
18 */
19
20 IMPLEMENT_DYNAMIC_CLASS( wxRichTextIndentsSpacingPage, wxPanel )
21
22 /*!
23 * wxRichTextIndentsSpacingPage event table definition
24 */
25
26 BEGIN_EVENT_TABLE( wxRichTextIndentsSpacingPage, wxPanel )
27
28 ////@begin wxRichTextIndentsSpacingPage event table entries
29 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT, wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected )
30
31 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT, wxRichTextIndentsSpacingPage::OnAlignmentRightSelected )
32
33 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED, wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected )
34
35 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED, wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected )
36
37 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE, wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected )
38
39 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, wxRichTextIndentsSpacingPage::OnIndentLeftUpdated )
40
41 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated )
42
43 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, wxRichTextIndentsSpacingPage::OnIndentRightUpdated )
44
45 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated )
46
47 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated )
48
49 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, wxRichTextIndentsSpacingPage::OnSpacingLineSelected )
50
51 ////@end wxRichTextIndentsSpacingPage event table entries
52
53 END_EVENT_TABLE()
54
55 /*!
56 * wxRichTextIndentsSpacingPage constructors
57 */
58
59 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( )
60 {
61 Init();
62 }
63
64 wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
65 {
66 Init();
67 Create(parent, id, pos, size, style);
68 }
69
70 /*!
71 * Initialise members
72 */
73
74 void wxRichTextIndentsSpacingPage::Init()
75 {
76 m_dontUpdate = false;
77
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;
84 m_indentLeft = NULL;
85 m_indentLeftFirst = NULL;
86 m_indentRight = NULL;
87 m_spacingBefore = NULL;
88 m_spacingAfter = NULL;
89 m_spacingLine = NULL;
90 m_previewCtrl = NULL;
91 ////@end wxRichTextIndentsSpacingPage member initialisation
92
93 }
94
95 /*!
96 * wxRichTextIndentsSpacingPage creator
97 */
98
99 bool wxRichTextIndentsSpacingPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
100 {
101 ////@begin wxRichTextIndentsSpacingPage creation
102 wxPanel::Create( parent, id, pos, size, style );
103
104 CreateControls();
105 if (GetSizer())
106 {
107 GetSizer()->SetSizeHints(this);
108 }
109 Centre();
110 ////@end wxRichTextIndentsSpacingPage creation
111 return true;
112 }
113
114 /*!
115 * Control creation for wxRichTextIndentsSpacingPage
116 */
117
118 void wxRichTextIndentsSpacingPage::CreateControls()
119 {
120 ////@begin wxRichTextIndentsSpacingPage content construction
121 wxRichTextIndentsSpacingPage* itemPanel1 = this;
122
123 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
124 itemPanel1->SetSizer(itemBoxSizer2);
125
126 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
127 itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
128
129 wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
130 itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW, 5);
131
132 wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
133 itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5);
134
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);
137
138 wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
139 itemBoxSizer5->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
140
141 itemBoxSizer7->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
142
143 wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL);
144 itemBoxSizer7->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5);
145
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."));
149 if (ShowToolTips())
150 m_alignmentLeft->SetToolTip(_("Left-align text."));
151 itemBoxSizer9->Add(m_alignmentLeft, 0, wxALIGN_LEFT|wxALL, 5);
152
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."));
156 if (ShowToolTips())
157 m_alignmentRight->SetToolTip(_("Right-align text."));
158 itemBoxSizer9->Add(m_alignmentRight, 0, wxALIGN_LEFT|wxALL, 5);
159
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."));
163 if (ShowToolTips())
164 m_alignmentJustified->SetToolTip(_("Justify text left and right."));
165 itemBoxSizer9->Add(m_alignmentJustified, 0, wxALIGN_LEFT|wxALL, 5);
166
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."));
170 if (ShowToolTips())
171 m_alignmentCentred->SetToolTip(_("Centre text."));
172 itemBoxSizer9->Add(m_alignmentCentred, 0, wxALIGN_LEFT|wxALL, 5);
173
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."));
177 if (ShowToolTips())
178 m_alignmentIndeterminate->SetToolTip(_("Use the current alignment setting."));
179 itemBoxSizer9->Add(m_alignmentIndeterminate, 0, wxALIGN_LEFT|wxALL, 5);
180
181 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
182
183 wxStaticLine* itemStaticLine16 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
184 itemBoxSizer4->Add(itemStaticLine16, 0, wxGROW|wxLEFT|wxBOTTOM, 5);
185
186 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
187
188 wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL);
189 itemBoxSizer4->Add(itemBoxSizer18, 0, wxGROW, 5);
190
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);
193
194 wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
195 itemBoxSizer18->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALL, 5);
196
197 itemBoxSizer20->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
198
199 wxFlexGridSizer* itemFlexGridSizer22 = new wxFlexGridSizer(2, 2, 0, 0);
200 itemBoxSizer20->Add(itemFlexGridSizer22, 0, wxALIGN_CENTER_VERTICAL, 5);
201
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);
204
205 wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL);
206 itemFlexGridSizer22->Add(itemBoxSizer24, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
207
208 m_indentLeft = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
209 m_indentLeft->SetHelpText(_("The left indent."));
210 if (ShowToolTips())
211 m_indentLeft->SetToolTip(_("The left indent."));
212 itemBoxSizer24->Add(m_indentLeft, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
213
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);
216
217 wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxHORIZONTAL);
218 itemFlexGridSizer22->Add(itemBoxSizer27, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
219
220 m_indentLeftFirst = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
221 m_indentLeftFirst->SetHelpText(_("The first line indent."));
222 if (ShowToolTips())
223 m_indentLeftFirst->SetToolTip(_("The first line indent."));
224 itemBoxSizer27->Add(m_indentLeftFirst, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
225
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);
228
229 wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxHORIZONTAL);
230 itemFlexGridSizer22->Add(itemBoxSizer30, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
231
232 m_indentRight = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
233 m_indentRight->SetHelpText(_("The right indent."));
234 if (ShowToolTips())
235 m_indentRight->SetToolTip(_("The right indent."));
236 itemBoxSizer30->Add(m_indentRight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
237
238 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
239
240 wxStaticLine* itemStaticLine33 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
241 itemBoxSizer4->Add(itemStaticLine33, 0, wxGROW|wxTOP|wxBOTTOM, 5);
242
243 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
244
245 wxBoxSizer* itemBoxSizer35 = new wxBoxSizer(wxVERTICAL);
246 itemBoxSizer4->Add(itemBoxSizer35, 0, wxGROW, 5);
247
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);
250
251 wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxHORIZONTAL);
252 itemBoxSizer35->Add(itemBoxSizer37, 0, wxALIGN_LEFT|wxALL, 5);
253
254 itemBoxSizer37->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
255
256 wxFlexGridSizer* itemFlexGridSizer39 = new wxFlexGridSizer(2, 2, 0, 0);
257 itemBoxSizer37->Add(itemFlexGridSizer39, 0, wxALIGN_CENTER_VERTICAL, 5);
258
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);
261
262 wxBoxSizer* itemBoxSizer41 = new wxBoxSizer(wxHORIZONTAL);
263 itemFlexGridSizer39->Add(itemBoxSizer41, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
264
265 m_spacingBefore = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
266 m_spacingBefore->SetHelpText(_("The spacing before the paragraph."));
267 if (ShowToolTips())
268 m_spacingBefore->SetToolTip(_("The spacing before the paragraph."));
269 itemBoxSizer41->Add(m_spacingBefore, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
270
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);
273
274 wxBoxSizer* itemBoxSizer44 = new wxBoxSizer(wxHORIZONTAL);
275 itemFlexGridSizer39->Add(itemBoxSizer44, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
276
277 m_spacingAfter = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
278 if (ShowToolTips())
279 m_spacingAfter->SetToolTip(_("The spacing after the paragraph."));
280 itemBoxSizer44->Add(m_spacingAfter, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
281
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);
284
285 wxBoxSizer* itemBoxSizer47 = new wxBoxSizer(wxHORIZONTAL);
286 itemFlexGridSizer39->Add(itemBoxSizer47, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
287
288 wxString m_spacingLineStrings[] = {
289 _("Single"),
290 _("1.5"),
291 _("2")
292 };
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."));
296 if (ShowToolTips())
297 m_spacingLine->SetToolTip(_("The line spacing."));
298 itemBoxSizer47->Add(m_spacingLine, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
299
300 itemBoxSizer3->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
301
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."));
304 if (ShowToolTips())
305 m_previewCtrl->SetToolTip(_("Shows a preview of the paragraph settings."));
306 itemBoxSizer3->Add(m_previewCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
307
308 ////@end wxRichTextIndentsSpacingPage content construction
309 }
310
311 wxTextAttrEx* wxRichTextIndentsSpacingPage::GetAttributes()
312 {
313 return wxRichTextFormattingDialog::GetDialogAttributes(this);
314 }
315
316 /// Updates the font preview
317 void wxRichTextIndentsSpacingPage::UpdatePreview()
318 {
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.");
321
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.");
324
325 static const wxChar* s_para3 = wxT("\nInteger convallis dolor at augue \
326 iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
327
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_TEXT));
334
335 wxFont font(m_previewCtrl->GetFont());
336 font.SetPointSize(9);
337 m_previewCtrl->SetFont(font);
338
339 wxTextAttrEx normalParaAttr;
340 normalParaAttr.SetFont(font);
341 normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
342
343 m_previewCtrl->Freeze();
344 m_previewCtrl->Clear();
345
346 m_previewCtrl->BeginStyle(normalParaAttr);
347 m_previewCtrl->WriteText(s_para1);
348 m_previewCtrl->EndStyle();
349
350 m_previewCtrl->BeginStyle(attr);
351 m_previewCtrl->WriteText(s_para2);
352 m_previewCtrl->EndStyle();
353
354 m_previewCtrl->BeginStyle(normalParaAttr);
355 m_previewCtrl->WriteText(s_para3);
356 m_previewCtrl->EndStyle();
357
358 m_previewCtrl->Thaw();
359 }
360
361 /// Transfer data from/to window
362 bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
363 {
364 wxPanel::TransferDataFromWindow();
365
366 wxTextAttrEx* attr = GetAttributes();
367
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);
376 else
377 {
378 attr->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT);
379 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT));
380 }
381
382 wxString leftIndent(m_indentLeft->GetValue());
383 wxString leftFirstIndent(m_indentLeftFirst->GetValue());
384 if (!leftIndent.empty())
385 {
386 int visualLeftIndent = wxAtoi(leftIndent);
387 int visualLeftFirstIndent = wxAtoi(leftFirstIndent);
388 int actualLeftIndent = visualLeftFirstIndent;
389 int actualLeftSubIndent = visualLeftIndent - visualLeftFirstIndent;
390
391 attr->SetLeftIndent(actualLeftIndent, actualLeftSubIndent);
392 }
393 else
394 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT));
395
396 wxString rightIndent(m_indentRight->GetValue());
397 if (!rightIndent.empty())
398 attr->SetRightIndent(wxAtoi(rightIndent));
399 else
400 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT));
401
402 wxString spacingAfter(m_spacingAfter->GetValue());
403 if (!spacingAfter.empty())
404 attr->SetParagraphSpacingAfter(wxAtoi(spacingAfter));
405 else
406 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER));
407
408 wxString spacingBefore(m_spacingBefore->GetValue());
409 if (!spacingBefore.empty())
410 attr->SetParagraphSpacingBefore(wxAtoi(spacingBefore));
411 else
412 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE));
413
414 int spacingIndex = m_spacingLine->GetSelection();
415 int lineSpacing = 0;
416 if (spacingIndex == 0)
417 lineSpacing = 10;
418 else if (spacingIndex == 1)
419 lineSpacing = 15;
420 else if (spacingIndex == 2)
421 lineSpacing = 20;
422
423 if (lineSpacing == 0)
424 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING));
425 else
426 attr->SetLineSpacing(lineSpacing);
427
428 return true;
429 }
430
431 bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
432 {
433 m_dontUpdate = true;
434
435 wxPanel::TransferDataToWindow();
436
437 wxTextAttrEx* attr = GetAttributes();
438
439 if (attr->HasAlignment())
440 {
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);
449 else
450 m_alignmentIndeterminate->SetValue(true);
451 }
452 else
453 m_alignmentIndeterminate->SetValue(true);
454
455 if (attr->HasLeftIndent())
456 {
457 wxString leftIndent(wxString::Format(wxT("%ld"), attr->GetLeftIndent() + attr->GetLeftSubIndent()));
458 wxString leftFirstIndent(wxString::Format(wxT("%ld"), attr->GetLeftIndent()));
459
460 m_indentLeft->SetValue(leftIndent);
461 m_indentLeftFirst->SetValue(leftFirstIndent);
462 }
463 else
464 {
465 m_indentLeft->SetValue(wxEmptyString);
466 m_indentLeftFirst->SetValue(wxEmptyString);
467 }
468
469 if (attr->HasRightIndent())
470 {
471 wxString rightIndent(wxString::Format(wxT("%ld"), attr->GetRightIndent()));
472
473 m_indentRight->SetValue(rightIndent);
474 }
475 else
476 m_indentRight->SetValue(wxEmptyString);
477
478 if (attr->HasParagraphSpacingAfter())
479 {
480 wxString spacingAfter(wxString::Format(wxT("%d"), attr->GetParagraphSpacingAfter()));
481
482 m_spacingAfter->SetValue(spacingAfter);
483 }
484 else
485 m_spacingAfter->SetValue(wxEmptyString);
486
487 if (attr->HasParagraphSpacingBefore())
488 {
489 wxString spacingBefore(wxString::Format(wxT("%d"), attr->GetParagraphSpacingBefore()));
490
491 m_spacingBefore->SetValue(spacingBefore);
492 }
493 else
494 m_spacingBefore->SetValue(wxEmptyString);
495
496 if (attr->HasLineSpacing())
497 {
498 int index = 0;
499
500 int lineSpacing = attr->GetLineSpacing();
501 if (lineSpacing == 10)
502 index = 0;
503 else if (lineSpacing == 15)
504 index = 1;
505 else if (lineSpacing == 20)
506 index = 2;
507 else
508 index = -1;
509
510 m_spacingLine->SetSelection(index);
511 }
512 else
513 m_spacingLine->SetSelection(-1);
514
515 UpdatePreview();
516
517 m_dontUpdate = false;
518
519 return true;
520 }
521
522
523 /*!
524 * Should we show tooltips?
525 */
526
527 bool wxRichTextIndentsSpacingPage::ShowToolTips()
528 {
529 return wxRichTextFormattingDialog::ShowToolTips();
530 }
531
532 /*!
533 * Get bitmap resources
534 */
535
536 wxBitmap wxRichTextIndentsSpacingPage::GetBitmapResource( const wxString& name )
537 {
538 // Bitmap retrieval
539 ////@begin wxRichTextIndentsSpacingPage bitmap retrieval
540 wxUnusedVar(name);
541 return wxNullBitmap;
542 ////@end wxRichTextIndentsSpacingPage bitmap retrieval
543 }
544
545 /*!
546 * Get icon resources
547 */
548
549 wxIcon wxRichTextIndentsSpacingPage::GetIconResource( const wxString& name )
550 {
551 // Icon retrieval
552 ////@begin wxRichTextIndentsSpacingPage icon retrieval
553 wxUnusedVar(name);
554 return wxNullIcon;
555 ////@end wxRichTextIndentsSpacingPage icon retrieval
556 }
557 /*!
558 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
559 */
560
561 void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent& WXUNUSED(event) )
562 {
563 if (!m_dontUpdate)
564 UpdatePreview();
565 }
566
567
568 /*!
569 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
570 */
571
572 void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent& WXUNUSED(event) )
573 {
574 if (!m_dontUpdate)
575 UpdatePreview();
576 }
577
578
579 /*!
580 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
581 */
582
583 void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent& WXUNUSED(event) )
584 {
585 if (!m_dontUpdate)
586 UpdatePreview();
587 }
588
589
590 /*!
591 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
592 */
593
594 void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent& WXUNUSED(event) )
595 {
596 if (!m_dontUpdate)
597 UpdatePreview();
598 }
599
600
601 /*!
602 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
603 */
604
605 void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent& WXUNUSED(event) )
606 {
607 if (!m_dontUpdate)
608 UpdatePreview();
609 }
610
611
612 /*!
613 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
614 */
615
616 void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent& WXUNUSED(event) )
617 {
618 if (!m_dontUpdate)
619 UpdatePreview();
620 }
621
622
623 /*!
624 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
625 */
626
627 void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent& WXUNUSED(event) )
628 {
629 if (!m_dontUpdate)
630 UpdatePreview();
631 }
632
633
634 /*!
635 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
636 */
637
638 void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent& WXUNUSED(event) )
639 {
640 if (!m_dontUpdate)
641 UpdatePreview();
642 }
643
644
645 /*!
646 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
647 */
648
649 void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent& WXUNUSED(event) )
650 {
651 if (!m_dontUpdate)
652 UpdatePreview();
653 }
654
655
656 /*!
657 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
658 */
659
660 void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent& WXUNUSED(event) )
661 {
662 if (!m_dontUpdate)
663 UpdatePreview();
664 }
665
666 /*!
667 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
668 */
669
670 void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent& WXUNUSED(event) )
671 {
672 if (!m_dontUpdate)
673 UpdatePreview();
674 }
675
676 #endif // wxUSE_RICHTEXT