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