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