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 wxRichTextImage
* imageObj
= NULL
;
538 imageObj
= wxDynamicCast(dialog
->GetObject(), wxRichTextImage
);
540 // For an image, show the original width and height if the size is not explicitly specified.
541 if (imageObj
&& !GetAttributes()->GetTextBoxAttr().GetWidth().IsValid() && !GetAttributes()->GetTextBoxAttr().GetHeight().IsValid() &&
542 imageObj
->GetOriginalImageSize() != wxSize(-1, -1))
544 m_widthCheckbox
->SetValue(false);
545 m_heightCheckbox
->SetValue(false);
546 m_unitsW
->SetSelection(0);
547 m_unitsH
->SetSelection(0);
548 m_width
->SetValue(wxString::Format(wxT("%d"), (int) imageObj
->GetOriginalImageSize().GetWidth()));
549 m_height
->SetValue(wxString::Format(wxT("%d"), (int) imageObj
->GetOriginalImageSize().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
);
557 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMinSize().GetWidth(), m_minWidth
, m_unitsMinW
, m_minWidthCheckbox
);
558 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMinSize().GetHeight(), m_minHeight
, m_unitsMinH
, m_minHeightCheckbox
);
559 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMaxSize().GetWidth(), m_maxWidth
, m_unitsMaxW
, m_maxWidthCheckbox
);
560 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMaxSize().GetHeight(), m_maxHeight
, m_unitsMaxH
, m_maxHeightCheckbox
);
561 wxRichTextFormattingDialog::SetDimensionValue(GetAttributes()->GetTextBoxAttr().GetTop(), m_offset
, m_unitsOffset
, m_offsetYCheckbox
);
566 bool wxRichTextSizePage::TransferDataFromWindow()
568 GetAttributes()->GetTextBoxAttr().SetFloatMode((wxTextBoxAttrFloatStyle
) m_float
->GetSelection());
569 if (m_float
->GetSelection() == 0)
570 GetAttributes()->GetTextBoxAttr().RemoveFlag(wxTEXT_BOX_ATTR_FLOAT
);
572 if (m_verticalAlignmentCheckbox
->GetValue())
573 GetAttributes()->GetTextBoxAttr().SetVerticalAlignment((wxTextBoxAttrVerticalAlignment
) (m_verticalAlignmentComboBox
->GetSelection() + 1));
576 GetAttributes()->GetTextBoxAttr().SetVerticalAlignment(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE
);
577 GetAttributes()->GetTextBoxAttr().RemoveFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT
);
580 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetWidth(), m_width
, m_unitsW
, m_widthCheckbox
);
581 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetHeight(), m_height
, m_unitsH
, m_heightCheckbox
);
582 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMinSize().GetWidth(), m_minWidth
, m_unitsMinW
, m_minWidthCheckbox
);
583 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMinSize().GetHeight(), m_minHeight
, m_unitsMinH
, m_minHeightCheckbox
);
584 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMaxSize().GetWidth(), m_maxWidth
, m_unitsMaxW
, m_maxWidthCheckbox
);
585 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetMaxSize().GetHeight(), m_maxHeight
, m_unitsMaxH
, m_maxHeightCheckbox
);
586 wxRichTextFormattingDialog::GetDimensionValue(GetAttributes()->GetTextBoxAttr().GetTop(), m_offset
, m_unitsOffset
, m_offsetYCheckbox
);
591 // Show/hide position controls
592 void wxRichTextSizePage::ShowPositionControls(bool show
)
596 m_parentSizer
->Show(m_positionControls
, show
);
601 // Show/hide floating controls
602 void wxRichTextSizePage::ShowFloatingControls(bool show
)
606 m_parentSizer
->Show(m_floatingControls
, show
);
613 * Get bitmap resources
616 wxBitmap
wxRichTextSizePage::GetBitmapResource( const wxString
& name
)
619 ////@begin wxRichTextSizePage bitmap retrieval
622 ////@end wxRichTextSizePage bitmap retrieval
629 wxIcon
wxRichTextSizePage::GetIconResource( const wxString
& name
)
632 ////@begin wxRichTextSizePage icon retrieval
635 ////@end wxRichTextSizePage icon retrieval
640 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_WIDTH
643 void wxRichTextSizePage::OnRichtextWidthUpdate( wxUpdateUIEvent
& event
)
645 event
.Enable(m_widthCheckbox
->GetValue());
649 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_HEIGHT
652 void wxRichTextSizePage::OnRichtextHeightUpdate( wxUpdateUIEvent
& event
)
654 event
.Enable(m_heightCheckbox
->GetValue());
658 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_OFFSET
661 void wxRichTextSizePage::OnRichtextOffsetUpdate( wxUpdateUIEvent
& event
)
663 event
.Enable(m_offsetYCheckbox
->GetValue());
668 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXT_PARA_UP
671 void wxRichTextSizePage::OnRichtextParaUpClick( wxCommandEvent
& WXUNUSED(event
) )
673 wxRichTextFormattingDialog
* dialog
= wxRichTextFormattingDialog::GetDialog(this);
674 if (!dialog
|| !dialog
->GetObject())
677 // Make sure object attributes are up-to-date
678 dialog
->TransferDataFromWindow();
680 wxRichTextBuffer
* buffer
= dialog
->GetObject()->GetBuffer();
681 wxRichTextParagraphLayoutBox
* container
= dialog
->GetObject()->GetParentContainer();
682 wxRichTextObject
* parent
= dialog
->GetObject()->GetParent();
683 if (!container
|| !parent
|| !buffer
)
686 wxRichTextRange range
= dialog
->GetObject()->GetRange();
687 wxRichTextObjectList::compatibility_iterator iter
= container
->GetChildren().GetFirst();
693 if (iter
->GetData() == parent
)
695 iter
= iter
->GetNext();
699 iter
= iter
->GetPrevious();
703 wxRichTextObject
*obj
= iter
->GetData();
704 wxRichTextRange rg
= obj
->GetRange();
705 // tempObj will be deleted along with the undo object, and a clone of it will be
706 // returned by InsertObjectWithUndo
707 wxRichTextObject
* tempObj
= dialog
->GetObject()->Clone();
709 container
->DeleteRangeWithUndo(range
, buffer
->GetRichTextCtrl(), buffer
);
711 wxRichTextObject
* obj2
= container
->InsertObjectWithUndo(buffer
, rg
.GetStart(), tempObj
, buffer
->GetRichTextCtrl(), 0);
712 dialog
->SetObject(obj2
);
716 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXT_DOWN
719 void wxRichTextSizePage::OnRichtextParaDownClick( wxCommandEvent
& WXUNUSED(event
) )
721 wxRichTextFormattingDialog
* dialog
= wxRichTextFormattingDialog::GetDialog(this);
722 if (!dialog
|| !dialog
->GetObject())
725 // Make sure object attributes are up-to-date
726 dialog
->TransferDataFromWindow();
728 wxRichTextBuffer
* buffer
= dialog
->GetObject()->GetBuffer();
729 wxRichTextParagraphLayoutBox
* container
= dialog
->GetObject()->GetParentContainer();
730 wxRichTextObject
* parent
= dialog
->GetObject()->GetParent();
731 if (!container
|| !parent
|| !buffer
)
734 wxRichTextRange range
= dialog
->GetObject()->GetRange();
736 wxRichTextObjectList::compatibility_iterator iter
= buffer
->GetChildren().GetFirst();
742 if (iter
->GetData() == parent
)
744 iter
= iter
->GetNext();
747 iter
= iter
->GetNext();
751 wxRichTextObject
*obj
= iter
->GetData();
752 wxRichTextRange rg
= obj
->GetRange();
753 // tempObj will be deleted along with the undo object, and a clone of it will be
754 // returned by InsertObjectWithUndo
755 wxRichTextObject
* tempObj
= dialog
->GetObject()->Clone();
757 container
->DeleteRangeWithUndo(range
, buffer
->GetRichTextCtrl(), buffer
);
759 // Minus one because we deleted an object
760 wxRichTextObject
* obj2
= container
->InsertObjectWithUndo(buffer
, rg
.GetStart()-1, tempObj
, buffer
->GetRichTextCtrl(), 0);
761 dialog
->SetObject(obj2
);
766 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_VERTICAL_ALIGNMENT_COMBOBOX
769 void wxRichTextSizePage::OnRichtextVerticalAlignmentComboboxUpdate( wxUpdateUIEvent
& event
)
771 event
.Enable(m_verticalAlignmentCheckbox
->GetValue());
776 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_MIN_WIDTH
779 void wxRichTextSizePage::OnRichtextMinWidthUpdate( wxUpdateUIEvent
& event
)
781 event
.Enable(m_minWidthCheckbox
->GetValue());
785 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_MIN_HEIGHT
788 void wxRichTextSizePage::OnRichtextMinHeightUpdate( wxUpdateUIEvent
& event
)
790 event
.Enable(m_minHeightCheckbox
->GetValue());
795 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_MAX_WIDTH
798 void wxRichTextSizePage::OnRichtextMaxWidthUpdate( wxUpdateUIEvent
& event
)
800 event
.Enable(m_maxWidthCheckbox
->GetValue());
805 * wxEVT_UPDATE_UI event handler for ID_RICHTEXT_MAX_HEIGHT
808 void wxRichTextSizePage::OnRichtextMaxHeightUpdate( wxUpdateUIEvent
& event
)
810 event
.Enable(m_maxHeightCheckbox
->GetValue());