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