]> git.saurik.com Git - wxWidgets.git/blame - src/richtext/richtextimagedlg.cpp
Make the wxComboCtrl's wxTextEntry interface more complete and consistent. All text...
[wxWidgets.git] / src / richtext / richtextimagedlg.cpp
CommitLineData
6255fac9
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/richtext/richtextimagedlg.cpp
ce00f59b 3// Purpose:
6255fac9 4// Author: Mingquan Yang
ce00f59b 5// Modified by:
6255fac9 6// Created: Wed 02 Jun 2010 11:27:23 CST
ce00f59b 7// RCS-ID:
6255fac9
VZ
8// Copyright: (c) Mingquan Yang
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx/wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
0ef18b97
SC
19
20#if wxUSE_RICHTEXT
21
6255fac9
VZ
22#ifndef WX_PRECOMP
23 #include "wx/button.h"
24 #include "wx/combobox.h"
3a3349f5
VZ
25 #include "wx/sizer.h"
26 #include "wx/stattext.h"
6255fac9
VZ
27 #include "wx/textctrl.h"
28#endif
29
30#include "wx/statline.h"
31
32#include "wx/richtext/richtextimagedlg.h"
33#include "wx/richtext/richtextctrl.h"
34
35////@begin XPM images
36////@end XPM images
37
38
39/*!
40 * wxRichTextImageDialog type definition
41 */
42
43IMPLEMENT_DYNAMIC_CLASS( wxRichTextImageDialog, wxDialog )
44
45
46/*!
47 * wxRichTextImageDialog event table definition
48 */
49
50BEGIN_EVENT_TABLE( wxRichTextImageDialog, wxDialog )
51
52////@begin wxRichTextImageDialog event table entries
53 EVT_BUTTON( ID_RICHTEXTIMAGEDIALOG_PARA_UP, wxRichTextImageDialog::OnRichtextimagedialogParaUpClick )
54
55 EVT_BUTTON( ID_RICHTEXTIMAGEDIALOG_DOWN, wxRichTextImageDialog::OnRichtextimagedialogDownClick )
56
57////@end wxRichTextImageDialog event table entries
58
59END_EVENT_TABLE()
60
61
62/*!
63 * wxRichTextImageDialog constructors
64 */
65
66wxRichTextImageDialog::wxRichTextImageDialog()
67{
68 Init();
69}
70
71wxRichTextImageDialog::wxRichTextImageDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
72{
73 Init();
74 Create(parent, id, caption, pos, size, style);
75}
76
77
78/*!
79 * wxRichTextImageDlg creator
80 */
81
82bool wxRichTextImageDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
83{
84////@begin wxRichTextImageDialog creation
85 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
86 wxDialog::Create( parent, id, caption, pos, size, style );
87
88 CreateControls();
89 if (GetSizer())
90 {
91 GetSizer()->SetSizeHints(this);
92 }
93 Centre();
94////@end wxRichTextImageDialog creation
95 return true;
96}
97
98
99/*!
100 * wxRichTextImageDialog destructor
101 */
102
103wxRichTextImageDialog::~wxRichTextImageDialog()
104{
105////@begin wxRichTextImageDialog destruction
106////@end wxRichTextImageDialog destruction
107}
108
109
110/*!
111 * Member initialisation
112 */
113
114void wxRichTextImageDialog::Init()
115{
116////@begin wxRichTextImageDialog member initialisation
6255fac9
VZ
117 m_float = NULL;
118 m_width = NULL;
119 m_unitsW = NULL;
120 m_height = NULL;
121 m_unitsH = NULL;
122 m_offset = NULL;
123 m_unitsOffset = NULL;
124 m_saveButton = NULL;
125 m_cancelButton = NULL;
126////@end wxRichTextImageDialog member initialisation
127}
128
129
130/*!
131 * Control creation for wxRichTextImageDlg
132 */
133
134void wxRichTextImageDialog::CreateControls()
ce00f59b 135{
6255fac9
VZ
136#ifdef __WXMAC__
137 SetWindowVariant(wxWINDOW_VARIANT_SMALL);
138#endif
139
140////@begin wxRichTextImageDialog content construction
141 wxRichTextImageDialog* itemDialog1 = this;
142
143 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
144 itemDialog1->SetSizer(itemBoxSizer2);
145
146 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
147 itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5);
148
149 wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(0, 2, 0, 0);
150 itemBoxSizer3->Add(itemFlexGridSizer4, 0, wxALIGN_TOP|wxRIGHT, 5);
151
24777478
JS
152 wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Floating mode:"), wxDefaultPosition, wxDefaultSize, 0 );
153 itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9
VZ
154
155 wxArrayString m_floatStrings;
156 m_floatStrings.Add(_("None"));
157 m_floatStrings.Add(_("Left"));
158 m_floatStrings.Add(_("Right"));
159 m_float = new wxComboBox( itemDialog1, ID_RICHTEXTIMAGEDIALOG_FLOATING_MODE, _("None"), wxDefaultPosition, wxSize(80, -1), m_floatStrings, wxCB_READONLY );
160 m_float->SetStringSelection(_("None"));
161 m_float->SetHelpText(_("How the image will float relative to the text."));
162 if (wxRichTextImageDialog::ShowToolTips())
163 m_float->SetToolTip(_("How the image will float relative to the text."));
164 itemFlexGridSizer4->Add(m_float, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
165
24777478
JS
166 wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
167 itemFlexGridSizer4->Add(itemStaticText7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9 168
24777478
JS
169 wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
170 itemFlexGridSizer4->Add(itemBoxSizer8, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
6255fac9
VZ
171
172 m_width = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_WIDTH, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
173 m_width->SetHelpText(_("The image width to be shown - does not change the source image width."));
174 if (wxRichTextImageDialog::ShowToolTips())
175 m_width->SetToolTip(_("The image width to be shown - does not change the source image width."));
24777478 176 itemBoxSizer8->Add(m_width, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9
VZ
177
178 wxArrayString m_unitsWStrings;
179 m_unitsWStrings.Add(_("px"));
180 m_unitsWStrings.Add(_("cm"));
181 m_unitsW = new wxComboBox( itemDialog1, ID_RICHTEXTIMAGEDIALOG_UNITS_W, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsWStrings, wxCB_READONLY );
182 m_unitsW->SetStringSelection(_("px"));
183 m_unitsW->SetHelpText(_("Units for the image width."));
184 if (wxRichTextImageDialog::ShowToolTips())
185 m_unitsW->SetToolTip(_("Units for the image width."));
24777478 186 itemBoxSizer8->Add(m_unitsW, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9 187
24777478
JS
188 wxStaticText* itemStaticText11 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Height:"), wxDefaultPosition, wxDefaultSize, 0 );
189 itemFlexGridSizer4->Add(itemStaticText11, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9 190
24777478
JS
191 wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
192 itemFlexGridSizer4->Add(itemBoxSizer12, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
6255fac9
VZ
193
194 m_height = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_HEIGHT, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
195 m_height->SetHelpText(_("The image height to be shown - does not change the source image height."));
196 if (wxRichTextImageDialog::ShowToolTips())
197 m_height->SetToolTip(_("The image height to be shown - does not change the source image height."));
24777478 198 itemBoxSizer12->Add(m_height, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9
VZ
199
200 wxArrayString m_unitsHStrings;
201 m_unitsHStrings.Add(_("px"));
202 m_unitsHStrings.Add(_("cm"));
203 m_unitsH = new wxComboBox( itemDialog1, ID_RICHTEXTIMAGEDIALOG_UNITS_H, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsHStrings, wxCB_READONLY );
204 m_unitsH->SetStringSelection(_("px"));
205 m_unitsH->SetHelpText(_("Units for the image height."));
206 if (wxRichTextImageDialog::ShowToolTips())
207 m_unitsH->SetToolTip(_("Units for the image height."));
24777478 208 itemBoxSizer12->Add(m_unitsH, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9 209
24777478
JS
210 wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Image Vertical &Offset:"), wxDefaultPosition, wxDefaultSize, 0 );
211 itemFlexGridSizer4->Add(itemStaticText15, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9 212
24777478
JS
213 wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
214 itemFlexGridSizer4->Add(itemBoxSizer16, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
6255fac9
VZ
215
216 m_offset = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_OFFSET, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
217 m_offset->SetMaxLength(10);
218 m_offset->SetHelpText(_("The vertical offset relative to the paragraph."));
219 if (wxRichTextImageDialog::ShowToolTips())
220 m_offset->SetToolTip(_("The vertical offset relative to the paragraph."));
24777478 221 itemBoxSizer16->Add(m_offset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9
VZ
222
223 wxArrayString m_unitsOffsetStrings;
224 m_unitsOffsetStrings.Add(_("px"));
225 m_unitsOffsetStrings.Add(_("cm"));
226 m_unitsOffset = new wxComboBox( itemDialog1, ID_RICHTEXTIMAGEDIALOG_OFFSET_UNITS, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsOffsetStrings, wxCB_READONLY );
227 m_unitsOffset->SetStringSelection(_("px"));
228 m_unitsOffset->SetHelpText(_("Units for the image offset."));
229 if (wxRichTextImageDialog::ShowToolTips())
230 m_unitsOffset->SetToolTip(_("Units for the image offset."));
24777478 231 itemBoxSizer16->Add(m_unitsOffset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9 232
24777478
JS
233 wxStaticText* itemStaticText19 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Move the image to:"), wxDefaultPosition, wxDefaultSize, 0 );
234 itemFlexGridSizer4->Add(itemStaticText19, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9 235
24777478
JS
236 wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
237 itemFlexGridSizer4->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
6255fac9 238
24777478
JS
239 wxButton* itemButton21 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_PARA_UP, _("&Previous Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
240 itemButton21->SetHelpText(_("Moves the image to the previous paragraph."));
6255fac9 241 if (wxRichTextImageDialog::ShowToolTips())
24777478
JS
242 itemButton21->SetToolTip(_("Moves the image to the previous paragraph."));
243 itemBoxSizer20->Add(itemButton21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
6255fac9 244
24777478
JS
245 wxButton* itemButton22 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_DOWN, _("&Next Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
246 itemButton22->SetHelpText(_("Moves the image to the next paragraph."));
6255fac9 247 if (wxRichTextImageDialog::ShowToolTips())
24777478
JS
248 itemButton22->SetToolTip(_("Moves the image to the next paragraph."));
249 itemBoxSizer20->Add(itemButton22, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
6255fac9 250
24777478
JS
251 wxStaticLine* itemStaticLine23 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
252 itemBoxSizer2->Add(itemStaticLine23, 0, wxGROW|wxALL, 5);
6255fac9 253
24777478 254 wxStdDialogButtonSizer* itemStdDialogButtonSizer24 = new wxStdDialogButtonSizer;
6255fac9 255
24777478 256 itemBoxSizer2->Add(itemStdDialogButtonSizer24, 0, wxGROW|wxALL, 5);
6255fac9
VZ
257 m_saveButton = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
258 m_saveButton->SetHelpText(_("Click to confirm your changes."));
259 if (wxRichTextImageDialog::ShowToolTips())
260 m_saveButton->SetToolTip(_("Click to confirm your changes."));
24777478 261 itemStdDialogButtonSizer24->AddButton(m_saveButton);
6255fac9
VZ
262
263 m_cancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
264 m_cancelButton->SetHelpText(_("Click to discard your changes."));
265 if (wxRichTextImageDialog::ShowToolTips())
266 m_cancelButton->SetToolTip(_("Click to discard your changes."));
24777478 267 itemStdDialogButtonSizer24->AddButton(m_cancelButton);
6255fac9 268
24777478 269 itemStdDialogButtonSizer24->Realize();
6255fac9
VZ
270
271////@end wxRichTextImageDialog content construction
272}
273
274
275/*!
276 * Should we show tooltips?
277 */
278
279bool wxRichTextImageDialog::ShowToolTips()
280{
281 return true;
282}
283
284/*!
285 * Get bitmap resources
286 */
287
288wxBitmap wxRichTextImageDialog::GetBitmapResource( const wxString& name )
289{
290 // Bitmap retrieval
291////@begin wxRichTextImageDialog bitmap retrieval
292 wxUnusedVar(name);
293 return wxNullBitmap;
294////@end wxRichTextImageDialog bitmap retrieval
295}
296
297/*!
298 * Get icon resources
299 */
300
301wxIcon wxRichTextImageDialog::GetIconResource( const wxString& name )
302{
303 // Icon retrieval
304////@begin wxRichTextImageDialog icon retrieval
305 wxUnusedVar(name);
306 return wxNullIcon;
307////@end wxRichTextImageDialog icon retrieval
308}
309
310/*!
311 * Set the image attribute
312 */
24777478 313void wxRichTextImageDialog::SetImageAttr(const wxRichTextAttr& textAttr)
6255fac9 314{
24777478
JS
315 m_textAttr = textAttr;
316
6255fac9
VZ
317 TransferDataToWindow();
318}
319
320/*!
321 * Apply the new style
322 */
323wxRichTextImage* wxRichTextImageDialog::ApplyImageAttr()
324{
325 wxRichTextImage* image = wxDynamicCast(m_image, wxRichTextImage);
326
327 TransferDataFromWindow();
328 if (m_buffer->GetRichTextCtrl())
329 {
24777478 330 m_buffer->GetRichTextCtrl()->SetImageStyle(image, m_textAttr);
6255fac9
VZ
331 }
332 return image;
333}
334
335void wxRichTextImageDialog::SetImageObject(wxRichTextImage* image, wxRichTextBuffer* buffer)
336{
337 wxRichTextObject* parent = image->GetParent();
338
339 m_buffer = buffer;
340 m_image = image;
341 m_parent = parent;
24777478 342 SetImageAttr(image->GetAttributes());
6255fac9
VZ
343 if (image->GetImageCache().IsOk())
344 {
24777478 345 if (!m_textAttr.GetTextBoxAttr().GetWidth().IsPresent() || m_textAttr.GetTextBoxAttr().GetWidth().GetValue() <= 0)
6255fac9 346 {
24777478
JS
347 m_textAttr.GetTextBoxAttr().GetWidth().SetValue(image->GetImageCache().GetWidth());
348 m_textAttr.GetTextBoxAttr().GetWidth().SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
6255fac9 349 }
24777478 350 if (!m_textAttr.GetTextBoxAttr().GetHeight().IsPresent() || m_textAttr.GetTextBoxAttr().GetHeight().GetValue() <= 0)
6255fac9 351 {
24777478
JS
352 m_textAttr.GetTextBoxAttr().GetHeight().SetValue(image->GetImageCache().GetHeight());
353 m_textAttr.GetTextBoxAttr().GetHeight().SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
6255fac9
VZ
354 }
355 }
356}
357
24777478 358void wxRichTextImageDialog::SetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl)
6255fac9 359{
24777478
JS
360 int unitsIdx = 0;
361
362 if (!dim.IsPresent())
6255fac9 363 {
24777478
JS
364 dim.SetValue(0);
365 dim.SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
6255fac9
VZ
366 }
367
24777478 368 if (dim.GetUnits() == wxTEXT_ATTR_UNITS_TENTHS_MM)
6255fac9 369 {
24777478
JS
370 unitsIdx = 1;
371 float value = float(dim.GetValue()) / 10.0;
372 valueCtrl->SetValue(wxString::Format(wxT("%.2f"), value));
6255fac9
VZ
373 }
374 else
375 {
24777478
JS
376 unitsIdx = 0;
377 valueCtrl->SetValue(wxString::Format(wxT("%d"), (int) dim.GetValue()));
6255fac9
VZ
378 }
379
24777478
JS
380 unitsCtrl->SetSelection(unitsIdx);
381}
382
383void wxRichTextImageDialog::GetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl)
384{
385 if (unitsCtrl->GetSelection() == 1)
386 dim.SetUnits(wxTEXT_ATTR_UNITS_TENTHS_MM);
6255fac9 387 else
24777478 388 dim.SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
6255fac9 389
24777478
JS
390 int value = 0;
391 if (ConvertFromString(valueCtrl->GetValue(), value, dim.GetUnits()))
392 dim.SetValue(value);
6255fac9
VZ
393}
394
24777478 395bool wxRichTextImageDialog::TransferDataToWindow()
6255fac9 396{
24777478
JS
397 m_float->SetSelection(m_textAttr.GetTextBoxAttr().GetFloatMode());
398
399 SetDimensionValue(m_textAttr.GetTextBoxAttr().GetWidth(), m_width, m_unitsW);
400 SetDimensionValue(m_textAttr.GetTextBoxAttr().GetHeight(), m_height, m_unitsH);
401 SetDimensionValue(m_textAttr.GetTextBoxAttr().GetTop(), m_offset, m_unitsOffset);
6255fac9 402
24777478
JS
403 return true;
404}
6255fac9 405
24777478
JS
406bool wxRichTextImageDialog::TransferDataFromWindow()
407{
408 m_textAttr.GetTextBoxAttr().SetFloatMode(m_float->GetSelection());
6255fac9 409
24777478
JS
410 GetDimensionValue(m_textAttr.GetTextBoxAttr().GetWidth(), m_width, m_unitsW);
411 GetDimensionValue(m_textAttr.GetTextBoxAttr().GetHeight(), m_height, m_unitsH);
412 GetDimensionValue(m_textAttr.GetTextBoxAttr().GetTop(), m_offset, m_unitsOffset);
6255fac9
VZ
413
414 return true;
415}
416
417bool wxRichTextImageDialog::ConvertFromString(const wxString& string, int& ret, int scale)
418{
419 const wxChar* chars = string.GetData();
420 int remain = 2;
421 bool dot = false;
422 ret = 0;
423
424 for (unsigned int i = 0; i < string.Len() && remain; i++)
425 {
24777478 426 if (!(chars[i] >= '0' && chars[i] <= '9') && !(scale == wxTEXT_ATTR_UNITS_TENTHS_MM && chars[i] == '.'))
6255fac9
VZ
427 return false;
428
429 if (chars[i] == '.')
430 {
431 dot = true;
432 continue;
433 }
434
435 if (dot)
436 remain--;
437
438 ret = ret * 10 + chars[i] - '0';
439 }
440
24777478 441 while (remain-- > 0 && scale == wxTEXT_ATTR_UNITS_TENTHS_MM)
6255fac9
VZ
442 ret *= 10;
443
444 return true;
445}
446
447
448/*!
449 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_PARA_UP
450 */
451void wxRichTextImageDialog::OnRichtextimagedialogParaUpClick( wxCommandEvent& WXUNUSED(event))
452{
453 // Before editing this code, remove the block markers.
454 wxRichTextRange range = m_image->GetRange();
455 wxRichTextObjectList::compatibility_iterator iter = m_buffer->GetChildren().GetFirst();
864299f7 456 if (!iter)
6255fac9
VZ
457 return;
458
459 while (iter)
460 {
461 if (iter->GetData() == m_parent)
462 break;
463 iter = iter->GetNext();
464 }
465
466 iter = iter->GetPrevious();
864299f7 467 if (!iter)
6255fac9
VZ
468 return;
469
470 wxRichTextObject *obj = iter->GetData();
471 wxRichTextRange rg = obj->GetRange();
472 m_image = m_image->Clone();
473
474 m_buffer->DeleteRangeWithUndo(range, m_buffer->GetRichTextCtrl());
475 m_buffer->InsertObjectWithUndo(rg.GetEnd(), m_image, m_buffer->GetRichTextCtrl(), 0);
476 m_parent = obj;
477 m_image->SetRange(wxRichTextRange(rg.GetEnd(), rg.GetEnd()));
478}
479
480
481/*!
482 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_PARA_DOWN
483 */
484
485void wxRichTextImageDialog::OnRichtextimagedialogDownClick( wxCommandEvent& WXUNUSED(event))
486{
487 // Before editing this code, remove the block markers.
488 wxRichTextRange range = m_image->GetRange();
489 wxRichTextObjectList::compatibility_iterator iter = m_buffer->GetChildren().GetFirst();
864299f7 490 if (!iter)
6255fac9
VZ
491 return;
492
493 while (iter)
494 {
495 if (iter->GetData() == m_parent)
496 break;
497 iter = iter->GetNext();
498 }
499
500 iter = iter->GetNext();
864299f7 501 if (!iter)
6255fac9
VZ
502 return;
503
504 wxRichTextObject *obj = iter->GetData();
505 wxRichTextRange rg = obj->GetRange();
506 m_image = m_image->Clone();
507
508 m_buffer->DeleteRangeWithUndo(range, m_buffer->GetRichTextCtrl());
509 m_buffer->InsertObjectWithUndo(rg.GetEnd(), m_image, m_buffer->GetRichTextCtrl(), 0);
510 m_parent = obj;
511 m_image->SetRange(wxRichTextRange(rg.GetEnd(), rg.GetEnd()));
512}
513
0ef18b97 514#endif