]> git.saurik.com Git - wxWidgets.git/blame - samples/newgrid/griddemo.h
First draft of a cygwin script to create wxMSW distributions
[wxWidgets.git] / samples / newgrid / griddemo.h
CommitLineData
10434f3c
MB
1/////////////////////////////////////////////////////////////////////////////
2// Name: griddemo.h
3// Purpose: Grid control wxWindows sample
4// Author: Michael Bedward
5// Modified by:
6// RCS-ID: $Id$
7// Copyright: (c) Michael Bedward, Julian Smart
8// Licence: wxWindows license
9/////////////////////////////////////////////////////////////////////////////
e442cc0d
MB
10
11
12#ifndef griddemo_h
13#define griddemo_h
14
b99be8fb
VZ
15#if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID)
16 #error "This sample requires the new wxGrid class."
17#endif
e442cc0d
MB
18
19class wxGrid;
20
21class GridApp : public wxApp
22{
ab79958a 23public:
e442cc0d
MB
24 bool OnInit();
25};
26
27
28class GridFrame : public wxFrame
29{
30 wxGrid *grid;
31 wxTextCtrl *logWin;
32 wxLogTextCtrl *logger;
33 wxString logBuf;
34
35 void SetDefaults();
f445b853 36
e442cc0d
MB
37 void ToggleRowLabels( wxCommandEvent& );
38 void ToggleColLabels( wxCommandEvent& );
f445b853 39 void ToggleEditing( wxCommandEvent& );
dd16fdae
MB
40 void ToggleRowSizing( wxCommandEvent& );
41 void ToggleColSizing( wxCommandEvent& );
4cfa5de6 42 void ToggleGridSizing( wxCommandEvent& );
f6bcfd97
BP
43 void ToggleGridLines( wxCommandEvent& );
44 void AutoSizeCols( wxCommandEvent& );
e442cc0d
MB
45 void SetLabelColour( wxCommandEvent& );
46 void SetLabelTextColour( wxCommandEvent& );
47 void SetRowLabelHorizAlignment( wxCommandEvent& );
48 void SetRowLabelVertAlignment( wxCommandEvent& );
49 void SetColLabelHorizAlignment( wxCommandEvent& );
50 void SetColLabelVertAlignment( wxCommandEvent& );
51 void SetGridLineColour( wxCommandEvent& );
0eee5283 52
ab79958a
VZ
53 void SetCellFgColour(wxCommandEvent &);
54 void SetCellBgColour(wxCommandEvent &);
55
b99be8fb
VZ
56 void InsertRow( wxCommandEvent& );
57 void InsertCol( wxCommandEvent& );
58 void DeleteSelectedRows( wxCommandEvent& );
59 void DeleteSelectedCols( wxCommandEvent& );
e442cc0d 60 void ClearGrid( wxCommandEvent& );
043d16b2
SN
61 void SelectCells( wxCommandEvent& );
62 void SelectRows( wxCommandEvent& );
63 void SelectCols( wxCommandEvent& );
e442cc0d 64
e442cc0d
MB
65 void OnLabelLeftClick( wxGridEvent& );
66 void OnCellLeftClick( wxGridEvent& );
67 void OnRowSize( wxGridSizeEvent& );
68 void OnColSize( wxGridSizeEvent& );
c336585e 69 void OnSelectCell( wxGridEvent& );
e442cc0d
MB
70 void OnRangeSelected( wxGridRangeSelectEvent& );
71 void OnCellValueChanged( wxGridEvent& );
b99be8fb 72
b54ba671
VZ
73 void OnEditorShown(wxGridEvent&);
74 void OnEditorHidden(wxGridEvent&);
75
ab79958a 76public:
e442cc0d
MB
77 GridFrame();
78 ~GridFrame();
79
e442cc0d 80 void OnQuit( wxCommandEvent& );
f445b853 81 void About( wxCommandEvent& );
f97c9b5b 82 void OnVTable( wxCommandEvent& );
35f97e95 83 void OnBugsTable( wxCommandEvent& );
e442cc0d 84
ab79958a
VZ
85 enum
86 {
87 ID_TOGGLEROWLABELS = 100,
88 ID_TOGGLECOLLABELS,
89 ID_TOGGLEEDIT,
dd16fdae
MB
90 ID_TOGGLEROWSIZING,
91 ID_TOGGLECOLSIZING,
4cfa5de6 92 ID_TOGGLEGRIDSIZING,
f6bcfd97
BP
93 ID_TOGGLEGRIDLINES,
94 ID_AUTOSIZECOLS,
ab79958a
VZ
95 ID_SETLABELCOLOUR,
96 ID_SETLABELTEXTCOLOUR,
97 ID_ROWLABELALIGN,
98 ID_ROWLABELHORIZALIGN,
99 ID_ROWLABELVERTALIGN,
100 ID_COLLABELALIGN,
101 ID_COLLABELHORIZALIGN,
102 ID_COLLABELVERTALIGN,
103 ID_GRIDLINECOLOUR,
104 ID_INSERTROW,
105 ID_INSERTCOL,
106 ID_DELETEROW,
107 ID_DELETECOL,
108 ID_CLEARGRID,
043d16b2
SN
109 ID_CHANGESEL,
110 ID_SELCELLS,
111 ID_SELROWS,
112 ID_SELCOLS,
ab79958a
VZ
113 ID_SET_CELL_FG_COLOUR,
114 ID_SET_CELL_BG_COLOUR,
115 ID_ABOUT,
f97c9b5b 116 ID_VTABLE,
35f97e95 117 ID_BUGS_TABLE,
ab79958a
VZ
118
119 ID_TESTFUNC
120 };
b99be8fb 121
66b3609e
VZ
122 wxLog *m_logOld;
123
e442cc0d
MB
124 DECLARE_EVENT_TABLE()
125};
126
ab79958a
VZ
127class MyGridCellRenderer : public wxGridCellStringRenderer
128{
129public:
130 virtual void Draw(wxGrid& grid,
f97c9b5b 131 wxGridCellAttr& attr,
ab79958a
VZ
132 wxDC& dc,
133 const wxRect& rect,
134 int row, int col,
135 bool isSelected);
136};
e442cc0d 137
1618dca7
VZ
138// ----------------------------------------------------------------------------
139// demonstration of virtual table which doesn't store all of its data in
140// memory
141// ----------------------------------------------------------------------------
f97c9b5b 142
1618dca7
VZ
143class BigGridTable : public wxGridTableBase
144{
f97c9b5b 145public:
1618dca7
VZ
146 BigGridTable(long sizeGrid) { m_sizeGrid = sizeGrid; }
147
e32352cf
SN
148 int GetNumberRows() { return m_sizeGrid; }
149 int GetNumberCols() { return m_sizeGrid; }
1618dca7
VZ
150 wxString GetValue( int row, int col )
151 {
152 return wxString::Format("(%d, %d)", row, col);
f97c9b5b
RD
153 }
154
1618dca7 155 void SetValue( int , int , const wxString& ) { /* ignore */ }
f97c9b5b 156 bool IsEmptyCell( int , int ) { return FALSE; }
1618dca7
VZ
157
158private:
159 long m_sizeGrid;
f97c9b5b
RD
160};
161
1618dca7
VZ
162class BigGridFrame : public wxFrame
163{
f97c9b5b 164public:
1618dca7 165 BigGridFrame(long sizeGrid);
f97c9b5b
RD
166
167private:
168 wxGrid* m_grid;
169 BigGridTable* m_table;
170};
171
a68c1246
VZ
172// ----------------------------------------------------------------------------
173// an example of custom attr provider: this one makes all odd rows appear grey
174// ----------------------------------------------------------------------------
175
176class MyGridCellAttrProvider : public wxGridCellAttrProvider
177{
178public:
179 MyGridCellAttrProvider();
180 virtual ~MyGridCellAttrProvider();
181
182 virtual wxGridCellAttr *GetAttr(int row, int col) const;
183
184private:
185 wxGridCellAttr *m_attrForOddRows;
186};
187
35f97e95 188// ----------------------------------------------------------------------------
816be743 189// another, more realistic, grid example: shows typed columns and more
35f97e95
VZ
190// ----------------------------------------------------------------------------
191
816be743
VZ
192class BugsGridTable : public wxGridTableBase
193{
194public:
195 BugsGridTable();
196
e32352cf
SN
197 virtual int GetNumberRows();
198 virtual int GetNumberCols();
816be743
VZ
199 virtual bool IsEmptyCell( int row, int col );
200 virtual wxString GetValue( int row, int col );
201 virtual void SetValue( int row, int col, const wxString& value );
202
203 virtual wxString GetColLabelValue( int col );
204
205 virtual wxString GetTypeName( int row, int col );
206 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
207 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
208
209 virtual long GetValueAsLong( int row, int col );
210 virtual bool GetValueAsBool( int row, int col );
211
212 virtual void SetValueAsLong( int row, int col, long value );
213 virtual void SetValueAsBool( int row, int col, bool value );
214};
215
35f97e95
VZ
216class BugsGridFrame : public wxFrame
217{
218public:
219 BugsGridFrame();
220};
f97c9b5b 221
1618dca7 222#endif // griddemo_h
e442cc0d 223