]>
git.saurik.com Git - wxWidgets.git/blob - samples/newgrid/griddemo.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Grid control wxWindows sample
4 // Author: Michael Bedward
7 // Copyright: (c) Michael Bedward, Julian Smart
8 // Licence: wxWindows license
9 /////////////////////////////////////////////////////////////////////////////
15 #if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID)
16 #error "This sample requires the new wxGrid class."
21 class GridApp
: public wxApp
28 class GridFrame
: public wxFrame
32 wxLogTextCtrl
*logger
;
37 void ToggleRowLabels( wxCommandEvent
& );
38 void ToggleColLabels( wxCommandEvent
& );
39 void ToggleEditing( wxCommandEvent
& );
40 void ToggleRowSizing( wxCommandEvent
& );
41 void ToggleColSizing( wxCommandEvent
& );
42 void SetLabelColour( wxCommandEvent
& );
43 void SetLabelTextColour( wxCommandEvent
& );
44 void SetRowLabelHorizAlignment( wxCommandEvent
& );
45 void SetRowLabelVertAlignment( wxCommandEvent
& );
46 void SetColLabelHorizAlignment( wxCommandEvent
& );
47 void SetColLabelVertAlignment( wxCommandEvent
& );
48 void SetGridLineColour( wxCommandEvent
& );
50 void SetCellFgColour(wxCommandEvent
&);
51 void SetCellBgColour(wxCommandEvent
&);
53 void InsertRow( wxCommandEvent
& );
54 void InsertCol( wxCommandEvent
& );
55 void DeleteSelectedRows( wxCommandEvent
& );
56 void DeleteSelectedCols( wxCommandEvent
& );
57 void ClearGrid( wxCommandEvent
& );
59 void OnLabelLeftClick( wxGridEvent
& );
60 void OnCellLeftClick( wxGridEvent
& );
61 void OnRowSize( wxGridSizeEvent
& );
62 void OnColSize( wxGridSizeEvent
& );
63 void OnSelectCell( wxGridEvent
& );
64 void OnRangeSelected( wxGridRangeSelectEvent
& );
65 void OnCellValueChanged( wxGridEvent
& );
67 void OnEditorShown(wxGridEvent
&);
68 void OnEditorHidden(wxGridEvent
&);
74 void OnQuit( wxCommandEvent
& );
75 void About( wxCommandEvent
& );
76 void OnVTable( wxCommandEvent
& );
77 void OnBugsTable( wxCommandEvent
& );
81 ID_TOGGLEROWLABELS
= 100,
87 ID_SETLABELTEXTCOLOUR
,
89 ID_ROWLABELHORIZALIGN
,
92 ID_COLLABELHORIZALIGN
,
100 ID_SET_CELL_FG_COLOUR
,
101 ID_SET_CELL_BG_COLOUR
,
109 DECLARE_EVENT_TABLE()
112 class MyGridCellRenderer
: public wxGridCellStringRenderer
115 virtual void Draw(wxGrid
& grid
,
116 wxGridCellAttr
& attr
,
123 // ----------------------------------------------------------------------------
124 // demonstration of virtual table which doesn't store all of its data in
126 // ----------------------------------------------------------------------------
128 class SimpleTable
: public wxGridStringTable
{
130 SimpleTable( int numRows
, int numCols
)
131 : wxGridStringTable( numRows
, numCols
) {}
133 // override this to fake a row as all bools
134 wxString
GetTypeName( int row
, int col
)
138 else if (row
== 9 && col
== 1)
139 return wxT("unknown type"); // to test fallback
141 return wxGridStringTable::GetTypeName(row
, col
);
146 class BigGridTable
: public wxGridTableBase
149 BigGridTable(long sizeGrid
) { m_sizeGrid
= sizeGrid
; }
151 long GetNumberRows() { return m_sizeGrid
; }
152 long GetNumberCols() { return m_sizeGrid
; }
153 wxString
GetValue( int row
, int col
)
155 return wxString::Format("(%d, %d)", row
, col
);
158 void SetValue( int , int , const wxString
& ) { /* ignore */ }
159 bool IsEmptyCell( int , int ) { return FALSE
; }
165 class BigGridFrame
: public wxFrame
168 BigGridFrame(long sizeGrid
);
172 BigGridTable
* m_table
;
175 // ----------------------------------------------------------------------------
176 // another, more realistic, grid example
177 // ----------------------------------------------------------------------------
179 class BugsGridFrame
: public wxFrame