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