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