]> git.saurik.com Git - wxWidgets.git/blame - samples/grid/griddemo.h
use a slightly less ugly way to conditionally suppress unused parameter warnings
[wxWidgets.git] / samples / grid / griddemo.h
CommitLineData
f7556ff0
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: griddemo.h
be5a51fb 3// Purpose: Grid control wxWidgets sample
f7556ff0
JS
4// Author: Michael Bedward
5// Modified by:
6// RCS-ID: $Id$
7// Copyright: (c) Michael Bedward, Julian Smart
8// Licence: wxWindows license
9/////////////////////////////////////////////////////////////////////////////
10
11
12#ifndef griddemo_h
13#define griddemo_h
14
f7556ff0
JS
15class wxGrid;
16
17class GridApp : public wxApp
18{
19public:
20 bool OnInit();
21};
22
23
24class GridFrame : public wxFrame
25{
26 wxGrid *grid;
f07941fc 27#if wxUSE_LOG
f7556ff0
JS
28 wxTextCtrl *logWin;
29 wxLogTextCtrl *logger;
f07941fc 30#endif // wxUSE_LOG
f7556ff0
JS
31
32 void SetDefaults();
33
34 void ToggleRowLabels( wxCommandEvent& );
35 void ToggleColLabels( wxCommandEvent& );
36 void ToggleEditing( wxCommandEvent& );
37 void ToggleRowSizing( wxCommandEvent& );
38 void ToggleColSizing( wxCommandEvent& );
d4175745 39 void ToggleColMoving( wxCommandEvent& );
f7556ff0 40 void ToggleGridSizing( wxCommandEvent& );
79dbea21 41 void ToggleGridDragCell ( wxCommandEvent& );
4a25320b 42 void ToggleNativeHeader ( wxCommandEvent& );
f7556ff0
JS
43 void ToggleGridLines( wxCommandEvent& );
44 void AutoSizeCols( wxCommandEvent& );
45 void CellOverflow( wxCommandEvent& );
46 void ResizeCell( wxCommandEvent& );
47 void SetLabelColour( wxCommandEvent& );
48 void SetLabelTextColour( wxCommandEvent& );
49 void SetLabelFont(wxCommandEvent &);
50 void SetRowLabelHorizAlignment( wxCommandEvent& );
51 void SetRowLabelVertAlignment( wxCommandEvent& );
52 void SetColLabelHorizAlignment( wxCommandEvent& );
53 void SetColLabelVertAlignment( wxCommandEvent& );
54 void SetGridLineColour( wxCommandEvent& );
55
56 void SetCellFgColour(wxCommandEvent &);
57 void SetCellBgColour(wxCommandEvent &);
58
59 void InsertRow( wxCommandEvent& );
60 void InsertCol( wxCommandEvent& );
61 void DeleteSelectedRows( wxCommandEvent& );
62 void DeleteSelectedCols( wxCommandEvent& );
63 void ClearGrid( wxCommandEvent& );
64 void SelectCells( wxCommandEvent& );
65 void SelectRows( wxCommandEvent& );
66 void SelectCols( wxCommandEvent& );
8a3e536c 67 void SelectRowsOrCols( wxCommandEvent& );
f7556ff0
JS
68
69 void DeselectCell(wxCommandEvent& event);
70 void DeselectCol(wxCommandEvent& event);
71 void DeselectRow(wxCommandEvent& event);
72 void DeselectAll(wxCommandEvent& event);
73 void SelectCell(wxCommandEvent& event);
74 void SelectCol(wxCommandEvent& event);
75 void SelectRow(wxCommandEvent& event);
76 void SelectAll(wxCommandEvent& event);
77 void OnAddToSelectToggle(wxCommandEvent& event);
1ecf2613 78 void OnShowSelection(wxCommandEvent& event);
f7556ff0 79
733f486a
VZ
80 void AutoSizeRow(wxCommandEvent& event);
81 void AutoSizeCol(wxCommandEvent& event);
82 void AutoSizeRowLabel(wxCommandEvent& event);
83 void AutoSizeColLabel(wxCommandEvent& event);
84 void AutoSizeLabelsCol(wxCommandEvent& event);
85 void AutoSizeLabelsRow(wxCommandEvent& event);
86 void AutoSizeTable(wxCommandEvent& event);
87
f7556ff0
JS
88 void OnLabelLeftClick( wxGridEvent& );
89 void OnCellLeftClick( wxGridEvent& );
90 void OnRowSize( wxGridSizeEvent& );
91 void OnColSize( wxGridSizeEvent& );
92 void OnSelectCell( wxGridEvent& );
93 void OnRangeSelected( wxGridRangeSelectEvent& );
94 void OnCellValueChanged( wxGridEvent& );
79dbea21 95 void OnCellBeginDrag( wxGridEvent& );
f7556ff0
JS
96
97 void OnEditorShown(wxGridEvent&);
98 void OnEditorHidden(wxGridEvent&);
99
100 void OnSetHighlightWidth(wxCommandEvent&);
101 void OnSetROHighlightWidth(wxCommandEvent&);
102
103public:
104 GridFrame();
105 ~GridFrame();
106
107 void OnQuit( wxCommandEvent& );
108 void About( wxCommandEvent& );
109 void OnVTable( wxCommandEvent& );
110 void OnBugsTable( wxCommandEvent& );
e7ae8a69 111 void OnTabularTable( wxCommandEvent& );
f7556ff0
JS
112
113 enum
114 {
115 ID_TOGGLEROWLABELS = 100,
116 ID_TOGGLECOLLABELS,
117 ID_TOGGLEEDIT,
118 ID_TOGGLEROWSIZING,
119 ID_TOGGLECOLSIZING,
d4175745 120 ID_TOGGLECOLMOVING,
f7556ff0 121 ID_TOGGLEGRIDSIZING,
79dbea21 122 ID_TOGGLEGRIDDRAGCELL,
4a25320b 123 ID_TOGGLENATIVEHEADER,
f7556ff0
JS
124 ID_TOGGLEGRIDLINES,
125 ID_AUTOSIZECOLS,
126 ID_CELLOVERFLOW,
127 ID_RESIZECELL,
128 ID_SETLABELCOLOUR,
129 ID_SETLABELTEXTCOLOUR,
130 ID_SETLABEL_FONT,
131 ID_ROWLABELALIGN,
132 ID_ROWLABELHORIZALIGN,
133 ID_ROWLABELVERTALIGN,
134 ID_COLLABELALIGN,
135 ID_COLLABELHORIZALIGN,
136 ID_COLLABELVERTALIGN,
137 ID_GRIDLINECOLOUR,
138 ID_INSERTROW,
139 ID_INSERTCOL,
140 ID_DELETEROW,
141 ID_DELETECOL,
142 ID_CLEARGRID,
143 ID_CHANGESEL,
144 ID_SELCELLS,
145 ID_SELROWS,
146 ID_SELCOLS,
8a3e536c 147 ID_SELROWSORCOLS,
f7556ff0
JS
148 ID_SET_CELL_FG_COLOUR,
149 ID_SET_CELL_BG_COLOUR,
f7556ff0
JS
150 ID_VTABLE,
151 ID_BUGS_TABLE,
e7ae8a69 152 ID_TABULAR_TABLE,
f7556ff0 153 ID_SELECT_UNSELECT,
1ecf2613 154 ID_SHOW_SELECTION,
f7556ff0
JS
155 ID_SELECT_ALL,
156 ID_SELECT_ROW,
157 ID_SELECT_COL,
158 ID_SELECT_CELL,
159 ID_DESELECT_ALL,
160 ID_DESELECT_ROW,
161 ID_DESELECT_COL,
162 ID_DESELECT_CELL,
733f486a
VZ
163 ID_SIZE_ROW,
164 ID_SIZE_COL,
165 ID_SIZE_ROW_LABEL,
166 ID_SIZE_COL_LABEL,
167 ID_SIZE_LABELS_COL,
168 ID_SIZE_LABELS_ROW,
169 ID_SIZE_GRID,
f7556ff0
JS
170
171 ID_SET_HIGHLIGHT_WIDTH,
172 ID_SET_RO_HIGHLIGHT_WIDTH,
173
174 ID_TESTFUNC
175 };
176
f07941fc 177#if wxUSE_LOG
f7556ff0 178 wxLog *m_logOld;
f07941fc 179#endif // wxUSE_LOG
f7556ff0
JS
180
181 // add the cells to selection when using commands from select menu?
182 bool m_addToSel;
183
184 DECLARE_EVENT_TABLE()
185};
186
187class MyGridCellRenderer : public wxGridCellStringRenderer
188{
189public:
190 virtual void Draw(wxGrid& grid,
191 wxGridCellAttr& attr,
192 wxDC& dc,
193 const wxRect& rect,
194 int row, int col,
195 bool isSelected);
196};
197
198// ----------------------------------------------------------------------------
199// demonstration of virtual table which doesn't store all of its data in
200// memory
201// ----------------------------------------------------------------------------
202
203class BigGridTable : public wxGridTableBase
204{
205public:
206 BigGridTable(long sizeGrid) { m_sizeGrid = sizeGrid; }
207
208 int GetNumberRows() { return m_sizeGrid; }
209 int GetNumberCols() { return m_sizeGrid; }
210 wxString GetValue( int row, int col )
211 {
212 return wxString::Format(wxT("(%d, %d)"), row, col);
213 }
214
215 void SetValue( int , int , const wxString& ) { /* ignore */ }
af870ed8 216 bool IsEmptyCell( int , int ) { return false; }
f7556ff0
JS
217
218private:
219 long m_sizeGrid;
220};
221
222class BigGridFrame : public wxFrame
223{
224public:
225 BigGridFrame(long sizeGrid);
226
227private:
228 wxGrid* m_grid;
229 BigGridTable* m_table;
230};
231
232// ----------------------------------------------------------------------------
233// an example of custom attr provider: this one makes all odd rows appear grey
234// ----------------------------------------------------------------------------
235
236class MyGridCellAttrProvider : public wxGridCellAttrProvider
237{
238public:
239 MyGridCellAttrProvider();
240 virtual ~MyGridCellAttrProvider();
241
242 virtual wxGridCellAttr *GetAttr(int row, int col,
243 wxGridCellAttr::wxAttrKind kind) const;
244
245private:
246 wxGridCellAttr *m_attrForOddRows;
247};
248
249// ----------------------------------------------------------------------------
250// another, more realistic, grid example: shows typed columns and more
251// ----------------------------------------------------------------------------
252
253class BugsGridTable : public wxGridTableBase
254{
255public:
e7ae8a69 256 BugsGridTable() { }
f7556ff0
JS
257
258 virtual int GetNumberRows();
259 virtual int GetNumberCols();
260 virtual bool IsEmptyCell( int row, int col );
261 virtual wxString GetValue( int row, int col );
262 virtual void SetValue( int row, int col, const wxString& value );
263
264 virtual wxString GetColLabelValue( int col );
265
266 virtual wxString GetTypeName( int row, int col );
267 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
268 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
269
270 virtual long GetValueAsLong( int row, int col );
271 virtual bool GetValueAsBool( int row, int col );
272
273 virtual void SetValueAsLong( int row, int col, long value );
274 virtual void SetValueAsBool( int row, int col, bool value );
275};
276
277class BugsGridFrame : public wxFrame
278{
279public:
280 BugsGridFrame();
281};
282
283
284#endif // griddemo_h
285