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