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