]> git.saurik.com Git - wxWidgets.git/blob - src/richtext/richtextimagedlg.cpp
Improve inotify()-based wxFileSystemWatcher to handle creation/deletion.
[wxWidgets.git] / src / richtext / richtextimagedlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextimagedlg.cpp
3 // Purpose:
4 // Author: Mingquan Yang
5 // Modified by: Julian Smart
6 // Created: Wed 02 Jun 2010 11:27:23 CST
7 // RCS-ID:
8 // Copyright: (c) Mingquan Yang, Julian Smart
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
19 #if wxUSE_RICHTEXT
20
21 #ifndef WX_PRECOMP
22 #include "wx/button.h"
23 #include "wx/combobox.h"
24 #include "wx/sizer.h"
25 #include "wx/stattext.h"
26 #include "wx/textctrl.h"
27 #endif
28
29 #include "wx/statline.h"
30
31 #include "wx/richtext/richtextimagedlg.h"
32 #include "wx/richtext/richtextctrl.h"
33
34 ////@begin XPM images
35 ////@end XPM images
36
37
38 /*!
39 * wxRichTextObjectPropertiesDialog type definition
40 */
41
42 IMPLEMENT_DYNAMIC_CLASS( wxRichTextObjectPropertiesDialog, wxRichTextFormattingDialog )
43
44
45 /*!
46 * wxRichTextObjectPropertiesDialog event table definition
47 */
48
49 BEGIN_EVENT_TABLE( wxRichTextObjectPropertiesDialog, wxRichTextFormattingDialog )
50
51 ////@begin wxRichTextObjectPropertiesDialog event table entries
52 ////@end wxRichTextObjectPropertiesDialog event table entries
53
54 END_EVENT_TABLE()
55
56
57 /*!
58 * wxRichTextObjectPropertiesDialog constructors
59 */
60
61 wxRichTextObjectPropertiesDialog::wxRichTextObjectPropertiesDialog()
62 {
63 Init();
64 }
65
66 wxRichTextObjectPropertiesDialog::wxRichTextObjectPropertiesDialog( wxRichTextObject* obj, wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
67 {
68 Init();
69 Create(obj, parent, id, caption, pos, size, style);
70 }
71
72
73 /*!
74 * wxRichTextImageDlg creator
75 */
76
77 bool wxRichTextObjectPropertiesDialog::Create( wxRichTextObject* obj, wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
78 {
79 SetObject(obj);
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 );
83
84 CreateControls();
85
86 return true;
87 }
88
89
90 /*!
91 * wxRichTextObjectPropertiesDialog destructor
92 */
93
94 wxRichTextObjectPropertiesDialog::~wxRichTextObjectPropertiesDialog()
95 {
96 ////@begin wxRichTextObjectPropertiesDialog destruction
97 ////@end wxRichTextObjectPropertiesDialog destruction
98 }
99
100
101 /*!
102 * Member initialisation
103 */
104
105 void wxRichTextObjectPropertiesDialog::Init()
106 {
107 ////@begin wxRichTextObjectPropertiesDialog member initialisation
108 ////@end wxRichTextObjectPropertiesDialog member initialisation
109 }
110
111
112 /*!
113 * Control creation for wxRichTextImageDlg
114 */
115
116 void wxRichTextObjectPropertiesDialog::CreateControls()
117 {
118 }
119
120
121 /*!
122 * Should we show tooltips?
123 */
124
125 bool wxRichTextObjectPropertiesDialog::ShowToolTips()
126 {
127 return true;
128 }
129
130 /*!
131 * Get bitmap resources
132 */
133
134 wxBitmap wxRichTextObjectPropertiesDialog::GetBitmapResource( const wxString& name )
135 {
136 // Bitmap retrieval
137 ////@begin wxRichTextObjectPropertiesDialog bitmap retrieval
138 wxUnusedVar(name);
139 return wxNullBitmap;
140 ////@end wxRichTextObjectPropertiesDialog bitmap retrieval
141 }
142
143 /*!
144 * Get icon resources
145 */
146
147 wxIcon wxRichTextObjectPropertiesDialog::GetIconResource( const wxString& name )
148 {
149 // Icon retrieval
150 ////@begin wxRichTextObjectPropertiesDialog icon retrieval
151 wxUnusedVar(name);
152 return wxNullIcon;
153 ////@end wxRichTextObjectPropertiesDialog icon retrieval
154 }
155
156 #if 0
157 /*!
158 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_PARA_UP
159 */
160 void wxRichTextObjectPropertiesDialog::OnRichtextParaUpClick( wxCommandEvent& WXUNUSED(event))
161 {
162 // Before editing this code, remove the block markers.
163 wxRichTextRange range = m_object->GetRange();
164 wxRichTextObjectList::compatibility_iterator iter = m_buffer->GetChildren().GetFirst();
165 if (!iter)
166 return;
167
168 while (iter)
169 {
170 if (iter->GetData() == m_parent)
171 break;
172 iter = iter->GetNext();
173 }
174
175 iter = iter->GetPrevious();
176 if (!iter)
177 return;
178
179 wxRichTextObject *obj = iter->GetData();
180 wxRichTextRange rg = obj->GetRange();
181 m_object = m_object->Clone();
182
183 m_buffer->DeleteRangeWithUndo(range, m_buffer->GetRichTextCtrl());
184 m_buffer->InsertObjectWithUndo(rg.GetEnd(), m_object, m_buffer->GetRichTextCtrl(), 0);
185 m_parent = obj;
186 m_object->SetRange(wxRichTextRange(rg.GetEnd(), rg.GetEnd()));
187 }
188
189
190 /*!
191 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_PARA_DOWN
192 */
193
194 void wxRichTextObjectPropertiesDialog::OnRichtextDownClick( wxCommandEvent& WXUNUSED(event))
195 {
196 // Before editing this code, remove the block markers.
197 wxRichTextRange range = m_object->GetRange();
198 wxRichTextObjectList::compatibility_iterator iter = m_buffer->GetChildren().GetFirst();
199 if (!iter)
200 return;
201
202 while (iter)
203 {
204 if (iter->GetData() == m_parent)
205 break;
206 iter = iter->GetNext();
207 }
208
209 iter = iter->GetNext();
210 if (!iter)
211 return;
212
213 wxRichTextObject *obj = iter->GetData();
214 wxRichTextRange rg = obj->GetRange();
215 m_object = m_object->Clone();
216
217 m_buffer->DeleteRangeWithUndo(range, m_buffer->GetRichTextCtrl());
218 m_buffer->InsertObjectWithUndo(rg.GetEnd(), m_object, m_buffer->GetRichTextCtrl(), 0);
219 m_parent = obj;
220 m_object->SetRange(wxRichTextRange(rg.GetEnd(), rg.GetEnd()));
221 }
222
223 #endif
224
225 #endif
226 // wxUSE_RICHTEXT