]> git.saurik.com Git - wxWidgets.git/blame_incremental - samples/grid/griddemo.h
Add a wxHtmlTag helper parsing both absolute values and percents.
[wxWidgets.git] / samples / grid / griddemo.h
... / ...
CommitLineData
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
15class wxGrid;
16
17class GridApp : public wxApp
18{
19public:
20 bool OnInit();
21};
22
23
24class 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 OnLabelLeftClick( wxGridEvent& );
92 void OnCellLeftClick( wxGridEvent& );
93 void OnRowSize( wxGridSizeEvent& );
94 void OnColSize( wxGridSizeEvent& );
95 void OnSelectCell( wxGridEvent& );
96 void OnRangeSelected( wxGridRangeSelectEvent& );
97 void OnCellValueChanging( wxGridEvent& );
98 void OnCellValueChanged( wxGridEvent& );
99 void OnCellBeginDrag( wxGridEvent& );
100
101 void OnEditorShown(wxGridEvent&);
102 void OnEditorHidden(wxGridEvent&);
103
104 void OnSetHighlightWidth(wxCommandEvent&);
105 void OnSetROHighlightWidth(wxCommandEvent&);
106
107 void OnGridCustomTab(wxGridEvent& event);
108
109public:
110 GridFrame();
111 ~GridFrame();
112
113 void OnQuit( wxCommandEvent& );
114 void About( wxCommandEvent& );
115 void OnVTable( wxCommandEvent& );
116 void OnBugsTable( wxCommandEvent& );
117 void OnTabularTable( wxCommandEvent& );
118 void OnGridRender( wxCommandEvent& event );
119 void OnRenderPaint( wxPaintEvent& event );
120
121 enum
122 {
123 ID_TOGGLEROWLABELS = 100,
124 ID_TOGGLECOLLABELS,
125 ID_TOGGLEEDIT,
126 ID_TOGGLEROWSIZING,
127 ID_TOGGLECOLSIZING,
128 ID_TOGGLECOLMOVING,
129 ID_TOGGLEGRIDSIZING,
130 ID_TOGGLEGRIDDRAGCELL,
131 ID_TOGGLEGRIDLINES,
132 ID_AUTOSIZECOLS,
133 ID_CELLOVERFLOW,
134 ID_RESIZECELL,
135 ID_SETLABELCOLOUR,
136 ID_SETLABELTEXTCOLOUR,
137 ID_SETLABEL_FONT,
138 ID_ROWLABELALIGN,
139 ID_ROWLABELHORIZALIGN,
140 ID_ROWLABELVERTALIGN,
141 ID_COLLABELALIGN,
142 ID_COLLABELHORIZALIGN,
143 ID_COLLABELVERTALIGN,
144 ID_COLDEFAULTHEADER,
145 ID_COLNATIVEHEADER,
146 ID_COLCUSTOMHEADER,
147 ID_TAB_STOP,
148 ID_TAB_WRAP,
149 ID_TAB_LEAVE,
150 ID_TAB_CUSTOM,
151 ID_GRIDLINECOLOUR,
152 ID_INSERTROW,
153 ID_INSERTCOL,
154 ID_DELETEROW,
155 ID_DELETECOL,
156 ID_CLEARGRID,
157 ID_CHANGESEL,
158 ID_SELCELLS,
159 ID_SELROWS,
160 ID_SELCOLS,
161 ID_SELROWSORCOLS,
162 ID_SET_CELL_FG_COLOUR,
163 ID_SET_CELL_BG_COLOUR,
164 ID_VTABLE,
165 ID_BUGS_TABLE,
166 ID_TABULAR_TABLE,
167 ID_SELECT_UNSELECT,
168 ID_SELECT_ALL,
169 ID_SELECT_ROW,
170 ID_SELECT_COL,
171 ID_SELECT_CELL,
172 ID_DESELECT_ALL,
173 ID_DESELECT_ROW,
174 ID_DESELECT_COL,
175 ID_DESELECT_CELL,
176 ID_SIZE_ROW,
177 ID_SIZE_COL,
178 ID_SIZE_ROW_LABEL,
179 ID_SIZE_COL_LABEL,
180 ID_SIZE_LABELS_COL,
181 ID_SIZE_LABELS_ROW,
182 ID_SIZE_GRID,
183
184 ID_SET_HIGHLIGHT_WIDTH,
185 ID_SET_RO_HIGHLIGHT_WIDTH,
186
187 ID_TESTFUNC,
188
189 ID_RENDER_ROW_LABEL,
190 ID_RENDER_COL_LABEL,
191 ID_RENDER_GRID_LINES,
192 ID_RENDER_GRID_BORDER,
193 ID_RENDER_SELECT_HLIGHT,
194 ID_RENDER_LOMETRIC,
195 ID_RENDER_COORDS,
196 ID_RENDER_ZOOM,
197 ID_RENDER_MARGIN,
198 ID_RENDER_DEFAULT_SIZE,
199 };
200
201#if wxUSE_LOG
202 wxLog *m_logOld;
203#endif // wxUSE_LOG
204
205 // add the cells to selection when using commands from select menu?
206 bool m_addToSel;
207
208 wxBitmap m_gridBitmap;
209
210 DECLARE_EVENT_TABLE()
211};
212
213class MyGridCellRenderer : public wxGridCellStringRenderer
214{
215public:
216 virtual void Draw(wxGrid& grid,
217 wxGridCellAttr& attr,
218 wxDC& dc,
219 const wxRect& rect,
220 int row, int col,
221 bool isSelected);
222};
223
224// ----------------------------------------------------------------------------
225// demonstration of virtual table which doesn't store all of its data in
226// memory
227// ----------------------------------------------------------------------------
228
229class BigGridTable : public wxGridTableBase
230{
231public:
232 BigGridTable(long sizeGrid) { m_sizeGrid = sizeGrid; }
233
234 int GetNumberRows() { return m_sizeGrid; }
235 int GetNumberCols() { return m_sizeGrid; }
236 wxString GetValue( int row, int col )
237 {
238 return wxString::Format(wxT("(%d, %d)"), row, col);
239 }
240
241 void SetValue( int , int , const wxString& ) { /* ignore */ }
242 bool IsEmptyCell( int , int ) { return false; }
243
244private:
245 long m_sizeGrid;
246};
247
248class BigGridFrame : public wxFrame
249{
250public:
251 BigGridFrame(long sizeGrid);
252
253private:
254 wxGrid* m_grid;
255 BigGridTable* m_table;
256};
257
258// ----------------------------------------------------------------------------
259// an example of custom attr provider: this one makes all odd rows appear grey
260// ----------------------------------------------------------------------------
261
262class MyGridCellAttrProvider : public wxGridCellAttrProvider
263{
264public:
265 MyGridCellAttrProvider();
266 virtual ~MyGridCellAttrProvider();
267
268 virtual wxGridCellAttr *GetAttr(int row, int col,
269 wxGridCellAttr::wxAttrKind kind) const;
270
271private:
272 wxGridCellAttr *m_attrForOddRows;
273};
274
275// ----------------------------------------------------------------------------
276// another, more realistic, grid example: shows typed columns and more
277// ----------------------------------------------------------------------------
278
279class BugsGridTable : public wxGridTableBase
280{
281public:
282 BugsGridTable() { }
283
284 virtual int GetNumberRows();
285 virtual int GetNumberCols();
286 virtual bool IsEmptyCell( int row, int col );
287 virtual wxString GetValue( int row, int col );
288 virtual void SetValue( int row, int col, const wxString& value );
289
290 virtual wxString GetColLabelValue( int col );
291
292 virtual wxString GetTypeName( int row, int col );
293 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
294 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
295
296 virtual long GetValueAsLong( int row, int col );
297 virtual bool GetValueAsBool( int row, int col );
298
299 virtual void SetValueAsLong( int row, int col, long value );
300 virtual void SetValueAsBool( int row, int col, bool value );
301};
302
303class BugsGridFrame : public wxFrame
304{
305public:
306 BugsGridFrame();
307};
308
309
310#endif // griddemo_h
311