]>
Commit | Line | Data |
---|---|---|
bd6169a6 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dataview.cpp | |
9861f022 | 3 | // Purpose: wxDataViewCtrl wxWidgets sample |
bd6169a6 | 4 | // Author: Robert Roebling |
b7e9f8b1 | 5 | // Modified by: Francesco Montorsi, Bo Yang |
bd6169a6 RR |
6 | // Created: 06/01/06 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Robert Roebling | |
9 | // Licence: wxWindows license | |
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 | #ifndef WX_PRECOMP | |
0bcd4039 | 20 | #include "wx/wx.h" |
bd6169a6 RR |
21 | #endif |
22 | ||
b910a8ad | 23 | #include "wx/datetime.h" |
87f0efe2 RR |
24 | #include "wx/splitter.h" |
25 | #include "wx/aboutdlg.h" | |
9861f022 RR |
26 | #include "wx/choicdlg.h" |
27 | #include "wx/numdlg.h" | |
28 | #include "wx/dataview.h" | |
1e510b1e | 29 | #include "wx/spinctrl.h" |
b910a8ad | 30 | |
bd6169a6 | 31 | #ifndef __WXMSW__ |
0bcd4039 | 32 | #include "../sample.xpm" |
bd6169a6 RR |
33 | #endif |
34 | ||
cbc9145c RR |
35 | #include "null.xpm" |
36 | ||
a75124d0 RR |
37 | /* XPM */ |
38 | static const char *small1_xpm[] = { | |
39 | /* columns rows colors chars-per-pixel */ | |
40 | "16 16 6 1", | |
41 | ". c Black", | |
42 | "o c #FFFFFF", | |
43 | "X c #000080", | |
44 | "O c #FFFF00", | |
45 | " c None", | |
46 | "+ c #FF0000", | |
47 | /* pixels */ | |
48 | " ", | |
49 | " ", | |
50 | " ", | |
51 | " ....... ", | |
52 | " .XXXXX. ", | |
53 | " .oXXXX. ", | |
54 | " .oXXX.......", | |
55 | ".....oXXX.OOOOO.", | |
56 | ".+++.XXXX.oOOOO.", | |
57 | ".o++......oOOOO.", | |
58 | ".o++++. .oOOOO.", | |
59 | ".o++++. .OOOOO.", | |
60 | ".+++++. .......", | |
61 | "....... ", | |
62 | " ", | |
63 | " " | |
64 | }; | |
65 | ||
66 | ||
9861f022 RR |
67 | |
68 | #define DEFAULT_ALIGN wxALIGN_LEFT | |
69 | #define DATAVIEW_DEFAULT_STYLE (wxDV_MULTIPLE|wxDV_HORIZ_RULES|wxDV_VERT_RULES) | |
70 | ||
71 | ||
362d7fb9 | 72 | // ------------------------------------- |
5debbdcf | 73 | // MyMusicModel |
362d7fb9 | 74 | // ------------------------------------- |
bd6169a6 | 75 | |
5debbdcf RR |
76 | /* |
77 | Implement this data model | |
78 | Title Artist Year | |
79 | ------------------------------------------------------------- | |
80 | 1: My Music: | |
81 | 2: Pop music | |
82 | 3: You are not alone Michael Jackson 1995 | |
83 | 4: Take a bow Madonna 1994 | |
84 | 5: Classical music | |
85 | 6: Ninth Symphony Ludwig v. Beethoven 1824 | |
86 | 7: German Requiem Johannes Brahms 1868 | |
87 | */ | |
4d496ecb | 88 | |
1e08ad10 RR |
89 | |
90 | ||
91 | class MyMusicModelNode; | |
92 | WX_DEFINE_ARRAY_PTR( MyMusicModelNode*, MyMusicModelNodes ); | |
93 | ||
94 | class MyMusicModelNode | |
95 | { | |
96 | public: | |
b5fce9e2 | 97 | MyMusicModelNode( MyMusicModelNode* parent, |
405a351f | 98 | const wxString &title, const wxString &artist, int year ) |
1e08ad10 RR |
99 | { |
100 | m_parent = parent; | |
1e08ad10 RR |
101 | m_title = title; |
102 | m_artist = artist; | |
103 | m_year = year; | |
104 | m_isContainer = false; | |
105 | } | |
106 | ||
b5fce9e2 | 107 | MyMusicModelNode( MyMusicModelNode* parent, |
1e08ad10 RR |
108 | const wxString &branch ) |
109 | { | |
110 | m_parent = parent; | |
1e08ad10 | 111 | m_title = branch; |
405a351f | 112 | m_year = -1; |
1e08ad10 RR |
113 | m_isContainer = true; |
114 | } | |
115 | ||
116 | ~MyMusicModelNode() | |
117 | { | |
118 | size_t count = m_children.GetCount(); | |
119 | size_t i; | |
120 | for (i = 0; i < count; i++) | |
121 | { | |
122 | MyMusicModelNode *child = m_children[i]; | |
123 | delete child; | |
124 | } | |
125 | } | |
126 | ||
1e08ad10 RR |
127 | bool IsContainer() { return m_isContainer; } |
128 | ||
129 | MyMusicModelNode* GetParent() { return m_parent; } | |
130 | MyMusicModelNodes &GetChildren() { return m_children; } | |
131 | MyMusicModelNode* GetNthChild( unsigned int n ) { return m_children.Item( n ); } | |
132 | void Insert( MyMusicModelNode* child, unsigned int n) { m_children.Insert( child, n); } | |
133 | void Append( MyMusicModelNode* child ) { m_children.Add( child ); } | |
134 | unsigned int GetChildCount() { return m_children.GetCount(); } | |
135 | ||
136 | public: | |
137 | wxString m_title; | |
138 | wxString m_artist; | |
405a351f | 139 | int m_year; |
1e08ad10 RR |
140 | |
141 | private: | |
142 | MyMusicModelNode *m_parent; | |
143 | MyMusicModelNodes m_children; | |
1e08ad10 RR |
144 | bool m_isContainer; |
145 | }; | |
146 | ||
aba9bfd0 | 147 | |
5debbdcf | 148 | class MyMusicModel: public wxDataViewModel |
bd6169a6 RR |
149 | { |
150 | public: | |
e63807a8 RR |
151 | |
152 | // constructor | |
153 | ||
1e08ad10 RR |
154 | MyMusicModel() |
155 | { | |
b5fce9e2 RR |
156 | m_root = new MyMusicModelNode( NULL, "My Music" ); |
157 | m_pop = new MyMusicModelNode( m_root, "Pop music" ); | |
1e08ad10 | 158 | m_root->Append( m_pop ); |
b5fce9e2 | 159 | m_pop->Append( new MyMusicModelNode( m_pop, |
405a351f | 160 | "You are not alone", "Michael Jackson", 1995 ) ); |
b5fce9e2 | 161 | m_pop->Append( new MyMusicModelNode( m_pop, |
405a351f | 162 | "Take a bow", "Madonna", 1994 ) ); |
b5fce9e2 | 163 | m_classical = new MyMusicModelNode( m_root, "Classical music" ); |
1e08ad10 | 164 | m_root->Append( m_classical ); |
b5fce9e2 | 165 | m_classical->Append( new MyMusicModelNode( m_classical, |
405a351f | 166 | "Ninth symphony", "Ludwig van Beethoven", 1824 ) ); |
b5fce9e2 | 167 | m_classical->Append( new MyMusicModelNode( m_classical, |
405a351f | 168 | "German Requiem", "Johannes Brahms", 1868 ) ); |
befa9b61 | 169 | m_classicalMusicIsKnownToControl = false; |
1e08ad10 RR |
170 | } |
171 | ||
d32332aa RR |
172 | // helper method for wxLog |
173 | ||
174 | wxString GetTitle( const wxDataViewItem &item ) | |
175 | { | |
176 | MyMusicModelNode *node = (MyMusicModelNode*) item.GetID(); | |
177 | if (!node) | |
178 | return wxEmptyString; | |
179 | ||
180 | return node->m_title; | |
181 | } | |
182 | ||
e63807a8 RR |
183 | // helper methods to change the model |
184 | ||
405a351f | 185 | void AddToClassical( const wxString &title, const wxString &artist, int year ) |
1e08ad10 RR |
186 | { |
187 | // add to data | |
188 | MyMusicModelNode *child_node = | |
b5fce9e2 | 189 | new MyMusicModelNode( m_classical, title, artist, year ); |
b7e9f8b1 | 190 | |
1e08ad10 RR |
191 | m_classical->Append( child_node ); |
192 | ||
befa9b61 RR |
193 | if (m_classicalMusicIsKnownToControl) |
194 | { | |
195 | // notify control | |
b5fce9e2 RR |
196 | wxDataViewItem child( (void*) child_node ); |
197 | wxDataViewItem parent( (void*) m_classical ); | |
befa9b61 RR |
198 | ItemAdded( parent, child ); |
199 | } | |
1e08ad10 | 200 | } |
e63807a8 RR |
201 | |
202 | void Delete( const wxDataViewItem &item ) | |
203 | { | |
b5fce9e2 | 204 | MyMusicModelNode *node = (MyMusicModelNode*) item.GetID(); |
9d8fe14a | 205 | wxDataViewItem parent( node->GetParent() ); |
e63807a8 | 206 | |
d3f00f59 VZ |
207 | node->GetParent()->GetChildren().Remove( node ); |
208 | delete node; | |
405a351f RR |
209 | |
210 | // notify control | |
211 | ItemDeleted( parent, item ); | |
e63807a8 RR |
212 | } |
213 | ||
cf283a47 RR |
214 | // override sorting to always sort branches ascendingly |
215 | ||
7ee7191c RR |
216 | int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
217 | unsigned int column, bool ascending ) | |
cf283a47 | 218 | { |
ed903e42 | 219 | if (IsContainer(item1) && IsContainer(item2)) |
cf283a47 RR |
220 | { |
221 | wxVariant value1,value2; | |
222 | GetValue( value1, item1, 0 ); | |
223 | GetValue( value2, item2, 0 ); | |
224 | ||
225 | wxString str1 = value1.GetString(); | |
226 | wxString str2 = value2.GetString(); | |
227 | int res = str1.Cmp( str2 ); | |
228 | if (res) return res; | |
229 | ||
230 | // items must be different | |
231 | unsigned long litem1 = (unsigned long) item1.GetID(); | |
232 | unsigned long litem2 = (unsigned long) item2.GetID(); | |
233 | ||
234 | return litem1-litem2; | |
235 | } | |
236 | ||
7ee7191c | 237 | return wxDataViewModel::Compare( item1, item2, column, ascending ); |
cf283a47 RR |
238 | } |
239 | ||
e63807a8 | 240 | // implementation of base class virtuals to define model |
5debbdcf RR |
241 | |
242 | virtual unsigned int GetColumnCount() const | |
a7f61f76 | 243 | { |
fc5eacdb | 244 | return 3; |
a7f61f76 | 245 | } |
b910a8ad | 246 | |
9861f022 | 247 | virtual wxString GetColumnType( unsigned int col ) const |
5debbdcf | 248 | { |
405a351f RR |
249 | if (col == 2) |
250 | return "long"; | |
251 | ||
5debbdcf RR |
252 | return "string"; |
253 | } | |
b910a8ad | 254 | |
5debbdcf RR |
255 | virtual void GetValue( wxVariant &variant, |
256 | const wxDataViewItem &item, unsigned int col ) const | |
257 | { | |
b5fce9e2 | 258 | MyMusicModelNode *node = (MyMusicModelNode*) item.GetID(); |
1e08ad10 | 259 | switch (col) |
605c2c4a | 260 | { |
1e08ad10 RR |
261 | case 0: variant = node->m_title; break; |
262 | case 1: variant = node->m_artist; break; | |
405a351f | 263 | case 2: variant = (long) node->m_year; break; |
0bd26819 RR |
264 | default: |
265 | { | |
266 | wxLogError( "MyMusicModel::GetValue: wrong column" ); | |
405a351f RR |
267 | |
268 | // provoke a crash when mouse button down | |
0bd26819 RR |
269 | wxMouseState state = wxGetMouseState(); |
270 | if (state.ShiftDown()) | |
271 | { | |
272 | char *crash = 0; | |
273 | *crash = 0; | |
274 | } | |
275 | } | |
a7f61f76 | 276 | } |
e152afc3 | 277 | } |
9861f022 | 278 | |
5debbdcf RR |
279 | virtual bool SetValue( const wxVariant &variant, |
280 | const wxDataViewItem &item, unsigned int col ) | |
9861f022 | 281 | { |
b5fce9e2 | 282 | MyMusicModelNode *node = (MyMusicModelNode*) item.GetID(); |
1e08ad10 RR |
283 | switch (col) |
284 | { | |
c2a92c80 RR |
285 | case 0: node->m_title = variant.GetString(); return true; |
286 | case 1: node->m_artist = variant.GetString(); return true; | |
287 | case 2: node->m_year = variant.GetLong(); return true; | |
1e08ad10 RR |
288 | default: wxLogError( "MyMusicModel::SetValue: wrong column" ); |
289 | } | |
c2a92c80 | 290 | return false; |
9861f022 RR |
291 | } |
292 | ||
ed903e42 | 293 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const |
b910a8ad | 294 | { |
ed903e42 RR |
295 | // the invisble root node has no parent |
296 | if (!item.IsOk()) | |
297 | return wxDataViewItem(0); | |
298 | ||
b5fce9e2 | 299 | MyMusicModelNode *node = (MyMusicModelNode*) item.GetID(); |
ed903e42 RR |
300 | |
301 | // "MyMusic" also has no parent | |
302 | if (node == m_root) | |
303 | return wxDataViewItem(0); | |
304 | ||
305 | return wxDataViewItem( (void*) node->GetParent() ); | |
306 | } | |
307 | ||
308 | virtual bool IsContainer( const wxDataViewItem &item ) const | |
309 | { | |
310 | // the invisble root node can have children (in | |
311 | // our model always "MyMusic") | |
312 | if (!item.IsOk()) | |
1e08ad10 RR |
313 | return true; |
314 | ||
ed903e42 | 315 | MyMusicModelNode *node = (MyMusicModelNode*) item.GetID(); |
1e08ad10 | 316 | return node->IsContainer(); |
e152afc3 | 317 | } |
5debbdcf | 318 | |
74fe973b | 319 | virtual unsigned int GetChildren( const wxDataViewItem &parent, wxDataViewItemArray &array ) const |
1e510b1e | 320 | { |
b5fce9e2 RR |
321 | MyMusicModelNode *node = (MyMusicModelNode*) parent.GetID(); |
322 | if (!node) | |
74fe973b RR |
323 | { |
324 | array.Add( wxDataViewItem( (void*) m_root ) ); | |
325 | return 1; | |
326 | } | |
1e08ad10 | 327 | |
befa9b61 RR |
328 | if (node == m_classical) |
329 | { | |
330 | MyMusicModel *model = (MyMusicModel*)(const MyMusicModel*) this; | |
331 | model->m_classicalMusicIsKnownToControl = true; | |
332 | } | |
1e510b1e | 333 | |
74fe973b RR |
334 | if (node->GetChildCount() == 0) |
335 | { | |
336 | return 0; | |
337 | } | |
338 | ||
339 | unsigned int count = node->GetChildren().GetCount(); | |
340 | unsigned int pos; | |
341 | for (pos = 0; pos < count; pos++) | |
342 | { | |
343 | MyMusicModelNode *child = node->GetChildren().Item( pos ); | |
344 | array.Add( wxDataViewItem( (void*) child ) ); | |
345 | } | |
346 | return count; | |
9861f022 | 347 | } |
1e08ad10 | 348 | |
1e08ad10 | 349 | private: |
1e08ad10 RR |
350 | MyMusicModelNode* m_root; |
351 | MyMusicModelNode* m_pop; | |
352 | MyMusicModelNode* m_classical; | |
befa9b61 | 353 | bool m_classicalMusicIsKnownToControl; |
241cb04b RR |
354 | }; |
355 | ||
8b6cf9bf RR |
356 | |
357 | static int my_sort_reverse( int *v1, int *v2 ) | |
358 | { | |
359 | return *v2-*v1; | |
360 | } | |
361 | ||
362 | static int my_sort( int *v1, int *v2 ) | |
363 | { | |
364 | return *v1-*v2; | |
365 | } | |
366 | ||
c534e696 RR |
367 | class MyListModel: public wxDataViewIndexListModel |
368 | { | |
369 | public: | |
370 | MyListModel() : | |
a75124d0 | 371 | #ifdef __WXMAC__ |
33ba5a05 | 372 | wxDataViewIndexListModel( 1000 + 100 ) |
a75124d0 | 373 | #else |
33ba5a05 | 374 | wxDataViewIndexListModel( 100000 + 100 ) |
a75124d0 | 375 | #endif |
c534e696 | 376 | { |
33ba5a05 RR |
377 | #ifdef __WXMAC__ |
378 | m_virtualItems = 1000; | |
379 | #else | |
380 | m_virtualItems = 100000; | |
381 | #endif | |
382 | ||
c534e696 RR |
383 | unsigned int i; |
384 | for (i = 0; i < 100; i++) | |
385 | { | |
386 | wxString str; | |
33ba5a05 | 387 | str.Printf( "Test %d", i ); |
c534e696 RR |
388 | m_array.Add( str ); |
389 | } | |
c9c13e70 RR |
390 | |
391 | m_icon = wxIcon( null_xpm ); | |
c534e696 RR |
392 | } |
393 | ||
394 | // helper methods to change the model | |
395 | ||
396 | void Prepend( const wxString &text ) | |
397 | { | |
398 | m_array.Insert( text, 0 ); | |
399 | RowPrepended(); | |
400 | } | |
401 | ||
402 | void DeleteItem( const wxDataViewItem &item ) | |
403 | { | |
404 | unsigned int row = GetRow( item ); | |
33ba5a05 RR |
405 | if (row >= m_array.GetCount()) |
406 | return; | |
407 | ||
c534e696 RR |
408 | m_array.RemoveAt( row ); |
409 | RowDeleted( row ); | |
410 | } | |
8b6cf9bf RR |
411 | |
412 | void DeleteItems( const wxDataViewItemArray &items ) | |
413 | { | |
414 | wxArrayInt rows; | |
415 | unsigned int i; | |
416 | for (i = 0; i < items.GetCount(); i++) | |
417 | { | |
418 | unsigned int row = GetRow( items[i] ); | |
33ba5a05 RR |
419 | if (row < m_array.GetCount()) |
420 | rows.Add( row ); | |
8b6cf9bf RR |
421 | } |
422 | ||
423 | // Sort in descending order so that the last | |
424 | // row will be deleted first. Otherwise the | |
425 | // remaining indeces would all be wrong. | |
426 | rows.Sort( my_sort_reverse ); | |
427 | for (i = 0; i < rows.GetCount(); i++) | |
428 | m_array.RemoveAt( rows[i] ); | |
429 | ||
430 | // This is just to test if wxDataViewCtrl can | |
431 | // cope with removing rows not sorted in | |
432 | // descending order | |
433 | rows.Sort( my_sort ); | |
434 | RowsDeleted( rows ); | |
435 | } | |
436 | ||
437 | void AddMany() | |
438 | { | |
33ba5a05 RR |
439 | m_virtualItems += 1000; |
440 | Reset( m_array.GetCount() + m_virtualItems ); | |
8b6cf9bf | 441 | } |
c534e696 RR |
442 | |
443 | // implementation of base class virtuals to define model | |
444 | ||
445 | virtual unsigned int GetColumnCount() const | |
446 | { | |
c9c13e70 | 447 | return 3; |
c534e696 RR |
448 | } |
449 | ||
450 | virtual wxString GetColumnType( unsigned int col ) const | |
451 | { | |
c9c13e70 RR |
452 | if (col == 1) |
453 | return "wxDataViewIconText"; | |
454 | ||
c534e696 RR |
455 | return "string"; |
456 | } | |
457 | ||
c534e696 RR |
458 | virtual void GetValue( wxVariant &variant, |
459 | unsigned int row, unsigned int col ) const | |
460 | { | |
461 | if (col==0) | |
462 | { | |
a75124d0 RR |
463 | if (row >= m_array.GetCount()) |
464 | { | |
465 | wxString str; | |
33ba5a05 | 466 | str.Printf( "row %d", row - m_array.GetCount() ); |
a75124d0 RR |
467 | variant = str; |
468 | } | |
469 | else | |
470 | { | |
471 | variant = m_array[ row ]; | |
472 | } | |
c9c13e70 RR |
473 | } else |
474 | if (col==1) | |
475 | { | |
476 | wxDataViewIconText data( "test", m_icon ); | |
477 | variant << data; | |
4264606e RR |
478 | } else |
479 | if (col==2) | |
c534e696 | 480 | { |
33ba5a05 RR |
481 | if (row >= m_array.GetCount()) |
482 | variant = "plain"; | |
4264606e | 483 | else |
1117d56f | 484 | variant = "blue"; |
c534e696 RR |
485 | } |
486 | } | |
4264606e RR |
487 | |
488 | virtual bool GetAttr( unsigned int row, unsigned int col, wxDataViewItemAttr &attr ) | |
489 | { | |
490 | if (col != 2) | |
491 | return false; | |
492 | ||
33ba5a05 RR |
493 | if (row < m_array.GetCount()) |
494 | { | |
4264606e | 495 | attr.SetColour( *wxBLUE ); |
4264606e | 496 | attr.SetItalic( true ); |
33ba5a05 | 497 | } |
4264606e RR |
498 | |
499 | return true; | |
500 | } | |
c534e696 RR |
501 | |
502 | virtual bool SetValue( const wxVariant &variant, | |
503 | unsigned int row, unsigned int col ) | |
504 | { | |
505 | if (col == 0) | |
506 | { | |
a75124d0 RR |
507 | if (row >= m_array.GetCount()) |
508 | return false; | |
509 | ||
c534e696 RR |
510 | m_array[row] = variant.GetString(); |
511 | return true; | |
512 | } | |
513 | ||
514 | return false; | |
515 | } | |
516 | ||
517 | wxArrayString m_array; | |
c9c13e70 | 518 | wxIcon m_icon; |
33ba5a05 | 519 | int m_virtualItems; |
c534e696 RR |
520 | }; |
521 | ||
362d7fb9 RR |
522 | // ------------------------------------- |
523 | // MyApp | |
524 | // ------------------------------------- | |
bd6169a6 RR |
525 | |
526 | class MyApp: public wxApp | |
527 | { | |
528 | public: | |
529 | bool OnInit(void); | |
87f0efe2 | 530 | int OnExit(); |
bd6169a6 RR |
531 | }; |
532 | ||
362d7fb9 RR |
533 | // ------------------------------------- |
534 | // MyFrame | |
535 | // ------------------------------------- | |
536 | ||
87f0efe2 | 537 | class MyFrame : public wxFrame |
bd6169a6 RR |
538 | { |
539 | public: | |
e94d0c1e | 540 | MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int h); |
bd6169a6 RR |
541 | |
542 | public: | |
543 | void OnQuit(wxCommandEvent& event); | |
544 | void OnAbout(wxCommandEvent& event); | |
c534e696 RR |
545 | |
546 | void OnAddMozart(wxCommandEvent& event); | |
547 | void OnDeleteMusic(wxCommandEvent& event); | |
736fe67c | 548 | void OnDeleteYear(wxCommandEvent& event); |
c534e696 RR |
549 | |
550 | void OnPrependList(wxCommandEvent& event); | |
551 | void OnDeleteList(wxCommandEvent& event); | |
b910a8ad | 552 | |
d8331a01 | 553 | void OnValueChanged( wxDataViewEvent &event ); |
718fd180 | 554 | |
b7e9f8b1 | 555 | void OnActivated( wxDataViewEvent &event ); |
718fd180 RR |
556 | void OnExpanding( wxDataViewEvent &event ); |
557 | void OnExpanded( wxDataViewEvent &event ); | |
558 | void OnCollapsing( wxDataViewEvent &event ); | |
559 | void OnCollapsed( wxDataViewEvent &event ); | |
aed836f3 | 560 | void OnSelectionChanged( wxDataViewEvent &event ); |
718fd180 | 561 | |
d14e1c3a RR |
562 | void OnEditingStarted( wxDataViewEvent &event ); |
563 | void OnEditingDone( wxDataViewEvent &event ); | |
564 | ||
b7e9f8b1 RR |
565 | void OnHeaderClick( wxDataViewEvent &event ); |
566 | void OnHeaderRightClick( wxDataViewEvent &event ); | |
567 | void OnSorted( wxDataViewEvent &event ); | |
568 | ||
74dea0de RR |
569 | void OnContextMenu( wxDataViewEvent &event ); |
570 | ||
b7e9f8b1 RR |
571 | void OnRightClick( wxMouseEvent &event ); |
572 | void OnGoto( wxCommandEvent &event); | |
8b6cf9bf | 573 | void OnAddMany( wxCommandEvent &event); |
d8331a01 | 574 | |
bd6169a6 | 575 | private: |
c534e696 RR |
576 | wxDataViewCtrl* m_musicCtrl; |
577 | wxObjectDataPtr<MyMusicModel> m_music_model; | |
578 | ||
579 | wxDataViewCtrl* m_listCtrl; | |
580 | wxObjectDataPtr<MyListModel> m_list_model; | |
fbda518c RR |
581 | |
582 | wxDataViewColumn * m_col; | |
c534e696 | 583 | |
1e08ad10 | 584 | wxTextCtrl * m_log; |
b7e9f8b1 | 585 | wxLog *m_logOld; |
31fb32e1 | 586 | |
241cb04b | 587 | private: |
abd6692c | 588 | DECLARE_EVENT_TABLE() |
241cb04b RR |
589 | }; |
590 | ||
362d7fb9 RR |
591 | // ------------------------------------- |
592 | // MyApp | |
593 | // ------------------------------------- | |
594 | ||
87f0efe2 | 595 | IMPLEMENT_APP(MyApp) |
bd6169a6 | 596 | |
bd6169a6 RR |
597 | bool MyApp::OnInit(void) |
598 | { | |
45e6e6f8 VZ |
599 | if ( !wxApp::OnInit() ) |
600 | return false; | |
601 | ||
87f0efe2 RR |
602 | // build the first frame |
603 | MyFrame *frame = | |
8b6cf9bf | 604 | new MyFrame(NULL, wxT("wxDataViewCtrl feature test"), 40, 40, 800, 540); |
bd6169a6 RR |
605 | frame->Show(true); |
606 | ||
607 | SetTopWindow(frame); | |
bd6169a6 RR |
608 | return true; |
609 | } | |
610 | ||
87f0efe2 RR |
611 | int MyApp::OnExit() |
612 | { | |
613 | return 0; | |
614 | } | |
615 | ||
616 | ||
bd6169a6 RR |
617 | // ------------------------------------- |
618 | // MyFrame | |
619 | // ------------------------------------- | |
620 | ||
87f0efe2 RR |
621 | enum |
622 | { | |
623 | // file menu | |
624 | ID_ABOUT = wxID_ABOUT, | |
87f0efe2 | 625 | ID_EXIT = wxID_EXIT, |
1e08ad10 | 626 | |
d8331a01 RR |
627 | ID_MUSIC_CTRL = 50, |
628 | ||
c534e696 RR |
629 | ID_ADD_MOZART = 100, |
630 | ID_DELETE_MUSIC = 101, | |
736fe67c | 631 | ID_DELETE_YEAR = 102, |
c534e696 RR |
632 | |
633 | ID_PREPEND_LIST = 200, | |
b7e9f8b1 | 634 | ID_DELETE_LIST = 201, |
8b6cf9bf RR |
635 | ID_GOTO = 202, |
636 | ID_ADD_MANY = 203 | |
87f0efe2 RR |
637 | }; |
638 | ||
639 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
87f0efe2 | 640 | EVT_MENU( ID_ABOUT, MyFrame::OnAbout ) |
87f0efe2 | 641 | EVT_MENU( ID_EXIT, MyFrame::OnQuit ) |
c534e696 RR |
642 | EVT_BUTTON( ID_ADD_MOZART, MyFrame::OnAddMozart ) |
643 | EVT_BUTTON( ID_DELETE_MUSIC, MyFrame::OnDeleteMusic ) | |
736fe67c | 644 | EVT_BUTTON( ID_DELETE_YEAR, MyFrame::OnDeleteYear ) |
c534e696 RR |
645 | EVT_BUTTON( ID_PREPEND_LIST, MyFrame::OnPrependList ) |
646 | EVT_BUTTON( ID_DELETE_LIST, MyFrame::OnDeleteList ) | |
b7e9f8b1 | 647 | EVT_BUTTON( ID_GOTO, MyFrame::OnGoto) |
8b6cf9bf | 648 | EVT_BUTTON( ID_ADD_MANY, MyFrame::OnAddMany) |
718fd180 | 649 | |
0376cc52 | 650 | EVT_DATAVIEW_ITEM_VALUE_CHANGED( ID_MUSIC_CTRL, MyFrame::OnValueChanged ) |
718fd180 | 651 | |
b7e9f8b1 | 652 | EVT_DATAVIEW_ITEM_ACTIVATED(ID_MUSIC_CTRL, MyFrame::OnActivated ) |
718fd180 RR |
653 | EVT_DATAVIEW_ITEM_EXPANDING(ID_MUSIC_CTRL, MyFrame::OnExpanding) |
654 | EVT_DATAVIEW_ITEM_EXPANDED(ID_MUSIC_CTRL, MyFrame::OnExpanded) | |
655 | EVT_DATAVIEW_ITEM_COLLAPSING(ID_MUSIC_CTRL, MyFrame::OnCollapsing) | |
656 | EVT_DATAVIEW_ITEM_COLLAPSED(ID_MUSIC_CTRL, MyFrame::OnCollapsed) | |
aed836f3 | 657 | EVT_DATAVIEW_SELECTION_CHANGED(ID_MUSIC_CTRL, MyFrame::OnSelectionChanged) |
718fd180 | 658 | |
d14e1c3a RR |
659 | EVT_DATAVIEW_ITEM_EDITING_STARTED(ID_MUSIC_CTRL, MyFrame::OnEditingStarted) |
660 | EVT_DATAVIEW_ITEM_EDITING_DONE(ID_MUSIC_CTRL, MyFrame::OnEditingDone) | |
661 | ||
b7e9f8b1 RR |
662 | EVT_DATAVIEW_COLUMN_HEADER_CLICK(ID_MUSIC_CTRL, MyFrame::OnHeaderClick) |
663 | EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(ID_MUSIC_CTRL, MyFrame::OnHeaderRightClick) | |
664 | EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL, MyFrame::OnSorted) | |
74dea0de RR |
665 | |
666 | EVT_DATAVIEW_ITEM_CONTEXT_MENU(ID_MUSIC_CTRL, MyFrame::OnContextMenu) | |
718fd180 | 667 | |
b7e9f8b1 | 668 | EVT_RIGHT_UP(MyFrame::OnRightClick) |
87f0efe2 RR |
669 | END_EVENT_TABLE() |
670 | ||
e94d0c1e | 671 | MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int h): |
bd6169a6 RR |
672 | wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)) |
673 | { | |
d8331a01 | 674 | m_log = NULL; |
fbda518c | 675 | m_col = NULL; |
d8331a01 | 676 | |
0bcd4039 | 677 | SetIcon(wxICON(sample)); |
bd6169a6 | 678 | |
87f0efe2 RR |
679 | // build the menus: |
680 | ||
bd6169a6 | 681 | wxMenu *file_menu = new wxMenu; |
5debbdcf | 682 | file_menu->Append(ID_ABOUT, "&About"); |
87f0efe2 | 683 | file_menu->AppendSeparator(); |
5debbdcf | 684 | file_menu->Append(ID_EXIT, "E&xit"); |
bd6169a6 | 685 | |
bd6169a6 | 686 | wxMenuBar *menu_bar = new wxMenuBar; |
5debbdcf | 687 | menu_bar->Append(file_menu, "&File"); |
87f0efe2 | 688 | |
bd6169a6 | 689 | SetMenuBar(menu_bar); |
87f0efe2 | 690 | CreateStatusBar(); |
bd6169a6 | 691 | |
1e08ad10 RR |
692 | wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); |
693 | ||
c534e696 | 694 | wxBoxSizer *data_sizer = new wxBoxSizer( wxHORIZONTAL ); |
bd6169a6 | 695 | |
c534e696 | 696 | // MyMusic |
b910a8ad | 697 | |
d8331a01 | 698 | m_musicCtrl = new wxDataViewCtrl( this, ID_MUSIC_CTRL, wxDefaultPosition, |
b7e9f8b1 | 699 | wxDefaultSize, wxDV_MULTIPLE ); |
a75124d0 | 700 | |
c534e696 RR |
701 | m_music_model = new MyMusicModel; |
702 | m_musicCtrl->AssociateModel( m_music_model.get() ); | |
703 | ||
4264606e | 704 | /* wxDataViewColumn *col = */ m_musicCtrl->AppendTextColumn( "Title", 0, wxDATAVIEW_CELL_INERT, 200, |
94b1f7bc | 705 | DEFAULT_ALIGN, wxDATAVIEW_COL_SORTABLE ); |
0bd26819 RR |
706 | #if 0 |
707 | // Call this and sorting is enabled | |
708 | // immediatly upon start up. | |
709 | col->SetSortOrder( true ); | |
710 | #endif | |
711 | ||
405a351f | 712 | m_musicCtrl->AppendTextColumn( "Artist", 1, wxDATAVIEW_CELL_EDITABLE, 150, |
94b1f7bc | 713 | DEFAULT_ALIGN, wxDATAVIEW_COL_SORTABLE ); |
405a351f | 714 | |
ee17111a | 715 | wxDataViewSpinRenderer *sr = new wxDataViewSpinRenderer( 0, 2010 ); |
405a351f RR |
716 | wxDataViewColumn *column = new wxDataViewColumn( "year", sr, 2, -1, wxALIGN_CENTRE, wxDATAVIEW_COL_SORTABLE ); |
717 | m_musicCtrl->AppendColumn( column ); | |
1e08ad10 | 718 | |
c534e696 RR |
719 | data_sizer->Add( m_musicCtrl, 3, wxGROW ); |
720 | ||
721 | #if 1 | |
722 | ||
723 | // MyList | |
724 | ||
725 | m_listCtrl = new wxDataViewCtrl( this, wxID_ANY, wxDefaultPosition, | |
b7e9f8b1 | 726 | wxDefaultSize, wxDV_MULTIPLE ); |
c534e696 RR |
727 | |
728 | m_list_model = new MyListModel; | |
729 | m_listCtrl->AssociateModel( m_list_model.get() ); | |
730 | ||
731 | m_listCtrl->AppendTextColumn( "editable string", 0, wxDATAVIEW_CELL_EDITABLE, 120 ); | |
b04fcede | 732 | m_listCtrl->AppendIconTextColumn( "icon", 1, wxDATAVIEW_CELL_INERT, 60 ); |
4264606e RR |
733 | |
734 | wxDataViewTextRendererAttr *ra = new wxDataViewTextRendererAttr; | |
735 | column = new wxDataViewColumn( "attributes", ra, 2 ); | |
736 | m_listCtrl->AppendColumn( column ); | |
c534e696 RR |
737 | |
738 | data_sizer->Add( m_listCtrl, 2, wxGROW ); | |
739 | ||
740 | #endif | |
741 | ||
742 | main_sizer->Add( data_sizer, 2, wxGROW ); | |
1e08ad10 RR |
743 | |
744 | wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); | |
745 | ||
c534e696 RR |
746 | button_sizer->Add( new wxButton( this, ID_ADD_MOZART, "Add Mozart"), 0, wxALL, 10 ); |
747 | button_sizer->Add( new wxButton( this, ID_DELETE_MUSIC, "Delete selected"), 0, wxALL, 10 ); | |
736fe67c | 748 | button_sizer->Add( new wxButton( this, ID_DELETE_YEAR, "Delete \"Year\" column"), 0, wxALL, 10 ); |
c534e696 | 749 | button_sizer->Add( 10, 10, 1 ); |
8b6cf9bf RR |
750 | wxFlexGridSizer *grid_sizer = new wxFlexGridSizer( 2, 2 ); |
751 | grid_sizer->Add( new wxButton( this, ID_PREPEND_LIST, "Prepend"), 0, wxALL, 2 ); | |
752 | grid_sizer->Add( new wxButton( this, ID_DELETE_LIST, "Delete selected"), 0, wxALL, 2 ); | |
753 | grid_sizer->Add( new wxButton( this, ID_GOTO, "Goto 50"), 0, wxALL, 2 ); | |
754 | grid_sizer->Add( new wxButton( this, ID_ADD_MANY, "Add 1000"), 0, wxALL, 2 ); | |
755 | button_sizer->Add( grid_sizer, 0, wxALL, 10 ); | |
1e08ad10 | 756 | |
c534e696 | 757 | main_sizer->Add( button_sizer, 0, wxGROW, 0 ); |
a75124d0 RR |
758 | |
759 | wxBoxSizer *bottom_sizer = new wxBoxSizer( wxHORIZONTAL ); | |
1e08ad10 RR |
760 | |
761 | m_log = new wxTextCtrl( this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); | |
b7e9f8b1 RR |
762 | m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_log)); |
763 | wxLogMessage("This is the log window"); | |
764 | ||
a75124d0 RR |
765 | bottom_sizer->Add( m_log, 1, wxGROW ); |
766 | ||
767 | // wxDataViewTreeStore | |
e94d0c1e | 768 | |
a75124d0 | 769 | wxDataViewCtrl *treectrl = new wxDataViewCtrl( this, -1, |
e94d0c1e | 770 | wxDefaultPosition, wxSize(300,200), wxDV_NO_HEADER ); |
e94d0c1e | 771 | |
e94d0c1e RR |
772 | wxDataViewTreeStore *store = new wxDataViewTreeStore; |
773 | wxDataViewItem parent = store->AppendContainer( wxDataViewItem(0), "Root 1", wxIcon(small1_xpm) ); | |
0a13ee1b RR |
774 | wxDataViewItem child = store->AppendItem( parent, "Child 1", wxIcon(small1_xpm) ); |
775 | child = store->AppendItem( parent, "Child 2", wxIcon(small1_xpm) ); | |
776 | child = store->AppendItem( parent, "Child 3", wxIcon(small1_xpm) ); | |
e94d0c1e | 777 | treectrl->AssociateModel( store ); |
e94d0c1e | 778 | store->DecRef(); |
b89cac3f | 779 | |
672e58d9 RR |
780 | treectrl->AppendIconTextColumn( "no label", 0, wxDATAVIEW_CELL_INERT, 200 ); |
781 | ||
a75124d0 | 782 | bottom_sizer->Add( treectrl ); |
672e58d9 | 783 | |
a75124d0 RR |
784 | // wxDataViewTreeCtrl |
785 | ||
786 | wxDataViewTreeCtrl *treectrl2 = new wxDataViewTreeCtrl( this, -1, wxDefaultPosition, wxSize(300,200) ); | |
83aa1cf4 | 787 | |
75a2e426 | 788 | wxImageList *ilist = new wxImageList( 16, 16 ); |
a75124d0 | 789 | ilist->Add( wxIcon(small1_xpm) ); |
83aa1cf4 RR |
790 | treectrl2->SetImageList( ilist ); |
791 | ||
a75124d0 RR |
792 | parent = treectrl2->AppendContainer( wxDataViewItem(0), "Root 1", 0 ); |
793 | child = treectrl2->AppendItem( parent, "Child 1", 0 ); | |
794 | child = treectrl2->AppendItem( parent, "Child 2", 0 ); | |
795 | child = treectrl2->AppendItem( parent, "Child 3", 0 ); | |
796 | ||
797 | bottom_sizer->Add( treectrl2 ); | |
798 | ||
799 | // main sizer | |
800 | ||
801 | main_sizer->Add( bottom_sizer, 0, wxGROW ); | |
e94d0c1e | 802 | |
a75124d0 RR |
803 | SetSizer( main_sizer ); |
804 | } | |
805 | ||
806 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) | |
807 | { | |
808 | Close(true); | |
e94d0c1e RR |
809 | } |
810 | ||
c534e696 RR |
811 | void MyFrame::OnAddMozart(wxCommandEvent& WXUNUSED(event) ) |
812 | { | |
405a351f | 813 | m_music_model->AddToClassical( "Kleine Nachtmusik", "Wolfgang Mozart", 1787 ); |
c534e696 RR |
814 | } |
815 | ||
816 | void MyFrame::OnDeleteMusic(wxCommandEvent& WXUNUSED(event) ) | |
1e08ad10 | 817 | { |
b7e9f8b1 RR |
818 | wxDataViewItemArray items; |
819 | int len = m_musicCtrl->GetSelections( items ); | |
820 | for( int i = 0; i < len; i ++ ) | |
821 | if (items[i].IsOk()) | |
822 | m_music_model->Delete( items[i] ); | |
e63807a8 RR |
823 | } |
824 | ||
736fe67c RR |
825 | void MyFrame::OnDeleteYear( wxCommandEvent& WXUNUSED(event) ) |
826 | { | |
827 | m_musicCtrl->DeleteColumn( m_musicCtrl->GetColumn( 2 ) ); | |
828 | FindWindow( ID_DELETE_YEAR )->Disable(); | |
829 | } | |
830 | ||
c534e696 | 831 | void MyFrame::OnPrependList( wxCommandEvent& WXUNUSED(event) ) |
e63807a8 | 832 | { |
c534e696 RR |
833 | m_list_model->Prepend( "Test" ); |
834 | } | |
835 | ||
836 | void MyFrame::OnDeleteList( wxCommandEvent& WXUNUSED(event) ) | |
837 | { | |
b7e9f8b1 RR |
838 | wxDataViewItemArray items; |
839 | int len = m_listCtrl->GetSelections( items ); | |
8b6cf9bf RR |
840 | if (len > 0) |
841 | m_list_model->DeleteItems( items ); | |
1e08ad10 RR |
842 | } |
843 | ||
d8331a01 RR |
844 | void MyFrame::OnValueChanged( wxDataViewEvent &event ) |
845 | { | |
846 | if (!m_log) | |
847 | return; | |
848 | ||
0376cc52 | 849 | wxLogMessage( "EVT_DATAVIEW_ITEM_VALUE_CHANGED, Item Id: %d; Column: %d", event.GetItem().GetID(), event.GetColumn() ); |
b7e9f8b1 RR |
850 | } |
851 | ||
852 | void MyFrame::OnActivated( wxDataViewEvent &event ) | |
853 | { | |
854 | if(!m_log) | |
855 | return; | |
856 | ||
d32332aa RR |
857 | wxString title = m_music_model->GetTitle( event.GetItem() ); |
858 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item: %s", title ); | |
b7e9f8b1 RR |
859 | } |
860 | ||
aed836f3 | 861 | void MyFrame::OnSelectionChanged( wxDataViewEvent &event ) |
6848478c RR |
862 | { |
863 | if(!m_log) | |
864 | return; | |
865 | ||
d32332aa RR |
866 | wxString title = m_music_model->GetTitle( event.GetItem() ); |
867 | if (title.empty()) | |
868 | title = "None"; | |
869 | ||
870 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, First selected Item: %s", title ); | |
6848478c RR |
871 | } |
872 | ||
718fd180 RR |
873 | void MyFrame::OnExpanding( wxDataViewEvent &event ) |
874 | { | |
875 | if (!m_log) | |
876 | return; | |
877 | ||
d32332aa RR |
878 | wxString title = m_music_model->GetTitle( event.GetItem() ); |
879 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, Item: %s", title ); | |
718fd180 RR |
880 | } |
881 | ||
d14e1c3a RR |
882 | |
883 | void MyFrame::OnEditingStarted( wxDataViewEvent &event ) | |
884 | { | |
885 | if (!m_log) | |
886 | return; | |
887 | ||
d32332aa RR |
888 | wxString title = m_music_model->GetTitle( event.GetItem() ); |
889 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, Item: %s", title ); | |
d14e1c3a RR |
890 | } |
891 | ||
892 | void MyFrame::OnEditingDone( wxDataViewEvent &event ) | |
893 | { | |
894 | if (!m_log) | |
895 | return; | |
896 | ||
d32332aa RR |
897 | wxString title = m_music_model->GetTitle( event.GetItem() ); |
898 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, Item: %s", title ); | |
d14e1c3a RR |
899 | } |
900 | ||
718fd180 RR |
901 | void MyFrame::OnExpanded( wxDataViewEvent &event ) |
902 | { | |
903 | if (!m_log) | |
904 | return; | |
905 | ||
d32332aa RR |
906 | wxString title = m_music_model->GetTitle( event.GetItem() ); |
907 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, Item: %s", title ); | |
718fd180 RR |
908 | } |
909 | ||
910 | void MyFrame::OnCollapsing( wxDataViewEvent &event ) | |
911 | { | |
912 | if (!m_log) | |
913 | return; | |
914 | ||
d32332aa RR |
915 | wxString title = m_music_model->GetTitle( event.GetItem() ); |
916 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, Item: %s", title ); | |
718fd180 RR |
917 | } |
918 | ||
919 | void MyFrame::OnCollapsed( wxDataViewEvent &event ) | |
920 | { | |
921 | if (!m_log) | |
922 | return; | |
d32332aa RR |
923 | |
924 | wxString title = m_music_model->GetTitle( event.GetItem() ); | |
925 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, Item: %s", title ); | |
718fd180 RR |
926 | } |
927 | ||
74dea0de RR |
928 | void MyFrame::OnContextMenu( wxDataViewEvent &event ) |
929 | { | |
930 | if (!m_log) | |
931 | return; | |
932 | ||
933 | wxString title = m_music_model->GetTitle( event.GetItem() ); | |
934 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, Item: %s", title ); | |
935 | } | |
936 | ||
b7e9f8b1 RR |
937 | void MyFrame::OnHeaderClick( wxDataViewEvent &event ) |
938 | { | |
939 | if(!m_log) | |
940 | return; | |
aed836f3 RR |
941 | |
942 | int pos = m_musicCtrl->GetColumnPosition( event.GetDataViewColumn() ); | |
b7e9f8b1 | 943 | |
aed836f3 | 944 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, Column position: %d", pos ); |
b7e9f8b1 RR |
945 | } |
946 | ||
947 | void MyFrame::OnHeaderRightClick( wxDataViewEvent &event ) | |
948 | { | |
949 | if(!m_log) | |
950 | return; | |
951 | ||
dadc879e RR |
952 | int pos = m_musicCtrl->GetColumnPosition( event.GetDataViewColumn() ); |
953 | ||
954 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, Column position: %d", pos ); | |
b7e9f8b1 RR |
955 | } |
956 | ||
957 | void MyFrame::OnSorted( wxDataViewEvent &event ) | |
958 | { | |
959 | if(!m_log) | |
960 | return; | |
961 | ||
d32332aa RR |
962 | int pos = m_musicCtrl->GetColumnPosition( event.GetDataViewColumn() ); |
963 | ||
964 | wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, Column position: %d", pos ); | |
b7e9f8b1 RR |
965 | } |
966 | ||
967 | void MyFrame::OnRightClick( wxMouseEvent &event ) | |
968 | { | |
969 | if(!m_log) | |
970 | return; | |
971 | ||
972 | wxLogMessage("wxEVT_MOUSE_RIGHT_UP, Click Point is X: %d, Y: %d", event.GetX(), event.GetY()); | |
973 | } | |
974 | ||
d5ef211f | 975 | void MyFrame::OnGoto(wxCommandEvent& WXUNUSED(event)) |
b7e9f8b1 | 976 | { |
718fd180 | 977 | wxDataViewItem item = m_list_model->GetItem( 50 ); |
fbda518c | 978 | m_listCtrl->EnsureVisible(item,m_col); |
d8331a01 RR |
979 | } |
980 | ||
8b6cf9bf RR |
981 | void MyFrame::OnAddMany(wxCommandEvent& WXUNUSED(event)) |
982 | { | |
983 | m_list_model->AddMany(); | |
984 | } | |
985 | ||
986 | ||
bd6169a6 RR |
987 | void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) |
988 | { | |
87f0efe2 RR |
989 | wxAboutDialogInfo info; |
990 | info.SetName(_("DataView sample")); | |
991 | info.SetDescription(_("This sample demonstrates the dataview control handling")); | |
992 | info.SetCopyright(_T("(C) 2007 Robert Roebling")); | |
bd6169a6 | 993 | |
87f0efe2 | 994 | wxAboutBox(info); |
bd6169a6 RR |
995 | } |
996 |