1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextimagedlg.cpp
4 // Author: Mingquan Yang
5 // Modified by: Julian Smart
6 // Created: Wed 02 Jun 2010 11:27:23 CST
8 // Copyright: (c) Mingquan Yang, Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
22 #include "wx/button.h"
23 #include "wx/combobox.h"
25 #include "wx/stattext.h"
26 #include "wx/textctrl.h"
29 #include "wx/statline.h"
31 #include "wx/richtext/richtextimagedlg.h"
32 #include "wx/richtext/richtextctrl.h"
39 * wxRichTextObjectPropertiesDialog type definition
42 IMPLEMENT_DYNAMIC_CLASS( wxRichTextObjectPropertiesDialog
, wxRichTextFormattingDialog
)
46 * wxRichTextObjectPropertiesDialog event table definition
49 BEGIN_EVENT_TABLE( wxRichTextObjectPropertiesDialog
, wxRichTextFormattingDialog
)
51 ////@begin wxRichTextObjectPropertiesDialog event table entries
52 ////@end wxRichTextObjectPropertiesDialog event table entries
58 * wxRichTextObjectPropertiesDialog constructors
61 wxRichTextObjectPropertiesDialog::wxRichTextObjectPropertiesDialog()
66 wxRichTextObjectPropertiesDialog::wxRichTextObjectPropertiesDialog( wxRichTextObject
* obj
, wxWindow
* parent
, wxWindowID id
, const wxString
& caption
, const wxPoint
& pos
, const wxSize
& size
, long style
)
69 Create(obj
, parent
, id
, caption
, pos
, size
, style
);
74 * wxRichTextImageDlg creator
77 bool wxRichTextObjectPropertiesDialog::Create( wxRichTextObject
* obj
, wxWindow
* parent
, wxWindowID id
, const wxString
& caption
, const wxPoint
& pos
, const wxSize
& size
, long style
)
80 SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
);
81 long flags
= wxRICHTEXT_FORMAT_SIZE
|wxRICHTEXT_FORMAT_MARGINS
|wxRICHTEXT_FORMAT_BORDERS
|wxRICHTEXT_FORMAT_BACKGROUND
;
82 wxRichTextFormattingDialog::Create( flags
, parent
, caption
, id
, pos
, size
, style
);
91 * wxRichTextObjectPropertiesDialog destructor
94 wxRichTextObjectPropertiesDialog::~wxRichTextObjectPropertiesDialog()
96 ////@begin wxRichTextObjectPropertiesDialog destruction
97 ////@end wxRichTextObjectPropertiesDialog destruction
102 * Member initialisation
105 void wxRichTextObjectPropertiesDialog::Init()
107 ////@begin wxRichTextObjectPropertiesDialog member initialisation
108 ////@end wxRichTextObjectPropertiesDialog member initialisation
113 * Control creation for wxRichTextImageDlg
116 void wxRichTextObjectPropertiesDialog::CreateControls()
122 * Should we show tooltips?
125 bool wxRichTextObjectPropertiesDialog::ShowToolTips()
131 * Get bitmap resources
134 wxBitmap
wxRichTextObjectPropertiesDialog::GetBitmapResource( const wxString
& name
)
137 ////@begin wxRichTextObjectPropertiesDialog bitmap retrieval
140 ////@end wxRichTextObjectPropertiesDialog bitmap retrieval
147 wxIcon
wxRichTextObjectPropertiesDialog::GetIconResource( const wxString
& name
)
150 ////@begin wxRichTextObjectPropertiesDialog icon retrieval
153 ////@end wxRichTextObjectPropertiesDialog icon retrieval
158 * wxEVT_BUTTON event handler for ID_BUTTON_PARA_UP
160 void wxRichTextObjectPropertiesDialog::OnRichtextParaUpClick( wxCommandEvent
& WXUNUSED(event
))
162 // Before editing this code, remove the block markers.
163 wxRichTextRange range
= m_object
->GetRange();
164 wxRichTextObjectList::compatibility_iterator iter
= m_buffer
->GetChildren().GetFirst();
170 if (iter
->GetData() == m_parent
)
172 iter
= iter
->GetNext();
175 iter
= iter
->GetPrevious();
179 wxRichTextObject
*obj
= iter
->GetData();
180 wxRichTextRange rg
= obj
->GetRange();
181 m_object
= m_object
->Clone();
183 m_buffer
->DeleteRangeWithUndo(range
, m_buffer
->GetRichTextCtrl());
184 m_buffer
->InsertObjectWithUndo(rg
.GetEnd(), m_object
, m_buffer
->GetRichTextCtrl(), 0);
186 m_object
->SetRange(wxRichTextRange(rg
.GetEnd(), rg
.GetEnd()));
191 * wxEVT_BUTTON event handler for ID_BUTTON_PARA_DOWN
194 void wxRichTextObjectPropertiesDialog::OnRichtextDownClick( wxCommandEvent
& WXUNUSED(event
))
196 // Before editing this code, remove the block markers.
197 wxRichTextRange range
= m_object
->GetRange();
198 wxRichTextObjectList::compatibility_iterator iter
= m_buffer
->GetChildren().GetFirst();
204 if (iter
->GetData() == m_parent
)
206 iter
= iter
->GetNext();
209 iter
= iter
->GetNext();
213 wxRichTextObject
*obj
= iter
->GetData();
214 wxRichTextRange rg
= obj
->GetRange();
215 m_object
= m_object
->Clone();
217 m_buffer
->DeleteRangeWithUndo(range
, m_buffer
->GetRichTextCtrl());
218 m_buffer
->InsertObjectWithUndo(rg
.GetEnd(), m_object
, m_buffer
->GetRichTextCtrl(), 0);
220 m_object
->SetRange(wxRichTextRange(rg
.GetEnd(), rg
.GetEnd()));