1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtextsizepage.cpp
4 // Author: Julian Smart
6 // Created: 20/10/2010 10:23:24
8 // Copyright: (c) Julian Smart
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/richtext/richtextsizepage.h"
19 * wxRichTextSizePage type definition
22 IMPLEMENT_DYNAMIC_CLASS( wxRichTextSizePage
, wxRichTextDialogPage
)
26 * wxRichTextSizePage event table definition
29 BEGIN_EVENT_TABLE( wxRichTextSizePage
, wxRichTextDialogPage
)
31 ////@begin wxRichTextSizePage event table entries
32 EVT_UPDATE_UI( ID_RICHTEXT_WIDTH
, wxRichTextSizePage::OnRichtextWidthUpdate
)
34 EVT_UPDATE_UI( ID_RICHTEXT_UNITS_W
, wxRichTextSizePage::OnRichtextWidthUpdate
)
36 EVT_UPDATE_UI( ID_RICHTEXT_HEIGHT
, wxRichTextSizePage::OnRichtextHeightUpdate
)
38 EVT_UPDATE_UI( ID_RICHTEXT_UNITS_H
, wxRichTextSizePage::OnRichtextHeightUpdate
)
40 EVT_UPDATE_UI( ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX
, wxRichTextSizePage::OnRichtextVerticalAlignmentComboboxUpdate
)
42 EVT_UPDATE_UI( ID_RICHTEXT_OFFSET
, wxRichTextSizePage::OnRichtextOffsetUpdate
)
44 EVT_UPDATE_UI( ID_RICHTEXT_OFFSET_UNITS
, wxRichTextSizePage::OnRichtextOffsetUpdate
)
46 EVT_BUTTON( ID_RICHTEXT_PARA_UP
, wxRichTextSizePage::OnRichtextParaUpClick
)
48 EVT_BUTTON( ID_RICHTEXT_PARA_DOWN
, wxRichTextSizePage::OnRichtextParaDownClick
)
50 ////@end wxRichTextSizePage event table entries
54 IMPLEMENT_HELP_PROVISION(wxRichTextSizePage
)
57 * wxRichTextSizePage constructors
60 wxRichTextSizePage::wxRichTextSizePage()
65 wxRichTextSizePage::wxRichTextSizePage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
68 Create(parent
, id
, pos
, size
, style
);
73 * wxRichTextSizePage creator
76 bool wxRichTextSizePage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
78 ////@begin wxRichTextSizePage creation
79 wxRichTextDialogPage::Create( parent
, id
, pos
, size
, style
);
84 GetSizer()->SetSizeHints(this);
87 ////@end wxRichTextSizePage creation
93 * wxRichTextSizePage destructor
96 wxRichTextSizePage::~wxRichTextSizePage()
98 ////@begin wxRichTextSizePage destruction
99 ////@end wxRichTextSizePage destruction
104 * Member initialisation
107 void wxRichTextSizePage::Init()
109 ////@begin wxRichTextSizePage member initialisation
110 m_parentSizer
= NULL
;
111 m_floatingControls
= NULL
;
113 m_widthCheckbox
= NULL
;
116 m_heightCheckbox
= 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
;
126 m_unitsOffset
= NULL
;
127 m_moveObjectSizer
= NULL
;
128 ////@end wxRichTextSizePage member initialisation
133 * Control creation for wxRichTextSizePage
136 void wxRichTextSizePage::CreateControls()
138 ////@begin wxRichTextSizePage content construction
139 wxRichTextSizePage
* itemRichTextDialogPage1
= this;
141 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
142 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
144 m_parentSizer
= new wxBoxSizer(wxVERTICAL
);
145 itemBoxSizer2
->Add(m_parentSizer
, 0, wxGROW
|wxALL
, 5);
147 m_floatingControls
= new wxBoxSizer(wxVERTICAL
);
148 m_parentSizer
->Add(m_floatingControls
, 0, wxGROW
, 5);
150 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxHORIZONTAL
);
151 m_floatingControls
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
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);
157 wxStaticLine
* itemStaticLine7
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_HORIZONTAL
);
158 itemBoxSizer5
->Add(itemStaticLine7
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
160 wxBoxSizer
* itemBoxSizer8
= new wxBoxSizer(wxHORIZONTAL
);
161 m_floatingControls
->Add(itemBoxSizer8
, 0, wxGROW
, 5);
163 itemBoxSizer8
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
165 wxFlexGridSizer
* itemFlexGridSizer10
= new wxFlexGridSizer(0, 2, 0, 0);
166 itemBoxSizer8
->Add(itemFlexGridSizer10
, 0, wxALIGN_CENTER_VERTICAL
|wxRIGHT
, 5);
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);
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);
182 wxBoxSizer
* itemBoxSizer13
= new wxBoxSizer(wxHORIZONTAL
);
183 m_parentSizer
->Add(itemBoxSizer13
, 0, wxGROW
, 5);
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);
189 wxStaticLine
* itemStaticLine15
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_HORIZONTAL
);
190 itemBoxSizer13
->Add(itemStaticLine15
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
192 wxBoxSizer
* itemBoxSizer16
= new wxBoxSizer(wxHORIZONTAL
);
193 m_parentSizer
->Add(itemBoxSizer16
, 0, wxGROW
, 5);
195 itemBoxSizer16
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
197 wxFlexGridSizer
* itemFlexGridSizer18
= new wxFlexGridSizer(0, 2, 0, 0);
198 itemBoxSizer16
->Add(itemFlexGridSizer18
, 0, wxALIGN_CENTER_VERTICAL
, 5);
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);
207 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
208 itemFlexGridSizer18
->Add(itemBoxSizer20
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
, 5);
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);
216 wxArrayString m_unitsWStrings
;
217 m_unitsWStrings
.Add(_("px"));
218 m_unitsWStrings
.Add(_("cm"));
219 m_unitsW
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_UNITS_W
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsWStrings
, wxCB_READONLY
);
220 m_unitsW
->SetStringSelection(_("px"));
221 m_unitsW
->SetHelpText(_("Units for the object width."));
222 if (wxRichTextSizePage::ShowToolTips())
223 m_unitsW
->SetToolTip(_("Units for the object width."));
224 itemBoxSizer20
->Add(m_unitsW
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
226 m_heightCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_HEIGHT_CHECKBOX
, _("&Height:"), wxDefaultPosition
, wxDefaultSize
, 0 );
227 m_heightCheckbox
->SetValue(false);
228 m_heightCheckbox
->SetHelpText(_("Enable the height value."));
229 if (wxRichTextSizePage::ShowToolTips())
230 m_heightCheckbox
->SetToolTip(_("Enable the height value."));
231 itemFlexGridSizer18
->Add(m_heightCheckbox
, 0, wxALIGN_CENTER_HORIZONTAL
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
233 wxBoxSizer
* itemBoxSizer24
= new wxBoxSizer(wxHORIZONTAL
);
234 itemFlexGridSizer18
->Add(itemBoxSizer24
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
, 5);
236 m_height
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_HEIGHT
, wxEmptyString
, wxDefaultPosition
, wxSize(65, -1), 0 );
237 m_height
->SetHelpText(_("The object height."));
238 if (wxRichTextSizePage::ShowToolTips())
239 m_height
->SetToolTip(_("The object height."));
240 itemBoxSizer24
->Add(m_height
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
242 wxArrayString m_unitsHStrings
;
243 m_unitsHStrings
.Add(_("px"));
244 m_unitsHStrings
.Add(_("cm"));
245 m_unitsH
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_UNITS_H
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsHStrings
, wxCB_READONLY
);
246 m_unitsH
->SetStringSelection(_("px"));
247 m_unitsH
->SetHelpText(_("Units for the object height."));
248 if (wxRichTextSizePage::ShowToolTips())
249 m_unitsH
->SetToolTip(_("Units for the object height."));
250 itemBoxSizer24
->Add(m_unitsH
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
252 m_alignmentControls
= new wxBoxSizer(wxVERTICAL
);
253 m_parentSizer
->Add(m_alignmentControls
, 0, wxGROW
, 5);
255 wxBoxSizer
* itemBoxSizer28
= new wxBoxSizer(wxHORIZONTAL
);
256 m_alignmentControls
->Add(itemBoxSizer28
, 0, wxGROW
, 5);
258 wxStaticText
* itemStaticText29
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Alignment"), wxDefaultPosition
, wxDefaultSize
, 0 );
259 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("")));
260 itemBoxSizer28
->Add(itemStaticText29
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
262 wxStaticLine
* itemStaticLine30
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_HORIZONTAL
);
263 itemBoxSizer28
->Add(itemStaticLine30
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
265 wxBoxSizer
* itemBoxSizer31
= new wxBoxSizer(wxHORIZONTAL
);
266 m_alignmentControls
->Add(itemBoxSizer31
, 0, wxGROW
, 5);
268 itemBoxSizer31
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
270 m_verticalAlignmentCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_VERTICAL_ALIGNMENT_CHECKBOX
, _("&Vertical alignment:"), wxDefaultPosition
, wxDefaultSize
, 0 );
271 m_verticalAlignmentCheckbox
->SetValue(false);
272 m_verticalAlignmentCheckbox
->SetHelpText(_("Enable vertical alignment."));
273 if (wxRichTextSizePage::ShowToolTips())
274 m_verticalAlignmentCheckbox
->SetToolTip(_("Enable vertical alignment."));
275 itemBoxSizer31
->Add(m_verticalAlignmentCheckbox
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
277 wxArrayString m_verticalAlignmentComboBoxStrings
;
278 m_verticalAlignmentComboBoxStrings
.Add(_("Top"));
279 m_verticalAlignmentComboBoxStrings
.Add(_("Centred"));
280 m_verticalAlignmentComboBoxStrings
.Add(_("Bottom"));
281 m_verticalAlignmentComboBox
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX
, _("Top"), wxDefaultPosition
, wxDefaultSize
, m_verticalAlignmentComboBoxStrings
, wxCB_READONLY
);
282 m_verticalAlignmentComboBox
->SetStringSelection(_("Top"));
283 m_verticalAlignmentComboBox
->SetHelpText(_("Vertical alignment."));
284 if (wxRichTextSizePage::ShowToolTips())
285 m_verticalAlignmentComboBox
->SetToolTip(_("Vertical alignment."));
286 itemBoxSizer31
->Add(m_verticalAlignmentComboBox
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
288 m_positionControls
= new wxBoxSizer(wxVERTICAL
);
289 m_parentSizer
->Add(m_positionControls
, 0, wxGROW
, 5);
291 wxBoxSizer
* itemBoxSizer36
= new wxBoxSizer(wxHORIZONTAL
);
292 m_positionControls
->Add(itemBoxSizer36
, 0, wxGROW
, 5);
294 wxStaticText
* itemStaticText37
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Position"), wxDefaultPosition
, wxDefaultSize
, 0 );
295 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("")));
296 itemBoxSizer36
->Add(itemStaticText37
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
298 wxStaticLine
* itemStaticLine38
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_HORIZONTAL
);
299 itemBoxSizer36
->Add(itemStaticLine38
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
301 wxBoxSizer
* itemBoxSizer39
= new wxBoxSizer(wxHORIZONTAL
);
302 m_positionControls
->Add(itemBoxSizer39
, 0, wxGROW
, 5);
304 itemBoxSizer39
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
306 m_moveObjectParentSizer
= new wxBoxSizer(wxVERTICAL
);
307 itemBoxSizer39
->Add(m_moveObjectParentSizer
, 0, wxALIGN_TOP
, 5);
309 wxBoxSizer
* itemBoxSizer42
= new wxBoxSizer(wxHORIZONTAL
);
310 m_moveObjectParentSizer
->Add(itemBoxSizer42
, 0, wxGROW
, 5);
312 m_offsetYCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_OFFSET_CHECKBOX
, _("Vertical &Offset:"), wxDefaultPosition
, wxDefaultSize
, 0 );
313 m_offsetYCheckbox
->SetValue(false);
314 m_offsetYCheckbox
->SetHelpText(_("Enable vertical offset."));
315 if (wxRichTextSizePage::ShowToolTips())
316 m_offsetYCheckbox
->SetToolTip(_("Enable vertical offset."));
317 itemBoxSizer42
->Add(m_offsetYCheckbox
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
319 m_offset
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_OFFSET
, wxEmptyString
, wxDefaultPosition
, wxSize(65, -1), 0 );
320 m_offset
->SetMaxLength(10);
321 m_offset
->SetHelpText(_("The vertical offset relative to the paragraph."));
322 if (wxRichTextSizePage::ShowToolTips())
323 m_offset
->SetToolTip(_("The vertical offset relative to the paragraph."));
324 itemBoxSizer42
->Add(m_offset
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
326 wxArrayString m_unitsOffsetStrings
;
327 m_unitsOffsetStrings
.Add(_("px"));
328 m_unitsOffsetStrings
.Add(_("cm"));
329 m_unitsOffset
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_OFFSET_UNITS
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsOffsetStrings
, wxCB_READONLY
);
330 m_unitsOffset
->SetStringSelection(_("px"));
331 m_unitsOffset
->SetHelpText(_("Units for the object offset."));
332 if (wxRichTextSizePage::ShowToolTips())
333 m_unitsOffset
->SetToolTip(_("Units for the object offset."));
334 itemBoxSizer42
->Add(m_unitsOffset
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
336 m_moveObjectSizer
= new wxBoxSizer(wxHORIZONTAL
);
337 m_moveObjectParentSizer
->Add(m_moveObjectSizer
, 0, wxGROW
, 5);
339 wxStaticText
* itemStaticText47
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Move the object to:"), wxDefaultPosition
, wxDefaultSize
, 0 );
340 m_moveObjectSizer
->Add(itemStaticText47
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
342 wxButton
* itemButton48
= new wxButton( itemRichTextDialogPage1
, ID_RICHTEXT_PARA_UP
, _("&Previous Paragraph"), wxDefaultPosition
, wxDefaultSize
, 0 );
343 itemButton48
->SetHelpText(_("Moves the object to the previous paragraph."));
344 if (wxRichTextSizePage::ShowToolTips())
345 itemButton48
->SetToolTip(_("Moves the object to the previous paragraph."));
346 m_moveObjectSizer
->Add(itemButton48
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
348 wxButton
* itemButton49
= new wxButton( itemRichTextDialogPage1
, ID_RICHTEXT_PARA_DOWN
, _("&Next Paragraph"), wxDefaultPosition
, wxDefaultSize
, 0 );
349 itemButton49
->SetHelpText(_("Moves the object to the next paragraph."));
350 if (wxRichTextSizePage::ShowToolTips())
351 itemButton49
->SetToolTip(_("Moves the object to the next paragraph."));
352 m_moveObjectSizer
->Add(itemButton49
, 0, wxALIGN_CENTER_VERTICAL
|wxRIGHT
|wxTOP
|wxBOTTOM
, 5);
354 ////@end wxRichTextSizePage content construction
357 wxRichTextAttr
* wxRichTextSizePage::GetAttributes()
359 return wxRichTextFormattingDialog::GetDialogAttributes(this);
363 * Should we show tooltips?
366 bool wxRichTextSizePage::ShowToolTips()
371 bool wxRichTextSizePage::TransferDataToWindow()
373 m_float
->SetSelection(GetAttributes()->GetTextBoxAttr().GetFloatMode());
374 m_verticalAlignmentCheckbox
->SetValue(GetAttributes()->GetTextBoxAttr().HasVerticalAlignment());
375 if (GetAttributes()->GetTextBoxAttr().HasVerticalAlignment())
377 if ((int) GetAttributes()->GetTextBoxAttr().GetVerticalAlignment() > 0 &&
378 (int) GetAttributes()->GetTextBoxAttr().GetVerticalAlignment() < 4)
380 m_verticalAlignmentComboBox
->SetSelection(((int) GetAttributes()->GetTextBoxAttr().GetVerticalAlignment() - 1));
383 m_verticalAlignmentComboBox
->SetSelection(0);
386 wxRichTextFormattingDialog
* dialog
= wxRichTextFormattingDialog::GetDialog(this);
390 // Only show the Move Object controls if there's an object.
391 if (!dialog
->GetObject())
393 m_moveObjectParentSizer
->Show(m_moveObjectSizer
, false);
394 GetSizer()->Layout();
398 if (dialog
&& dialog
->GetObject())
400 wxTextAttrSize size
= dialog
->GetObject()->GetNaturalSize();
401 if (size
.GetWidth().IsValid() && size
.GetHeight().IsValid())
403 if (!GetAttributes()->GetTextBoxAttr().GetWidth().IsValid() || GetAttributes()->GetTextBoxAttr().GetWidth().GetValue() <= 0)
405 GetAttributes()->GetTextBoxAttr().GetWidth() = size
.GetWidth();
408 if (!GetAttributes()->GetTextBoxAttr().GetHeight().IsValid() || GetAttributes()->GetTextBoxAttr().GetHeight().GetValue() <= 0)
410 GetAttributes()->GetTextBoxAttr().GetHeight() = size
.GetHeight();
415 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetWidth(), m_width
, m_unitsW
, m_widthCheckbox
);
416 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetHeight(), m_height
, m_unitsH
, m_heightCheckbox
);
417 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetTop(), m_offset
, m_unitsOffset
, m_offsetYCheckbox
);
422 bool wxRichTextSizePage::TransferDataFromWindow()
424 GetAttributes()->GetTextBoxAttr().SetFloatMode((wxTextBoxAttrFloatStyle
) m_float
->GetSelection());
425 if (m_float
->GetSelection() == 0)
426 GetAttributes()->GetTextBoxAttr().RemoveFlag(wxTEXT_BOX_ATTR_FLOAT
);
428 if (m_verticalAlignmentCheckbox
->GetValue())
429 GetAttributes()->GetTextBoxAttr().SetVerticalAlignment((wxTextBoxAttrVerticalAlignment
) (m_verticalAlignmentComboBox
->GetSelection() + 1));
432 GetAttributes()->GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE
);
433 GetAttributes()->GetTextBoxAttr().RemoveFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT
);
436 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetWidth(), m_width
, m_unitsW
, m_widthCheckbox
);
437 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetHeight(), m_height
, m_unitsH
, m_heightCheckbox
);
438 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetTop(), m_offset
, m_unitsOffset
, m_offsetYCheckbox
);
443 // Show/hide position controls
444 void wxRichTextSizePage::ShowPositionControls(bool show
)
448 m_parentSizer
->Show(m_positionControls
, show
);
453 // Show/hide floating controls
454 void wxRichTextSizePage::ShowFloatingControls(bool show
)
458 m_parentSizer
->Show(m_floatingControls
, show
);
465 * Get bitmap resources
468 wxBitmap
wxRichTextSizePage::GetBitmapResource( const wxString
& name
)
471 ////@begin wxRichTextSizePage bitmap retrieval
474 ////@end wxRichTextSizePage bitmap retrieval
481 wxIcon
wxRichTextSizePage::GetIconResource( const wxString
& name
)
484 ////@begin wxRichTextSizePage icon retrieval
487 ////@end wxRichTextSizePage icon retrieval
492 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_WIDTH
495 void wxRichTextSizePage::OnRichtextWidthUpdate( wxUpdateUIEvent
& event
)
497 event
.Enable(m_widthCheckbox
->GetValue());
501 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_HEIGHT
504 void wxRichTextSizePage::OnRichtextHeightUpdate( wxUpdateUIEvent
& event
)
506 event
.Enable(m_heightCheckbox
->GetValue());
510 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_OFFSET
513 void wxRichTextSizePage::OnRichtextOffsetUpdate( wxUpdateUIEvent
& event
)
515 event
.Enable(m_offsetYCheckbox
->GetValue());
520 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXT_PARA_UP
523 void wxRichTextSizePage::OnRichtextParaUpClick( wxCommandEvent
& WXUNUSED(event
) )
525 wxRichTextFormattingDialog
* dialog
= wxRichTextFormattingDialog::GetDialog(this);
526 if (!dialog
|| !dialog
->GetObject())
529 // Make sure object attributes are up-to-date
530 dialog
->TransferDataFromWindow();
532 wxRichTextBuffer
* buffer
= dialog
->GetObject()->GetBuffer();
533 wxRichTextParagraphLayoutBox
* container
= dialog
->GetObject()->GetParentContainer();
534 wxRichTextObject
* parent
= dialog
->GetObject()->GetParent();
535 if (!container
|| !parent
|| !buffer
)
538 wxRichTextRange range
= dialog
->GetObject()->GetRange();
539 wxRichTextObjectList::compatibility_iterator iter
= container
->GetChildren().GetFirst();
545 if (iter
->GetData() == parent
)
547 iter
= iter
->GetNext();
551 iter
= iter
->GetPrevious();
555 wxRichTextObject
*obj
= iter
->GetData();
556 wxRichTextRange rg
= obj
->GetRange();
557 // tempObj will be deleted along with the undo object, and a clone of it will be
558 // returned by InsertObjectWithUndo
559 wxRichTextObject
* tempObj
= dialog
->GetObject()->Clone();
561 container
->DeleteRangeWithUndo(range
, buffer
->GetRichTextCtrl(), buffer
);
563 wxRichTextObject
* obj2
= container
->InsertObjectWithUndo(rg
.GetStart(), tempObj
, buffer
->GetRichTextCtrl(), buffer
, 0);
564 dialog
->SetObject(obj2
);
568 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXT_DOWN
571 void wxRichTextSizePage::OnRichtextParaDownClick( wxCommandEvent
& WXUNUSED(event
) )
573 wxRichTextFormattingDialog
* dialog
= wxRichTextFormattingDialog::GetDialog(this);
574 if (!dialog
|| !dialog
->GetObject())
577 // Make sure object attributes are up-to-date
578 dialog
->TransferDataFromWindow();
580 wxRichTextBuffer
* buffer
= dialog
->GetObject()->GetBuffer();
581 wxRichTextParagraphLayoutBox
* container
= dialog
->GetObject()->GetParentContainer();
582 wxRichTextObject
* parent
= dialog
->GetObject()->GetParent();
583 if (!container
|| !parent
|| !buffer
)
586 wxRichTextRange range
= dialog
->GetObject()->GetRange();
588 wxRichTextObjectList::compatibility_iterator iter
= buffer
->GetChildren().GetFirst();
594 if (iter
->GetData() == parent
)
596 iter
= iter
->GetNext();
599 iter
= iter
->GetNext();
603 wxRichTextObject
*obj
= iter
->GetData();
604 wxRichTextRange rg
= obj
->GetRange();
605 // tempObj will be deleted along with the undo object, and a clone of it will be
606 // returned by InsertObjectWithUndo
607 wxRichTextObject
* tempObj
= dialog
->GetObject()->Clone();
609 container
->DeleteRangeWithUndo(range
, buffer
->GetRichTextCtrl(), buffer
);
611 // Minus one because we deleted an object
612 wxRichTextObject
* obj2
= container
->InsertObjectWithUndo(rg
.GetStart()-1, tempObj
, buffer
->GetRichTextCtrl(), buffer
, 0);
613 dialog
->SetObject(obj2
);
618 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX
621 void wxRichTextSizePage::OnRichtextVerticalAlignmentComboboxUpdate( wxUpdateUIEvent
& event
)
623 event
.Enable(m_verticalAlignmentCheckbox
->GetValue());