]> git.saurik.com Git - wxWidgets.git/blame - samples/grid/griddemo.h
added hyperlink alignment flags (patch 1537043)
[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 wxString logBuf;
32
33 void SetDefaults();
34
35 void ToggleRowLabels( wxCommandEvent& );
36 void ToggleColLabels( wxCommandEvent& );
37 void ToggleEditing( wxCommandEvent& );
38 void ToggleRowSizing( wxCommandEvent& );
39 void ToggleColSizing( wxCommandEvent& );
d4175745 40 void ToggleColMoving( wxCommandEvent& );
f7556ff0 41 void ToggleGridSizing( wxCommandEvent& );
79dbea21 42 void ToggleGridDragCell ( 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& );
67
68 void DeselectCell(wxCommandEvent& event);
69 void DeselectCol(wxCommandEvent& event);
70 void DeselectRow(wxCommandEvent& event);
71 void DeselectAll(wxCommandEvent& event);
72 void SelectCell(wxCommandEvent& event);
73 void SelectCol(wxCommandEvent& event);
74 void SelectRow(wxCommandEvent& event);
75 void SelectAll(wxCommandEvent& event);
76 void OnAddToSelectToggle(wxCommandEvent& event);
1ecf2613 77 void OnShowSelection(wxCommandEvent& event);
f7556ff0
JS
78
79 void OnLabelLeftClick( wxGridEvent& );
80 void OnCellLeftClick( wxGridEvent& );
81 void OnRowSize( wxGridSizeEvent& );
82 void OnColSize( wxGridSizeEvent& );
83 void OnSelectCell( wxGridEvent& );
84 void OnRangeSelected( wxGridRangeSelectEvent& );
85 void OnCellValueChanged( wxGridEvent& );
79dbea21 86 void OnCellBeginDrag( wxGridEvent& );
f7556ff0
JS
87
88 void OnEditorShown(wxGridEvent&);
89 void OnEditorHidden(wxGridEvent&);
90
91 void OnSetHighlightWidth(wxCommandEvent&);
92 void OnSetROHighlightWidth(wxCommandEvent&);
93
94public:
95 GridFrame();
96 ~GridFrame();
97
98 void OnQuit( wxCommandEvent& );
99 void About( wxCommandEvent& );
100 void OnVTable( wxCommandEvent& );
101 void OnBugsTable( wxCommandEvent& );
102 void OnSmallGrid( wxCommandEvent& );
103
104 enum
105 {
106 ID_TOGGLEROWLABELS = 100,
107 ID_TOGGLECOLLABELS,
108 ID_TOGGLEEDIT,
109 ID_TOGGLEROWSIZING,
110 ID_TOGGLECOLSIZING,
d4175745 111 ID_TOGGLECOLMOVING,
f7556ff0 112 ID_TOGGLEGRIDSIZING,
79dbea21 113 ID_TOGGLEGRIDDRAGCELL,
f7556ff0
JS
114 ID_TOGGLEGRIDLINES,
115 ID_AUTOSIZECOLS,
116 ID_CELLOVERFLOW,
117 ID_RESIZECELL,
118 ID_SETLABELCOLOUR,
119 ID_SETLABELTEXTCOLOUR,
120 ID_SETLABEL_FONT,
121 ID_ROWLABELALIGN,
122 ID_ROWLABELHORIZALIGN,
123 ID_ROWLABELVERTALIGN,
124 ID_COLLABELALIGN,
125 ID_COLLABELHORIZALIGN,
126 ID_COLLABELVERTALIGN,
127 ID_GRIDLINECOLOUR,
128 ID_INSERTROW,
129 ID_INSERTCOL,
130 ID_DELETEROW,
131 ID_DELETECOL,
132 ID_CLEARGRID,
133 ID_CHANGESEL,
134 ID_SELCELLS,
135 ID_SELROWS,
136 ID_SELCOLS,
137 ID_SET_CELL_FG_COLOUR,
138 ID_SET_CELL_BG_COLOUR,
f7556ff0
JS
139 ID_VTABLE,
140 ID_BUGS_TABLE,
141 ID_SMALL_GRID,
142 ID_SELECT_UNSELECT,
1ecf2613 143 ID_SHOW_SELECTION,
f7556ff0
JS
144 ID_SELECT_ALL,
145 ID_SELECT_ROW,
146 ID_SELECT_COL,
147 ID_SELECT_CELL,
148 ID_DESELECT_ALL,
149 ID_DESELECT_ROW,
150 ID_DESELECT_COL,
151 ID_DESELECT_CELL,
152
153 ID_SET_HIGHLIGHT_WIDTH,
154 ID_SET_RO_HIGHLIGHT_WIDTH,
155
156 ID_TESTFUNC
157 };
158
f07941fc 159#if wxUSE_LOG
f7556ff0 160 wxLog *m_logOld;
f07941fc 161#endif // wxUSE_LOG
f7556ff0
JS
162
163 // add the cells to selection when using commands from select menu?
164 bool m_addToSel;
165
166 DECLARE_EVENT_TABLE()
167};
168
169class MyGridCellRenderer : public wxGridCellStringRenderer
170{
171public:
172 virtual void Draw(wxGrid& grid,
173 wxGridCellAttr& attr,
174 wxDC& dc,
175 const wxRect& rect,
176 int row, int col,
177 bool isSelected);
178};
179
180// ----------------------------------------------------------------------------
181// demonstration of virtual table which doesn't store all of its data in
182// memory
183// ----------------------------------------------------------------------------
184
185class BigGridTable : public wxGridTableBase
186{
187public:
188 BigGridTable(long sizeGrid) { m_sizeGrid = sizeGrid; }
189
190 int GetNumberRows() { return m_sizeGrid; }
191 int GetNumberCols() { return m_sizeGrid; }
192 wxString GetValue( int row, int col )
193 {
194 return wxString::Format(wxT("(%d, %d)"), row, col);
195 }
196
197 void SetValue( int , int , const wxString& ) { /* ignore */ }
af870ed8 198 bool IsEmptyCell( int , int ) { return false; }
f7556ff0
JS
199
200private:
201 long m_sizeGrid;
202};
203
204class BigGridFrame : public wxFrame
205{
206public:
207 BigGridFrame(long sizeGrid);
208
209private:
210 wxGrid* m_grid;
211 BigGridTable* m_table;
212};
213
214// ----------------------------------------------------------------------------
215// an example of custom attr provider: this one makes all odd rows appear grey
216// ----------------------------------------------------------------------------
217
218class MyGridCellAttrProvider : public wxGridCellAttrProvider
219{
220public:
221 MyGridCellAttrProvider();
222 virtual ~MyGridCellAttrProvider();
223
224 virtual wxGridCellAttr *GetAttr(int row, int col,
225 wxGridCellAttr::wxAttrKind kind) const;
226
227private:
228 wxGridCellAttr *m_attrForOddRows;
229};
230
231// ----------------------------------------------------------------------------
232// another, more realistic, grid example: shows typed columns and more
233// ----------------------------------------------------------------------------
234
235class BugsGridTable : public wxGridTableBase
236{
237public:
925e9792 238 BugsGridTable(){};
f7556ff0
JS
239
240 virtual int GetNumberRows();
241 virtual int GetNumberCols();
242 virtual bool IsEmptyCell( int row, int col );
243 virtual wxString GetValue( int row, int col );
244 virtual void SetValue( int row, int col, const wxString& value );
245
246 virtual wxString GetColLabelValue( int col );
247
248 virtual wxString GetTypeName( int row, int col );
249 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
250 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
251
252 virtual long GetValueAsLong( int row, int col );
253 virtual bool GetValueAsBool( int row, int col );
254
255 virtual void SetValueAsLong( int row, int col, long value );
256 virtual void SetValueAsBool( int row, int col, bool value );
257};
258
259class BugsGridFrame : public wxFrame
260{
261public:
262 BugsGridFrame();
263};
264
265
266#endif // griddemo_h
267