]> git.saurik.com Git - wxWidgets.git/blame - src/richtext/richtextindentspage.cpp
Add GetPageText to MSW IE and to GTK WebKit. Add stub for OSX and document.
[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
JS
209
210 wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL);
4d6d8bf4 211 itemFlexGridSizer22->Add(itemBoxSizer24, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 212
603f702b 213 m_indentLeft = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55 214 m_indentLeft->SetHelpText(_("The left indent."));
6103234e 215 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 216 m_indentLeft->SetToolTip(_("The left indent."));
4d6d8bf4 217 itemBoxSizer24->Add(m_indentLeft, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 218
603f702b 219 wxStaticText* itemStaticText26 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 220 itemFlexGridSizer22->Add(itemStaticText26, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
221
222 wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxHORIZONTAL);
4d6d8bf4 223 itemFlexGridSizer22->Add(itemBoxSizer27, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 224
603f702b 225 m_indentLeftFirst = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55 226 m_indentLeftFirst->SetHelpText(_("The first line indent."));
6103234e 227 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 228 m_indentLeftFirst->SetToolTip(_("The first line indent."));
4d6d8bf4 229 itemBoxSizer27->Add(m_indentLeftFirst, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 230
603f702b 231 wxStaticText* itemStaticText29 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 232 itemFlexGridSizer22->Add(itemStaticText29, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
233
234 wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxHORIZONTAL);
4d6d8bf4 235 itemFlexGridSizer22->Add(itemBoxSizer30, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 236
603f702b 237 m_indentRight = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55 238 m_indentRight->SetHelpText(_("The right indent."));
6103234e 239 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 240 m_indentRight->SetToolTip(_("The right indent."));
4d6d8bf4
JS
241 itemBoxSizer30->Add(m_indentRight, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
242
603f702b 243 wxStaticText* itemStaticText32 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Outline level:"), wxDefaultPosition, wxDefaultSize, 0 );
5bf3b6fe 244 itemFlexGridSizer22->Add(itemStaticText32, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
4d6d8bf4 245
6103234e
JS
246 wxArrayString m_outlineLevelCtrlStrings;
247 m_outlineLevelCtrlStrings.Add(_("Normal"));
248 m_outlineLevelCtrlStrings.Add(_("1"));
249 m_outlineLevelCtrlStrings.Add(_("2"));
250 m_outlineLevelCtrlStrings.Add(_("3"));
251 m_outlineLevelCtrlStrings.Add(_("4"));
252 m_outlineLevelCtrlStrings.Add(_("5"));
253 m_outlineLevelCtrlStrings.Add(_("6"));
254 m_outlineLevelCtrlStrings.Add(_("7"));
255 m_outlineLevelCtrlStrings.Add(_("8"));
256 m_outlineLevelCtrlStrings.Add(_("9"));
603f702b 257 m_outlineLevelCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL, _("Normal"), wxDefaultPosition, wxSize(90, -1), m_outlineLevelCtrlStrings, wxCB_READONLY );
4d6d8bf4
JS
258 m_outlineLevelCtrl->SetStringSelection(_("Normal"));
259 m_outlineLevelCtrl->SetHelpText(_("The outline level."));
6103234e 260 if (wxRichTextIndentsSpacingPage::ShowToolTips())
4d6d8bf4
JS
261 m_outlineLevelCtrl->SetToolTip(_("The outline level."));
262 itemFlexGridSizer22->Add(m_outlineLevelCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
263
264 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
265
603f702b 266 wxStaticLine* itemStaticLine35 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
4d6d8bf4 267 itemBoxSizer4->Add(itemStaticLine35, 0, wxGROW|wxTOP|wxBOTTOM, 5);
97ff49b3
JS
268
269 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
270
4d6d8bf4
JS
271 wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
272 itemBoxSizer4->Add(itemBoxSizer37, 0, wxGROW, 5);
97ff49b3 273
603f702b 274 wxStaticText* itemStaticText38 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 275 itemBoxSizer37->Add(itemStaticText38, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3 276
4d6d8bf4
JS
277 wxBoxSizer* itemBoxSizer39 = new wxBoxSizer(wxHORIZONTAL);
278 itemBoxSizer37->Add(itemBoxSizer39, 0, wxALIGN_LEFT|wxALL, 5);
97ff49b3 279
4d6d8bf4 280 itemBoxSizer39->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 281
706465df 282 wxFlexGridSizer* itemFlexGridSizer41 = new wxFlexGridSizer(30, 2, 0, 0);
4d6d8bf4
JS
283 itemFlexGridSizer41->AddGrowableCol(1);
284 itemBoxSizer39->Add(itemFlexGridSizer41, 0, wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 285
603f702b 286 wxStaticText* itemStaticText42 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 287 itemFlexGridSizer41->Add(itemStaticText42, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 288
4d6d8bf4
JS
289 wxBoxSizer* itemBoxSizer43 = new wxBoxSizer(wxHORIZONTAL);
290 itemFlexGridSizer41->Add(itemBoxSizer43, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 291
603f702b 292 m_spacingBefore = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55 293 m_spacingBefore->SetHelpText(_("The spacing before the paragraph."));
6103234e 294 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 295 m_spacingBefore->SetToolTip(_("The spacing before the paragraph."));
4d6d8bf4 296 itemBoxSizer43->Add(m_spacingBefore, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 297
603f702b 298 wxStaticText* itemStaticText45 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 299 itemFlexGridSizer41->Add(itemStaticText45, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 300
4d6d8bf4
JS
301 wxBoxSizer* itemBoxSizer46 = new wxBoxSizer(wxHORIZONTAL);
302 itemFlexGridSizer41->Add(itemBoxSizer46, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 303
603f702b 304 m_spacingAfter = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
6103234e 305 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 306 m_spacingAfter->SetToolTip(_("The spacing after the paragraph."));
4d6d8bf4 307 itemBoxSizer46->Add(m_spacingAfter, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 308
603f702b 309 wxStaticText* itemStaticText48 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("L&ine spacing:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 310 itemFlexGridSizer41->Add(itemStaticText48, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 311
4d6d8bf4
JS
312 wxBoxSizer* itemBoxSizer49 = new wxBoxSizer(wxHORIZONTAL);
313 itemFlexGridSizer41->Add(itemBoxSizer49, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 314
6103234e
JS
315 wxArrayString m_spacingLineStrings;
316 m_spacingLineStrings.Add(_("Single"));
02aa812c
JS
317 m_spacingLineStrings.Add(_("1.1"));
318 m_spacingLineStrings.Add(_("1.2"));
319 m_spacingLineStrings.Add(_("1.3"));
320 m_spacingLineStrings.Add(_("1.4"));
6103234e 321 m_spacingLineStrings.Add(_("1.5"));
02aa812c
JS
322 m_spacingLineStrings.Add(_("1.6"));
323 m_spacingLineStrings.Add(_("1.7"));
324 m_spacingLineStrings.Add(_("1.8"));
325 m_spacingLineStrings.Add(_("1.9"));
6103234e 326 m_spacingLineStrings.Add(_("2"));
603f702b 327 m_spacingLine = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, _("Single"), wxDefaultPosition, wxSize(90, -1), m_spacingLineStrings, wxCB_READONLY );
97ff49b3 328 m_spacingLine->SetStringSelection(_("Single"));
dadd4f55 329 m_spacingLine->SetHelpText(_("The line spacing."));
6103234e 330 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 331 m_spacingLine->SetToolTip(_("The line spacing."));
4d6d8bf4 332 itemBoxSizer49->Add(m_spacingLine, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 333
2fce6547 334 itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5);
97ff49b3 335
603f702b 336 m_previewCtrl = new wxRichTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 100), wxVSCROLL|wxTE_READONLY );
97ff49b3 337 m_previewCtrl->SetHelpText(_("Shows a preview of the paragraph settings."));
6103234e 338 if (wxRichTextIndentsSpacingPage::ShowToolTips())
97ff49b3 339 m_previewCtrl->SetToolTip(_("Shows a preview of the paragraph settings."));
2fce6547 340 itemBoxSizer3->Add(m_previewCtrl, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
97ff49b3
JS
341
342////@end wxRichTextIndentsSpacingPage content construction
343}
344
24777478 345wxRichTextAttr* wxRichTextIndentsSpacingPage::GetAttributes()
97ff49b3
JS
346{
347 return wxRichTextFormattingDialog::GetDialogAttributes(this);
348}
349
350/// Updates the font preview
351void wxRichTextIndentsSpacingPage::UpdatePreview()
352{
353 static const wxChar* s_para1 = wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
2a94806c 354Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n");
97ff49b3 355
2a94806c
JS
356 static const wxChar* s_para2 = wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \
357et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n");
97ff49b3 358
2a94806c 359 static const wxChar* s_para3 = wxT("Integer convallis dolor at augue \
97ff49b3
JS
360iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
361
362 TransferDataFromWindow();
24777478 363 wxRichTextAttr attr(*GetAttributes());
97ff49b3
JS
364 attr.SetFlags(attr.GetFlags() &
365 (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
366 wxTEXT_ATTR_LINE_SPACING|
d2d0adc7 367 wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT));
97ff49b3
JS
368
369 wxFont font(m_previewCtrl->GetFont());
370 font.SetPointSize(9);
371 m_previewCtrl->SetFont(font);
372
24777478 373 wxRichTextAttr normalParaAttr;
dadd4f55
JS
374 normalParaAttr.SetFont(font);
375 normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
97ff49b3 376
dadd4f55 377 m_previewCtrl->Freeze();
97ff49b3
JS
378 m_previewCtrl->Clear();
379
dadd4f55 380 m_previewCtrl->BeginStyle(normalParaAttr);
97ff49b3 381 m_previewCtrl->WriteText(s_para1);
dadd4f55
JS
382 m_previewCtrl->EndStyle();
383
97ff49b3
JS
384 m_previewCtrl->BeginStyle(attr);
385 m_previewCtrl->WriteText(s_para2);
386 m_previewCtrl->EndStyle();
dadd4f55
JS
387
388 m_previewCtrl->BeginStyle(normalParaAttr);
97ff49b3 389 m_previewCtrl->WriteText(s_para3);
dadd4f55
JS
390 m_previewCtrl->EndStyle();
391
392 m_previewCtrl->Thaw();
97ff49b3
JS
393}
394
395/// Transfer data from/to window
396bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
397{
398 wxPanel::TransferDataFromWindow();
399
24777478 400 wxRichTextAttr* attr = GetAttributes();
97ff49b3
JS
401
402 if (m_alignmentLeft->GetValue())
403 attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT);
404 else if (m_alignmentCentred->GetValue())
405 attr->SetAlignment(wxTEXT_ALIGNMENT_CENTRE);
406 else if (m_alignmentRight->GetValue())
407 attr->SetAlignment(wxTEXT_ALIGNMENT_RIGHT);
408 else if (m_alignmentJustified->GetValue())
409 attr->SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED);
410 else
411 {
412 attr->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT);
413 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT));
414 }
415
416 wxString leftIndent(m_indentLeft->GetValue());
417 wxString leftFirstIndent(m_indentLeftFirst->GetValue());
b68603d5 418 if (!leftIndent.empty())
97ff49b3
JS
419 {
420 int visualLeftIndent = wxAtoi(leftIndent);
421 int visualLeftFirstIndent = wxAtoi(leftFirstIndent);
422 int actualLeftIndent = visualLeftFirstIndent;
423 int actualLeftSubIndent = visualLeftIndent - visualLeftFirstIndent;
424
425 attr->SetLeftIndent(actualLeftIndent, actualLeftSubIndent);
426 }
427 else
428 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT));
429
430 wxString rightIndent(m_indentRight->GetValue());
b68603d5 431 if (!rightIndent.empty())
97ff49b3
JS
432 attr->SetRightIndent(wxAtoi(rightIndent));
433 else
434 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT));
435
436 wxString spacingAfter(m_spacingAfter->GetValue());
b68603d5 437 if (!spacingAfter.empty())
97ff49b3
JS
438 attr->SetParagraphSpacingAfter(wxAtoi(spacingAfter));
439 else
440 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER));
441
442 wxString spacingBefore(m_spacingBefore->GetValue());
b68603d5 443 if (!spacingBefore.empty())
97ff49b3
JS
444 attr->SetParagraphSpacingBefore(wxAtoi(spacingBefore));
445 else
446 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE));
447
448 int spacingIndex = m_spacingLine->GetSelection();
449 int lineSpacing = 0;
02aa812c
JS
450 if (spacingIndex != -1)
451 lineSpacing = 10 + spacingIndex;
97ff49b3
JS
452
453 if (lineSpacing == 0)
454 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING));
455 else
456 attr->SetLineSpacing(lineSpacing);
44cc96a8 457
4d6d8bf4
JS
458 int outlineLevel = m_outlineLevelCtrl->GetSelection();
459 if (outlineLevel != wxNOT_FOUND)
460 attr->SetOutlineLevel(outlineLevel);
97ff49b3
JS
461
462 return true;
463}
464
465bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
466{
467 m_dontUpdate = true;
468
469 wxPanel::TransferDataToWindow();
470
24777478 471 wxRichTextAttr* attr = GetAttributes();
97ff49b3
JS
472
473 if (attr->HasAlignment())
474 {
475 if (attr->GetAlignment() == wxTEXT_ALIGNMENT_LEFT)
476 m_alignmentLeft->SetValue(true);
477 else if (attr->GetAlignment() == wxTEXT_ALIGNMENT_RIGHT)
478 m_alignmentRight->SetValue(true);
479 else if (attr->GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
480 m_alignmentCentred->SetValue(true);
481 else if (attr->GetAlignment() == wxTEXT_ALIGNMENT_JUSTIFIED)
482 m_alignmentJustified->SetValue(true);
483 else
484 m_alignmentIndeterminate->SetValue(true);
485 }
486 else
487 m_alignmentIndeterminate->SetValue(true);
488
489 if (attr->HasLeftIndent())
490 {
e79322ef
VZ
491 wxString leftIndent(wxString::Format(wxT("%ld"), attr->GetLeftIndent() + attr->GetLeftSubIndent()));
492 wxString leftFirstIndent(wxString::Format(wxT("%ld"), attr->GetLeftIndent()));
97ff49b3
JS
493
494 m_indentLeft->SetValue(leftIndent);
495 m_indentLeftFirst->SetValue(leftFirstIndent);
496 }
497 else
498 {
499 m_indentLeft->SetValue(wxEmptyString);
500 m_indentLeftFirst->SetValue(wxEmptyString);
501 }
502
503 if (attr->HasRightIndent())
504 {
e79322ef 505 wxString rightIndent(wxString::Format(wxT("%ld"), attr->GetRightIndent()));
97ff49b3
JS
506
507 m_indentRight->SetValue(rightIndent);
508 }
509 else
510 m_indentRight->SetValue(wxEmptyString);
511
512 if (attr->HasParagraphSpacingAfter())
513 {
514 wxString spacingAfter(wxString::Format(wxT("%d"), attr->GetParagraphSpacingAfter()));
515
516 m_spacingAfter->SetValue(spacingAfter);
517 }
518 else
519 m_spacingAfter->SetValue(wxEmptyString);
520
521 if (attr->HasParagraphSpacingBefore())
522 {
523 wxString spacingBefore(wxString::Format(wxT("%d"), attr->GetParagraphSpacingBefore()));
524
525 m_spacingBefore->SetValue(spacingBefore);
526 }
527 else
528 m_spacingBefore->SetValue(wxEmptyString);
529
530 if (attr->HasLineSpacing())
531 {
532 int index = 0;
533
534 int lineSpacing = attr->GetLineSpacing();
02aa812c
JS
535 if (lineSpacing >= 10 && lineSpacing <= 20)
536 index = lineSpacing - 10;
97ff49b3
JS
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)
44cc96a8 551 outlineLevel = 9;
4d6d8bf4
JS
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