]>
Commit | Line | Data |
---|---|---|
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 | |
19 | class wxGrid; | |
20 | ||
21 | class GridApp : public wxApp | |
22 | { | |
ab79958a | 23 | public: |
e442cc0d MB |
24 | bool OnInit(); |
25 | }; | |
26 | ||
27 | ||
28 | class 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& ); |
e442cc0d MB |
40 | void SetLabelColour( wxCommandEvent& ); |
41 | void SetLabelTextColour( wxCommandEvent& ); | |
42 | void SetRowLabelHorizAlignment( wxCommandEvent& ); | |
43 | void SetRowLabelVertAlignment( wxCommandEvent& ); | |
44 | void SetColLabelHorizAlignment( wxCommandEvent& ); | |
45 | void SetColLabelVertAlignment( wxCommandEvent& ); | |
46 | void SetGridLineColour( wxCommandEvent& ); | |
0eee5283 | 47 | |
ab79958a VZ |
48 | void SetCellFgColour(wxCommandEvent &); |
49 | void SetCellBgColour(wxCommandEvent &); | |
50 | ||
b99be8fb VZ |
51 | void InsertRow( wxCommandEvent& ); |
52 | void InsertCol( wxCommandEvent& ); | |
53 | void DeleteSelectedRows( wxCommandEvent& ); | |
54 | void DeleteSelectedCols( wxCommandEvent& ); | |
e442cc0d MB |
55 | void ClearGrid( wxCommandEvent& ); |
56 | ||
e442cc0d MB |
57 | void OnLabelLeftClick( wxGridEvent& ); |
58 | void OnCellLeftClick( wxGridEvent& ); | |
59 | void OnRowSize( wxGridSizeEvent& ); | |
60 | void OnColSize( wxGridSizeEvent& ); | |
c336585e | 61 | void OnSelectCell( wxGridEvent& ); |
e442cc0d MB |
62 | void OnRangeSelected( wxGridRangeSelectEvent& ); |
63 | void OnCellValueChanged( wxGridEvent& ); | |
b99be8fb | 64 | |
b54ba671 VZ |
65 | void OnEditorShown(wxGridEvent&); |
66 | void OnEditorHidden(wxGridEvent&); | |
67 | ||
ab79958a | 68 | public: |
e442cc0d MB |
69 | GridFrame(); |
70 | ~GridFrame(); | |
71 | ||
e442cc0d | 72 | void OnQuit( wxCommandEvent& ); |
f445b853 | 73 | void About( wxCommandEvent& ); |
f97c9b5b | 74 | void OnVTable( wxCommandEvent& ); |
e442cc0d | 75 | |
ab79958a VZ |
76 | enum |
77 | { | |
78 | ID_TOGGLEROWLABELS = 100, | |
79 | ID_TOGGLECOLLABELS, | |
80 | ID_TOGGLEEDIT, | |
81 | ID_SETLABELCOLOUR, | |
82 | ID_SETLABELTEXTCOLOUR, | |
83 | ID_ROWLABELALIGN, | |
84 | ID_ROWLABELHORIZALIGN, | |
85 | ID_ROWLABELVERTALIGN, | |
86 | ID_COLLABELALIGN, | |
87 | ID_COLLABELHORIZALIGN, | |
88 | ID_COLLABELVERTALIGN, | |
89 | ID_GRIDLINECOLOUR, | |
90 | ID_INSERTROW, | |
91 | ID_INSERTCOL, | |
92 | ID_DELETEROW, | |
93 | ID_DELETECOL, | |
94 | ID_CLEARGRID, | |
95 | ID_SET_CELL_FG_COLOUR, | |
96 | ID_SET_CELL_BG_COLOUR, | |
97 | ID_ABOUT, | |
f97c9b5b | 98 | ID_VTABLE, |
ab79958a VZ |
99 | |
100 | ID_TESTFUNC | |
101 | }; | |
b99be8fb | 102 | |
e442cc0d MB |
103 | DECLARE_EVENT_TABLE() |
104 | }; | |
105 | ||
ab79958a VZ |
106 | class MyGridCellRenderer : public wxGridCellStringRenderer |
107 | { | |
108 | public: | |
109 | virtual void Draw(wxGrid& grid, | |
f97c9b5b | 110 | wxGridCellAttr& attr, |
ab79958a VZ |
111 | wxDC& dc, |
112 | const wxRect& rect, | |
113 | int row, int col, | |
114 | bool isSelected); | |
115 | }; | |
e442cc0d | 116 | |
1618dca7 VZ |
117 | // ---------------------------------------------------------------------------- |
118 | // demonstration of virtual table which doesn't store all of its data in | |
119 | // memory | |
120 | // ---------------------------------------------------------------------------- | |
f97c9b5b | 121 | |
1618dca7 VZ |
122 | class BigGridTable : public wxGridTableBase |
123 | { | |
f97c9b5b | 124 | public: |
1618dca7 VZ |
125 | BigGridTable(long sizeGrid) { m_sizeGrid = sizeGrid; } |
126 | ||
127 | long GetNumberRows() { return m_sizeGrid; } | |
128 | long GetNumberCols() { return m_sizeGrid; } | |
f97c9b5b | 129 | |
1618dca7 VZ |
130 | wxString GetValue( int row, int col ) |
131 | { | |
132 | return wxString::Format("(%d, %d)", row, col); | |
f97c9b5b RD |
133 | } |
134 | ||
1618dca7 | 135 | void SetValue( int , int , const wxString& ) { /* ignore */ } |
f97c9b5b | 136 | bool IsEmptyCell( int , int ) { return FALSE; } |
1618dca7 VZ |
137 | |
138 | private: | |
139 | long m_sizeGrid; | |
f97c9b5b RD |
140 | }; |
141 | ||
1618dca7 VZ |
142 | class BigGridFrame : public wxFrame |
143 | { | |
f97c9b5b | 144 | public: |
1618dca7 | 145 | BigGridFrame(long sizeGrid); |
f97c9b5b RD |
146 | |
147 | private: | |
148 | wxGrid* m_grid; | |
149 | BigGridTable* m_table; | |
150 | }; | |
151 | ||
152 | ||
1618dca7 | 153 | #endif // griddemo_h |
e442cc0d | 154 |