]>
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 BigGridTable
: public wxGridTableBase
131 BigGridTable(long sizeGrid
) { m_sizeGrid
= sizeGrid
; }
133 long GetNumberRows() { return m_sizeGrid
; }
134 long GetNumberCols() { return m_sizeGrid
; }
135 wxString
GetValue( int row
, int col
)
137 return wxString::Format("(%d, %d)", row
, col
);
140 void SetValue( int , int , const wxString
& ) { /* ignore */ }
141 bool IsEmptyCell( int , int ) { return FALSE
; }
147 class BigGridFrame
: public wxFrame
150 BigGridFrame(long sizeGrid
);
154 BigGridTable
* m_table
;
157 // ----------------------------------------------------------------------------
158 // another, more realistic, grid example: shows typed columns and more
159 // ----------------------------------------------------------------------------
161 class BugsGridTable
: public wxGridTableBase
166 virtual long GetNumberRows();
167 virtual long GetNumberCols();
168 virtual bool IsEmptyCell( int row
, int col
);
169 virtual wxString
GetValue( int row
, int col
);
170 virtual void SetValue( int row
, int col
, const wxString
& value
);
172 virtual wxString
GetColLabelValue( int col
);
174 virtual wxString
GetTypeName( int row
, int col
);
175 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
176 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
178 virtual long GetValueAsLong( int row
, int col
);
179 virtual bool GetValueAsBool( int row
, int col
);
181 virtual void SetValueAsLong( int row
, int col
, long value
);
182 virtual void SetValueAsBool( int row
, int col
, bool value
);
185 class BugsGridFrame
: public wxFrame