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