]> git.saurik.com Git - wxWidgets.git/blame - samples/dataview/dataview.cpp
workaround for GDIPlus conversion errors, adding wxMask support
[wxWidgets.git] / samples / dataview / dataview.cpp
CommitLineData
bd6169a6
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: dataview.cpp
3// Purpose: DataVewCtrl wxWidgets sample
4// Author: Robert Roebling
5// Modified by:
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
JS
23#include "wx/datetime.h"
24
bd6169a6 25#ifndef __WXMSW__
0bcd4039 26 #include "../sample.xpm"
bd6169a6
RR
27#endif
28
cbc9145c
RR
29#include "null.xpm"
30
362d7fb9 31#include "wx/dataview.h"
bd6169a6 32
362d7fb9
RR
33// -------------------------------------
34// MyTextModel
35// -------------------------------------
bd6169a6 36
4d496ecb
RR
37WX_DECLARE_LIST(wxDateTime,wxArrayDate);
38#include <wx/listimpl.cpp>
004f4002 39WX_DEFINE_LIST(wxArrayDate)
4d496ecb 40
362d7fb9 41class MyTextModel: public wxDataViewListModel
bd6169a6
RR
42{
43public:
b910a8ad 44 MyTextModel()
a7f61f76
RR
45 {
46 size_t i;
47 for (i = 0; i < 1000; i++)
48 m_list.Add( wxT("Test") );
605c2c4a
RR
49 for (i = 0; i < 500; i++)
50 { m_bools.Add( 0 ); m_bools.Add( 1 ); }
e152afc3
RR
51 for (i = 0; i < 500; i++)
52 { m_colours.Add( wxT("red") ); m_colours.Add( wxT("green") ); }
ad63bf41
RR
53 for (i = 0; i < 1000; i++)
54 { m_progress.Add( i/10 ); }
4d496ecb 55 for (i = 0; i < 1000; i++)
b910a8ad 56 {
4d496ecb 57 wxDateTime *date = new wxDateTime( wxDateTime::Now() );
b910a8ad 58 m_dates.Append( date );
4d496ecb 59 }
a7f61f76 60 }
b910a8ad
JS
61
62 virtual size_t GetNumberOfRows()
362d7fb9
RR
63 { return 1000; }
64 virtual size_t GetNumberOfCols()
4d496ecb 65 { return 7; }
b910a8ad 66
362d7fb9
RR
67 // as reported by wxVariant
68 virtual wxString GetColType( size_t col )
605c2c4a 69 {
4d496ecb
RR
70 if (col == 6)
71 return wxT("datetime");
b910a8ad 72
ad63bf41
RR
73 if (col == 5)
74 return wxT("long");
b910a8ad 75
605c2c4a
RR
76 if (col == 3)
77 return wxT("bool");
b910a8ad
JS
78
79 return wxT("string");
605c2c4a 80 }
b910a8ad 81
3f3af7e7 82 virtual void GetValue( wxVariant &variant, size_t col, size_t row )
605c2c4a 83 {
4d496ecb
RR
84 if (col == 6)
85 {
3f3af7e7 86 variant = (wxDateTime) *m_dates[row];
4d496ecb 87 } else
ad63bf41 88 if (col == 5)
605c2c4a 89 {
3f3af7e7 90 variant = (long) m_progress[row];
ad63bf41 91 } else
e152afc3
RR
92 if (col == 4)
93 {
3f3af7e7 94 variant = m_colours[row];
ad63bf41
RR
95 } else
96 if (col == 3)
97 {
3f3af7e7 98 variant = (bool) m_bools[row];
b910a8ad 99 } else
a7f61f76
RR
100 if (col == 2)
101 {
3f3af7e7 102 variant = m_list[row];
a7f61f76
RR
103 }
104 else
105 {
b910a8ad
JS
106 wxString tmp;
107 tmp.Printf( wxT("item(%d;%d)"), (int)row, (int)col );
3f3af7e7 108 variant = tmp;
a7f61f76 109 }
362d7fb9 110 }
a7f61f76
RR
111 virtual bool SetValue( wxVariant &value, size_t col, size_t row )
112 {
4d496ecb
RR
113 if (col == 6)
114 {
115 *m_dates[row] = value.GetDateTime();
116 } else
605c2c4a
RR
117 if (col == 3)
118 {
119 m_bools[row] = (int) value.GetBool();
120 } else
a7f61f76
RR
121 if (col == 2)
122 {
123 m_list[row] = value.GetString();
124 }
125 return true;
126 }
b910a8ad 127
a7f61f76 128 wxArrayString m_list;
605c2c4a 129 wxArrayInt m_bools;
e152afc3 130 wxArrayString m_colours;
ad63bf41 131 wxArrayInt m_progress;
4d496ecb 132 wxArrayDate m_dates;
e152afc3
RR
133};
134
135// -------------------------------------
136// MyCustomCell
137// -------------------------------------
138
139class MyCustomCell: public wxDataViewCustomCell
140{
141public:
142 MyCustomCell() :
b910a8ad
JS
143 wxDataViewCustomCell( wxT("string"), wxDATAVIEW_CELL_ACTIVATABLE )
144 {
145 m_colour = wxT("black");
e152afc3
RR
146 }
147 bool SetValue( const wxVariant &value )
148 {
149 m_colour = value.GetString();
150 return true;
151 }
f554a14b 152 bool Render( wxRect rect, wxDC *dc, int WXUNUSED(state) )
b910a8ad 153 {
e152afc3
RR
154 dc->SetPen( *wxBLACK_PEN );
155 if (m_colour == wxT("red"))
156 dc->SetBrush( *wxRED_BRUSH );
157 else if (m_colour == wxT("green"))
158 dc->SetBrush( *wxGREEN_BRUSH );
b910a8ad 159 else
e152afc3
RR
160 dc->SetBrush( *wxBLACK_BRUSH );
161 dc->DrawRectangle( rect );
162 return true;
163 }
164 wxSize GetSize()
165 {
166 return wxSize(20,8);
167 }
f554a14b
WS
168 bool Activate( wxRect WXUNUSED(rect),
169 wxDataViewListModel *WXUNUSED(model),
170 size_t WXUNUSED(col),
171 size_t WXUNUSED(row) )
553f7d8f 172 {
553f7d8f
RR
173 return false;
174 }
e152afc3
RR
175
176private:
b910a8ad 177 wxString m_colour;
0313c114 178};
bd6169a6 179
241cb04b
RR
180// -------------------------------------
181// MyUnsortedTextModel
182// -------------------------------------
183
184class MyUnsortedTextModel: public wxDataViewListModel
185{
186public:
187 MyUnsortedTextModel()
188 {
189 m_list.Add( wxT("This") );
190 m_list.Add( wxT("is") );
191 m_list.Add( wxT("an") );
192 m_list.Add( wxT("unsorted") );
193 m_list.Add( wxT("list") );
194 m_list.Add( wxT("of") );
195 m_list.Add( wxT("words.") );
cbc9145c
RR
196
197 m_bitmap = wxBitmap( null_xpm );
241cb04b
RR
198 }
199
200 virtual size_t GetNumberOfRows() { return m_list.GetCount(); }
201 virtual size_t GetNumberOfCols() { return 2; }
f554a14b 202 virtual wxString GetColType( size_t WXUNUSED(col) ) { return wxT("string"); }
3f3af7e7 203 virtual void GetValue( wxVariant &variant, size_t col, size_t row )
241cb04b
RR
204 {
205 if (col == 0)
3f3af7e7
RR
206 {
207 variant = m_list[row];
208 return;
209 }
cbc9145c
RR
210 if (col == 2)
211 {
212 variant = &m_bitmap;
213 return;
214 }
241cb04b 215 wxString tmp;
b910a8ad 216 tmp.Printf( wxT("item(%d;%d)"), (int)row, (int)col );
3f3af7e7 217 variant = tmp;
241cb04b
RR
218 }
219 virtual bool SetValue( wxVariant &variant, size_t col, size_t row )
220 {
221 if (col == 0)
222 {
223 m_list[row] = variant.GetString();
224 return true;
225 }
226 return false;
b910a8ad 227
241cb04b
RR
228 }
229
4627af27
RR
230 void AppendRow( const wxString &text )
231 {
232 m_list.Add( text );
233 RowAppended();
234 }
235
236 void PrependRow( const wxString &text )
237 {
238 m_list.Insert( text, 0 );
239 RowPrepended();
240 }
241
242 void InsertRowAt1( const wxString &text )
243 {
244 m_list.Insert( text, 1 );
245 RowInserted( 1 );
246 }
247
248 void DeleteRow( size_t index )
249 {
250 m_list.RemoveAt( index );
251 RowDeleted( index );
252 }
253
241cb04b 254 wxArrayString m_list;
cbc9145c 255 wxBitmap m_bitmap;
241cb04b
RR
256};
257
362d7fb9
RR
258// -------------------------------------
259// MyApp
260// -------------------------------------
bd6169a6
RR
261
262class MyApp: public wxApp
263{
264public:
265 bool OnInit(void);
266};
267
362d7fb9
RR
268// -------------------------------------
269// MyFrame
270// -------------------------------------
271
bd6169a6
RR
272class MyFrame: public wxFrame
273{
274public:
275 MyFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h);
276
277public:
278 void OnQuit(wxCommandEvent& event);
279 void OnAbout(wxCommandEvent& event);
b910a8ad 280
bd6169a6 281private:
a7f61f76
RR
282 wxDataViewCtrl* dataview_left;
283 wxDataViewCtrl* dataview_right;
bd6169a6
RR
284};
285
241cb04b
RR
286// -------------------------------------
287// MySortingFrame
288// -------------------------------------
289
abd6692c
RR
290enum my_events
291{
292 ID_APPEND_ROW_LEFT = 1000,
293 ID_PREPEND_ROW_LEFT,
294 ID_INSERT_ROW_LEFT,
295 ID_DELETE_ROW_LEFT,
296 ID_EDIT_ROW_LEFT,
b910a8ad 297
abd6692c
RR
298 ID_APPEND_ROW_RIGHT,
299 ID_PREPEND_ROW_RIGHT,
300 ID_INSERT_ROW_RIGHT,
301 ID_DELETE_ROW_RIGHT,
302 ID_EDIT_ROW_RIGHT
303};
304
241cb04b
RR
305class MySortingFrame: public wxFrame
306{
307public:
308 MySortingFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h);
309
310public:
311 void OnQuit(wxCommandEvent& event);
312 void OnAbout(wxCommandEvent& event);
b910a8ad 313
abd6692c
RR
314 void OnAppendRowLeft(wxCommandEvent& event);
315 void OnPrependRowLeft(wxCommandEvent& event);
316 void OnInsertRowLeft(wxCommandEvent& event);
317 void OnDeleteRowLeft(wxCommandEvent& event);
318 void OnEditRowLeft(wxCommandEvent& event);
b910a8ad 319
abd6692c
RR
320 void OnAppendRowRight(wxCommandEvent& event);
321 void OnPrependRowRight(wxCommandEvent& event);
322 void OnInsertRowRight(wxCommandEvent& event);
323 void OnDeleteRowRight(wxCommandEvent& event);
324 void OnEditRowRight(wxCommandEvent& event);
b910a8ad 325
241cb04b
RR
326private:
327 wxDataViewCtrl* dataview_left;
328 wxDataViewCtrl* dataview_right;
b910a8ad 329
4627af27
RR
330 MyUnsortedTextModel *m_unsorted_model;
331
abd6692c 332 DECLARE_EVENT_TABLE()
241cb04b
RR
333};
334
362d7fb9
RR
335// -------------------------------------
336// MyApp
337// -------------------------------------
338
bd6169a6
RR
339#define DYNAMIC_QUIT wxID_EXIT
340#define DYNAMIC_ABOUT wxID_ABOUT
341
bd6169a6
RR
342IMPLEMENT_APP (MyApp)
343
bd6169a6
RR
344bool MyApp::OnInit(void)
345{
abd6692c 346 MyFrame *frame = new MyFrame(NULL, wxT("wxDataViewCtrl feature test"), 10, 10, 800, 340);
bd6169a6
RR
347 frame->Show(true);
348
abd6692c 349 MySortingFrame *frame2 = new MySortingFrame(NULL, wxT("wxDataViewCtrl sorting test"), 10, 350, 600, 300);
241cb04b
RR
350 frame2->Show(true);
351
bd6169a6
RR
352 SetTopWindow(frame);
353
354 return true;
355}
356
357// -------------------------------------
358// MyFrame
359// -------------------------------------
360
bd6169a6
RR
361MyFrame::MyFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h):
362 wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
363{
0bcd4039 364 SetIcon(wxICON(sample));
bd6169a6 365
bd6169a6
RR
366 wxMenu *file_menu = new wxMenu;
367
368 file_menu->Append(DYNAMIC_ABOUT, _T("&About"));
369 file_menu->Append(DYNAMIC_QUIT, _T("E&xit"));
370 wxMenuBar *menu_bar = new wxMenuBar;
371 menu_bar->Append(file_menu, _T("&File"));
372 SetMenuBar(menu_bar);
373
374 // You used to have to do some casting for param 4, but now there are type-safe handlers
375 Connect( DYNAMIC_QUIT, wxID_ANY,
376 wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyFrame::OnQuit) );
377 Connect( DYNAMIC_ABOUT, wxID_ANY,
378 wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyFrame::OnAbout) );
379
380 CreateStatusBar();
b910a8ad 381
0bcd4039 382 wxPanel *panel = new wxPanel( this, wxID_ANY );
b6339e0b 383
b910a8ad 384
a7f61f76 385 // Left wxDataViewCtrl
b6339e0b 386 dataview_left = new wxDataViewCtrl( panel, wxID_ANY );
b910a8ad 387
362d7fb9 388 MyTextModel *model = new MyTextModel;
a7f61f76 389 dataview_left->AssociateModel( model );
b910a8ad 390
605c2c4a
RR
391 dataview_left->AppendTextColumn( wxT("first"), 0 );
392 dataview_left->AppendTextColumn( wxT("second"), 1 );
553f7d8f 393
605c2c4a
RR
394 wxDataViewTextCell *text_cell = new wxDataViewTextCell( wxT("string"), wxDATAVIEW_CELL_EDITABLE );
395 wxDataViewColumn *column = new wxDataViewColumn( wxT("editable"), text_cell, 2 );
a7f61f76 396 dataview_left->AppendColumn( column );
b910a8ad 397
605c2c4a 398 dataview_left->AppendToggleColumn( wxT("fourth"), 3 );
b910a8ad 399
e152afc3
RR
400 MyCustomCell *custom_cell = new MyCustomCell;
401 column = new wxDataViewColumn( wxT("custom"), custom_cell, 4 );
402 dataview_left->AppendColumn( column );
b910a8ad 403
ad63bf41 404 dataview_left->AppendProgressColumn( wxT("progress"), 5 );
b910a8ad 405
4d496ecb 406 dataview_left->AppendDateColumn( wxT("date"), 6 );
b910a8ad 407
a7f61f76 408 // Right wxDataViewCtrl using the same model
b6339e0b 409 dataview_right = new wxDataViewCtrl( panel, wxID_ANY );
a7f61f76 410 dataview_right->AssociateModel( model );
553f7d8f 411
605c2c4a
RR
412 text_cell = new wxDataViewTextCell( wxT("string"), wxDATAVIEW_CELL_EDITABLE );
413 column = new wxDataViewColumn( wxT("editable"), text_cell, 2 );
414 dataview_right->AppendColumn( column );
415 dataview_right->AppendTextColumn( wxT("first"), 0 );
416 dataview_right->AppendTextColumn( wxT("second"), 1 );
0fdc2321 417 wxDataViewToggleCell *toggle_cell = new wxDataViewToggleCell( wxT("bool"), wxDATAVIEW_CELL_ACTIVATABLE );
533544f2 418 column = new wxDataViewColumn( wxT("bool"), toggle_cell, 3, 30 );
a7f61f76 419 dataview_right->AppendColumn( column );
553f7d8f 420
7ea3a0de 421 dataview_right->AppendDateColumn( wxT("date"), 6 );
b910a8ad 422
7ea3a0de 423 // layout dataview controls.
b910a8ad 424
a7f61f76 425 wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
4d496ecb 426 sizer->Add( dataview_left, 3, wxGROW );
a7f61f76 427 sizer->Add(10,10);
4d496ecb 428 sizer->Add( dataview_right, 2, wxGROW );
b6339e0b 429 panel->SetSizer( sizer );
bd6169a6
RR
430}
431
432void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
433{
434 Close(true);
435}
436
437void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
438{
439 wxMessageDialog dialog(this, _T("This demonstrates the dataview control handling"),
440 _T("About DataView"), wxOK);
441
442 dialog.ShowModal();
443}
444
241cb04b
RR
445// -------------------------------------
446// MySortingFrame
447// -------------------------------------
448
abd6692c
RR
449BEGIN_EVENT_TABLE(MySortingFrame,wxFrame)
450 EVT_BUTTON( ID_APPEND_ROW_LEFT, MySortingFrame::OnAppendRowLeft )
4627af27
RR
451 EVT_BUTTON( ID_PREPEND_ROW_LEFT, MySortingFrame::OnPrependRowLeft )
452 EVT_BUTTON( ID_INSERT_ROW_LEFT, MySortingFrame::OnInsertRowLeft )
453 EVT_BUTTON( ID_DELETE_ROW_LEFT, MySortingFrame::OnDeleteRowLeft )
abd6692c
RR
454END_EVENT_TABLE()
455
241cb04b
RR
456MySortingFrame::MySortingFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h):
457 wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
458{
0bcd4039 459 SetIcon(wxICON(sample));
241cb04b
RR
460
461 wxMenu *file_menu = new wxMenu;
462
463 file_menu->Append(DYNAMIC_ABOUT, _T("&About"));
464 file_menu->Append(DYNAMIC_QUIT, _T("E&xit"));
465 wxMenuBar *menu_bar = new wxMenuBar;
466 menu_bar->Append(file_menu, _T("&File"));
467 SetMenuBar(menu_bar);
468
469 // You used to have to do some casting for param 4, but now there are type-safe handlers
470 Connect( DYNAMIC_QUIT, wxID_ANY,
471 wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MySortingFrame::OnQuit) );
472 Connect( DYNAMIC_ABOUT, wxID_ANY,
473 wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MySortingFrame::OnAbout) );
474
475 CreateStatusBar();
b910a8ad
JS
476
477
241cb04b 478 // Left wxDataViewCtrl
e21f75bd 479 dataview_left = new wxDataViewCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_MULTIPLE );
241cb04b 480
4627af27
RR
481 m_unsorted_model = new MyUnsortedTextModel;
482 dataview_left->AssociateModel( m_unsorted_model );
241cb04b
RR
483 wxDataViewTextCell *text_cell = new wxDataViewTextCell( wxT("string"), wxDATAVIEW_CELL_EDITABLE );
484 wxDataViewColumn *column = new wxDataViewColumn( wxT("editable"), text_cell, 0 );
485 dataview_left->AppendColumn( column );
486 dataview_left->AppendTextColumn( wxT("second"), 1 );
cbc9145c 487 dataview_left->AppendColumn( new wxDataViewColumn( wxT("icon"), new wxDataViewBitmapCell, 2 ) );
b910a8ad 488
241cb04b 489 // Right wxDataViewCtrl using the sorting model
f554a14b 490 dataview_right = new wxDataViewCtrl( this, wxID_ANY );
b910a8ad 491 wxDataViewSortedListModel *sorted_model =
4627af27 492 new wxDataViewSortedListModel( m_unsorted_model );
241cb04b
RR
493 dataview_right->AssociateModel( sorted_model );
494 text_cell = new wxDataViewTextCell( wxT("string"), wxDATAVIEW_CELL_EDITABLE );
495 column = new wxDataViewColumn( wxT("editable"), text_cell, 0 );
496 dataview_right->AppendColumn( column );
497 dataview_right->AppendTextColumn( wxT("second"), 1 );
498
499 // layout dataview controls.
b910a8ad 500
abd6692c
RR
501 wxBoxSizer *top_sizer = new wxBoxSizer( wxHORIZONTAL );
502 top_sizer->Add( dataview_left, 1, wxGROW );
503 top_sizer->Add(10,10);
504 top_sizer->Add( dataview_right, 1, wxGROW );
b910a8ad 505
abd6692c
RR
506 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
507 button_sizer->Add( 10, 10, 1 );
508 wxFlexGridSizer *left_sizer = new wxFlexGridSizer( 2 );
509 left_sizer->Add( new wxButton( this, ID_APPEND_ROW_LEFT, wxT("Append") ), 0, wxALL, 5 );
510 left_sizer->Add( new wxButton( this, ID_PREPEND_ROW_LEFT, wxT("Prepend") ), 0, wxALL, 5 );
511 left_sizer->Add( new wxButton( this, ID_INSERT_ROW_LEFT, wxT("Insert") ), 0, wxALL, 5 );
cbc9145c 512 left_sizer->Add( new wxButton( this, ID_DELETE_ROW_LEFT, wxT("Delete second") ), 0, wxALL, 5 );
abd6692c
RR
513 left_sizer->Add( new wxButton( this, ID_EDIT_ROW_LEFT, wxT("Edit") ), 0, wxALL, 5 );
514 button_sizer->Add( left_sizer );
515 button_sizer->Add( 10, 10, 2 );
516 wxFlexGridSizer *right_sizer = new wxFlexGridSizer( 2 );
517 right_sizer->Add( new wxButton( this, ID_APPEND_ROW_RIGHT, wxT("Append") ), 0, wxALL, 5 );
518 right_sizer->Add( new wxButton( this, ID_PREPEND_ROW_RIGHT, wxT("Prepend") ), 0, wxALL, 5 );
519 right_sizer->Add( new wxButton( this, ID_INSERT_ROW_RIGHT, wxT("Insert") ), 0, wxALL, 5 );
cbc9145c 520 right_sizer->Add( new wxButton( this, ID_DELETE_ROW_RIGHT, wxT("Delete second") ), 0, wxALL, 5 );
abd6692c
RR
521 right_sizer->Add( new wxButton( this, ID_EDIT_ROW_RIGHT, wxT("Edit") ), 0, wxALL, 5 );
522 button_sizer->Add( right_sizer );
523 button_sizer->Add( 10, 10, 1 );
b910a8ad 524
abd6692c
RR
525 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
526 main_sizer->Add( top_sizer, 1, wxGROW );
527 main_sizer->Add( button_sizer, 0, wxGROW );
b910a8ad 528
abd6692c 529 SetSizer( main_sizer );
241cb04b
RR
530}
531
532void MySortingFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
533{
534 Close(true);
535}
536
537void MySortingFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
538{
539 wxMessageDialog dialog(this, _T("This demonstrates the dataview control sorting"),
540 _T("About DataView"), wxOK);
541
542 dialog.ShowModal();
543}
bd6169a6 544
f554a14b 545void MySortingFrame::OnAppendRowLeft(wxCommandEvent& WXUNUSED(event))
abd6692c 546{
4627af27
RR
547 wxTextEntryDialog dialog( this, wxT("Enter text to append") );
548 if (dialog.ShowModal() == wxID_OK)
549 {
550 wxString value = dialog.GetValue();
551 if (!value.empty())
552 m_unsorted_model->AppendRow( value );
553 }
abd6692c
RR
554}
555
f554a14b 556void MySortingFrame::OnPrependRowLeft(wxCommandEvent& WXUNUSED(event))
abd6692c 557{
4627af27
RR
558 wxTextEntryDialog dialog( this, wxT("Enter text to prepend") );
559 if (dialog.ShowModal() == wxID_OK)
560 {
561 wxString value = dialog.GetValue();
562 if (!value.empty())
563 m_unsorted_model->PrependRow( value );
564 }
abd6692c
RR
565}
566
f554a14b 567void MySortingFrame::OnInsertRowLeft(wxCommandEvent& WXUNUSED(event))
abd6692c 568{
cbc9145c 569 wxTextEntryDialog dialog( this, wxT("Enter text to insert before second") );
4627af27
RR
570 if (dialog.ShowModal() == wxID_OK)
571 {
572 wxString value = dialog.GetValue();
573 if (!value.empty())
574 m_unsorted_model->InsertRowAt1( value );
575 }
abd6692c
RR
576}
577
f554a14b 578void MySortingFrame::OnDeleteRowLeft(wxCommandEvent& WXUNUSED(event))
abd6692c 579{
4627af27 580 m_unsorted_model->DeleteRow( 1 );
abd6692c
RR
581}
582
f554a14b 583void MySortingFrame::OnEditRowLeft(wxCommandEvent& WXUNUSED(event))
abd6692c
RR
584{
585}
586
f554a14b 587void MySortingFrame::OnAppendRowRight(wxCommandEvent& WXUNUSED(event))
abd6692c
RR
588{
589}
590
f554a14b 591void MySortingFrame::OnPrependRowRight(wxCommandEvent& WXUNUSED(event))
abd6692c
RR
592{
593}
594
f554a14b 595void MySortingFrame::OnInsertRowRight(wxCommandEvent& WXUNUSED(event))
abd6692c
RR
596{
597}
598
f554a14b 599void MySortingFrame::OnDeleteRowRight(wxCommandEvent& WXUNUSED(event))
abd6692c
RR
600{
601}
602
f554a14b 603void MySortingFrame::OnEditRowRight(wxCommandEvent& WXUNUSED(event))
abd6692c
RR
604{
605}
606