]>
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 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
& );
59 void SelectCells( wxCommandEvent
& );
60 void SelectRows( wxCommandEvent
& );
61 void SelectCols( wxCommandEvent
& );
63 void OnLabelLeftClick( wxGridEvent
& );
64 void OnCellLeftClick( wxGridEvent
& );
65 void OnRowSize( wxGridSizeEvent
& );
66 void OnColSize( wxGridSizeEvent
& );
67 void OnSelectCell( wxGridEvent
& );
68 void OnRangeSelected( wxGridRangeSelectEvent
& );
69 void OnCellValueChanged( wxGridEvent
& );
71 void OnEditorShown(wxGridEvent
&);
72 void OnEditorHidden(wxGridEvent
&);
78 void OnQuit( wxCommandEvent
& );
79 void About( wxCommandEvent
& );
80 void OnVTable( wxCommandEvent
& );
81 void OnBugsTable( wxCommandEvent
& );
85 ID_TOGGLEROWLABELS
= 100,
92 ID_SETLABELTEXTCOLOUR
,
94 ID_ROWLABELHORIZALIGN
,
97 ID_COLLABELHORIZALIGN
,
109 ID_SET_CELL_FG_COLOUR
,
110 ID_SET_CELL_BG_COLOUR
,
120 DECLARE_EVENT_TABLE()
123 class MyGridCellRenderer
: public wxGridCellStringRenderer
126 virtual void Draw(wxGrid
& grid
,
127 wxGridCellAttr
& attr
,
134 // ----------------------------------------------------------------------------
135 // demonstration of virtual table which doesn't store all of its data in
137 // ----------------------------------------------------------------------------
139 class BigGridTable
: public wxGridTableBase
142 BigGridTable(long sizeGrid
) { m_sizeGrid
= sizeGrid
; }
144 long GetNumberRows() { return m_sizeGrid
; }
145 long GetNumberCols() { return m_sizeGrid
; }
146 wxString
GetValue( int row
, int col
)
148 return wxString::Format("(%d, %d)", row
, col
);
151 void SetValue( int , int , const wxString
& ) { /* ignore */ }
152 bool IsEmptyCell( int , int ) { return FALSE
; }
158 class BigGridFrame
: public wxFrame
161 BigGridFrame(long sizeGrid
);
165 BigGridTable
* m_table
;
168 // ----------------------------------------------------------------------------
169 // an example of custom attr provider: this one makes all odd rows appear grey
170 // ----------------------------------------------------------------------------
172 class MyGridCellAttrProvider
: public wxGridCellAttrProvider
175 MyGridCellAttrProvider();
176 virtual ~MyGridCellAttrProvider();
178 virtual wxGridCellAttr
*GetAttr(int row
, int col
) const;
181 wxGridCellAttr
*m_attrForOddRows
;
184 // ----------------------------------------------------------------------------
185 // another, more realistic, grid example: shows typed columns and more
186 // ----------------------------------------------------------------------------
188 class BugsGridTable
: public wxGridTableBase
193 virtual long GetNumberRows();
194 virtual long GetNumberCols();
195 virtual bool IsEmptyCell( int row
, int col
);
196 virtual wxString
GetValue( int row
, int col
);
197 virtual void SetValue( int row
, int col
, const wxString
& value
);
199 virtual wxString
GetColLabelValue( int col
);
201 virtual wxString
GetTypeName( int row
, int col
);
202 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
203 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
205 virtual long GetValueAsLong( int row
, int col
);
206 virtual bool GetValueAsBool( int row
, int col
);
208 virtual void SetValueAsLong( int row
, int col
, long value
);
209 virtual void SetValueAsBool( int row
, int col
, bool value
);
212 class BugsGridFrame
: public wxFrame