]> git.saurik.com Git - wxWidgets.git/blob - samples/newgrid/griddemo.cpp
c24309c46e64d1d6c76396314bf1ef78efe8332b
[wxWidgets.git] / samples / newgrid / griddemo.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: griddemo.cpp
3 // Purpose: Grid control wxWindows sample
4 // Author: Michael Bedward
5 // Modified by:
6 // RCS-ID: $Id$
7 // Copyright: (c) Michael Bedward, Julian Smart
8 // Licence: wxWindows license
9 /////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #ifdef __GNUG__
20 #pragma implementation
21 #pragma interface
22 #endif
23
24 // For compilers that support precompilation, includes "wx/wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/wx.h"
33 #endif
34
35 #include "wx/colordlg.h"
36
37 #include "wx/grid.h"
38
39 #include "griddemo.h"
40
41 // ----------------------------------------------------------------------------
42 // wxWin macros
43 // ----------------------------------------------------------------------------
44
45 IMPLEMENT_APP( GridApp )
46
47 // ============================================================================
48 // implementation
49 // ============================================================================
50
51 // ----------------------------------------------------------------------------
52 // GridApp
53 // ----------------------------------------------------------------------------
54
55 bool GridApp::OnInit()
56 {
57 GridFrame *frame = new GridFrame;
58 frame->Show( TRUE );
59
60 return TRUE;
61 }
62
63 // ----------------------------------------------------------------------------
64 // GridFrame
65 // ----------------------------------------------------------------------------
66
67 BEGIN_EVENT_TABLE( GridFrame, wxFrame )
68 EVT_MENU( ID_TOGGLEROWLABELS, GridFrame::ToggleRowLabels )
69 EVT_MENU( ID_TOGGLECOLLABELS, GridFrame::ToggleColLabels )
70 EVT_MENU( ID_TOGGLEEDIT, GridFrame::ToggleEditing )
71 EVT_MENU( ID_SETLABELCOLOUR, GridFrame::SetLabelColour )
72 EVT_MENU( ID_SETLABELTEXTCOLOUR, GridFrame::SetLabelTextColour )
73 EVT_MENU( ID_ROWLABELHORIZALIGN, GridFrame::SetRowLabelHorizAlignment )
74 EVT_MENU( ID_ROWLABELVERTALIGN, GridFrame::SetRowLabelVertAlignment )
75 EVT_MENU( ID_COLLABELHORIZALIGN, GridFrame::SetColLabelHorizAlignment )
76 EVT_MENU( ID_COLLABELVERTALIGN, GridFrame::SetColLabelVertAlignment )
77 EVT_MENU( ID_GRIDLINECOLOUR, GridFrame::SetGridLineColour )
78 EVT_MENU( ID_INSERTROW, GridFrame::InsertRow )
79 EVT_MENU( ID_INSERTCOL, GridFrame::InsertCol )
80 EVT_MENU( ID_DELETEROW, GridFrame::DeleteSelectedRows )
81 EVT_MENU( ID_DELETECOL, GridFrame::DeleteSelectedCols )
82 EVT_MENU( ID_CLEARGRID, GridFrame::ClearGrid )
83
84 EVT_MENU( ID_SET_CELL_FG_COLOUR, GridFrame::SetCellFgColour )
85 EVT_MENU( ID_SET_CELL_BG_COLOUR, GridFrame::SetCellBgColour )
86
87 EVT_MENU( ID_ABOUT, GridFrame::About )
88 EVT_MENU( wxID_EXIT, GridFrame::OnQuit )
89 EVT_MENU( ID_VTABLE, GridFrame::OnVTable)
90 EVT_MENU( ID_BUGS_TABLE, GridFrame::OnBugsTable)
91
92 EVT_GRID_LABEL_LEFT_CLICK( GridFrame::OnLabelLeftClick )
93 EVT_GRID_CELL_LEFT_CLICK( GridFrame::OnCellLeftClick )
94 EVT_GRID_ROW_SIZE( GridFrame::OnRowSize )
95 EVT_GRID_COL_SIZE( GridFrame::OnColSize )
96 EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell )
97 EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected )
98 EVT_GRID_CELL_CHANGE( GridFrame::OnCellValueChanged )
99
100 EVT_GRID_EDITOR_SHOWN( GridFrame::OnEditorShown )
101 EVT_GRID_EDITOR_HIDDEN( GridFrame::OnEditorHidden )
102 END_EVENT_TABLE()
103
104
105 GridFrame::GridFrame()
106 : wxFrame( (wxFrame *)NULL, -1, "wxWindows grid class demo",
107 wxDefaultPosition,
108 wxDefaultSize )
109 {
110 int gridW = 600, gridH = 300;
111 int logW = gridW, logH = 100;
112
113 wxMenu *fileMenu = new wxMenu;
114 fileMenu->Append( ID_VTABLE, "&Virtual table test\tCtrl-V");
115 fileMenu->Append( ID_BUGS_TABLE, "&Bugs table test\tCtrl-B");
116 fileMenu->AppendSeparator();
117 fileMenu->Append( wxID_EXIT, "E&xit\tAlt-X" );
118
119 wxMenu *viewMenu = new wxMenu;
120 viewMenu->Append( ID_TOGGLEROWLABELS, "&Row labels", "", TRUE );
121 viewMenu->Append( ID_TOGGLECOLLABELS, "&Col labels", "", TRUE );
122 viewMenu->Append( ID_TOGGLEEDIT, "&Editable", "", TRUE );
123
124 wxMenu *rowLabelMenu = new wxMenu;
125
126 viewMenu->Append( ID_ROWLABELALIGN, "R&ow label alignment",
127 rowLabelMenu,
128 "Change alignment of row labels" );
129
130 rowLabelMenu->Append( ID_ROWLABELHORIZALIGN, "&Horizontal" );
131 rowLabelMenu->Append( ID_ROWLABELVERTALIGN, "&Vertical" );
132
133 wxMenu *colLabelMenu = new wxMenu;
134
135 viewMenu->Append( ID_COLLABELALIGN, "Col l&abel alignment",
136 colLabelMenu,
137 "Change alignment of col labels" );
138
139 colLabelMenu->Append( ID_COLLABELHORIZALIGN, "&Horizontal" );
140 colLabelMenu->Append( ID_COLLABELVERTALIGN, "&Vertical" );
141
142 wxMenu *colMenu = new wxMenu;
143 colMenu->Append( ID_SETLABELCOLOUR, "Set &label colour" );
144 colMenu->Append( ID_SETLABELTEXTCOLOUR, "Set label &text colour" );
145 colMenu->Append( ID_GRIDLINECOLOUR, "&Grid line colour" );
146 colMenu->Append( ID_SET_CELL_FG_COLOUR, "Set cell &foreground colour" );
147 colMenu->Append( ID_SET_CELL_BG_COLOUR, "Set cell &background colour" );
148
149 wxMenu *editMenu = new wxMenu;
150 editMenu->Append( ID_INSERTROW, "Insert &row" );
151 editMenu->Append( ID_INSERTCOL, "Insert &column" );
152 editMenu->Append( ID_DELETEROW, "Delete selected ro&ws" );
153 editMenu->Append( ID_DELETECOL, "Delete selected co&ls" );
154 editMenu->Append( ID_CLEARGRID, "Cl&ear grid cell contents" );
155
156 wxMenu *helpMenu = new wxMenu;
157 helpMenu->Append( ID_ABOUT, "&About wxGrid demo" );
158
159 wxMenuBar *menuBar = new wxMenuBar;
160 menuBar->Append( fileMenu, "&File" );
161 menuBar->Append( viewMenu, "&View" );
162 menuBar->Append( colMenu, "&Colours" );
163 menuBar->Append( editMenu, "&Edit" );
164 menuBar->Append( helpMenu, "&Help" );
165
166 SetMenuBar( menuBar );
167
168 grid = new wxGrid( this,
169 -1,
170 wxPoint( 0, 0 ),
171 wxSize( 400, 300 ) );
172
173 logWin = new wxTextCtrl( this,
174 -1,
175 wxEmptyString,
176 wxPoint( 0, gridH + 20 ),
177 wxSize( logW, logH ),
178 wxTE_MULTILINE );
179
180 logger = new wxLogTextCtrl( logWin );
181 logger->SetActiveTarget( logger );
182 logger->SetTimestamp( NULL );
183
184 // this will create a grid and, by default, an associated grid
185 // table for string data
186 //
187 grid->CreateGrid( 100, 100 );
188
189 grid->SetRowSize( 0, 60 );
190 grid->SetCellValue( 0, 0, "Ctrl+Home\nwill go to\nthis cell" );
191
192 grid->SetCellValue( 0, 1, "Blah" );
193 grid->SetCellValue( 0, 2, "Blah" );
194 grid->SetCellValue( 0, 3, "Read only" );
195 grid->SetReadOnly( 0, 3 );
196
197 grid->SetCellValue( 0, 5, "Press\nCtrl+arrow\nto skip over\ncells" );
198
199 grid->SetRowSize( 99, 60 );
200 grid->SetCellValue( 99, 99, "Ctrl+End\nwill go to\nthis cell" );
201
202 grid->SetCellValue(2, 2, "red");
203
204 grid->SetCellTextColour(2, 2, *wxRED);
205 grid->SetCellValue(3, 3, "green on grey");
206 grid->SetCellTextColour(3, 3, *wxGREEN);
207 grid->SetCellBackgroundColour(3, 3, *wxLIGHT_GREY);
208
209 grid->SetCellValue(4, 4, "a weird looking cell");
210 grid->SetCellAlignment(4, 4, wxCENTRE, wxCENTRE);
211 grid->SetCellRenderer(4, 4, new MyGridCellRenderer);
212
213 grid->SetCellValue(3, 0, "1");
214 grid->SetCellRenderer(3, 0, new wxGridCellBoolRenderer);
215 grid->SetCellEditor(3, 0, new wxGridCellBoolEditor);
216
217 wxGridCellAttr *attr;
218 attr = new wxGridCellAttr;
219 attr->SetTextColour(*wxBLUE);
220 grid->SetColAttr(5, attr);
221 attr = new wxGridCellAttr;
222 attr->SetBackgroundColour(*wxBLUE);
223 grid->SetRowAttr(5, attr);
224
225 grid->SetCellValue(2, 4, "a wider column");
226 grid->SetColSize(4, 120);
227 grid->SetColMinimalWidth(4, 120);
228
229 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
230 topSizer->Add( grid,
231 1,
232 wxEXPAND );
233
234 topSizer->Add( logWin,
235 0,
236 wxEXPAND );
237
238 SetAutoLayout( TRUE );
239 SetSizer( topSizer );
240
241 topSizer->Fit( this );
242 topSizer->SetSizeHints( this );
243
244 Centre();
245 SetDefaults();
246 }
247
248
249 GridFrame::~GridFrame()
250 {
251 }
252
253
254 void GridFrame::SetDefaults()
255 {
256 GetMenuBar()->Check( ID_TOGGLEROWLABELS, TRUE );
257 GetMenuBar()->Check( ID_TOGGLECOLLABELS, TRUE );
258 GetMenuBar()->Check( ID_TOGGLEEDIT, TRUE );
259 }
260
261
262 void GridFrame::ToggleRowLabels( wxCommandEvent& WXUNUSED(ev) )
263 {
264 if ( GetMenuBar()->IsChecked( ID_TOGGLEROWLABELS ) )
265 {
266 grid->SetRowLabelSize( grid->GetDefaultRowLabelSize() );
267 }
268 else
269 {
270 grid->SetRowLabelSize( 0 );
271 }
272 }
273
274
275 void GridFrame::ToggleColLabels( wxCommandEvent& WXUNUSED(ev) )
276 {
277 if ( GetMenuBar()->IsChecked( ID_TOGGLECOLLABELS ) )
278 {
279 grid->SetColLabelSize( grid->GetDefaultColLabelSize() );
280 }
281 else
282 {
283 grid->SetColLabelSize( 0 );
284 }
285 }
286
287
288 void GridFrame::ToggleEditing( wxCommandEvent& WXUNUSED(ev) )
289 {
290 grid->EnableEditing(
291 GetMenuBar()->IsChecked( ID_TOGGLEEDIT ) );
292 }
293
294
295 void GridFrame::SetLabelColour( wxCommandEvent& WXUNUSED(ev) )
296 {
297 wxColourDialog dlg( NULL );
298 if ( dlg.ShowModal() == wxID_OK )
299 {
300 wxColourData retData;
301 retData = dlg.GetColourData();
302 wxColour colour = retData.GetColour();
303
304 grid->SetLabelBackgroundColour( colour );
305 }
306 }
307
308
309 void GridFrame::SetLabelTextColour( wxCommandEvent& WXUNUSED(ev) )
310 {
311 wxColourDialog dlg( NULL );
312 if ( dlg.ShowModal() == wxID_OK )
313 {
314 wxColourData retData;
315 retData = dlg.GetColourData();
316 wxColour colour = retData.GetColour();
317
318 grid->SetLabelTextColour( colour );
319 }
320 }
321
322
323 void GridFrame::SetRowLabelHorizAlignment( wxCommandEvent& WXUNUSED(ev) )
324 {
325 int horiz, vert;
326 grid->GetRowLabelAlignment( &horiz, &vert );
327
328 switch ( horiz )
329 {
330 case wxLEFT:
331 horiz = wxCENTRE;
332 break;
333
334 case wxCENTRE:
335 horiz = wxRIGHT;
336 break;
337
338 case wxRIGHT:
339 horiz = wxLEFT;
340 break;
341 }
342
343 grid->SetRowLabelAlignment( horiz, -1 );
344 }
345
346 void GridFrame::SetRowLabelVertAlignment( wxCommandEvent& WXUNUSED(ev) )
347 {
348 int horiz, vert;
349 grid->GetRowLabelAlignment( &horiz, &vert );
350
351 switch ( vert )
352 {
353 case wxTOP:
354 vert = wxCENTRE;
355 break;
356
357 case wxCENTRE:
358 vert = wxBOTTOM;
359 break;
360
361 case wxBOTTOM:
362 vert = wxTOP;
363 break;
364 }
365
366 grid->SetRowLabelAlignment( -1, vert );
367 }
368
369
370 void GridFrame::SetColLabelHorizAlignment( wxCommandEvent& WXUNUSED(ev) )
371 {
372 int horiz, vert;
373 grid->GetColLabelAlignment( &horiz, &vert );
374
375 switch ( horiz )
376 {
377 case wxLEFT:
378 horiz = wxCENTRE;
379 break;
380
381 case wxCENTRE:
382 horiz = wxRIGHT;
383 break;
384
385 case wxRIGHT:
386 horiz = wxLEFT;
387 break;
388 }
389
390 grid->SetColLabelAlignment( horiz, -1 );
391 }
392
393
394 void GridFrame::SetColLabelVertAlignment( wxCommandEvent& WXUNUSED(ev) )
395 {
396 int horiz, vert;
397 grid->GetColLabelAlignment( &horiz, &vert );
398
399 switch ( vert )
400 {
401 case wxTOP:
402 vert = wxCENTRE;
403 break;
404
405 case wxCENTRE:
406 vert = wxBOTTOM;
407 break;
408
409 case wxBOTTOM:
410 vert = wxTOP;
411 break;
412 }
413
414 grid->SetColLabelAlignment( -1, vert );
415 }
416
417
418 void GridFrame::SetGridLineColour( wxCommandEvent& WXUNUSED(ev) )
419 {
420 wxColourDialog dlg( NULL );
421 if ( dlg.ShowModal() == wxID_OK )
422 {
423 wxColourData retData;
424 retData = dlg.GetColourData();
425 wxColour colour = retData.GetColour();
426
427 grid->SetGridLineColour( colour );
428 }
429 }
430
431
432 void GridFrame::InsertRow( wxCommandEvent& WXUNUSED(ev) )
433 {
434 grid->InsertRows( grid->GetGridCursorRow(), 1 );
435 }
436
437
438 void GridFrame::InsertCol( wxCommandEvent& WXUNUSED(ev) )
439 {
440 grid->InsertCols( grid->GetGridCursorCol(), 1 );
441 }
442
443
444 void GridFrame::DeleteSelectedRows( wxCommandEvent& WXUNUSED(ev) )
445 {
446 if ( grid->IsSelection() )
447 {
448 int topRow, bottomRow, leftCol, rightCol;
449 grid->GetSelection( &topRow, &leftCol, &bottomRow, &rightCol );
450 grid->DeleteRows( topRow, bottomRow - topRow + 1 );
451 }
452 }
453
454
455 void GridFrame::DeleteSelectedCols( wxCommandEvent& WXUNUSED(ev) )
456 {
457 if ( grid->IsSelection() )
458 {
459 int topRow, bottomRow, leftCol, rightCol;
460 grid->GetSelection( &topRow, &leftCol, &bottomRow, &rightCol );
461 grid->DeleteCols( leftCol, rightCol - leftCol + 1 );
462 }
463 }
464
465
466 void GridFrame::ClearGrid( wxCommandEvent& WXUNUSED(ev) )
467 {
468 grid->ClearGrid();
469 }
470
471 void GridFrame::SetCellFgColour( wxCommandEvent& WXUNUSED(ev) )
472 {
473 wxColour col = wxGetColourFromUser(this);
474 if ( col.Ok() )
475 {
476 grid->SetDefaultCellTextColour(col);
477 grid->Refresh();
478 }
479 }
480
481 void GridFrame::SetCellBgColour( wxCommandEvent& WXUNUSED(ev) )
482 {
483 wxColour col = wxGetColourFromUser(this);
484 if ( col.Ok() )
485 {
486 grid->SetDefaultCellBackgroundColour(col);
487 grid->Refresh();
488 }
489 }
490
491 void GridFrame::OnLabelLeftClick( wxGridEvent& ev )
492 {
493 logBuf = "";
494 if ( ev.GetRow() != -1 )
495 {
496 logBuf << "Left click on row label " << ev.GetRow();
497 }
498 else if ( ev.GetCol() != -1 )
499 {
500 logBuf << "Left click on col label " << ev.GetCol();
501 }
502 else
503 {
504 logBuf << "Left click on corner label";
505 }
506
507 if ( ev.ShiftDown() ) logBuf << " (shift down)";
508 wxLogMessage( "%s", logBuf.c_str() );
509
510 // you must call event skip if you want default grid processing
511 //
512 ev.Skip();
513 }
514
515
516 void GridFrame::OnCellLeftClick( wxGridEvent& ev )
517 {
518 logBuf = "";
519 logBuf << "Left click at row " << ev.GetRow()
520 << " col " << ev.GetCol();
521 wxLogMessage( "%s", logBuf.c_str() );
522
523 // you must call event skip if you want default grid processing
524 // (cell highlighting etc.)
525 //
526 ev.Skip();
527 }
528
529
530 void GridFrame::OnRowSize( wxGridSizeEvent& ev )
531 {
532 logBuf = "";
533 logBuf << "Resized row " << ev.GetRowOrCol();
534 wxLogMessage( "%s", logBuf.c_str() );
535
536 ev.Skip();
537 }
538
539
540 void GridFrame::OnColSize( wxGridSizeEvent& ev )
541 {
542 logBuf = "";
543 logBuf << "Resized col " << ev.GetRowOrCol();
544 wxLogMessage( "%s", logBuf.c_str() );
545
546 ev.Skip();
547 }
548
549
550 void GridFrame::OnSelectCell( wxGridEvent& ev )
551 {
552 logBuf = "";
553 logBuf << "Selected cell at row " << ev.GetRow()
554 << " col " << ev.GetCol();
555 wxLogMessage( "%s", logBuf.c_str() );
556
557 // you must call Skip() if you want the default processing
558 // to occur in wxGrid
559 ev.Skip();
560 }
561
562 void GridFrame::OnRangeSelected( wxGridRangeSelectEvent& ev )
563 {
564 logBuf = "";
565 logBuf << "Selected cells from row " << ev.GetTopRow()
566 << " col " << ev.GetLeftCol()
567 << " to row " << ev.GetBottomRow()
568 << " col " << ev.GetRightCol();
569
570 wxLogMessage( "%s", logBuf.c_str() );
571
572 ev.Skip();
573 }
574
575 void GridFrame::OnCellValueChanged( wxGridEvent& ev )
576 {
577 logBuf = "";
578 logBuf << "Value changed for cell at"
579 << " row " << ev.GetRow()
580 << " col " << ev.GetCol();
581
582 wxLogMessage( "%s", logBuf.c_str() );
583
584 ev.Skip();
585 }
586
587 void GridFrame::OnEditorShown( wxGridEvent& ev )
588 {
589 wxLogMessage( "Cell editor shown." );
590
591 ev.Skip();
592 }
593
594 void GridFrame::OnEditorHidden( wxGridEvent& ev )
595 {
596 wxLogMessage( "Cell editor hidden." );
597
598 ev.Skip();
599 }
600
601 void GridFrame::About( wxCommandEvent& WXUNUSED(ev) )
602 {
603 (void)wxMessageBox( "\n\nwxGrid demo \n\n"
604 "Michael Bedward \n"
605 "mbedward@ozemail.com.au \n\n",
606 "About",
607 wxOK );
608 }
609
610
611 void GridFrame::OnQuit( wxCommandEvent& WXUNUSED(ev) )
612 {
613 Close( TRUE );
614 }
615
616 void GridFrame::OnBugsTable(wxCommandEvent& )
617 {
618 BugsGridFrame *frame = new BugsGridFrame;
619 frame->Show(TRUE);
620 }
621
622 void GridFrame::OnVTable(wxCommandEvent& )
623 {
624 static long s_sizeGrid = 10000;
625
626 s_sizeGrid = wxGetNumberFromUser("Size of the table to create",
627 "Size: ",
628 "wxGridDemo question",
629 s_sizeGrid,
630 0, 32000, this);
631 if ( s_sizeGrid != -1 )
632 {
633 BigGridFrame* win = new BigGridFrame(s_sizeGrid);
634 win->Show(TRUE);
635 }
636 }
637
638 // ----------------------------------------------------------------------------
639 // MyGridCellRenderer
640 // ----------------------------------------------------------------------------
641
642 // do something that the default renderer doesn't here just to show that it is
643 // possible to alter the appearance of the cell beyond what the attributes
644 // allow
645 void MyGridCellRenderer::Draw(wxGrid& grid,
646 wxGridCellAttr& attr,
647 wxDC& dc,
648 const wxRect& rect,
649 int row, int col,
650 bool isSelected)
651 {
652 wxGridCellStringRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
653
654 dc.SetPen(*wxGREEN_PEN);
655 dc.SetBrush(*wxTRANSPARENT_BRUSH);
656 dc.DrawEllipse(rect);
657 }
658
659
660 // ----------------------------------------------------------------------------
661 // BigGridFrame and BigGridTable: Sample of a non-standard table
662 // ----------------------------------------------------------------------------
663
664 BigGridFrame::BigGridFrame(long sizeGrid)
665 : wxFrame(NULL, -1, "Plugin Virtual Table",
666 wxDefaultPosition, wxSize(500, 450))
667 {
668 m_grid = new wxGrid(this, -1, wxDefaultPosition, wxDefaultSize);
669 m_table = new BigGridTable(sizeGrid);
670 m_grid->SetTable(m_table, TRUE);
671 }
672
673 // ----------------------------------------------------------------------------
674 // BugsGridFrame: a "realistic" table
675 // ----------------------------------------------------------------------------
676
677 BugsGridFrame::BugsGridFrame()
678 : wxFrame(NULL, -1, "Bugs table",
679 wxDefaultPosition, wxSize(500, 300))
680 {
681 enum Severity
682 {
683 Wish,
684 Minor,
685 Normal,
686 Major,
687 Critical
688 };
689
690 static const wxChar* severities[] =
691 {
692 _T("wishlist"),
693 _T("minor"),
694 _T("normal"),
695 _T("major"),
696 _T("critical"),
697 };
698
699 static const struct GridData
700 {
701 int id;
702 const wxChar *summary;
703 Severity severity;
704 int prio;
705 const wxChar *platform;
706 bool opened;
707 } data [] =
708 {
709 { 18, _T("foo doesn't work"), Major, 1, _T("wxMSW"), TRUE },
710 { 27, _T("bar crashes"), Critical, 1, _T("all"), FALSE },
711 { 45, _T("printing is slow"), Minor, 3, _T("wxMSW"), TRUE },
712 { 68, _T("Rectangle() fails"), Normal, 1, _T("wxMSW"), FALSE },
713 };
714
715 static const wxChar *headers[] =
716 {
717 _T("Id"),
718 _T("Summary"),
719 _T("Severity"),
720 _T("Priority"),
721 _T("Platform"),
722 _T("Opened?"),
723 };
724
725 // TODO the correct data type must be used for each column
726
727 wxGrid *grid = new wxGrid(this, -1);
728 wxGridTableBase *table =
729 new wxGridStringTable(WXSIZEOF(data), WXSIZEOF(headers));
730 for ( size_t row = 0; row < WXSIZEOF(data); row++ )
731 {
732 const GridData& gd = data[row];
733 table->SetValue(row, 0, wxString::Format("%d", gd.id));
734 table->SetValue(row, 1, gd.summary);
735 table->SetValue(row, 2, severities[gd.severity]);
736 table->SetValue(row, 3, wxString::Format("%d", gd.prio));
737 table->SetValue(row, 4, gd.platform);
738 table->SetValue(row, 5, gd.opened ? _T("True") : wxEmptyString);
739 }
740
741 for ( size_t col = 0; col < WXSIZEOF(headers); col++ )
742 {
743 table->SetColLabelValue(col, headers[col]);
744 }
745
746 grid->SetTable(table, TRUE);
747 }