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