]> git.saurik.com Git - wxWidgets.git/blob - src/richtext/richtextsizepage.cpp
33a4b051b499b286d004124db8eed083b344e812
[wxWidgets.git] / src / richtext / richtextsizepage.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtextsizepage.cpp
3 // Purpose:
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 20/10/2010 10:23:24
7 // RCS-ID:
8 // Copyright: (c) Julian Smart
9 // Licence:
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22
23 ////@begin includes
24 ////@end includes
25
26 #include "wx/richtext/richtextsizepage.h"
27
28 ////@begin XPM images
29 ////@end XPM images
30
31
32 /*!
33 * wxRichTextSizePage type definition
34 */
35
36 IMPLEMENT_DYNAMIC_CLASS( wxRichTextSizePage, wxRichTextDialogPage )
37
38
39 /*!
40 * wxRichTextSizePage event table definition
41 */
42
43 BEGIN_EVENT_TABLE( wxRichTextSizePage, wxRichTextDialogPage )
44
45 ////@begin wxRichTextSizePage event table entries
46 EVT_UPDATE_UI( ID_RICHTEXT_WIDTH, wxRichTextSizePage::OnRichtextWidthUpdate )
47
48 EVT_UPDATE_UI( ID_RICHTEXT_UNITS_W, wxRichTextSizePage::OnRichtextWidthUpdate )
49
50 EVT_UPDATE_UI( ID_RICHTEXT_HEIGHT, wxRichTextSizePage::OnRichtextHeightUpdate )
51
52 EVT_UPDATE_UI( ID_RICHTEXT_UNITS_H, wxRichTextSizePage::OnRichtextHeightUpdate )
53
54 EVT_UPDATE_UI( ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX, wxRichTextSizePage::OnRichtextVerticalAlignmentComboboxUpdate )
55
56 EVT_UPDATE_UI( ID_RICHTEXT_OFFSET, wxRichTextSizePage::OnRichtextOffsetUpdate )
57
58 EVT_UPDATE_UI( ID_RICHTEXT_OFFSET_UNITS, wxRichTextSizePage::OnRichtextOffsetUpdate )
59
60 EVT_BUTTON( ID_RICHTEXT_PARA_UP, wxRichTextSizePage::OnRichtextParaUpClick )
61
62 EVT_BUTTON( ID_RICHTEXT_PARA_DOWN, wxRichTextSizePage::OnRichtextParaDownClick )
63
64 ////@end wxRichTextSizePage event table entries
65
66 END_EVENT_TABLE()
67
68 IMPLEMENT_HELP_PROVISION(wxRichTextSizePage)
69
70 /*!
71 * wxRichTextSizePage constructors
72 */
73
74 wxRichTextSizePage::wxRichTextSizePage()
75 {
76 Init();
77 }
78
79 wxRichTextSizePage::wxRichTextSizePage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
80 {
81 Init();
82 Create(parent, id, pos, size, style);
83 }
84
85
86 /*!
87 * wxRichTextSizePage creator
88 */
89
90 bool wxRichTextSizePage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
91 {
92 ////@begin wxRichTextSizePage creation
93 wxRichTextDialogPage::Create( parent, id, pos, size, style );
94
95 CreateControls();
96 if (GetSizer())
97 {
98 GetSizer()->SetSizeHints(this);
99 }
100 Centre();
101 ////@end wxRichTextSizePage creation
102 return true;
103 }
104
105
106 /*!
107 * wxRichTextSizePage destructor
108 */
109
110 wxRichTextSizePage::~wxRichTextSizePage()
111 {
112 ////@begin wxRichTextSizePage destruction
113 ////@end wxRichTextSizePage destruction
114 }
115
116
117 /*!
118 * Member initialisation
119 */
120
121 void wxRichTextSizePage::Init()
122 {
123 ////@begin wxRichTextSizePage member initialisation
124 m_parentSizer = NULL;
125 m_floatingControls = NULL;
126 m_float = NULL;
127 m_widthCheckbox = NULL;
128 m_width = NULL;
129 m_unitsW = NULL;
130 m_heightCheckbox = NULL;
131 m_height = NULL;
132 m_unitsH = NULL;
133 m_alignmentControls = NULL;
134 m_verticalAlignmentCheckbox = NULL;
135 m_verticalAlignmentComboBox = NULL;
136 m_positionControls = NULL;
137 m_moveObjectParentSizer = NULL;
138 m_offsetYCheckbox = NULL;
139 m_offset = NULL;
140 m_unitsOffset = NULL;
141 m_moveObjectSizer = NULL;
142 ////@end wxRichTextSizePage member initialisation
143 }
144
145
146 /*!
147 * Control creation for wxRichTextSizePage
148 */
149
150 void wxRichTextSizePage::CreateControls()
151 {
152 ////@begin wxRichTextSizePage content construction
153 wxRichTextSizePage* itemRichTextDialogPage1 = this;
154
155 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
156 itemRichTextDialogPage1->SetSizer(itemBoxSizer2);
157
158 m_parentSizer = new wxBoxSizer(wxVERTICAL);
159 itemBoxSizer2->Add(m_parentSizer, 0, wxGROW|wxALL, 5);
160
161 m_floatingControls = new wxBoxSizer(wxVERTICAL);
162 m_parentSizer->Add(m_floatingControls, 0, wxGROW, 5);
163
164 wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
165 m_floatingControls->Add(itemBoxSizer5, 0, wxGROW, 5);
166
167 wxStaticText* itemStaticText6 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Floating"), wxDefaultPosition, wxDefaultSize, 0 );
168 itemStaticText6->SetFont(wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFamily(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetStyle(), wxBOLD, false, wxT("")));
169 itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
170
171 wxStaticLine* itemStaticLine7 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
172 itemBoxSizer5->Add(itemStaticLine7, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
173
174 wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
175 m_floatingControls->Add(itemBoxSizer8, 0, wxGROW, 5);
176
177 itemBoxSizer8->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
178
179 wxFlexGridSizer* itemFlexGridSizer10 = new wxFlexGridSizer(0, 2, 0, 0);
180 itemBoxSizer8->Add(itemFlexGridSizer10, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5);
181
182 wxStaticText* itemStaticText11 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Floating mode:"), wxDefaultPosition, wxDefaultSize, 0 );
183 itemFlexGridSizer10->Add(itemStaticText11, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
184
185 wxArrayString m_floatStrings;
186 m_floatStrings.Add(_("None"));
187 m_floatStrings.Add(_("Left"));
188 m_floatStrings.Add(_("Right"));
189 m_float = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXT_FLOATING_MODE, _("None"), wxDefaultPosition, wxSize(80, -1), m_floatStrings, wxCB_READONLY );
190 m_float->SetStringSelection(_("None"));
191 m_float->SetHelpText(_("How the object will float relative to the text."));
192 if (wxRichTextSizePage::ShowToolTips())
193 m_float->SetToolTip(_("How the object will float relative to the text."));
194 itemFlexGridSizer10->Add(m_float, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
195
196 wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
197 m_parentSizer->Add(itemBoxSizer13, 0, wxGROW, 5);
198
199 wxStaticText* itemStaticText14 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 );
200 itemStaticText14->SetFont(wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFamily(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetStyle(), wxBOLD, false, wxT("")));
201 itemBoxSizer13->Add(itemStaticText14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
202
203 wxStaticLine* itemStaticLine15 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
204 itemBoxSizer13->Add(itemStaticLine15, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
205
206 wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
207 m_parentSizer->Add(itemBoxSizer16, 0, wxGROW, 5);
208
209 itemBoxSizer16->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
210
211 wxFlexGridSizer* itemFlexGridSizer18 = new wxFlexGridSizer(0, 2, 0, 0);
212 itemBoxSizer16->Add(itemFlexGridSizer18, 0, wxALIGN_CENTER_VERTICAL, 5);
213
214 m_widthCheckbox = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXT_WIDTH_CHECKBOX, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
215 m_widthCheckbox->SetValue(false);
216 m_widthCheckbox->SetHelpText(_("Enable the width value."));
217 if (wxRichTextSizePage::ShowToolTips())
218 m_widthCheckbox->SetToolTip(_("Enable the width value."));
219 itemFlexGridSizer18->Add(m_widthCheckbox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
220
221 wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
222 itemFlexGridSizer18->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
223
224 m_width = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXT_WIDTH, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
225 m_width->SetHelpText(_("The object width."));
226 if (wxRichTextSizePage::ShowToolTips())
227 m_width->SetToolTip(_("The object width."));
228 itemBoxSizer20->Add(m_width, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
229
230 wxArrayString m_unitsWStrings;
231 m_unitsWStrings.Add(_("px"));
232 m_unitsWStrings.Add(_("cm"));
233 m_unitsW = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXT_UNITS_W, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsWStrings, wxCB_READONLY );
234 m_unitsW->SetStringSelection(_("px"));
235 m_unitsW->SetHelpText(_("Units for the object width."));
236 if (wxRichTextSizePage::ShowToolTips())
237 m_unitsW->SetToolTip(_("Units for the object width."));
238 itemBoxSizer20->Add(m_unitsW, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
239
240 m_heightCheckbox = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXT_HEIGHT_CHECKBOX, _("&Height:"), wxDefaultPosition, wxDefaultSize, 0 );
241 m_heightCheckbox->SetValue(false);
242 m_heightCheckbox->SetHelpText(_("Enable the height value."));
243 if (wxRichTextSizePage::ShowToolTips())
244 m_heightCheckbox->SetToolTip(_("Enable the height value."));
245 itemFlexGridSizer18->Add(m_heightCheckbox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
246
247 wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL);
248 itemFlexGridSizer18->Add(itemBoxSizer24, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
249
250 m_height = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXT_HEIGHT, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
251 m_height->SetHelpText(_("The object height."));
252 if (wxRichTextSizePage::ShowToolTips())
253 m_height->SetToolTip(_("The object height."));
254 itemBoxSizer24->Add(m_height, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
255
256 wxArrayString m_unitsHStrings;
257 m_unitsHStrings.Add(_("px"));
258 m_unitsHStrings.Add(_("cm"));
259 m_unitsH = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXT_UNITS_H, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsHStrings, wxCB_READONLY );
260 m_unitsH->SetStringSelection(_("px"));
261 m_unitsH->SetHelpText(_("Units for the object height."));
262 if (wxRichTextSizePage::ShowToolTips())
263 m_unitsH->SetToolTip(_("Units for the object height."));
264 itemBoxSizer24->Add(m_unitsH, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
265
266 m_alignmentControls = new wxBoxSizer(wxVERTICAL);
267 m_parentSizer->Add(m_alignmentControls, 0, wxGROW, 5);
268
269 wxBoxSizer* itemBoxSizer28 = new wxBoxSizer(wxHORIZONTAL);
270 m_alignmentControls->Add(itemBoxSizer28, 0, wxGROW, 5);
271
272 wxStaticText* itemStaticText29 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Alignment"), wxDefaultPosition, wxDefaultSize, 0 );
273 itemStaticText29->SetFont(wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFamily(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetStyle(), wxBOLD, false, wxT("")));
274 itemBoxSizer28->Add(itemStaticText29, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
275
276 wxStaticLine* itemStaticLine30 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
277 itemBoxSizer28->Add(itemStaticLine30, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
278
279 wxBoxSizer* itemBoxSizer31 = new wxBoxSizer(wxHORIZONTAL);
280 m_alignmentControls->Add(itemBoxSizer31, 0, wxGROW, 5);
281
282 itemBoxSizer31->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
283
284 m_verticalAlignmentCheckbox = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXT_VERTICAL_ALIGNMENT_CHECKBOX, _("&Vertical alignment:"), wxDefaultPosition, wxDefaultSize, 0 );
285 m_verticalAlignmentCheckbox->SetValue(false);
286 m_verticalAlignmentCheckbox->SetHelpText(_("Enable vertical alignment."));
287 if (wxRichTextSizePage::ShowToolTips())
288 m_verticalAlignmentCheckbox->SetToolTip(_("Enable vertical alignment."));
289 itemBoxSizer31->Add(m_verticalAlignmentCheckbox, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
290
291 wxArrayString m_verticalAlignmentComboBoxStrings;
292 m_verticalAlignmentComboBoxStrings.Add(_("Top"));
293 m_verticalAlignmentComboBoxStrings.Add(_("Centred"));
294 m_verticalAlignmentComboBoxStrings.Add(_("Bottom"));
295 m_verticalAlignmentComboBox = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX, _("Top"), wxDefaultPosition, wxDefaultSize, m_verticalAlignmentComboBoxStrings, wxCB_READONLY );
296 m_verticalAlignmentComboBox->SetStringSelection(_("Top"));
297 m_verticalAlignmentComboBox->SetHelpText(_("Vertical alignment."));
298 if (wxRichTextSizePage::ShowToolTips())
299 m_verticalAlignmentComboBox->SetToolTip(_("Vertical alignment."));
300 itemBoxSizer31->Add(m_verticalAlignmentComboBox, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
301
302 m_positionControls = new wxBoxSizer(wxVERTICAL);
303 m_parentSizer->Add(m_positionControls, 0, wxGROW, 5);
304
305 wxBoxSizer* itemBoxSizer36 = new wxBoxSizer(wxHORIZONTAL);
306 m_positionControls->Add(itemBoxSizer36, 0, wxGROW, 5);
307
308 wxStaticText* itemStaticText37 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Position"), wxDefaultPosition, wxDefaultSize, 0 );
309 itemStaticText37->SetFont(wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetPointSize(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetFamily(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).GetStyle(), wxBOLD, false, wxT("")));
310 itemBoxSizer36->Add(itemStaticText37, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
311
312 wxStaticLine* itemStaticLine38 = new wxStaticLine( itemRichTextDialogPage1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
313 itemBoxSizer36->Add(itemStaticLine38, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
314
315 wxBoxSizer* itemBoxSizer39 = new wxBoxSizer(wxHORIZONTAL);
316 m_positionControls->Add(itemBoxSizer39, 0, wxGROW, 5);
317
318 itemBoxSizer39->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
319
320 m_moveObjectParentSizer = new wxBoxSizer(wxVERTICAL);
321 itemBoxSizer39->Add(m_moveObjectParentSizer, 0, wxALIGN_TOP, 5);
322
323 wxBoxSizer* itemBoxSizer42 = new wxBoxSizer(wxHORIZONTAL);
324 m_moveObjectParentSizer->Add(itemBoxSizer42, 0, wxGROW, 5);
325
326 m_offsetYCheckbox = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXT_OFFSET_CHECKBOX, _("Vertical &Offset:"), wxDefaultPosition, wxDefaultSize, 0 );
327 m_offsetYCheckbox->SetValue(false);
328 m_offsetYCheckbox->SetHelpText(_("Enable vertical offset."));
329 if (wxRichTextSizePage::ShowToolTips())
330 m_offsetYCheckbox->SetToolTip(_("Enable vertical offset."));
331 itemBoxSizer42->Add(m_offsetYCheckbox, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
332
333 m_offset = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXT_OFFSET, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
334 m_offset->SetMaxLength(10);
335 m_offset->SetHelpText(_("The vertical offset relative to the paragraph."));
336 if (wxRichTextSizePage::ShowToolTips())
337 m_offset->SetToolTip(_("The vertical offset relative to the paragraph."));
338 itemBoxSizer42->Add(m_offset, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
339
340 wxArrayString m_unitsOffsetStrings;
341 m_unitsOffsetStrings.Add(_("px"));
342 m_unitsOffsetStrings.Add(_("cm"));
343 m_unitsOffset = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXT_OFFSET_UNITS, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsOffsetStrings, wxCB_READONLY );
344 m_unitsOffset->SetStringSelection(_("px"));
345 m_unitsOffset->SetHelpText(_("Units for the object offset."));
346 if (wxRichTextSizePage::ShowToolTips())
347 m_unitsOffset->SetToolTip(_("Units for the object offset."));
348 itemBoxSizer42->Add(m_unitsOffset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
349
350 m_moveObjectSizer = new wxBoxSizer(wxHORIZONTAL);
351 m_moveObjectParentSizer->Add(m_moveObjectSizer, 0, wxGROW, 5);
352
353 wxStaticText* itemStaticText47 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Move the object to:"), wxDefaultPosition, wxDefaultSize, 0 );
354 m_moveObjectSizer->Add(itemStaticText47, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
355
356 wxButton* itemButton48 = new wxButton( itemRichTextDialogPage1, ID_RICHTEXT_PARA_UP, _("&Previous Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
357 itemButton48->SetHelpText(_("Moves the object to the previous paragraph."));
358 if (wxRichTextSizePage::ShowToolTips())
359 itemButton48->SetToolTip(_("Moves the object to the previous paragraph."));
360 m_moveObjectSizer->Add(itemButton48, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
361
362 wxButton* itemButton49 = new wxButton( itemRichTextDialogPage1, ID_RICHTEXT_PARA_DOWN, _("&Next Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
363 itemButton49->SetHelpText(_("Moves the object to the next paragraph."));
364 if (wxRichTextSizePage::ShowToolTips())
365 itemButton49->SetToolTip(_("Moves the object to the next paragraph."));
366 m_moveObjectSizer->Add(itemButton49, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
367
368 ////@end wxRichTextSizePage content construction
369 }
370
371 wxRichTextAttr* wxRichTextSizePage::GetAttributes()
372 {
373 return wxRichTextFormattingDialog::GetDialogAttributes(this);
374 }
375
376 /*!
377 * Should we show tooltips?
378 */
379
380 bool wxRichTextSizePage::ShowToolTips()
381 {
382 return true;
383 }
384
385 bool wxRichTextSizePage::TransferDataToWindow()
386 {
387 m_float->SetSelection(GetAttributes()->GetTextBoxAttr().GetFloatMode());
388 m_verticalAlignmentCheckbox->SetValue(GetAttributes()->GetTextBoxAttr().HasVerticalAlignment());
389 if (GetAttributes()->GetTextBoxAttr().HasVerticalAlignment())
390 {
391 if ((int) GetAttributes()->GetTextBoxAttr().GetVerticalAlignment() > 0 &&
392 (int) GetAttributes()->GetTextBoxAttr().GetVerticalAlignment() < 4)
393 {
394 m_verticalAlignmentComboBox->SetSelection(((int) GetAttributes()->GetTextBoxAttr().GetVerticalAlignment() - 1));
395 }
396 else
397 m_verticalAlignmentComboBox->SetSelection(0);
398 }
399
400 wxRichTextFormattingDialog* dialog = wxRichTextFormattingDialog::GetDialog(this);
401
402 if (dialog)
403 {
404 // Only show the Move Object controls if there's an object.
405 if (!dialog->GetObject())
406 {
407 m_moveObjectParentSizer->Show(m_moveObjectSizer, false);
408 GetSizer()->Layout();
409 }
410 }
411
412 if (dialog && dialog->GetObject())
413 {
414 wxTextAttrSize size = dialog->GetObject()->GetNaturalSize();
415 if (size.GetWidth().IsValid() && size.GetHeight().IsValid())
416 {
417 if (!GetAttributes()->GetTextBoxAttr().GetWidth().IsValid() || GetAttributes()->GetTextBoxAttr().GetWidth().GetValue() <= 0)
418 {
419 GetAttributes()->GetTextBoxAttr().GetWidth() = size.GetWidth();
420 }
421
422 if (!GetAttributes()->GetTextBoxAttr().GetHeight().IsValid() || GetAttributes()->GetTextBoxAttr().GetHeight().GetValue() <= 0)
423 {
424 GetAttributes()->GetTextBoxAttr().GetHeight() = size.GetHeight();
425 }
426 }
427 }
428
429 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetWidth(), m_width, m_unitsW, m_widthCheckbox);
430 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetHeight(), m_height, m_unitsH, m_heightCheckbox);
431 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetTop(), m_offset, m_unitsOffset, m_offsetYCheckbox);
432
433 return true;
434 }
435
436 bool wxRichTextSizePage::TransferDataFromWindow()
437 {
438 GetAttributes()->GetTextBoxAttr().SetFloatMode((wxTextBoxAttrFloatStyle) m_float->GetSelection());
439 if (m_float->GetSelection() == 0)
440 GetAttributes()->GetTextBoxAttr().RemoveFlag(wxTEXT_BOX_ATTR_FLOAT);
441
442 if (m_verticalAlignmentCheckbox->GetValue())
443 GetAttributes()->GetTextBoxAttr().SetVerticalAlignment((wxTextBoxAttrVerticalAlignment) (m_verticalAlignmentComboBox->GetSelection() + 1));
444 else
445 {
446 GetAttributes()->GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE);
447 GetAttributes()->GetTextBoxAttr().RemoveFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT);
448 }
449
450 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetWidth(), m_width, m_unitsW, m_widthCheckbox);
451 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetHeight(), m_height, m_unitsH, m_heightCheckbox);
452 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetTop(), m_offset, m_unitsOffset, m_offsetYCheckbox);
453
454 return true;
455 }
456
457 // Show/hide position controls
458 void wxRichTextSizePage::ShowPositionControls(bool show)
459 {
460 if (m_parentSizer)
461 {
462 m_parentSizer->Show(m_positionControls, show);
463 Layout();
464 }
465 }
466
467 // Show/hide floating controls
468 void wxRichTextSizePage::ShowFloatingControls(bool show)
469 {
470 if (m_parentSizer)
471 {
472 m_parentSizer->Show(m_floatingControls, show);
473 Layout();
474 }
475 }
476
477
478 /*!
479 * Get bitmap resources
480 */
481
482 wxBitmap wxRichTextSizePage::GetBitmapResource( const wxString& name )
483 {
484 // Bitmap retrieval
485 ////@begin wxRichTextSizePage bitmap retrieval
486 wxUnusedVar(name);
487 return wxNullBitmap;
488 ////@end wxRichTextSizePage bitmap retrieval
489 }
490
491 /*!
492 * Get icon resources
493 */
494
495 wxIcon wxRichTextSizePage::GetIconResource( const wxString& name )
496 {
497 // Icon retrieval
498 ////@begin wxRichTextSizePage icon retrieval
499 wxUnusedVar(name);
500 return wxNullIcon;
501 ////@end wxRichTextSizePage icon retrieval
502 }
503
504
505 /*!
506 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_WIDTH
507 */
508
509 void wxRichTextSizePage::OnRichtextWidthUpdate( wxUpdateUIEvent& event )
510 {
511 event.Enable(m_widthCheckbox->GetValue());
512 }
513
514 /*!
515 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_HEIGHT
516 */
517
518 void wxRichTextSizePage::OnRichtextHeightUpdate( wxUpdateUIEvent& event )
519 {
520 event.Enable(m_heightCheckbox->GetValue());
521 }
522
523 /*!
524 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_OFFSET
525 */
526
527 void wxRichTextSizePage::OnRichtextOffsetUpdate( wxUpdateUIEvent& event )
528 {
529 event.Enable(m_offsetYCheckbox->GetValue());
530 }
531
532
533 /*!
534 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXT_PARA_UP
535 */
536
537 void wxRichTextSizePage::OnRichtextParaUpClick( wxCommandEvent& WXUNUSED(event) )
538 {
539 wxRichTextFormattingDialog* dialog = wxRichTextFormattingDialog::GetDialog(this);
540 if (!dialog || !dialog->GetObject())
541 return;
542
543 // Make sure object attributes are up-to-date
544 dialog->TransferDataFromWindow();
545
546 wxRichTextBuffer* buffer = dialog->GetObject()->GetBuffer();
547 wxRichTextParagraphLayoutBox* container = dialog->GetObject()->GetParentContainer();
548 wxRichTextObject* parent = dialog->GetObject()->GetParent();
549 if (!container || !parent || !buffer)
550 return;
551
552 wxRichTextRange range = dialog->GetObject()->GetRange();
553 wxRichTextObjectList::compatibility_iterator iter = container->GetChildren().GetFirst();
554 if (!iter)
555 return;
556
557 while (iter)
558 {
559 if (iter->GetData() == parent)
560 break;
561 iter = iter->GetNext();
562 }
563 if (!iter)
564 return;
565 iter = iter->GetPrevious();
566 if (!iter)
567 return;
568
569 wxRichTextObject *obj = iter->GetData();
570 wxRichTextRange rg = obj->GetRange();
571 // tempObj will be deleted along with the undo object, and a clone of it will be
572 // returned by InsertObjectWithUndo
573 wxRichTextObject* tempObj = dialog->GetObject()->Clone();
574
575 container->DeleteRangeWithUndo(range, buffer->GetRichTextCtrl(), buffer);
576
577 wxRichTextObject* obj2 = container->InsertObjectWithUndo(rg.GetStart(), tempObj, buffer->GetRichTextCtrl(), buffer, 0);
578 dialog->SetObject(obj2);
579 }
580
581 /*!
582 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXT_DOWN
583 */
584
585 void wxRichTextSizePage::OnRichtextParaDownClick( wxCommandEvent& WXUNUSED(event) )
586 {
587 wxRichTextFormattingDialog* dialog = wxRichTextFormattingDialog::GetDialog(this);
588 if (!dialog || !dialog->GetObject())
589 return;
590
591 // Make sure object attributes are up-to-date
592 dialog->TransferDataFromWindow();
593
594 wxRichTextBuffer* buffer = dialog->GetObject()->GetBuffer();
595 wxRichTextParagraphLayoutBox* container = dialog->GetObject()->GetParentContainer();
596 wxRichTextObject* parent = dialog->GetObject()->GetParent();
597 if (!container || !parent || !buffer)
598 return;
599
600 wxRichTextRange range = dialog->GetObject()->GetRange();
601
602 wxRichTextObjectList::compatibility_iterator iter = buffer->GetChildren().GetFirst();
603 if (!iter)
604 return;
605
606 while (iter)
607 {
608 if (iter->GetData() == parent)
609 break;
610 iter = iter->GetNext();
611 }
612
613 iter = iter->GetNext();
614 if (!iter)
615 return;
616
617 wxRichTextObject *obj = iter->GetData();
618 wxRichTextRange rg = obj->GetRange();
619 // tempObj will be deleted along with the undo object, and a clone of it will be
620 // returned by InsertObjectWithUndo
621 wxRichTextObject* tempObj = dialog->GetObject()->Clone();
622
623 container->DeleteRangeWithUndo(range, buffer->GetRichTextCtrl(), buffer);
624
625 // Minus one because we deleted an object
626 wxRichTextObject* obj2 = container->InsertObjectWithUndo(rg.GetStart()-1, tempObj, buffer->GetRichTextCtrl(), buffer, 0);
627 dialog->SetObject(obj2);
628 }
629
630
631 /*!
632 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX
633 */
634
635 void wxRichTextSizePage::OnRichtextVerticalAlignmentComboboxUpdate( wxUpdateUIEvent& event )
636 {
637 event.Enable(m_verticalAlignmentCheckbox->GetValue());
638 }
639