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