]>
git.saurik.com Git - wxWidgets.git/blob - samples/newgrid/griddemo.h
2bc68c20823fe3345221129ac0d0dd99c17e6619
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 ToggleGridSizing( wxCommandEvent
& );
43 void SetLabelColour( wxCommandEvent
& );
44 void SetLabelTextColour( wxCommandEvent
& );
45 void SetRowLabelHorizAlignment( wxCommandEvent
& );
46 void SetRowLabelVertAlignment( wxCommandEvent
& );
47 void SetColLabelHorizAlignment( wxCommandEvent
& );
48 void SetColLabelVertAlignment( wxCommandEvent
& );
49 void SetGridLineColour( wxCommandEvent
& );
51 void SetCellFgColour(wxCommandEvent
&);
52 void SetCellBgColour(wxCommandEvent
&);
54 void InsertRow( wxCommandEvent
& );
55 void InsertCol( wxCommandEvent
& );
56 void DeleteSelectedRows( wxCommandEvent
& );
57 void DeleteSelectedCols( wxCommandEvent
& );
58 void ClearGrid( wxCommandEvent
& );
60 void OnLabelLeftClick( wxGridEvent
& );
61 void OnCellLeftClick( wxGridEvent
& );
62 void OnRowSize( wxGridSizeEvent
& );
63 void OnColSize( wxGridSizeEvent
& );
64 void OnSelectCell( wxGridEvent
& );
65 void OnRangeSelected( wxGridRangeSelectEvent
& );
66 void OnCellValueChanged( wxGridEvent
& );
68 void OnEditorShown(wxGridEvent
&);
69 void OnEditorHidden(wxGridEvent
&);
75 void OnQuit( wxCommandEvent
& );
76 void About( wxCommandEvent
& );
77 void OnVTable( wxCommandEvent
& );
78 void OnBugsTable( wxCommandEvent
& );
82 ID_TOGGLEROWLABELS
= 100,
89 ID_SETLABELTEXTCOLOUR
,
91 ID_ROWLABELHORIZALIGN
,
94 ID_COLLABELHORIZALIGN
,
102 ID_SET_CELL_FG_COLOUR
,
103 ID_SET_CELL_BG_COLOUR
,
113 DECLARE_EVENT_TABLE()
116 class MyGridCellRenderer
: public wxGridCellStringRenderer
119 virtual void Draw(wxGrid
& grid
,
120 wxGridCellAttr
& attr
,
127 // ----------------------------------------------------------------------------
128 // demonstration of virtual table which doesn't store all of its data in
130 // ----------------------------------------------------------------------------
132 class BigGridTable
: public wxGridTableBase
135 BigGridTable(long sizeGrid
) { m_sizeGrid
= sizeGrid
; }
137 long GetNumberRows() { return m_sizeGrid
; }
138 long GetNumberCols() { return m_sizeGrid
; }
139 wxString
GetValue( int row
, int col
)
141 return wxString::Format("(%d, %d)", row
, col
);
144 void SetValue( int , int , const wxString
& ) { /* ignore */ }
145 bool IsEmptyCell( int , int ) { return FALSE
; }
151 class BigGridFrame
: public wxFrame
154 BigGridFrame(long sizeGrid
);
158 BigGridTable
* m_table
;
161 // ----------------------------------------------------------------------------
162 // another, more realistic, grid example: shows typed columns and more
163 // ----------------------------------------------------------------------------
165 class BugsGridTable
: public wxGridTableBase
170 virtual long GetNumberRows();
171 virtual long GetNumberCols();
172 virtual bool IsEmptyCell( int row
, int col
);
173 virtual wxString
GetValue( int row
, int col
);
174 virtual void SetValue( int row
, int col
, const wxString
& value
);
176 virtual wxString
GetColLabelValue( int col
);
178 virtual wxString
GetTypeName( int row
, int col
);
179 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
180 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
182 virtual long GetValueAsLong( int row
, int col
);
183 virtual bool GetValueAsBool( int row
, int col
);
185 virtual void SetValueAsLong( int row
, int col
, long value
);
186 virtual void SetValueAsBool( int row
, int col
, bool value
);
189 class BugsGridFrame
: public wxFrame