1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Grid control wxWindows sample
4 // Author: Michael Bedward
7 // Copyright: (c) Michael Bedward, Julian Smart
8 // Licence: wxWindows license
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #pragma implementation
24 // For compilers that support precompilation, includes "wx/wx.h".
25 #include "wx/wxprec.h"
35 #include "wx/colordlg.h"
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 IMPLEMENT_APP( GridApp
)
47 // ============================================================================
49 // ============================================================================
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 bool GridApp::OnInit()
57 GridFrame
*frame
= new GridFrame
;
63 // ----------------------------------------------------------------------------
65 // ----------------------------------------------------------------------------
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_TOGGLEROWSIZING
, GridFrame::ToggleRowSizing
)
72 EVT_MENU( ID_TOGGLECOLSIZING
, GridFrame::ToggleColSizing
)
73 EVT_MENU( ID_SETLABELCOLOUR
, GridFrame::SetLabelColour
)
74 EVT_MENU( ID_SETLABELTEXTCOLOUR
, GridFrame::SetLabelTextColour
)
75 EVT_MENU( ID_ROWLABELHORIZALIGN
, GridFrame::SetRowLabelHorizAlignment
)
76 EVT_MENU( ID_ROWLABELVERTALIGN
, GridFrame::SetRowLabelVertAlignment
)
77 EVT_MENU( ID_COLLABELHORIZALIGN
, GridFrame::SetColLabelHorizAlignment
)
78 EVT_MENU( ID_COLLABELVERTALIGN
, GridFrame::SetColLabelVertAlignment
)
79 EVT_MENU( ID_GRIDLINECOLOUR
, GridFrame::SetGridLineColour
)
80 EVT_MENU( ID_INSERTROW
, GridFrame::InsertRow
)
81 EVT_MENU( ID_INSERTCOL
, GridFrame::InsertCol
)
82 EVT_MENU( ID_DELETEROW
, GridFrame::DeleteSelectedRows
)
83 EVT_MENU( ID_DELETECOL
, GridFrame::DeleteSelectedCols
)
84 EVT_MENU( ID_CLEARGRID
, GridFrame::ClearGrid
)
86 EVT_MENU( ID_SET_CELL_FG_COLOUR
, GridFrame::SetCellFgColour
)
87 EVT_MENU( ID_SET_CELL_BG_COLOUR
, GridFrame::SetCellBgColour
)
89 EVT_MENU( ID_ABOUT
, GridFrame::About
)
90 EVT_MENU( wxID_EXIT
, GridFrame::OnQuit
)
91 EVT_MENU( ID_VTABLE
, GridFrame::OnVTable
)
92 EVT_MENU( ID_BUGS_TABLE
, GridFrame::OnBugsTable
)
94 EVT_GRID_LABEL_LEFT_CLICK( GridFrame::OnLabelLeftClick
)
95 EVT_GRID_CELL_LEFT_CLICK( GridFrame::OnCellLeftClick
)
96 EVT_GRID_ROW_SIZE( GridFrame::OnRowSize
)
97 EVT_GRID_COL_SIZE( GridFrame::OnColSize
)
98 EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell
)
99 EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected
)
100 EVT_GRID_CELL_CHANGE( GridFrame::OnCellValueChanged
)
102 EVT_GRID_EDITOR_SHOWN( GridFrame::OnEditorShown
)
103 EVT_GRID_EDITOR_HIDDEN( GridFrame::OnEditorHidden
)
107 GridFrame::GridFrame()
108 : wxFrame( (wxFrame
*)NULL
, -1, "wxWindows grid class demo",
112 int gridW
= 600, gridH
= 300;
113 int logW
= gridW
, logH
= 100;
115 wxMenu
*fileMenu
= new wxMenu
;
116 fileMenu
->Append( ID_VTABLE
, "&Virtual table test\tCtrl-V");
117 fileMenu
->Append( ID_BUGS_TABLE
, "&Bugs table test\tCtrl-B");
118 fileMenu
->AppendSeparator();
119 fileMenu
->Append( wxID_EXIT
, "E&xit\tAlt-X" );
121 wxMenu
*viewMenu
= new wxMenu
;
122 viewMenu
->Append( ID_TOGGLEROWLABELS
, "&Row labels", "", TRUE
);
123 viewMenu
->Append( ID_TOGGLECOLLABELS
, "&Col labels", "", TRUE
);
124 viewMenu
->Append( ID_TOGGLEEDIT
, "&Editable", "", TRUE
);
125 viewMenu
->Append( ID_TOGGLEROWSIZING
, "Ro&w drag-resize", "", TRUE
);
126 viewMenu
->Append( ID_TOGGLECOLSIZING
, "C&ol drag-resize", "", TRUE
);
128 wxMenu
*rowLabelMenu
= new wxMenu
;
130 viewMenu
->Append( ID_ROWLABELALIGN
, "R&ow label alignment",
132 "Change alignment of row labels" );
134 rowLabelMenu
->Append( ID_ROWLABELHORIZALIGN
, "&Horizontal" );
135 rowLabelMenu
->Append( ID_ROWLABELVERTALIGN
, "&Vertical" );
137 wxMenu
*colLabelMenu
= new wxMenu
;
139 viewMenu
->Append( ID_COLLABELALIGN
, "Col l&abel alignment",
141 "Change alignment of col labels" );
143 colLabelMenu
->Append( ID_COLLABELHORIZALIGN
, "&Horizontal" );
144 colLabelMenu
->Append( ID_COLLABELVERTALIGN
, "&Vertical" );
146 wxMenu
*colMenu
= new wxMenu
;
147 colMenu
->Append( ID_SETLABELCOLOUR
, "Set &label colour" );
148 colMenu
->Append( ID_SETLABELTEXTCOLOUR
, "Set label &text colour" );
149 colMenu
->Append( ID_GRIDLINECOLOUR
, "&Grid line colour" );
150 colMenu
->Append( ID_SET_CELL_FG_COLOUR
, "Set cell &foreground colour" );
151 colMenu
->Append( ID_SET_CELL_BG_COLOUR
, "Set cell &background colour" );
153 wxMenu
*editMenu
= new wxMenu
;
154 editMenu
->Append( ID_INSERTROW
, "Insert &row" );
155 editMenu
->Append( ID_INSERTCOL
, "Insert &column" );
156 editMenu
->Append( ID_DELETEROW
, "Delete selected ro&ws" );
157 editMenu
->Append( ID_DELETECOL
, "Delete selected co&ls" );
158 editMenu
->Append( ID_CLEARGRID
, "Cl&ear grid cell contents" );
160 wxMenu
*helpMenu
= new wxMenu
;
161 helpMenu
->Append( ID_ABOUT
, "&About wxGrid demo" );
163 wxMenuBar
*menuBar
= new wxMenuBar
;
164 menuBar
->Append( fileMenu
, "&File" );
165 menuBar
->Append( viewMenu
, "&View" );
166 menuBar
->Append( colMenu
, "&Colours" );
167 menuBar
->Append( editMenu
, "&Edit" );
168 menuBar
->Append( helpMenu
, "&Help" );
170 SetMenuBar( menuBar
);
172 grid
= new wxGrid( this,
175 wxSize( 400, 300 ) );
177 logWin
= new wxTextCtrl( this,
180 wxPoint( 0, gridH
+ 20 ),
181 wxSize( logW
, logH
),
184 logger
= new wxLogTextCtrl( logWin
);
185 logger
->SetActiveTarget( logger
);
186 logger
->SetTimestamp( NULL
);
188 // this will create a grid and, by default, an associated grid
189 // table for string gs_dataBugsGrid
190 grid
->CreateGrid( 100, 100 );
192 grid
->SetRowSize( 0, 60 );
193 grid
->SetCellValue( 0, 0, "Ctrl+Home\nwill go to\nthis cell" );
195 grid
->SetCellValue( 0, 1, "Blah" );
196 grid
->SetCellValue( 0, 2, "Blah" );
197 grid
->SetCellValue( 0, 3, "Read only" );
198 grid
->SetReadOnly( 0, 3 );
200 grid
->SetCellValue( 0, 5, "Press\nCtrl+arrow\nto skip over\ncells" );
202 grid
->SetRowSize( 99, 60 );
203 grid
->SetCellValue( 99, 99, "Ctrl+End\nwill go to\nthis cell" );
205 grid
->SetCellValue(2, 2, "red");
207 grid
->SetCellTextColour(2, 2, *wxRED
);
208 grid
->SetCellValue(3, 3, "green on grey");
209 grid
->SetCellTextColour(3, 3, *wxGREEN
);
210 grid
->SetCellBackgroundColour(3, 3, *wxLIGHT_GREY
);
212 grid
->SetCellValue(4, 4, "a weird looking cell");
213 grid
->SetCellAlignment(4, 4, wxCENTRE
, wxCENTRE
);
214 grid
->SetCellRenderer(4, 4, new MyGridCellRenderer
);
216 grid
->SetCellValue(3, 0, "1");
217 grid
->SetCellRenderer(3, 0, new wxGridCellBoolRenderer
);
218 grid
->SetCellEditor(3, 0, new wxGridCellBoolEditor
);
220 wxGridCellAttr
*attr
;
221 attr
= new wxGridCellAttr
;
222 attr
->SetTextColour(*wxBLUE
);
223 grid
->SetColAttr(5, attr
);
224 attr
= new wxGridCellAttr
;
225 attr
->SetBackgroundColour(*wxBLUE
);
226 grid
->SetRowAttr(5, attr
);
228 grid
->SetCellValue(2, 4, "a wider column");
229 grid
->SetColSize(4, 120);
230 grid
->SetColMinimalWidth(4, 120);
232 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
237 topSizer
->Add( logWin
,
241 SetAutoLayout( TRUE
);
242 SetSizer( topSizer
);
244 topSizer
->Fit( this );
245 topSizer
->SetSizeHints( this );
252 GridFrame::~GridFrame()
257 void GridFrame::SetDefaults()
259 GetMenuBar()->Check( ID_TOGGLEROWLABELS
, TRUE
);
260 GetMenuBar()->Check( ID_TOGGLECOLLABELS
, TRUE
);
261 GetMenuBar()->Check( ID_TOGGLEEDIT
, TRUE
);
262 GetMenuBar()->Check( ID_TOGGLEROWSIZING
, TRUE
);
263 GetMenuBar()->Check( ID_TOGGLECOLSIZING
, TRUE
);
267 void GridFrame::ToggleRowLabels( wxCommandEvent
& WXUNUSED(ev
) )
269 if ( GetMenuBar()->IsChecked( ID_TOGGLEROWLABELS
) )
271 grid
->SetRowLabelSize( grid
->GetDefaultRowLabelSize() );
275 grid
->SetRowLabelSize( 0 );
280 void GridFrame::ToggleColLabels( wxCommandEvent
& WXUNUSED(ev
) )
282 if ( GetMenuBar()->IsChecked( ID_TOGGLECOLLABELS
) )
284 grid
->SetColLabelSize( grid
->GetDefaultColLabelSize() );
288 grid
->SetColLabelSize( 0 );
293 void GridFrame::ToggleEditing( wxCommandEvent
& WXUNUSED(ev
) )
296 GetMenuBar()->IsChecked( ID_TOGGLEEDIT
) );
300 void GridFrame::ToggleRowSizing( wxCommandEvent
& WXUNUSED(ev
) )
302 grid
->EnableDragRowSize(
303 GetMenuBar()->IsChecked( ID_TOGGLEROWSIZING
) );
307 void GridFrame::ToggleColSizing( wxCommandEvent
& WXUNUSED(ev
) )
309 grid
->EnableDragColSize(
310 GetMenuBar()->IsChecked( ID_TOGGLECOLSIZING
) );
314 void GridFrame::SetLabelColour( wxCommandEvent
& WXUNUSED(ev
) )
316 wxColourDialog
dlg( NULL
);
317 if ( dlg
.ShowModal() == wxID_OK
)
319 wxColourData retData
;
320 retData
= dlg
.GetColourData();
321 wxColour colour
= retData
.GetColour();
323 grid
->SetLabelBackgroundColour( colour
);
328 void GridFrame::SetLabelTextColour( wxCommandEvent
& WXUNUSED(ev
) )
330 wxColourDialog
dlg( NULL
);
331 if ( dlg
.ShowModal() == wxID_OK
)
333 wxColourData retData
;
334 retData
= dlg
.GetColourData();
335 wxColour colour
= retData
.GetColour();
337 grid
->SetLabelTextColour( colour
);
342 void GridFrame::SetRowLabelHorizAlignment( wxCommandEvent
& WXUNUSED(ev
) )
345 grid
->GetRowLabelAlignment( &horiz
, &vert
);
362 grid
->SetRowLabelAlignment( horiz
, -1 );
365 void GridFrame::SetRowLabelVertAlignment( wxCommandEvent
& WXUNUSED(ev
) )
368 grid
->GetRowLabelAlignment( &horiz
, &vert
);
385 grid
->SetRowLabelAlignment( -1, vert
);
389 void GridFrame::SetColLabelHorizAlignment( wxCommandEvent
& WXUNUSED(ev
) )
392 grid
->GetColLabelAlignment( &horiz
, &vert
);
409 grid
->SetColLabelAlignment( horiz
, -1 );
413 void GridFrame::SetColLabelVertAlignment( wxCommandEvent
& WXUNUSED(ev
) )
416 grid
->GetColLabelAlignment( &horiz
, &vert
);
433 grid
->SetColLabelAlignment( -1, vert
);
437 void GridFrame::SetGridLineColour( wxCommandEvent
& WXUNUSED(ev
) )
439 wxColourDialog
dlg( NULL
);
440 if ( dlg
.ShowModal() == wxID_OK
)
442 wxColourData retData
;
443 retData
= dlg
.GetColourData();
444 wxColour colour
= retData
.GetColour();
446 grid
->SetGridLineColour( colour
);
451 void GridFrame::InsertRow( wxCommandEvent
& WXUNUSED(ev
) )
453 grid
->InsertRows( grid
->GetGridCursorRow(), 1 );
457 void GridFrame::InsertCol( wxCommandEvent
& WXUNUSED(ev
) )
459 grid
->InsertCols( grid
->GetGridCursorCol(), 1 );
463 void GridFrame::DeleteSelectedRows( wxCommandEvent
& WXUNUSED(ev
) )
465 if ( grid
->IsSelection() )
467 int topRow
, bottomRow
, leftCol
, rightCol
;
468 grid
->GetSelection( &topRow
, &leftCol
, &bottomRow
, &rightCol
);
469 grid
->DeleteRows( topRow
, bottomRow
- topRow
+ 1 );
474 void GridFrame::DeleteSelectedCols( wxCommandEvent
& WXUNUSED(ev
) )
476 if ( grid
->IsSelection() )
478 int topRow
, bottomRow
, leftCol
, rightCol
;
479 grid
->GetSelection( &topRow
, &leftCol
, &bottomRow
, &rightCol
);
480 grid
->DeleteCols( leftCol
, rightCol
- leftCol
+ 1 );
485 void GridFrame::ClearGrid( wxCommandEvent
& WXUNUSED(ev
) )
490 void GridFrame::SetCellFgColour( wxCommandEvent
& WXUNUSED(ev
) )
492 wxColour col
= wxGetColourFromUser(this);
495 grid
->SetDefaultCellTextColour(col
);
500 void GridFrame::SetCellBgColour( wxCommandEvent
& WXUNUSED(ev
) )
502 wxColour col
= wxGetColourFromUser(this);
505 grid
->SetDefaultCellBackgroundColour(col
);
510 void GridFrame::OnLabelLeftClick( wxGridEvent
& ev
)
513 if ( ev
.GetRow() != -1 )
515 logBuf
<< "Left click on row label " << ev
.GetRow();
517 else if ( ev
.GetCol() != -1 )
519 logBuf
<< "Left click on col label " << ev
.GetCol();
523 logBuf
<< "Left click on corner label";
526 if ( ev
.ShiftDown() ) logBuf
<< " (shift down)";
527 wxLogMessage( "%s", logBuf
.c_str() );
529 // you must call event skip if you want default grid processing
535 void GridFrame::OnCellLeftClick( wxGridEvent
& ev
)
538 logBuf
<< "Left click at row " << ev
.GetRow()
539 << " col " << ev
.GetCol();
540 wxLogMessage( "%s", logBuf
.c_str() );
542 // you must call event skip if you want default grid processing
543 // (cell highlighting etc.)
549 void GridFrame::OnRowSize( wxGridSizeEvent
& ev
)
552 logBuf
<< "Resized row " << ev
.GetRowOrCol();
553 wxLogMessage( "%s", logBuf
.c_str() );
559 void GridFrame::OnColSize( wxGridSizeEvent
& ev
)
562 logBuf
<< "Resized col " << ev
.GetRowOrCol();
563 wxLogMessage( "%s", logBuf
.c_str() );
569 void GridFrame::OnSelectCell( wxGridEvent
& ev
)
572 logBuf
<< "Selected cell at row " << ev
.GetRow()
573 << " col " << ev
.GetCol();
574 wxLogMessage( "%s", logBuf
.c_str() );
576 // you must call Skip() if you want the default processing
577 // to occur in wxGrid
581 void GridFrame::OnRangeSelected( wxGridRangeSelectEvent
& ev
)
584 logBuf
<< "Selected cells from row " << ev
.GetTopRow()
585 << " col " << ev
.GetLeftCol()
586 << " to row " << ev
.GetBottomRow()
587 << " col " << ev
.GetRightCol();
589 wxLogMessage( "%s", logBuf
.c_str() );
594 void GridFrame::OnCellValueChanged( wxGridEvent
& ev
)
597 logBuf
<< "Value changed for cell at"
598 << " row " << ev
.GetRow()
599 << " col " << ev
.GetCol();
601 wxLogMessage( "%s", logBuf
.c_str() );
606 void GridFrame::OnEditorShown( wxGridEvent
& ev
)
608 wxLogMessage( "Cell editor shown." );
613 void GridFrame::OnEditorHidden( wxGridEvent
& ev
)
615 wxLogMessage( "Cell editor hidden." );
620 void GridFrame::About( wxCommandEvent
& WXUNUSED(ev
) )
622 (void)wxMessageBox( "\n\nwxGrid demo \n\n"
624 "mbedward@ozemail.com.au \n\n",
630 void GridFrame::OnQuit( wxCommandEvent
& WXUNUSED(ev
) )
635 void GridFrame::OnBugsTable(wxCommandEvent
& )
637 BugsGridFrame
*frame
= new BugsGridFrame
;
641 void GridFrame::OnVTable(wxCommandEvent
& )
643 static long s_sizeGrid
= 10000;
645 s_sizeGrid
= wxGetNumberFromUser("Size of the table to create",
647 "wxGridDemo question",
650 if ( s_sizeGrid
!= -1 )
652 BigGridFrame
* win
= new BigGridFrame(s_sizeGrid
);
657 // ----------------------------------------------------------------------------
658 // MyGridCellRenderer
659 // ----------------------------------------------------------------------------
661 // do something that the default renderer doesn't here just to show that it is
662 // possible to alter the appearance of the cell beyond what the attributes
664 void MyGridCellRenderer::Draw(wxGrid
& grid
,
665 wxGridCellAttr
& attr
,
671 wxGridCellStringRenderer::Draw(grid
, attr
, dc
, rect
, row
, col
, isSelected
);
673 dc
.SetPen(*wxGREEN_PEN
);
674 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
675 dc
.DrawEllipse(rect
);
679 // ----------------------------------------------------------------------------
680 // BigGridFrame and BigGridTable: Sample of a non-standard table
681 // ----------------------------------------------------------------------------
683 BigGridFrame::BigGridFrame(long sizeGrid
)
684 : wxFrame(NULL
, -1, "Plugin Virtual Table",
685 wxDefaultPosition
, wxSize(500, 450))
687 m_grid
= new wxGrid(this, -1, wxDefaultPosition
, wxDefaultSize
);
688 m_table
= new BigGridTable(sizeGrid
);
689 m_grid
->SetTable(m_table
, TRUE
);
692 // ----------------------------------------------------------------------------
693 // BugsGridFrame: a "realistic" table
694 // ----------------------------------------------------------------------------
717 static const wxChar
* severities
[] =
726 static struct BugsGridData
729 const wxChar
*summary
;
732 const wxChar
*platform
;
734 } gs_dataBugsGrid
[] =
736 { 18, _T("foo doesn't work"), Sev_Major
, 1, _T("wxMSW"), TRUE
},
737 { 27, _T("bar crashes"), Sev_Critical
, 1, _T("all"), FALSE
},
738 { 45, _T("printing is slow"), Sev_Minor
, 3, _T("wxMSW"), TRUE
},
739 { 68, _T("Rectangle() fails"), Sev_Normal
, 1, _T("wxMSW"), FALSE
},
742 static const wxChar
*headers
[Col_Max
] =
752 wxString
BugsGridTable::GetTypeName(int WXUNUSED(row
), int col
)
758 return wxGRID_VALUE_NUMBER
;;
761 // fall thorugh (TODO should be a list)
765 return wxGRID_VALUE_STRING
;
768 return wxGRID_VALUE_BOOL
;
771 wxFAIL_MSG(_T("unknown column"));
773 return wxEmptyString
;
776 long BugsGridTable::GetNumberRows()
778 return WXSIZEOF(gs_dataBugsGrid
);
781 long BugsGridTable::GetNumberCols()
786 bool BugsGridTable::IsEmptyCell( int row
, int col
)
791 wxString
BugsGridTable::GetValue( int row
, int col
)
793 const BugsGridData
& gd
= gs_dataBugsGrid
[row
];
800 wxFAIL_MSG(_T("unexpected column"));
804 return severities
[gd
.severity
];
813 return wxEmptyString
;
816 void BugsGridTable::SetValue( int row
, int col
, const wxString
& value
)
818 BugsGridData
& gd
= gs_dataBugsGrid
[row
];
825 wxFAIL_MSG(_T("unexpected column"));
831 for ( n
= 0; n
< WXSIZEOF(severities
); n
++ )
833 if ( severities
[n
] == value
)
835 gd
.severity
= (Severity
)n
;
840 if ( n
== WXSIZEOF(severities
) )
842 wxLogWarning(_T("Invalid severity value '%s'."),
844 gd
.severity
= Sev_Normal
;
858 bool BugsGridTable::CanGetValueAs( int WXUNUSED(row
), int col
, const wxString
& typeName
)
860 if ( typeName
== wxGRID_VALUE_STRING
)
864 else if ( typeName
== wxGRID_VALUE_BOOL
)
866 return col
== Col_Opened
;
868 else if ( typeName
== wxGRID_VALUE_NUMBER
)
870 return col
== Col_Id
|| col
== Col_Priority
|| col
== Col_Severity
;
878 bool BugsGridTable::CanSetValueAs( int row
, int col
, const wxString
& typeName
)
880 return CanGetValueAs(row
, col
, typeName
);
883 long BugsGridTable::GetValueAsLong( int row
, int col
)
885 const BugsGridData
& gd
= gs_dataBugsGrid
[row
];
899 wxFAIL_MSG(_T("unexpected column"));
904 bool BugsGridTable::GetValueAsBool( int row
, int col
)
906 if ( col
== Col_Opened
)
908 return gs_dataBugsGrid
[row
].opened
;
912 wxFAIL_MSG(_T("unexpected column"));
918 void BugsGridTable::SetValueAsLong( int row
, int col
, long value
)
920 BugsGridData
& gd
= gs_dataBugsGrid
[row
];
929 wxFAIL_MSG(_T("unexpected column"));
933 void BugsGridTable::SetValueAsBool( int row
, int col
, bool value
)
935 if ( col
== Col_Opened
)
937 gs_dataBugsGrid
[row
].opened
= value
;
941 wxFAIL_MSG(_T("unexpected column"));
945 wxString
BugsGridTable::GetColLabelValue( int col
)
950 BugsGridTable::BugsGridTable()
954 BugsGridFrame::BugsGridFrame()
955 : wxFrame(NULL
, -1, "Bugs table",
956 wxDefaultPosition
, wxSize(500, 300))
958 wxGrid
*grid
= new wxGrid(this, -1, wxDefaultPosition
);
959 wxGridTableBase
*table
= new BugsGridTable();
960 grid
->SetTable(table
, TRUE
);
962 wxGridCellAttr
*attrRO
= new wxGridCellAttr
,
963 *attrRangeEditor
= new wxGridCellAttr
,
964 *attrCombo
= new wxGridCellAttr
;
966 attrRO
->SetReadOnly();
967 attrRangeEditor
->SetEditor(new wxGridCellNumberEditor(1, 5));
968 attrCombo
->SetEditor(new wxGridCellChoiceEditor(WXSIZEOF(severities
),
971 grid
->SetColAttr(Col_Id
, attrRO
);
972 grid
->SetColAttr(Col_Priority
, attrRangeEditor
);
973 grid
->SetColAttr(Col_Severity
, attrCombo
);
975 grid
->AutoSizeColumns();