]>
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 ToggleGridLines( wxCommandEvent
& );
44 void AutoSizeCols( wxCommandEvent
& );
45 void SetLabelColour( wxCommandEvent
& );
46 void SetLabelTextColour( wxCommandEvent
& );
47 void SetRowLabelHorizAlignment( wxCommandEvent
& );
48 void SetRowLabelVertAlignment( wxCommandEvent
& );
49 void SetColLabelHorizAlignment( wxCommandEvent
& );
50 void SetColLabelVertAlignment( wxCommandEvent
& );
51 void SetGridLineColour( wxCommandEvent
& );
53 void SetCellFgColour(wxCommandEvent
&);
54 void SetCellBgColour(wxCommandEvent
&);
56 void InsertRow( wxCommandEvent
& );
57 void InsertCol( wxCommandEvent
& );
58 void DeleteSelectedRows( wxCommandEvent
& );
59 void DeleteSelectedCols( wxCommandEvent
& );
60 void ClearGrid( wxCommandEvent
& );
61 void SelectCells( wxCommandEvent
& );
62 void SelectRows( wxCommandEvent
& );
63 void SelectCols( wxCommandEvent
& );
65 void OnLabelLeftClick( wxGridEvent
& );
66 void OnCellLeftClick( wxGridEvent
& );
67 void OnRowSize( wxGridSizeEvent
& );
68 void OnColSize( wxGridSizeEvent
& );
69 void OnSelectCell( wxGridEvent
& );
70 void OnRangeSelected( wxGridRangeSelectEvent
& );
71 void OnCellValueChanged( wxGridEvent
& );
73 void OnEditorShown(wxGridEvent
&);
74 void OnEditorHidden(wxGridEvent
&);
80 void OnQuit( wxCommandEvent
& );
81 void About( wxCommandEvent
& );
82 void OnVTable( wxCommandEvent
& );
83 void OnBugsTable( wxCommandEvent
& );
87 ID_TOGGLEROWLABELS
= 100,
96 ID_SETLABELTEXTCOLOUR
,
98 ID_ROWLABELHORIZALIGN
,
101 ID_COLLABELHORIZALIGN
,
102 ID_COLLABELVERTALIGN
,
113 ID_SET_CELL_FG_COLOUR
,
114 ID_SET_CELL_BG_COLOUR
,
124 DECLARE_EVENT_TABLE()
127 class MyGridCellRenderer
: public wxGridCellStringRenderer
130 virtual void Draw(wxGrid
& grid
,
131 wxGridCellAttr
& attr
,
138 // ----------------------------------------------------------------------------
139 // demonstration of virtual table which doesn't store all of its data in
141 // ----------------------------------------------------------------------------
143 class BigGridTable
: public wxGridTableBase
146 BigGridTable(long sizeGrid
) { m_sizeGrid
= sizeGrid
; }
148 int GetNumberRows() { return m_sizeGrid
; }
149 int GetNumberCols() { return m_sizeGrid
; }
150 wxString
GetValue( int row
, int col
)
152 return wxString::Format("(%d, %d)", row
, col
);
155 void SetValue( int , int , const wxString
& ) { /* ignore */ }
156 bool IsEmptyCell( int , int ) { return FALSE
; }
162 class BigGridFrame
: public wxFrame
165 BigGridFrame(long sizeGrid
);
169 BigGridTable
* m_table
;
172 // ----------------------------------------------------------------------------
173 // an example of custom attr provider: this one makes all odd rows appear grey
174 // ----------------------------------------------------------------------------
176 class MyGridCellAttrProvider
: public wxGridCellAttrProvider
179 MyGridCellAttrProvider();
180 virtual ~MyGridCellAttrProvider();
182 virtual wxGridCellAttr
*GetAttr(int row
, int col
) const;
185 wxGridCellAttr
*m_attrForOddRows
;
188 // ----------------------------------------------------------------------------
189 // another, more realistic, grid example: shows typed columns and more
190 // ----------------------------------------------------------------------------
192 class BugsGridTable
: public wxGridTableBase
197 virtual int GetNumberRows();
198 virtual int GetNumberCols();
199 virtual bool IsEmptyCell( int row
, int col
);
200 virtual wxString
GetValue( int row
, int col
);
201 virtual void SetValue( int row
, int col
, const wxString
& value
);
203 virtual wxString
GetColLabelValue( int col
);
205 virtual wxString
GetTypeName( int row
, int col
);
206 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
207 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
209 virtual long GetValueAsLong( int row
, int col
);
210 virtual bool GetValueAsBool( int row
, int col
);
212 virtual void SetValueAsLong( int row
, int col
, long value
);
213 virtual void SetValueAsBool( int row
, int col
, bool value
);
216 class BugsGridFrame
: public wxFrame