1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/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_MIN_WIDTH
, wxRichTextSizePage::OnRichtextMinWidthUpdate
)
42 EVT_UPDATE_UI( ID_RICHTEXT_UNITS_MIN_W
, wxRichTextSizePage::OnRichtextMinWidthUpdate
)
44 EVT_UPDATE_UI( ID_RICHTEXT_MIN_HEIGHT
, wxRichTextSizePage::OnRichtextMinHeightUpdate
)
46 EVT_UPDATE_UI( ID_RICHTEXT_UNITS_MIN_H
, wxRichTextSizePage::OnRichtextMinHeightUpdate
)
48 EVT_UPDATE_UI( ID_RICHTEXT_MAX_WIDTH
, wxRichTextSizePage::OnRichtextMaxWidthUpdate
)
50 EVT_UPDATE_UI( ID_RICHTEXT_UNITS_MAX_W
, wxRichTextSizePage::OnRichtextMaxWidthUpdate
)
52 EVT_UPDATE_UI( ID_RICHTEXT_MAX_HEIGHT
, wxRichTextSizePage::OnRichtextMaxHeightUpdate
)
54 EVT_UPDATE_UI( ID_RICHTEXT_UNITS_MAX_H
, wxRichTextSizePage::OnRichtextMaxHeightUpdate
)
56 EVT_UPDATE_UI( ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX
, wxRichTextSizePage::OnRichtextVerticalAlignmentComboboxUpdate
)
58 EVT_UPDATE_UI( ID_RICHTEXT_OFFSET
, wxRichTextSizePage::OnRichtextOffsetUpdate
)
60 EVT_UPDATE_UI( ID_RICHTEXT_OFFSET_UNITS
, wxRichTextSizePage::OnRichtextOffsetUpdate
)
62 EVT_BUTTON( ID_RICHTEXT_PARA_UP
, wxRichTextSizePage::OnRichtextParaUpClick
)
64 EVT_BUTTON( ID_RICHTEXT_PARA_DOWN
, wxRichTextSizePage::OnRichtextParaDownClick
)
66 ////@end wxRichTextSizePage event table entries
70 IMPLEMENT_HELP_PROVISION(wxRichTextSizePage
)
73 * wxRichTextSizePage constructors
76 wxRichTextSizePage::wxRichTextSizePage()
81 wxRichTextSizePage::wxRichTextSizePage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
84 Create(parent
, id
, pos
, size
, style
);
89 * wxRichTextSizePage creator
92 bool wxRichTextSizePage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
94 ////@begin wxRichTextSizePage creation
95 wxRichTextDialogPage::Create( parent
, id
, pos
, size
, style
);
100 GetSizer()->SetSizeHints(this);
103 ////@end wxRichTextSizePage creation
109 * wxRichTextSizePage destructor
112 wxRichTextSizePage::~wxRichTextSizePage()
114 ////@begin wxRichTextSizePage destruction
115 ////@end wxRichTextSizePage destruction
120 * Member initialisation
123 void wxRichTextSizePage::Init()
125 ////@begin wxRichTextSizePage member initialisation
126 m_parentSizer
= NULL
;
127 m_floatingControls
= NULL
;
129 m_widthCheckbox
= NULL
;
132 m_heightCheckbox
= NULL
;
135 m_minWidthCheckbox
= NULL
;
138 m_minHeightCheckbox
= NULL
;
141 m_maxWidthCheckbox
= NULL
;
144 m_maxHeightCheckbox
= NULL
;
147 m_alignmentControls
= NULL
;
148 m_verticalAlignmentCheckbox
= NULL
;
149 m_verticalAlignmentComboBox
= NULL
;
150 m_positionControls
= NULL
;
151 m_moveObjectParentSizer
= NULL
;
152 m_offsetYCheckbox
= NULL
;
154 m_unitsOffset
= NULL
;
155 m_moveObjectSizer
= NULL
;
156 ////@end wxRichTextSizePage member initialisation
161 * Control creation for wxRichTextSizePage
164 void wxRichTextSizePage::CreateControls()
166 ////@begin wxRichTextSizePage content construction
167 wxRichTextSizePage
* itemRichTextDialogPage1
= this;
169 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
170 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
172 m_parentSizer
= new wxBoxSizer(wxVERTICAL
);
173 itemBoxSizer2
->Add(m_parentSizer
, 0, wxGROW
|wxALL
, 5);
175 m_floatingControls
= new wxBoxSizer(wxVERTICAL
);
176 m_parentSizer
->Add(m_floatingControls
, 0, wxGROW
, 5);
178 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxHORIZONTAL
);
179 m_floatingControls
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
181 wxStaticText
* itemStaticText6
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Floating"), wxDefaultPosition
, wxDefaultSize
, 0 );
182 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("")));
183 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
185 wxStaticLine
* itemStaticLine7
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_HORIZONTAL
);
186 itemBoxSizer5
->Add(itemStaticLine7
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
188 wxBoxSizer
* itemBoxSizer8
= new wxBoxSizer(wxHORIZONTAL
);
189 m_floatingControls
->Add(itemBoxSizer8
, 0, wxGROW
, 5);
191 itemBoxSizer8
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
193 wxFlexGridSizer
* itemFlexGridSizer10
= new wxFlexGridSizer(0, 2, 0, 0);
194 itemBoxSizer8
->Add(itemFlexGridSizer10
, 0, wxALIGN_CENTER_VERTICAL
|wxRIGHT
, 5);
196 wxStaticText
* itemStaticText11
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Floating mode:"), wxDefaultPosition
, wxDefaultSize
, 0 );
197 itemFlexGridSizer10
->Add(itemStaticText11
, 0, wxALIGN_RIGHT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
199 wxArrayString m_floatStrings
;
200 m_floatStrings
.Add(_("None"));
201 m_floatStrings
.Add(_("Left"));
202 m_floatStrings
.Add(_("Right"));
203 m_float
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_FLOATING_MODE
, _("None"), wxDefaultPosition
, wxSize(80, -1), m_floatStrings
, wxCB_READONLY
);
204 m_float
->SetStringSelection(_("None"));
205 m_float
->SetHelpText(_("How the object will float relative to the text."));
206 if (wxRichTextSizePage::ShowToolTips())
207 m_float
->SetToolTip(_("How the object will float relative to the text."));
208 itemFlexGridSizer10
->Add(m_float
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
210 wxBoxSizer
* itemBoxSizer13
= new wxBoxSizer(wxHORIZONTAL
);
211 m_parentSizer
->Add(itemBoxSizer13
, 0, wxGROW
, 5);
213 wxStaticText
* itemStaticText14
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Size"), wxDefaultPosition
, wxDefaultSize
, 0 );
214 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("")));
215 itemBoxSizer13
->Add(itemStaticText14
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
217 wxStaticLine
* itemStaticLine15
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_HORIZONTAL
);
218 itemBoxSizer13
->Add(itemStaticLine15
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
220 wxBoxSizer
* itemBoxSizer16
= new wxBoxSizer(wxHORIZONTAL
);
221 m_parentSizer
->Add(itemBoxSizer16
, 0, wxGROW
, 5);
223 itemBoxSizer16
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
225 wxFlexGridSizer
* itemFlexGridSizer18
= new wxFlexGridSizer(0, 4, 0, 0);
226 itemBoxSizer16
->Add(itemFlexGridSizer18
, 0, wxALIGN_CENTER_VERTICAL
, 5);
228 m_widthCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_WIDTH_CHECKBOX
, _("&Width:"), wxDefaultPosition
, wxDefaultSize
, 0 );
229 m_widthCheckbox
->SetValue(false);
230 m_widthCheckbox
->SetHelpText(_("Enable the width value."));
231 if (wxRichTextSizePage::ShowToolTips())
232 m_widthCheckbox
->SetToolTip(_("Enable the width value."));
233 itemFlexGridSizer18
->Add(m_widthCheckbox
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
235 wxBoxSizer
* itemBoxSizer20
= new wxBoxSizer(wxHORIZONTAL
);
236 itemFlexGridSizer18
->Add(itemBoxSizer20
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
, 5);
238 m_width
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_WIDTH
, wxEmptyString
, wxDefaultPosition
, wxSize(60, -1), 0 );
239 m_width
->SetHelpText(_("The object width."));
240 if (wxRichTextSizePage::ShowToolTips())
241 m_width
->SetToolTip(_("The object width."));
242 itemBoxSizer20
->Add(m_width
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
244 wxArrayString m_unitsWStrings
;
245 m_unitsWStrings
.Add(_("px"));
246 m_unitsWStrings
.Add(_("cm"));
247 m_unitsWStrings
.Add(_("percent"));
248 m_unitsW
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_UNITS_W
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsWStrings
, wxCB_READONLY
);
249 m_unitsW
->SetStringSelection(_("px"));
250 m_unitsW
->SetHelpText(_("Units for the object width."));
251 if (wxRichTextSizePage::ShowToolTips())
252 m_unitsW
->SetToolTip(_("Units for the object width."));
253 itemBoxSizer20
->Add(m_unitsW
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
255 m_heightCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_HEIGHT_CHECKBOX
, _("&Height:"), wxDefaultPosition
, wxDefaultSize
, 0 );
256 m_heightCheckbox
->SetValue(false);
257 m_heightCheckbox
->SetHelpText(_("Enable the height value."));
258 if (wxRichTextSizePage::ShowToolTips())
259 m_heightCheckbox
->SetToolTip(_("Enable the height value."));
260 itemFlexGridSizer18
->Add(m_heightCheckbox
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
262 wxBoxSizer
* itemBoxSizer24
= new wxBoxSizer(wxHORIZONTAL
);
263 itemFlexGridSizer18
->Add(itemBoxSizer24
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
, 5);
265 m_height
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_HEIGHT
, wxEmptyString
, wxDefaultPosition
, wxSize(60, -1), 0 );
266 m_height
->SetHelpText(_("The object height."));
267 if (wxRichTextSizePage::ShowToolTips())
268 m_height
->SetToolTip(_("The object height."));
269 itemBoxSizer24
->Add(m_height
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
271 wxArrayString m_unitsHStrings
;
272 m_unitsHStrings
.Add(_("px"));
273 m_unitsHStrings
.Add(_("cm"));
274 m_unitsHStrings
.Add(_("percent"));
275 m_unitsH
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_UNITS_H
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsHStrings
, wxCB_READONLY
);
276 m_unitsH
->SetStringSelection(_("px"));
277 m_unitsH
->SetHelpText(_("Units for the object height."));
278 if (wxRichTextSizePage::ShowToolTips())
279 m_unitsH
->SetToolTip(_("Units for the object height."));
280 itemBoxSizer24
->Add(m_unitsH
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
282 m_minWidthCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_MIN_WIDTH_CHECKBOX
, _("Min width:"), wxDefaultPosition
, wxDefaultSize
, 0 );
283 m_minWidthCheckbox
->SetValue(false);
284 m_minWidthCheckbox
->SetHelpText(_("Enable the minimum width value."));
285 if (wxRichTextSizePage::ShowToolTips())
286 m_minWidthCheckbox
->SetToolTip(_("Enable the minimum width value."));
287 itemFlexGridSizer18
->Add(m_minWidthCheckbox
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
289 wxBoxSizer
* itemBoxSizer28
= new wxBoxSizer(wxHORIZONTAL
);
290 itemFlexGridSizer18
->Add(itemBoxSizer28
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
, 5);
292 m_minWidth
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_MIN_WIDTH
, wxEmptyString
, wxDefaultPosition
, wxSize(60, -1), 0 );
293 m_minWidth
->SetHelpText(_("The object minimum width."));
294 if (wxRichTextSizePage::ShowToolTips())
295 m_minWidth
->SetToolTip(_("The object minimum width."));
296 itemBoxSizer28
->Add(m_minWidth
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
298 wxArrayString m_unitsMinWStrings
;
299 m_unitsMinWStrings
.Add(_("px"));
300 m_unitsMinWStrings
.Add(_("cm"));
301 m_unitsMinWStrings
.Add(_("percent"));
302 m_unitsMinW
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_UNITS_MIN_W
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsMinWStrings
, wxCB_READONLY
);
303 m_unitsMinW
->SetStringSelection(_("px"));
304 m_unitsMinW
->SetHelpText(_("Units for the minimum object width."));
305 if (wxRichTextSizePage::ShowToolTips())
306 m_unitsMinW
->SetToolTip(_("Units for the minimum object width."));
307 itemBoxSizer28
->Add(m_unitsMinW
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
309 m_minHeightCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_MIN_HEIGHT_CHECKBOX
, _("Min height:"), wxDefaultPosition
, wxDefaultSize
, 0 );
310 m_minHeightCheckbox
->SetValue(false);
311 m_minHeightCheckbox
->SetHelpText(_("Enable the minimum height value."));
312 if (wxRichTextSizePage::ShowToolTips())
313 m_minHeightCheckbox
->SetToolTip(_("Enable the minimum height value."));
314 itemFlexGridSizer18
->Add(m_minHeightCheckbox
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
316 wxBoxSizer
* itemBoxSizer32
= new wxBoxSizer(wxHORIZONTAL
);
317 itemFlexGridSizer18
->Add(itemBoxSizer32
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
, 5);
319 m_minHeight
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_MIN_HEIGHT
, wxEmptyString
, wxDefaultPosition
, wxSize(60, -1), 0 );
320 m_minHeight
->SetHelpText(_("The object minmum height."));
321 if (wxRichTextSizePage::ShowToolTips())
322 m_minHeight
->SetToolTip(_("The object minmum height."));
323 itemBoxSizer32
->Add(m_minHeight
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
325 wxArrayString m_unitsMinHStrings
;
326 m_unitsMinHStrings
.Add(_("px"));
327 m_unitsMinHStrings
.Add(_("cm"));
328 m_unitsMinHStrings
.Add(_("percent"));
329 m_unitsMinH
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_UNITS_MIN_H
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsMinHStrings
, wxCB_READONLY
);
330 m_unitsMinH
->SetStringSelection(_("px"));
331 m_unitsMinH
->SetHelpText(_("Units for the minimum object height."));
332 if (wxRichTextSizePage::ShowToolTips())
333 m_unitsMinH
->SetToolTip(_("Units for the minimum object height."));
334 itemBoxSizer32
->Add(m_unitsMinH
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
336 m_maxWidthCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_MAX_WIDTH_CHECKBOX
, _("Max width:"), wxDefaultPosition
, wxDefaultSize
, 0 );
337 m_maxWidthCheckbox
->SetValue(false);
338 m_maxWidthCheckbox
->SetHelpText(_("Enable the maximum width value."));
339 if (wxRichTextSizePage::ShowToolTips())
340 m_maxWidthCheckbox
->SetToolTip(_("Enable the maximum width value."));
341 itemFlexGridSizer18
->Add(m_maxWidthCheckbox
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
343 wxBoxSizer
* itemBoxSizer36
= new wxBoxSizer(wxHORIZONTAL
);
344 itemFlexGridSizer18
->Add(itemBoxSizer36
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
, 5);
346 m_maxWidth
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_MAX_WIDTH
, wxEmptyString
, wxDefaultPosition
, wxSize(60, -1), 0 );
347 m_maxWidth
->SetHelpText(_("The object maximum width."));
348 if (wxRichTextSizePage::ShowToolTips())
349 m_maxWidth
->SetToolTip(_("The object maximum width."));
350 itemBoxSizer36
->Add(m_maxWidth
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
352 wxArrayString m_unitsMaxWStrings
;
353 m_unitsMaxWStrings
.Add(_("px"));
354 m_unitsMaxWStrings
.Add(_("cm"));
355 m_unitsMaxWStrings
.Add(_("percent"));
356 m_unitsMaxW
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_UNITS_MAX_W
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsMaxWStrings
, wxCB_READONLY
);
357 m_unitsMaxW
->SetStringSelection(_("px"));
358 m_unitsMaxW
->SetHelpText(_("Units for the maximum object width."));
359 if (wxRichTextSizePage::ShowToolTips())
360 m_unitsMaxW
->SetToolTip(_("Units for the maximum object width."));
361 itemBoxSizer36
->Add(m_unitsMaxW
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
363 m_maxHeightCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_MAX_HEIGHT_CHECKBOX
, _("Max height:"), wxDefaultPosition
, wxDefaultSize
, 0 );
364 m_maxHeightCheckbox
->SetValue(false);
365 m_maxHeightCheckbox
->SetHelpText(_("Enable the height value."));
366 if (wxRichTextSizePage::ShowToolTips())
367 m_maxHeightCheckbox
->SetToolTip(_("Enable the height value."));
368 itemFlexGridSizer18
->Add(m_maxHeightCheckbox
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
370 wxBoxSizer
* itemBoxSizer40
= new wxBoxSizer(wxHORIZONTAL
);
371 itemFlexGridSizer18
->Add(itemBoxSizer40
, 0, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
, 5);
373 m_maxHeight
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_MAX_HEIGHT
, wxEmptyString
, wxDefaultPosition
, wxSize(60, -1), 0 );
374 m_maxHeight
->SetHelpText(_("The object maximum height."));
375 if (wxRichTextSizePage::ShowToolTips())
376 m_maxHeight
->SetToolTip(_("The object maximum height."));
377 itemBoxSizer40
->Add(m_maxHeight
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
379 wxArrayString m_unitsMaxHStrings
;
380 m_unitsMaxHStrings
.Add(_("px"));
381 m_unitsMaxHStrings
.Add(_("cm"));
382 m_unitsMaxHStrings
.Add(_("percent"));
383 m_unitsMaxH
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_UNITS_MAX_H
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsMaxHStrings
, wxCB_READONLY
);
384 m_unitsMaxH
->SetStringSelection(_("px"));
385 m_unitsMaxH
->SetHelpText(_("Units for the maximum object height."));
386 if (wxRichTextSizePage::ShowToolTips())
387 m_unitsMaxH
->SetToolTip(_("Units for the maximum object height."));
388 itemBoxSizer40
->Add(m_unitsMaxH
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
390 m_alignmentControls
= new wxBoxSizer(wxVERTICAL
);
391 m_parentSizer
->Add(m_alignmentControls
, 0, wxGROW
, 5);
393 wxBoxSizer
* itemBoxSizer44
= new wxBoxSizer(wxHORIZONTAL
);
394 m_alignmentControls
->Add(itemBoxSizer44
, 0, wxGROW
, 5);
396 wxStaticText
* itemStaticText45
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Alignment"), wxDefaultPosition
, wxDefaultSize
, 0 );
397 itemStaticText45
->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("")));
398 itemBoxSizer44
->Add(itemStaticText45
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
400 wxStaticLine
* itemStaticLine46
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_HORIZONTAL
);
401 itemBoxSizer44
->Add(itemStaticLine46
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
403 wxBoxSizer
* itemBoxSizer47
= new wxBoxSizer(wxHORIZONTAL
);
404 m_alignmentControls
->Add(itemBoxSizer47
, 0, wxGROW
, 5);
406 itemBoxSizer47
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
408 m_verticalAlignmentCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_VERTICAL_ALIGNMENT_CHECKBOX
, _("&Vertical alignment:"), wxDefaultPosition
, wxDefaultSize
, 0 );
409 m_verticalAlignmentCheckbox
->SetValue(false);
410 m_verticalAlignmentCheckbox
->SetHelpText(_("Enable vertical alignment."));
411 if (wxRichTextSizePage::ShowToolTips())
412 m_verticalAlignmentCheckbox
->SetToolTip(_("Enable vertical alignment."));
413 itemBoxSizer47
->Add(m_verticalAlignmentCheckbox
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
415 wxArrayString m_verticalAlignmentComboBoxStrings
;
416 m_verticalAlignmentComboBoxStrings
.Add(_("Top"));
417 m_verticalAlignmentComboBoxStrings
.Add(_("Centred"));
418 m_verticalAlignmentComboBoxStrings
.Add(_("Bottom"));
419 m_verticalAlignmentComboBox
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX
, _("Top"), wxDefaultPosition
, wxDefaultSize
, m_verticalAlignmentComboBoxStrings
, wxCB_READONLY
);
420 m_verticalAlignmentComboBox
->SetStringSelection(_("Top"));
421 m_verticalAlignmentComboBox
->SetHelpText(_("Vertical alignment."));
422 if (wxRichTextSizePage::ShowToolTips())
423 m_verticalAlignmentComboBox
->SetToolTip(_("Vertical alignment."));
424 itemBoxSizer47
->Add(m_verticalAlignmentComboBox
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
426 m_positionControls
= new wxBoxSizer(wxVERTICAL
);
427 m_parentSizer
->Add(m_positionControls
, 0, wxGROW
, 5);
429 wxBoxSizer
* itemBoxSizer52
= new wxBoxSizer(wxHORIZONTAL
);
430 m_positionControls
->Add(itemBoxSizer52
, 0, wxGROW
, 5);
432 wxStaticText
* itemStaticText53
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Position"), wxDefaultPosition
, wxDefaultSize
, 0 );
433 itemStaticText53
->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("")));
434 itemBoxSizer52
->Add(itemStaticText53
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
436 wxStaticLine
* itemStaticLine54
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_HORIZONTAL
);
437 itemBoxSizer52
->Add(itemStaticLine54
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
439 wxBoxSizer
* itemBoxSizer55
= new wxBoxSizer(wxHORIZONTAL
);
440 m_positionControls
->Add(itemBoxSizer55
, 0, wxGROW
, 5);
442 itemBoxSizer55
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
444 m_moveObjectParentSizer
= new wxBoxSizer(wxVERTICAL
);
445 itemBoxSizer55
->Add(m_moveObjectParentSizer
, 0, wxALIGN_TOP
, 5);
447 wxBoxSizer
* itemBoxSizer58
= new wxBoxSizer(wxHORIZONTAL
);
448 m_moveObjectParentSizer
->Add(itemBoxSizer58
, 0, wxGROW
, 5);
450 m_offsetYCheckbox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_OFFSET_CHECKBOX
, _("Vertical &Offset:"), wxDefaultPosition
, wxDefaultSize
, 0 );
451 m_offsetYCheckbox
->SetValue(false);
452 m_offsetYCheckbox
->SetHelpText(_("Enable vertical offset."));
453 if (wxRichTextSizePage::ShowToolTips())
454 m_offsetYCheckbox
->SetToolTip(_("Enable vertical offset."));
455 itemBoxSizer58
->Add(m_offsetYCheckbox
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
457 m_offset
= new wxTextCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_OFFSET
, wxEmptyString
, wxDefaultPosition
, wxSize(65, -1), 0 );
458 m_offset
->SetMaxLength(10);
459 m_offset
->SetHelpText(_("The vertical offset relative to the paragraph."));
460 if (wxRichTextSizePage::ShowToolTips())
461 m_offset
->SetToolTip(_("The vertical offset relative to the paragraph."));
462 itemBoxSizer58
->Add(m_offset
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
, 5);
464 wxArrayString m_unitsOffsetStrings
;
465 m_unitsOffsetStrings
.Add(_("px"));
466 m_unitsOffsetStrings
.Add(_("cm"));
467 m_unitsOffset
= new wxComboBox( itemRichTextDialogPage1
, ID_RICHTEXT_OFFSET_UNITS
, _("px"), wxDefaultPosition
, wxSize(60, -1), m_unitsOffsetStrings
, wxCB_READONLY
);
468 m_unitsOffset
->SetStringSelection(_("px"));
469 m_unitsOffset
->SetHelpText(_("Units for the object offset."));
470 if (wxRichTextSizePage::ShowToolTips())
471 m_unitsOffset
->SetToolTip(_("Units for the object offset."));
472 itemBoxSizer58
->Add(m_unitsOffset
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
474 m_moveObjectSizer
= new wxBoxSizer(wxHORIZONTAL
);
475 m_moveObjectParentSizer
->Add(m_moveObjectSizer
, 0, wxGROW
, 5);
477 wxStaticText
* itemStaticText63
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("&Move the object to:"), wxDefaultPosition
, wxDefaultSize
, 0 );
478 m_moveObjectSizer
->Add(itemStaticText63
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
480 wxButton
* itemButton64
= new wxButton( itemRichTextDialogPage1
, ID_RICHTEXT_PARA_UP
, _("&Previous Paragraph"), wxDefaultPosition
, wxDefaultSize
, 0 );
481 itemButton64
->SetHelpText(_("Moves the object to the previous paragraph."));
482 if (wxRichTextSizePage::ShowToolTips())
483 itemButton64
->SetToolTip(_("Moves the object to the previous paragraph."));
484 m_moveObjectSizer
->Add(itemButton64
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
486 wxButton
* itemButton65
= new wxButton( itemRichTextDialogPage1
, ID_RICHTEXT_PARA_DOWN
, _("&Next Paragraph"), wxDefaultPosition
, wxDefaultSize
, 0 );
487 itemButton65
->SetHelpText(_("Moves the object to the next paragraph."));
488 if (wxRichTextSizePage::ShowToolTips())
489 itemButton65
->SetToolTip(_("Moves the object to the next paragraph."));
490 m_moveObjectSizer
->Add(itemButton65
, 0, wxALIGN_CENTER_VERTICAL
|wxRIGHT
|wxTOP
|wxBOTTOM
, 5);
492 ////@end wxRichTextSizePage content construction
495 wxRichTextAttr
* wxRichTextSizePage::GetAttributes()
497 return wxRichTextFormattingDialog::GetDialogAttributes(this);
501 * Should we show tooltips?
504 bool wxRichTextSizePage::ShowToolTips()
509 bool wxRichTextSizePage::TransferDataToWindow()
511 m_float
->SetSelection(GetAttributes()->GetTextBoxAttr().GetFloatMode());
512 m_verticalAlignmentCheckbox
->SetValue(GetAttributes()->GetTextBoxAttr().HasVerticalAlignment());
513 if (GetAttributes()->GetTextBoxAttr().HasVerticalAlignment())
515 if ((int) GetAttributes()->GetTextBoxAttr().GetVerticalAlignment() > 0 &&
516 (int) GetAttributes()->GetTextBoxAttr().GetVerticalAlignment() < 4)
518 m_verticalAlignmentComboBox
->SetSelection(((int) GetAttributes()->GetTextBoxAttr().GetVerticalAlignment() - 1));
521 m_verticalAlignmentComboBox
->SetSelection(0);
524 wxRichTextFormattingDialog
* dialog
= wxRichTextFormattingDialog::GetDialog(this);
528 // Only show the Move Object controls if there's an object.
529 if (!dialog
->GetObject())
531 m_moveObjectParentSizer
->Show(m_moveObjectSizer
, false);
532 GetSizer()->Layout();
536 if (dialog
&& dialog
->GetObject())
538 wxTextAttrSize size
= dialog
->GetObject()->GetNaturalSize();
539 if (size
.GetWidth().IsValid() && size
.GetHeight().IsValid())
541 if (!GetAttributes()->GetTextBoxAttr().GetWidth().IsValid() || GetAttributes()->GetTextBoxAttr().GetWidth().GetValue() <= 0)
543 GetAttributes()->GetTextBoxAttr().GetWidth() = size
.GetWidth();
546 if (!GetAttributes()->GetTextBoxAttr().GetHeight().IsValid() || GetAttributes()->GetTextBoxAttr().GetHeight().GetValue() <= 0)
548 GetAttributes()->GetTextBoxAttr().GetHeight() = size
.GetHeight();
553 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetWidth(), m_width
, m_unitsW
, m_widthCheckbox
);
554 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetHeight(), m_height
, m_unitsH
, m_heightCheckbox
);
555 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMinSize().GetWidth(), m_minWidth
, m_unitsMinW
, m_minWidthCheckbox
);
556 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMinSize().GetHeight(), m_minHeight
, m_unitsMinH
, m_minHeightCheckbox
);
557 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMaxSize().GetWidth(), m_maxWidth
, m_unitsMaxW
, m_maxWidthCheckbox
);
558 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMaxSize().GetHeight(), m_maxHeight
, m_unitsMaxH
, m_maxHeightCheckbox
);
559 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetTop(), m_offset
, m_unitsOffset
, m_offsetYCheckbox
);
564 bool wxRichTextSizePage::TransferDataFromWindow()
566 GetAttributes()->GetTextBoxAttr().SetFloatMode((wxTextBoxAttrFloatStyle
) m_float
->GetSelection());
567 if (m_float
->GetSelection() == 0)
568 GetAttributes()->GetTextBoxAttr().RemoveFlag(wxTEXT_BOX_ATTR_FLOAT
);
570 if (m_verticalAlignmentCheckbox
->GetValue())
571 GetAttributes()->GetTextBoxAttr().SetVerticalAlignment((wxTextBoxAttrVerticalAlignment
) (m_verticalAlignmentComboBox
->GetSelection() + 1));
574 GetAttributes()->GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE
);
575 GetAttributes()->GetTextBoxAttr().RemoveFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT
);
578 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetWidth(), m_width
, m_unitsW
, m_widthCheckbox
);
579 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetHeight(), m_height
, m_unitsH
, m_heightCheckbox
);
580 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMinSize().GetWidth(), m_minWidth
, m_unitsMinW
, m_minWidthCheckbox
);
581 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMinSize().GetHeight(), m_minHeight
, m_unitsMinH
, m_minHeightCheckbox
);
582 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMaxSize().GetWidth(), m_maxWidth
, m_unitsMaxW
, m_maxWidthCheckbox
);
583 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMaxSize().GetHeight(), m_maxHeight
, m_unitsMaxH
, m_maxHeightCheckbox
);
584 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetTop(), m_offset
, m_unitsOffset
, m_offsetYCheckbox
);
589 // Show/hide position controls
590 void wxRichTextSizePage::ShowPositionControls(bool show
)
594 m_parentSizer
->Show(m_positionControls
, show
);
599 // Show/hide floating controls
600 void wxRichTextSizePage::ShowFloatingControls(bool show
)
604 m_parentSizer
->Show(m_floatingControls
, show
);
611 * Get bitmap resources
614 wxBitmap
wxRichTextSizePage::GetBitmapResource( const wxString
& name
)
617 ////@begin wxRichTextSizePage bitmap retrieval
620 ////@end wxRichTextSizePage bitmap retrieval
627 wxIcon
wxRichTextSizePage::GetIconResource( const wxString
& name
)
630 ////@begin wxRichTextSizePage icon retrieval
633 ////@end wxRichTextSizePage icon retrieval
638 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_WIDTH
641 void wxRichTextSizePage::OnRichtextWidthUpdate( wxUpdateUIEvent
& event
)
643 event
.Enable(m_widthCheckbox
->GetValue());
647 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_HEIGHT
650 void wxRichTextSizePage::OnRichtextHeightUpdate( wxUpdateUIEvent
& event
)
652 event
.Enable(m_heightCheckbox
->GetValue());
656 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_OFFSET
659 void wxRichTextSizePage::OnRichtextOffsetUpdate( wxUpdateUIEvent
& event
)
661 event
.Enable(m_offsetYCheckbox
->GetValue());
666 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXT_PARA_UP
669 void wxRichTextSizePage::OnRichtextParaUpClick( wxCommandEvent
& WXUNUSED(event
) )
671 wxRichTextFormattingDialog
* dialog
= wxRichTextFormattingDialog::GetDialog(this);
672 if (!dialog
|| !dialog
->GetObject())
675 // Make sure object attributes are up-to-date
676 dialog
->TransferDataFromWindow();
678 wxRichTextBuffer
* buffer
= dialog
->GetObject()->GetBuffer();
679 wxRichTextParagraphLayoutBox
* container
= dialog
->GetObject()->GetParentContainer();
680 wxRichTextObject
* parent
= dialog
->GetObject()->GetParent();
681 if (!container
|| !parent
|| !buffer
)
684 wxRichTextRange range
= dialog
->GetObject()->GetRange();
685 wxRichTextObjectList::compatibility_iterator iter
= container
->GetChildren().GetFirst();
691 if (iter
->GetData() == parent
)
693 iter
= iter
->GetNext();
697 iter
= iter
->GetPrevious();
701 wxRichTextObject
*obj
= iter
->GetData();
702 wxRichTextRange rg
= obj
->GetRange();
703 // tempObj will be deleted along with the undo object, and a clone of it will be
704 // returned by InsertObjectWithUndo
705 wxRichTextObject
* tempObj
= dialog
->GetObject()->Clone();
707 container
->DeleteRangeWithUndo(range
, buffer
->GetRichTextCtrl(), buffer
);
709 wxRichTextObject
* obj2
= container
->InsertObjectWithUndo(buffer
, rg
.GetStart(), tempObj
, buffer
->GetRichTextCtrl(), 0);
710 dialog
->SetObject(obj2
);
714 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXT_DOWN
717 void wxRichTextSizePage::OnRichtextParaDownClick( wxCommandEvent
& WXUNUSED(event
) )
719 wxRichTextFormattingDialog
* dialog
= wxRichTextFormattingDialog::GetDialog(this);
720 if (!dialog
|| !dialog
->GetObject())
723 // Make sure object attributes are up-to-date
724 dialog
->TransferDataFromWindow();
726 wxRichTextBuffer
* buffer
= dialog
->GetObject()->GetBuffer();
727 wxRichTextParagraphLayoutBox
* container
= dialog
->GetObject()->GetParentContainer();
728 wxRichTextObject
* parent
= dialog
->GetObject()->GetParent();
729 if (!container
|| !parent
|| !buffer
)
732 wxRichTextRange range
= dialog
->GetObject()->GetRange();
734 wxRichTextObjectList::compatibility_iterator iter
= buffer
->GetChildren().GetFirst();
740 if (iter
->GetData() == parent
)
742 iter
= iter
->GetNext();
745 iter
= iter
->GetNext();
749 wxRichTextObject
*obj
= iter
->GetData();
750 wxRichTextRange rg
= obj
->GetRange();
751 // tempObj will be deleted along with the undo object, and a clone of it will be
752 // returned by InsertObjectWithUndo
753 wxRichTextObject
* tempObj
= dialog
->GetObject()->Clone();
755 container
->DeleteRangeWithUndo(range
, buffer
->GetRichTextCtrl(), buffer
);
757 // Minus one because we deleted an object
758 wxRichTextObject
* obj2
= container
->InsertObjectWithUndo(buffer
, rg
.GetStart()-1, tempObj
, buffer
->GetRichTextCtrl(), 0);
759 dialog
->SetObject(obj2
);
764 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX
767 void wxRichTextSizePage::OnRichtextVerticalAlignmentComboboxUpdate( wxUpdateUIEvent
& event
)
769 event
.Enable(m_verticalAlignmentCheckbox
->GetValue());
774 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_MIN_WIDTH
777 void wxRichTextSizePage::OnRichtextMinWidthUpdate( wxUpdateUIEvent
& event
)
779 event
.Enable(m_minWidthCheckbox
->GetValue());
783 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_MIN_HEIGHT
786 void wxRichTextSizePage::OnRichtextMinHeightUpdate( wxUpdateUIEvent
& event
)
788 event
.Enable(m_minHeightCheckbox
->GetValue());
793 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_MAX_WIDTH
796 void wxRichTextSizePage::OnRichtextMaxWidthUpdate( wxUpdateUIEvent
& event
)
798 event
.Enable(m_maxWidthCheckbox
->GetValue());
803 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_MAX_HEIGHT
806 void wxRichTextSizePage::OnRichtextMaxHeightUpdate( wxUpdateUIEvent
& event
)
808 event
.Enable(m_maxHeightCheckbox
->GetValue());