]> git.saurik.com Git - wxWidgets.git/blame - src/richtext/richtextindentspage.cpp
don't overwrite the existing local file if we failed to open it but it does exist
[wxWidgets.git] / src / richtext / richtextindentspage.cpp
CommitLineData
97ff49b3 1/////////////////////////////////////////////////////////////////////////////
b68603d5 2// Name: src/richtext/richtextindentspage.cpp
97ff49b3
JS
3// Purpose:
4// Author: Julian Smart
5// Modified by:
6// Created: 10/3/2006 2:28:21 PM
b68603d5 7// RCS-ID: $Id$
97ff49b3 8// Copyright: (c) Julian Smart
b68603d5 9// Licence: wxWindows licence
97ff49b3
JS
10/////////////////////////////////////////////////////////////////////////////
11
b68603d5
WS
12#if wxUSE_RICHTEXT
13
14#include "wx/richtext/richtextindentspage.h"
15
97ff49b3
JS
16/*!
17 * wxRichTextIndentsSpacingPage type definition
18 */
19
20IMPLEMENT_DYNAMIC_CLASS( wxRichTextIndentsSpacingPage, wxPanel )
21
22/*!
23 * wxRichTextIndentsSpacingPage event table definition
24 */
25
26BEGIN_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
4d6d8bf4
JS
45 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL, wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected )
46
97ff49b3
JS
47 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated )
48
49 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated )
50
51 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, wxRichTextIndentsSpacingPage::OnSpacingLineSelected )
52
53////@end wxRichTextIndentsSpacingPage event table entries
54
55END_EVENT_TABLE()
56
57/*!
58 * wxRichTextIndentsSpacingPage constructors
59 */
60
61wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( )
62{
63 Init();
64}
65
66wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
67{
68 Init();
69 Create(parent, id, pos, size, style);
70}
71
72/*!
73 * Initialise members
74 */
5778b3c8 75
97ff49b3
JS
76void wxRichTextIndentsSpacingPage::Init()
77{
78 m_dontUpdate = false;
79
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;
86 m_indentLeft = NULL;
87 m_indentLeftFirst = NULL;
88 m_indentRight = NULL;
4d6d8bf4 89 m_outlineLevelCtrl = NULL;
97ff49b3
JS
90 m_spacingBefore = NULL;
91 m_spacingAfter = NULL;
92 m_spacingLine = NULL;
93 m_previewCtrl = NULL;
94////@end wxRichTextIndentsSpacingPage member initialisation
95
96}
97
98/*!
99 * wxRichTextIndentsSpacingPage creator
100 */
101
102bool wxRichTextIndentsSpacingPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
103{
104////@begin wxRichTextIndentsSpacingPage creation
105 wxPanel::Create( parent, id, pos, size, style );
106
107 CreateControls();
108 if (GetSizer())
109 {
110 GetSizer()->SetSizeHints(this);
111 }
112 Centre();
113////@end wxRichTextIndentsSpacingPage creation
114 return true;
115}
116
117/*!
118 * Control creation for wxRichTextIndentsSpacingPage
119 */
120
121void wxRichTextIndentsSpacingPage::CreateControls()
122{
123////@begin wxRichTextIndentsSpacingPage content construction
124 wxRichTextIndentsSpacingPage* itemPanel1 = this;
125
126 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
127 itemPanel1->SetSizer(itemBoxSizer2);
128
129 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
130 itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
131
132 wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
133 itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW, 5);
134
135 wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
136 itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5);
137
138 wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Alignment"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 139 itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3
JS
140
141 wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
142 itemBoxSizer5->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
143
144 itemBoxSizer7->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
145
146 wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL);
147 itemBoxSizer7->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5);
148
149 m_alignmentLeft = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT, _("&Left"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
150 m_alignmentLeft->SetValue(false);
dadd4f55
JS
151 m_alignmentLeft->SetHelpText(_("Left-align text."));
152 if (ShowToolTips())
153 m_alignmentLeft->SetToolTip(_("Left-align text."));
97ff49b3
JS
154 itemBoxSizer9->Add(m_alignmentLeft, 0, wxALIGN_LEFT|wxALL, 5);
155
156 m_alignmentRight = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT, _("&Right"), wxDefaultPosition, wxDefaultSize, 0 );
157 m_alignmentRight->SetValue(false);
dadd4f55
JS
158 m_alignmentRight->SetHelpText(_("Right-align text."));
159 if (ShowToolTips())
160 m_alignmentRight->SetToolTip(_("Right-align text."));
97ff49b3
JS
161 itemBoxSizer9->Add(m_alignmentRight, 0, wxALIGN_LEFT|wxALL, 5);
162
163 m_alignmentJustified = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED, _("&Justified"), wxDefaultPosition, wxDefaultSize, 0 );
164 m_alignmentJustified->SetValue(false);
dadd4f55
JS
165 m_alignmentJustified->SetHelpText(_("Justify text left and right."));
166 if (ShowToolTips())
167 m_alignmentJustified->SetToolTip(_("Justify text left and right."));
97ff49b3
JS
168 itemBoxSizer9->Add(m_alignmentJustified, 0, wxALIGN_LEFT|wxALL, 5);
169
170 m_alignmentCentred = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED, _("Cen&tred"), wxDefaultPosition, wxDefaultSize, 0 );
171 m_alignmentCentred->SetValue(false);
dadd4f55
JS
172 m_alignmentCentred->SetHelpText(_("Centre text."));
173 if (ShowToolTips())
174 m_alignmentCentred->SetToolTip(_("Centre text."));
97ff49b3
JS
175 itemBoxSizer9->Add(m_alignmentCentred, 0, wxALIGN_LEFT|wxALL, 5);
176
177 m_alignmentIndeterminate = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE, _("&Indeterminate"), wxDefaultPosition, wxDefaultSize, 0 );
178 m_alignmentIndeterminate->SetValue(false);
dadd4f55
JS
179 m_alignmentIndeterminate->SetHelpText(_("Use the current alignment setting."));
180 if (ShowToolTips())
181 m_alignmentIndeterminate->SetToolTip(_("Use the current alignment setting."));
97ff49b3
JS
182 itemBoxSizer9->Add(m_alignmentIndeterminate, 0, wxALIGN_LEFT|wxALL, 5);
183
184 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
185
186 wxStaticLine* itemStaticLine16 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
187 itemBoxSizer4->Add(itemStaticLine16, 0, wxGROW|wxLEFT|wxBOTTOM, 5);
188
189 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
190
191 wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL);
192 itemBoxSizer4->Add(itemBoxSizer18, 0, wxGROW, 5);
193
194 wxStaticText* itemStaticText19 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Indentation (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 195 itemBoxSizer18->Add(itemStaticText19, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3
JS
196
197 wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
198 itemBoxSizer18->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALL, 5);
199
200 itemBoxSizer20->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
201
202 wxFlexGridSizer* itemFlexGridSizer22 = new wxFlexGridSizer(2, 2, 0, 0);
203 itemBoxSizer20->Add(itemFlexGridSizer22, 0, wxALIGN_CENTER_VERTICAL, 5);
204
205 wxStaticText* itemStaticText23 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Left:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 206 itemFlexGridSizer22->Add(itemStaticText23, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
207
208 wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL);
4d6d8bf4 209 itemFlexGridSizer22->Add(itemBoxSizer24, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 210
d2d0adc7 211 m_indentLeft = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55
JS
212 m_indentLeft->SetHelpText(_("The left indent."));
213 if (ShowToolTips())
214 m_indentLeft->SetToolTip(_("The left indent."));
4d6d8bf4 215 itemBoxSizer24->Add(m_indentLeft, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
216
217 wxStaticText* itemStaticText26 = new wxStaticText( itemPanel1, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 218 itemFlexGridSizer22->Add(itemStaticText26, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
219
220 wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxHORIZONTAL);
4d6d8bf4 221 itemFlexGridSizer22->Add(itemBoxSizer27, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 222
d2d0adc7 223 m_indentLeftFirst = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55
JS
224 m_indentLeftFirst->SetHelpText(_("The first line indent."));
225 if (ShowToolTips())
226 m_indentLeftFirst->SetToolTip(_("The first line indent."));
4d6d8bf4 227 itemBoxSizer27->Add(m_indentLeftFirst, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
228
229 wxStaticText* itemStaticText29 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 230 itemFlexGridSizer22->Add(itemStaticText29, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
231
232 wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxHORIZONTAL);
4d6d8bf4 233 itemFlexGridSizer22->Add(itemBoxSizer30, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 234
d2d0adc7 235 m_indentRight = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55
JS
236 m_indentRight->SetHelpText(_("The right indent."));
237 if (ShowToolTips())
238 m_indentRight->SetToolTip(_("The right indent."));
4d6d8bf4
JS
239 itemBoxSizer30->Add(m_indentRight, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
240
241 wxStaticText* itemStaticText32 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Outline level:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 242 itemFlexGridSizer22->Add(itemStaticText32, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
4d6d8bf4
JS
243
244 wxString m_outlineLevelCtrlStrings[] = {
245 _("Normal"),
246 _("1"),
247 _("2"),
248 _("3"),
249 _("4"),
250 _("5"),
251 _("6"),
252 _("7"),
253 _("8"),
254 _("9")
255 };
256 m_outlineLevelCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL, _("Normal"), wxDefaultPosition, wxDefaultSize, 10, m_outlineLevelCtrlStrings, wxCB_READONLY );
257 m_outlineLevelCtrl->SetStringSelection(_("Normal"));
258 m_outlineLevelCtrl->SetHelpText(_("The outline level."));
259 if (ShowToolTips())
260 m_outlineLevelCtrl->SetToolTip(_("The outline level."));
261 itemFlexGridSizer22->Add(m_outlineLevelCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
262
263 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
264
4d6d8bf4
JS
265 wxStaticLine* itemStaticLine35 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
266 itemBoxSizer4->Add(itemStaticLine35, 0, wxGROW|wxTOP|wxBOTTOM, 5);
97ff49b3
JS
267
268 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
269
4d6d8bf4
JS
270 wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
271 itemBoxSizer4->Add(itemBoxSizer37, 0, wxGROW, 5);
97ff49b3 272
4d6d8bf4 273 wxStaticText* itemStaticText38 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 274 itemBoxSizer37->Add(itemStaticText38, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3 275
4d6d8bf4
JS
276 wxBoxSizer* itemBoxSizer39 = new wxBoxSizer(wxHORIZONTAL);
277 itemBoxSizer37->Add(itemBoxSizer39, 0, wxALIGN_LEFT|wxALL, 5);
97ff49b3 278
4d6d8bf4 279 itemBoxSizer39->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 280
4d6d8bf4
JS
281 wxFlexGridSizer* itemFlexGridSizer41 = new wxFlexGridSizer(2, 2, 0, 0);
282 itemFlexGridSizer41->AddGrowableCol(1);
283 itemBoxSizer39->Add(itemFlexGridSizer41, 0, wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 284
4d6d8bf4 285 wxStaticText* itemStaticText42 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 286 itemFlexGridSizer41->Add(itemStaticText42, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 287
4d6d8bf4
JS
288 wxBoxSizer* itemBoxSizer43 = new wxBoxSizer(wxHORIZONTAL);
289 itemFlexGridSizer41->Add(itemBoxSizer43, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 290
d2d0adc7 291 m_spacingBefore = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55
JS
292 m_spacingBefore->SetHelpText(_("The spacing before the paragraph."));
293 if (ShowToolTips())
294 m_spacingBefore->SetToolTip(_("The spacing before the paragraph."));
4d6d8bf4 295 itemBoxSizer43->Add(m_spacingBefore, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 296
4d6d8bf4 297 wxStaticText* itemStaticText45 = new wxStaticText( itemPanel1, wxID_STATIC, _("&After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 298 itemFlexGridSizer41->Add(itemStaticText45, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 299
4d6d8bf4
JS
300 wxBoxSizer* itemBoxSizer46 = new wxBoxSizer(wxHORIZONTAL);
301 itemFlexGridSizer41->Add(itemBoxSizer46, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 302
d2d0adc7 303 m_spacingAfter = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55
JS
304 if (ShowToolTips())
305 m_spacingAfter->SetToolTip(_("The spacing after the paragraph."));
4d6d8bf4 306 itemBoxSizer46->Add(m_spacingAfter, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 307
4d6d8bf4 308 wxStaticText* itemStaticText48 = new wxStaticText( itemPanel1, wxID_STATIC, _("L&ine spacing:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 309 itemFlexGridSizer41->Add(itemStaticText48, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 310
4d6d8bf4
JS
311 wxBoxSizer* itemBoxSizer49 = new wxBoxSizer(wxHORIZONTAL);
312 itemFlexGridSizer41->Add(itemBoxSizer49, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3
JS
313
314 wxString m_spacingLineStrings[] = {
315 _("Single"),
316 _("1.5"),
317 _("2")
318 };
319 m_spacingLine = new wxComboBox( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, _("Single"), wxDefaultPosition, wxDefaultSize, 3, m_spacingLineStrings, wxCB_READONLY );
320 m_spacingLine->SetStringSelection(_("Single"));
dadd4f55
JS
321 m_spacingLine->SetHelpText(_("The line spacing."));
322 if (ShowToolTips())
323 m_spacingLine->SetToolTip(_("The line spacing."));
4d6d8bf4 324 itemBoxSizer49->Add(m_spacingLine, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
325
326 itemBoxSizer3->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
327
328 m_previewCtrl = new wxRichTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 180), wxSUNKEN_BORDER );
329 m_previewCtrl->SetHelpText(_("Shows a preview of the paragraph settings."));
330 if (ShowToolTips())
331 m_previewCtrl->SetToolTip(_("Shows a preview of the paragraph settings."));
332 itemBoxSizer3->Add(m_previewCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
333
334////@end wxRichTextIndentsSpacingPage content construction
335}
336
337wxTextAttrEx* wxRichTextIndentsSpacingPage::GetAttributes()
338{
339 return wxRichTextFormattingDialog::GetDialogAttributes(this);
340}
341
342/// Updates the font preview
343void wxRichTextIndentsSpacingPage::UpdatePreview()
344{
345 static const wxChar* s_para1 = wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
346Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.");
347
348 static const wxChar* s_para2 = wxT("\nDuis pharetra consequat dui. Cum sociis natoque penatibus \
349et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.");
350
351 static const wxChar* s_para3 = wxT("\nInteger convallis dolor at augue \
352iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
353
354 TransferDataFromWindow();
355 wxTextAttrEx attr(*GetAttributes());
356 attr.SetFlags(attr.GetFlags() &
357 (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
358 wxTEXT_ATTR_LINE_SPACING|
d2d0adc7 359 wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT));
97ff49b3
JS
360
361 wxFont font(m_previewCtrl->GetFont());
362 font.SetPointSize(9);
363 m_previewCtrl->SetFont(font);
364
dadd4f55
JS
365 wxTextAttrEx normalParaAttr;
366 normalParaAttr.SetFont(font);
367 normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
97ff49b3 368
dadd4f55 369 m_previewCtrl->Freeze();
97ff49b3
JS
370 m_previewCtrl->Clear();
371
dadd4f55 372 m_previewCtrl->BeginStyle(normalParaAttr);
97ff49b3 373 m_previewCtrl->WriteText(s_para1);
dadd4f55
JS
374 m_previewCtrl->EndStyle();
375
97ff49b3
JS
376 m_previewCtrl->BeginStyle(attr);
377 m_previewCtrl->WriteText(s_para2);
378 m_previewCtrl->EndStyle();
dadd4f55
JS
379
380 m_previewCtrl->BeginStyle(normalParaAttr);
97ff49b3 381 m_previewCtrl->WriteText(s_para3);
dadd4f55
JS
382 m_previewCtrl->EndStyle();
383
384 m_previewCtrl->Thaw();
97ff49b3
JS
385}
386
387/// Transfer data from/to window
388bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
389{
390 wxPanel::TransferDataFromWindow();
391
392 wxTextAttrEx* attr = GetAttributes();
393
394 if (m_alignmentLeft->GetValue())
395 attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT);
396 else if (m_alignmentCentred->GetValue())
397 attr->SetAlignment(wxTEXT_ALIGNMENT_CENTRE);
398 else if (m_alignmentRight->GetValue())
399 attr->SetAlignment(wxTEXT_ALIGNMENT_RIGHT);
400 else if (m_alignmentJustified->GetValue())
401 attr->SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED);
402 else
403 {
404 attr->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT);
405 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT));
406 }
407
408 wxString leftIndent(m_indentLeft->GetValue());
409 wxString leftFirstIndent(m_indentLeftFirst->GetValue());
b68603d5 410 if (!leftIndent.empty())
97ff49b3
JS
411 {
412 int visualLeftIndent = wxAtoi(leftIndent);
413 int visualLeftFirstIndent = wxAtoi(leftFirstIndent);
414 int actualLeftIndent = visualLeftFirstIndent;
415 int actualLeftSubIndent = visualLeftIndent - visualLeftFirstIndent;
416
417 attr->SetLeftIndent(actualLeftIndent, actualLeftSubIndent);
418 }
419 else
420 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT));
421
422 wxString rightIndent(m_indentRight->GetValue());
b68603d5 423 if (!rightIndent.empty())
97ff49b3
JS
424 attr->SetRightIndent(wxAtoi(rightIndent));
425 else
426 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT));
427
428 wxString spacingAfter(m_spacingAfter->GetValue());
b68603d5 429 if (!spacingAfter.empty())
97ff49b3
JS
430 attr->SetParagraphSpacingAfter(wxAtoi(spacingAfter));
431 else
432 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER));
433
434 wxString spacingBefore(m_spacingBefore->GetValue());
b68603d5 435 if (!spacingBefore.empty())
97ff49b3
JS
436 attr->SetParagraphSpacingBefore(wxAtoi(spacingBefore));
437 else
438 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE));
439
440 int spacingIndex = m_spacingLine->GetSelection();
441 int lineSpacing = 0;
442 if (spacingIndex == 0)
443 lineSpacing = 10;
444 else if (spacingIndex == 1)
445 lineSpacing = 15;
446 else if (spacingIndex == 2)
447 lineSpacing = 20;
448
449 if (lineSpacing == 0)
450 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING));
451 else
452 attr->SetLineSpacing(lineSpacing);
4d6d8bf4
JS
453
454 int outlineLevel = m_outlineLevelCtrl->GetSelection();
455 if (outlineLevel != wxNOT_FOUND)
456 attr->SetOutlineLevel(outlineLevel);
97ff49b3
JS
457
458 return true;
459}
460
461bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
462{
463 m_dontUpdate = true;
464
465 wxPanel::TransferDataToWindow();
466
467 wxTextAttrEx* attr = GetAttributes();
468
469 if (attr->HasAlignment())
470 {
471 if (attr->GetAlignment() == wxTEXT_ALIGNMENT_LEFT)
472 m_alignmentLeft->SetValue(true);
473 else if (attr->GetAlignment() == wxTEXT_ALIGNMENT_RIGHT)
474 m_alignmentRight->SetValue(true);
475 else if (attr->GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
476 m_alignmentCentred->SetValue(true);
477 else if (attr->GetAlignment() == wxTEXT_ALIGNMENT_JUSTIFIED)
478 m_alignmentJustified->SetValue(true);
479 else
480 m_alignmentIndeterminate->SetValue(true);
481 }
482 else
483 m_alignmentIndeterminate->SetValue(true);
484
485 if (attr->HasLeftIndent())
486 {
e79322ef
VZ
487 wxString leftIndent(wxString::Format(wxT("%ld"), attr->GetLeftIndent() + attr->GetLeftSubIndent()));
488 wxString leftFirstIndent(wxString::Format(wxT("%ld"), attr->GetLeftIndent()));
97ff49b3
JS
489
490 m_indentLeft->SetValue(leftIndent);
491 m_indentLeftFirst->SetValue(leftFirstIndent);
492 }
493 else
494 {
495 m_indentLeft->SetValue(wxEmptyString);
496 m_indentLeftFirst->SetValue(wxEmptyString);
497 }
498
499 if (attr->HasRightIndent())
500 {
e79322ef 501 wxString rightIndent(wxString::Format(wxT("%ld"), attr->GetRightIndent()));
97ff49b3
JS
502
503 m_indentRight->SetValue(rightIndent);
504 }
505 else
506 m_indentRight->SetValue(wxEmptyString);
507
508 if (attr->HasParagraphSpacingAfter())
509 {
510 wxString spacingAfter(wxString::Format(wxT("%d"), attr->GetParagraphSpacingAfter()));
511
512 m_spacingAfter->SetValue(spacingAfter);
513 }
514 else
515 m_spacingAfter->SetValue(wxEmptyString);
516
517 if (attr->HasParagraphSpacingBefore())
518 {
519 wxString spacingBefore(wxString::Format(wxT("%d"), attr->GetParagraphSpacingBefore()));
520
521 m_spacingBefore->SetValue(spacingBefore);
522 }
523 else
524 m_spacingBefore->SetValue(wxEmptyString);
525
526 if (attr->HasLineSpacing())
527 {
528 int index = 0;
529
530 int lineSpacing = attr->GetLineSpacing();
531 if (lineSpacing == 10)
532 index = 0;
533 else if (lineSpacing == 15)
534 index = 1;
535 else if (lineSpacing == 20)
536 index = 2;
537 else
538 index = -1;
539
540 m_spacingLine->SetSelection(index);
541 }
542 else
543 m_spacingLine->SetSelection(-1);
544
4d6d8bf4
JS
545 if (attr->HasOutlineLevel())
546 {
547 int outlineLevel = attr->GetOutlineLevel();
548 if (outlineLevel < 0)
549 outlineLevel = 0;
550 if (outlineLevel > 9)
551 outlineLevel = 9;
552
553 m_outlineLevelCtrl->SetSelection(outlineLevel);
554 }
555 else
556 m_outlineLevelCtrl->SetSelection(-1);
557
97ff49b3
JS
558 UpdatePreview();
559
560 m_dontUpdate = false;
561
562 return true;
563}
564
565
566/*!
567 * Should we show tooltips?
568 */
569
570bool wxRichTextIndentsSpacingPage::ShowToolTips()
571{
dadd4f55 572 return wxRichTextFormattingDialog::ShowToolTips();
97ff49b3
JS
573}
574
575/*!
576 * Get bitmap resources
577 */
578
579wxBitmap wxRichTextIndentsSpacingPage::GetBitmapResource( const wxString& name )
580{
581 // Bitmap retrieval
582////@begin wxRichTextIndentsSpacingPage bitmap retrieval
583 wxUnusedVar(name);
584 return wxNullBitmap;
585////@end wxRichTextIndentsSpacingPage bitmap retrieval
586}
587
588/*!
589 * Get icon resources
590 */
591
592wxIcon wxRichTextIndentsSpacingPage::GetIconResource( const wxString& name )
593{
594 // Icon retrieval
595////@begin wxRichTextIndentsSpacingPage icon retrieval
596 wxUnusedVar(name);
597 return wxNullIcon;
598////@end wxRichTextIndentsSpacingPage icon retrieval
599}
600/*!
601 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
602 */
603
604void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent& WXUNUSED(event) )
605{
606 if (!m_dontUpdate)
607 UpdatePreview();
608}
609
610
611/*!
612 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
613 */
614
615void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent& WXUNUSED(event) )
616{
617 if (!m_dontUpdate)
618 UpdatePreview();
619}
620
621
622/*!
623 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
624 */
625
626void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent& WXUNUSED(event) )
627{
628 if (!m_dontUpdate)
629 UpdatePreview();
630}
631
632
633/*!
634 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
635 */
636
637void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent& WXUNUSED(event) )
638{
639 if (!m_dontUpdate)
640 UpdatePreview();
641}
642
643
644/*!
645 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
646 */
647
648void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent& WXUNUSED(event) )
649{
650 if (!m_dontUpdate)
651 UpdatePreview();
652}
653
654
655/*!
656 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
657 */
658
659void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent& WXUNUSED(event) )
660{
661 if (!m_dontUpdate)
662 UpdatePreview();
663}
664
665
666/*!
667 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
668 */
669
670void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent& WXUNUSED(event) )
671{
672 if (!m_dontUpdate)
673 UpdatePreview();
674}
675
676
677/*!
678 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
679 */
680
681void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent& WXUNUSED(event) )
682{
683 if (!m_dontUpdate)
684 UpdatePreview();
685}
686
687
688/*!
689 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
690 */
691
692void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent& WXUNUSED(event) )
693{
694 if (!m_dontUpdate)
695 UpdatePreview();
696}
697
698
699/*!
700 * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
701 */
702
703void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent& WXUNUSED(event) )
704{
705 if (!m_dontUpdate)
706 UpdatePreview();
707}
708
709/*!
710 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
711 */
712
713void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent& WXUNUSED(event) )
714{
715 if (!m_dontUpdate)
716 UpdatePreview();
717}
718
4d6d8bf4
JS
719/*!
720 * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
721 */
722
723void wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected( wxCommandEvent& WXUNUSED(event) )
724{
725 if (!m_dontUpdate)
726 UpdatePreview();
727}
728
b68603d5 729#endif // wxUSE_RICHTEXT