]> git.saurik.com Git - wxWidgets.git/blame - src/richtext/richtextindentspage.cpp
Add doc for wxGraphicsContext.Create(), which is a lightweight context with no target...
[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 )
97ff49b3 30 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT, wxRichTextIndentsSpacingPage::OnAlignmentRightSelected )
97ff49b3 31 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED, wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected )
97ff49b3 32 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED, wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected )
97ff49b3 33 EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE, wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected )
97ff49b3 34 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, wxRichTextIndentsSpacingPage::OnIndentLeftUpdated )
97ff49b3 35 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated )
97ff49b3 36 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, wxRichTextIndentsSpacingPage::OnIndentRightUpdated )
4d6d8bf4 37 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL, wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected )
97ff49b3 38 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated )
97ff49b3 39 EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated )
97ff49b3 40 EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, wxRichTextIndentsSpacingPage::OnSpacingLineSelected )
97ff49b3
JS
41////@end wxRichTextIndentsSpacingPage event table entries
42
43END_EVENT_TABLE()
44
603f702b
JS
45IMPLEMENT_HELP_PROVISION(wxRichTextIndentsSpacingPage)
46
97ff49b3
JS
47/*!
48 * wxRichTextIndentsSpacingPage constructors
49 */
50
51wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( )
52{
53 Init();
54}
55
56wxRichTextIndentsSpacingPage::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 */
5778b3c8 65
97ff49b3
JS
66void 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;
4d6d8bf4 79 m_outlineLevelCtrl = NULL;
97ff49b3
JS
80 m_spacingBefore = NULL;
81 m_spacingAfter = NULL;
82 m_spacingLine = NULL;
4c7d9d88 83 m_pageBreakCtrl = NULL;
97ff49b3
JS
84 m_previewCtrl = NULL;
85////@end wxRichTextIndentsSpacingPage member initialisation
86
87}
88
89/*!
90 * wxRichTextIndentsSpacingPage creator
91 */
92
93bool wxRichTextIndentsSpacingPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
94{
95////@begin wxRichTextIndentsSpacingPage creation
603f702b 96 wxRichTextDialogPage::Create( parent, id, pos, size, style );
97ff49b3
JS
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
112void wxRichTextIndentsSpacingPage::CreateControls()
113{
114////@begin wxRichTextIndentsSpacingPage content construction
603f702b 115 wxRichTextIndentsSpacingPage* itemRichTextDialogPage1 = this;
97ff49b3
JS
116
117 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
603f702b 118 itemRichTextDialogPage1->SetSizer(itemBoxSizer2);
97ff49b3
JS
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
603f702b 129 wxStaticText* itemStaticText6 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Alignment"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 130 itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3
JS
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
603f702b 140 m_alignmentLeft = new wxRadioButton( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT, _("&Left"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
97ff49b3 141 m_alignmentLeft->SetValue(false);
dadd4f55 142 m_alignmentLeft->SetHelpText(_("Left-align text."));
6103234e 143 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 144 m_alignmentLeft->SetToolTip(_("Left-align text."));
97ff49b3
JS
145 itemBoxSizer9->Add(m_alignmentLeft, 0, wxALIGN_LEFT|wxALL, 5);
146
603f702b 147 m_alignmentRight = new wxRadioButton( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT, _("&Right"), wxDefaultPosition, wxDefaultSize, 0 );
97ff49b3 148 m_alignmentRight->SetValue(false);
dadd4f55 149 m_alignmentRight->SetHelpText(_("Right-align text."));
6103234e 150 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 151 m_alignmentRight->SetToolTip(_("Right-align text."));
97ff49b3
JS
152 itemBoxSizer9->Add(m_alignmentRight, 0, wxALIGN_LEFT|wxALL, 5);
153
603f702b 154 m_alignmentJustified = new wxRadioButton( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED, _("&Justified"), wxDefaultPosition, wxDefaultSize, 0 );
97ff49b3 155 m_alignmentJustified->SetValue(false);
dadd4f55 156 m_alignmentJustified->SetHelpText(_("Justify text left and right."));
6103234e 157 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 158 m_alignmentJustified->SetToolTip(_("Justify text left and right."));
97ff49b3
JS
159 itemBoxSizer9->Add(m_alignmentJustified, 0, wxALIGN_LEFT|wxALL, 5);
160
603f702b 161 m_alignmentCentred = new wxRadioButton( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED, _("Cen&tred"), wxDefaultPosition, wxDefaultSize, 0 );
97ff49b3 162 m_alignmentCentred->SetValue(false);
dadd4f55 163 m_alignmentCentred->SetHelpText(_("Centre text."));
6103234e 164 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 165 m_alignmentCentred->SetToolTip(_("Centre text."));
97ff49b3
JS
166 itemBoxSizer9->Add(m_alignmentCentred, 0, wxALIGN_LEFT|wxALL, 5);
167
603f702b 168 m_alignmentIndeterminate = new wxRadioButton( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE, _("&Indeterminate"), wxDefaultPosition, wxDefaultSize, 0 );
97ff49b3 169 m_alignmentIndeterminate->SetValue(false);
dadd4f55 170 m_alignmentIndeterminate->SetHelpText(_("Use the current alignment setting."));
6103234e 171 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 172 m_alignmentIndeterminate->SetToolTip(_("Use the current alignment setting."));
97ff49b3
JS
173 itemBoxSizer9->Add(m_alignmentIndeterminate, 0, wxALIGN_LEFT|wxALL, 5);
174
175 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
176
603f702b 177 wxStaticLine* itemStaticLine16 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
97ff49b3
JS
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
603f702b 185 wxStaticText* itemStaticText19 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Indentation (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 186 itemBoxSizer18->Add(itemStaticText19, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
97ff49b3
JS
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
706465df 193 wxFlexGridSizer* itemFlexGridSizer22 = new wxFlexGridSizer(0, 2, 0, 0);
97ff49b3
JS
194 itemBoxSizer20->Add(itemFlexGridSizer22, 0, wxALIGN_CENTER_VERTICAL, 5);
195
603f702b 196 wxStaticText* itemStaticText23 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Left:"), wxDefaultPosition, wxDefaultSize, 0 );
69ce77e2 197 itemFlexGridSizer22->Add(itemStaticText23, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 198
603f702b 199 m_indentLeft = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55 200 m_indentLeft->SetHelpText(_("The left indent."));
6103234e 201 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 202 m_indentLeft->SetToolTip(_("The left indent."));
41d9dcbc 203 itemFlexGridSizer22->Add(m_indentLeft, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 204
41d9dcbc
JS
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);
97ff49b3 207
603f702b 208 m_indentLeftFirst = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55 209 m_indentLeftFirst->SetHelpText(_("The first line indent."));
6103234e 210 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 211 m_indentLeftFirst->SetToolTip(_("The first line indent."));
41d9dcbc 212 itemFlexGridSizer22->Add(m_indentLeftFirst, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 213
41d9dcbc
JS
214 wxStaticText* itemStaticText27 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 );
215 itemFlexGridSizer22->Add(itemStaticText27, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 216
603f702b 217 m_indentRight = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55 218 m_indentRight->SetHelpText(_("The right indent."));
6103234e 219 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 220 m_indentRight->SetToolTip(_("The right indent."));
41d9dcbc 221 itemFlexGridSizer22->Add(m_indentRight, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
4d6d8bf4 222
41d9dcbc
JS
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);
4d6d8bf4 225
6103234e 226 wxArrayString m_outlineLevelCtrlStrings;
1c47b948 227 m_outlineLevelCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL, wxEmptyString, wxDefaultPosition, wxSize(85, -1), m_outlineLevelCtrlStrings, wxCB_READONLY );
4d6d8bf4 228 m_outlineLevelCtrl->SetHelpText(_("The outline level."));
6103234e 229 if (wxRichTextIndentsSpacingPage::ShowToolTips())
4d6d8bf4 230 m_outlineLevelCtrl->SetToolTip(_("The outline level."));
41d9dcbc 231 itemFlexGridSizer22->Add(m_outlineLevelCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3
JS
232
233 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
234
41d9dcbc
JS
235 wxStaticLine* itemStaticLine32 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
236 itemBoxSizer4->Add(itemStaticLine32, 0, wxGROW|wxTOP|wxBOTTOM, 5);
97ff49b3
JS
237
238 itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
239
41d9dcbc
JS
240 wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxVERTICAL);
241 itemBoxSizer4->Add(itemBoxSizer34, 0, wxGROW, 5);
97ff49b3 242
41d9dcbc
JS
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);
97ff49b3 245
41d9dcbc
JS
246 wxBoxSizer* itemBoxSizer36 = new wxBoxSizer(wxHORIZONTAL);
247 itemBoxSizer34->Add(itemBoxSizer36, 0, wxALIGN_LEFT|wxALL, 5);
97ff49b3 248
41d9dcbc 249 itemBoxSizer36->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 250
41d9dcbc
JS
251 wxFlexGridSizer* itemFlexGridSizer38 = new wxFlexGridSizer(30, 2, 0, 0);
252 itemBoxSizer36->Add(itemFlexGridSizer38, 0, wxALIGN_CENTER_VERTICAL, 5);
97ff49b3 253
41d9dcbc
JS
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);
97ff49b3 256
603f702b 257 m_spacingBefore = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
dadd4f55 258 m_spacingBefore->SetHelpText(_("The spacing before the paragraph."));
6103234e 259 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 260 m_spacingBefore->SetToolTip(_("The spacing before the paragraph."));
41d9dcbc 261 itemFlexGridSizer38->Add(m_spacingBefore, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 262
41d9dcbc
JS
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);
97ff49b3 265
603f702b 266 m_spacingAfter = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
6103234e 267 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 268 m_spacingAfter->SetToolTip(_("The spacing after the paragraph."));
41d9dcbc 269 itemFlexGridSizer38->Add(m_spacingAfter, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 270
41d9dcbc
JS
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);
97ff49b3 273
6103234e 274 wxArrayString m_spacingLineStrings;
41d9dcbc 275 m_spacingLineStrings.Add(_("(none)"));
6103234e 276 m_spacingLineStrings.Add(_("Single"));
02aa812c
JS
277 m_spacingLineStrings.Add(_("1.1"));
278 m_spacingLineStrings.Add(_("1.2"));
279 m_spacingLineStrings.Add(_("1.3"));
280 m_spacingLineStrings.Add(_("1.4"));
6103234e 281 m_spacingLineStrings.Add(_("1.5"));
02aa812c
JS
282 m_spacingLineStrings.Add(_("1.6"));
283 m_spacingLineStrings.Add(_("1.7"));
284 m_spacingLineStrings.Add(_("1.8"));
285 m_spacingLineStrings.Add(_("1.9"));
6103234e 286 m_spacingLineStrings.Add(_("2"));
41d9dcbc
JS
287 m_spacingLine = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, _("(none)"), wxDefaultPosition, wxSize(85, -1), m_spacingLineStrings, wxCB_READONLY );
288 m_spacingLine->SetStringSelection(_("(none)"));
dadd4f55 289 m_spacingLine->SetHelpText(_("The line spacing."));
6103234e 290 if (wxRichTextIndentsSpacingPage::ShowToolTips())
dadd4f55 291 m_spacingLine->SetToolTip(_("The line spacing."));
41d9dcbc 292 itemFlexGridSizer38->Add(m_spacingLine, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
97ff49b3 293
4c7d9d88
JS
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
2fce6547 301 itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5);
97ff49b3 302
cd720353 303 m_previewCtrl = new wxRichTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 100), wxBORDER_THEME|wxVSCROLL|wxTE_READONLY );
97ff49b3 304 m_previewCtrl->SetHelpText(_("Shows a preview of the paragraph settings."));
6103234e 305 if (wxRichTextIndentsSpacingPage::ShowToolTips())
97ff49b3 306 m_previewCtrl->SetToolTip(_("Shows a preview of the paragraph settings."));
2fce6547 307 itemBoxSizer3->Add(m_previewCtrl, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
97ff49b3
JS
308
309////@end wxRichTextIndentsSpacingPage content construction
1c47b948
JS
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)"));
97ff49b3
JS
328}
329
24777478 330wxRichTextAttr* wxRichTextIndentsSpacingPage::GetAttributes()
97ff49b3
JS
331{
332 return wxRichTextFormattingDialog::GetDialogAttributes(this);
333}
334
335/// Updates the font preview
336void wxRichTextIndentsSpacingPage::UpdatePreview()
337{
338 static const wxChar* s_para1 = wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
2a94806c 339Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n");
97ff49b3 340
2a94806c
JS
341 static const wxChar* s_para2 = wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \
342et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n");
97ff49b3 343
2a94806c 344 static const wxChar* s_para3 = wxT("Integer convallis dolor at augue \
97ff49b3
JS
345iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
346
347 TransferDataFromWindow();
24777478 348 wxRichTextAttr attr(*GetAttributes());
97ff49b3
JS
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|
d2d0adc7 352 wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT));
97ff49b3
JS
353
354 wxFont font(m_previewCtrl->GetFont());
355 font.SetPointSize(9);
356 m_previewCtrl->SetFont(font);
357
24777478 358 wxRichTextAttr normalParaAttr;
dadd4f55
JS
359 normalParaAttr.SetFont(font);
360 normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
97ff49b3 361
dadd4f55 362 m_previewCtrl->Freeze();
97ff49b3
JS
363 m_previewCtrl->Clear();
364
dadd4f55 365 m_previewCtrl->BeginStyle(normalParaAttr);
97ff49b3 366 m_previewCtrl->WriteText(s_para1);
dadd4f55
JS
367 m_previewCtrl->EndStyle();
368
97ff49b3
JS
369 m_previewCtrl->BeginStyle(attr);
370 m_previewCtrl->WriteText(s_para2);
371 m_previewCtrl->EndStyle();
dadd4f55
JS
372
373 m_previewCtrl->BeginStyle(normalParaAttr);
97ff49b3 374 m_previewCtrl->WriteText(s_para3);
dadd4f55
JS
375 m_previewCtrl->EndStyle();
376
377 m_previewCtrl->Thaw();
97ff49b3
JS
378}
379
380/// Transfer data from/to window
381bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
382{
383 wxPanel::TransferDataFromWindow();
384
24777478 385 wxRichTextAttr* attr = GetAttributes();
97ff49b3
JS
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());
6607ee15 403 if (!leftIndent.empty() || !leftFirstIndent.empty())
97ff49b3 404 {
6607ee15
JS
405 int visualLeftIndent = 0;
406 if (!leftIndent.empty())
407 visualLeftIndent = wxAtoi(leftIndent);
408
97ff49b3
JS
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());
b68603d5 419 if (!rightIndent.empty())
97ff49b3
JS
420 attr->SetRightIndent(wxAtoi(rightIndent));
421 else
422 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT));
423
424 wxString spacingAfter(m_spacingAfter->GetValue());
b68603d5 425 if (!spacingAfter.empty())
97ff49b3
JS
426 attr->SetParagraphSpacingAfter(wxAtoi(spacingAfter));
427 else
428 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER));
429
430 wxString spacingBefore(m_spacingBefore->GetValue());
b68603d5 431 if (!spacingBefore.empty())
97ff49b3
JS
432 attr->SetParagraphSpacingBefore(wxAtoi(spacingBefore));
433 else
434 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE));
435
41d9dcbc 436 int spacingIndex = m_spacingLine->GetSelection() - 1;
97ff49b3 437 int lineSpacing = 0;
41d9dcbc 438 if (spacingIndex > -1)
02aa812c 439 lineSpacing = 10 + spacingIndex;
97ff49b3
JS
440
441 if (lineSpacing == 0)
442 attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING));
443 else
444 attr->SetLineSpacing(lineSpacing);
44cc96a8 445
4d6d8bf4 446 int outlineLevel = m_outlineLevelCtrl->GetSelection();
41d9dcbc
JS
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);
97ff49b3 454
4c7d9d88
JS
455 attr->SetPageBreak(m_pageBreakCtrl->GetValue());
456
97ff49b3
JS
457 return true;
458}
459
460bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
461{
462 m_dontUpdate = true;
463
464 wxPanel::TransferDataToWindow();
465
24777478 466 wxRichTextAttr* attr = GetAttributes();
97ff49b3
JS
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 {
e79322ef
VZ
486 wxString leftIndent(wxString::Format(wxT("%ld"), attr->GetLeftIndent() + attr->GetLeftSubIndent()));
487 wxString leftFirstIndent(wxString::Format(wxT("%ld"), attr->GetLeftIndent()));
97ff49b3
JS
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 {
e79322ef 500 wxString rightIndent(wxString::Format(wxT("%ld"), attr->GetRightIndent()));
97ff49b3
JS
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();
02aa812c 530 if (lineSpacing >= 10 && lineSpacing <= 20)
41d9dcbc 531 index = (lineSpacing - 10) + 1;
97ff49b3 532 else
41d9dcbc 533 index = 0;
97ff49b3
JS
534
535 m_spacingLine->SetSelection(index);
536 }
537 else
41d9dcbc 538 m_spacingLine->SetSelection(0);
97ff49b3 539
4d6d8bf4
JS
540 if (attr->HasOutlineLevel())
541 {
542 int outlineLevel = attr->GetOutlineLevel();
543 if (outlineLevel < 0)
544 outlineLevel = 0;
545 if (outlineLevel > 9)
44cc96a8 546 outlineLevel = 9;
4d6d8bf4 547
41d9dcbc 548 m_outlineLevelCtrl->SetSelection(outlineLevel+1);
4d6d8bf4
JS
549 }
550 else
41d9dcbc 551 m_outlineLevelCtrl->SetSelection(0);
4d6d8bf4 552
4c7d9d88
JS
553 m_pageBreakCtrl->SetValue(attr->HasPageBreak());
554
97ff49b3
JS
555 UpdatePreview();
556
557 m_dontUpdate = false;
558
559 return true;
560}
561
562
563/*!
564 * Should we show tooltips?
565 */
566
567bool wxRichTextIndentsSpacingPage::ShowToolTips()
568{
dadd4f55 569 return wxRichTextFormattingDialog::ShowToolTips();
97ff49b3
JS
570}
571
572/*!
573 * Get bitmap resources
574 */
575
576wxBitmap 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
589wxIcon 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/*!
ce7fe42e 598 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
97ff49b3
JS
599 */
600
601void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent& WXUNUSED(event) )
602{
603 if (!m_dontUpdate)
604 UpdatePreview();
605}
606
607
608/*!
ce7fe42e 609 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
97ff49b3
JS
610 */
611
612void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent& WXUNUSED(event) )
613{
614 if (!m_dontUpdate)
615 UpdatePreview();
616}
617
618
619/*!
ce7fe42e 620 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
97ff49b3
JS
621 */
622
623void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent& WXUNUSED(event) )
624{
625 if (!m_dontUpdate)
626 UpdatePreview();
627}
628
629
630/*!
ce7fe42e 631 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
97ff49b3
JS
632 */
633
634void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent& WXUNUSED(event) )
635{
636 if (!m_dontUpdate)
637 UpdatePreview();
638}
639
640
641/*!
ce7fe42e 642 * wxEVT_RADIOBUTTON event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
97ff49b3
JS
643 */
644
645void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent& WXUNUSED(event) )
646{
647 if (!m_dontUpdate)
648 UpdatePreview();
649}
650
651
652/*!
ce7fe42e 653 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
97ff49b3
JS
654 */
655
656void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent& WXUNUSED(event) )
657{
658 if (!m_dontUpdate)
659 UpdatePreview();
660}
661
662
663/*!
ce7fe42e 664 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
97ff49b3
JS
665 */
666
667void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent& WXUNUSED(event) )
668{
669 if (!m_dontUpdate)
670 UpdatePreview();
671}
672
673
674/*!
ce7fe42e 675 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
97ff49b3
JS
676 */
677
678void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent& WXUNUSED(event) )
679{
680 if (!m_dontUpdate)
681 UpdatePreview();
682}
683
684
685/*!
ce7fe42e 686 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
97ff49b3
JS
687 */
688
689void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent& WXUNUSED(event) )
690{
691 if (!m_dontUpdate)
692 UpdatePreview();
693}
694
695
696/*!
ce7fe42e 697 * wxEVT_TEXT event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
97ff49b3
JS
698 */
699
700void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent& WXUNUSED(event) )
701{
702 if (!m_dontUpdate)
703 UpdatePreview();
704}
705
706/*!
ce7fe42e 707 * wxEVT_COMBOBOX event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
97ff49b3
JS
708 */
709
710void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent& WXUNUSED(event) )
711{
712 if (!m_dontUpdate)
713 UpdatePreview();
714}
715
4d6d8bf4 716/*!
ce7fe42e 717 * wxEVT_COMBOBOX event handler for ID_RICHTEXTINDENTSSPACINGPAGE_OUTLINELEVEL
4d6d8bf4
JS
718 */
719
720void wxRichTextIndentsSpacingPage::OnRichtextOutlinelevelSelected( wxCommandEvent& WXUNUSED(event) )
721{
722 if (!m_dontUpdate)
723 UpdatePreview();
724}
725
b68603d5 726#endif // wxUSE_RICHTEXT