]>
Commit | Line | Data |
---|---|---|
f85afd4e MB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: grid.h | |
3 | // Purpose: wxGrid and related classes | |
4 | // Author: Michael Bedward (based on code by Julian Smart, Robin Dunn) | |
5 | // Modified by: | |
6 | // Created: 1/08/1999 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Michael Bedward | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | ||
13 | #include "wx/defs.h" | |
14 | ||
15 | #if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID) | |
16 | #include "gridg.h" | |
17 | #else | |
18 | ||
19 | #ifndef __WXGRID_H__ | |
20 | #define __WXGRID_H__ | |
21 | ||
22 | #ifdef __GNUG__ | |
23 | #pragma interface "grid.h" | |
24 | #endif | |
25 | ||
26 | #include "wx/panel.h" | |
2d66e025 | 27 | #include "wx/scrolwin.h" |
f85afd4e MB |
28 | #include "wx/string.h" |
29 | #include "wx/scrolbar.h" | |
30 | #include "wx/event.h" | |
31 | #include "wx/textctrl.h" | |
32 | #include "wx/combobox.h" | |
33 | #include "wx/dynarray.h" | |
34 | ||
35 | ||
36 | // Default parameters for wxGrid | |
37 | // | |
38 | #define WXGRID_DEFAULT_NUMBER_ROWS 10 | |
39 | #define WXGRID_DEFAULT_NUMBER_COLS 10 | |
40 | #ifdef __WXMSW__ | |
41 | #define WXGRID_DEFAULT_ROW_HEIGHT 25 | |
42 | #else | |
43 | #define WXGRID_DEFAULT_ROW_HEIGHT 30 | |
44 | #endif // __WXMSW__ | |
45 | #define WXGRID_DEFAULT_COL_WIDTH 80 | |
46 | #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32 | |
47 | #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82 | |
48 | #define WXGRID_LABEL_EDGE_ZONE 5 | |
49 | #define WXGRID_MIN_ROW_HEIGHT 15 | |
50 | #define WXGRID_MIN_COL_WIDTH 15 | |
51 | #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16 | |
f85afd4e MB |
52 | |
53 | ||
6f4968e2 | 54 | class WXDLLEXPORT wxGrid; |
f85afd4e MB |
55 | |
56 | ||
57 | ////////////////////////////////////////////////////////////////////// | |
58 | // | |
59 | // Grid table classes | |
60 | // | |
61 | ////////////////////////////////////////////////////////////////////// | |
62 | ||
63 | ||
2d66e025 | 64 | class WXDLLEXPORT wxGridTableBase : public wxObject |
f85afd4e | 65 | { |
60ff3b99 | 66 | public: |
f85afd4e MB |
67 | wxGridTableBase(); |
68 | virtual ~wxGridTableBase(); | |
69 | ||
70 | // You must override these functions in a derived table class | |
71 | // | |
72 | virtual long GetNumberRows() = 0; | |
73 | virtual long GetNumberCols() = 0; | |
74 | virtual wxString GetValue( int row, int col ) = 0; | |
75 | virtual void SetValue( int row, int col, const wxString& s ) = 0; | |
76 | virtual bool IsEmptyCell( int row, int col ) = 0; | |
60ff3b99 | 77 | |
f85afd4e MB |
78 | // Overriding these is optional |
79 | // | |
80 | virtual void SetView( wxGrid *grid ) { m_view = grid; } | |
81 | virtual wxGrid * GetView() const { return m_view; } | |
82 | ||
83 | virtual void Clear() {} | |
84 | virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 ); | |
85 | virtual bool AppendRows( size_t numRows = 1 ); | |
86 | virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 ); | |
87 | virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 ); | |
88 | virtual bool AppendCols( size_t numCols = 1 ); | |
89 | virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 ); | |
90 | ||
91 | virtual wxString GetRowLabelValue( int row ); | |
92 | virtual wxString GetColLabelValue( int col ); | |
af111fc3 JS |
93 | virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {} |
94 | virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {} | |
60ff3b99 VZ |
95 | |
96 | private: | |
97 | wxGrid * m_view; | |
98 | ||
f85afd4e MB |
99 | DECLARE_ABSTRACT_CLASS( wxGridTableBase ); |
100 | }; | |
101 | ||
102 | ||
103 | ||
104 | // IDs for messages sent from grid table to view | |
105 | // | |
60ff3b99 VZ |
106 | enum wxGridTableRequest |
107 | { | |
f85afd4e MB |
108 | wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000, |
109 | wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES, | |
110 | wxGRIDTABLE_NOTIFY_ROWS_INSERTED, | |
111 | wxGRIDTABLE_NOTIFY_ROWS_APPENDED, | |
112 | wxGRIDTABLE_NOTIFY_ROWS_DELETED, | |
113 | wxGRIDTABLE_NOTIFY_COLS_INSERTED, | |
114 | wxGRIDTABLE_NOTIFY_COLS_APPENDED, | |
115 | wxGRIDTABLE_NOTIFY_COLS_DELETED | |
116 | }; | |
117 | ||
2d66e025 | 118 | class WXDLLEXPORT wxGridTableMessage |
f85afd4e | 119 | { |
60ff3b99 | 120 | public: |
f85afd4e MB |
121 | wxGridTableMessage(); |
122 | wxGridTableMessage( wxGridTableBase *table, int id, | |
123 | int comInt1 = -1, | |
124 | int comInt2 = -1 ); | |
125 | ||
126 | void SetTableObject( wxGridTableBase *table ) { m_table = table; } | |
127 | wxGridTableBase * GetTableObject() const { return m_table; } | |
128 | void SetId( int id ) { m_id = id; } | |
129 | int GetId() { return m_id; } | |
130 | void SetCommandInt( int comInt1 ) { m_comInt1 = comInt1; } | |
131 | int GetCommandInt() { return m_comInt1; } | |
132 | void SetCommandInt2( int comInt2 ) { m_comInt2 = comInt2; } | |
60ff3b99 VZ |
133 | int GetCommandInt2() { return m_comInt2; } |
134 | ||
135 | private: | |
136 | wxGridTableBase *m_table; | |
137 | int m_id; | |
138 | int m_comInt1; | |
139 | int m_comInt2; | |
f85afd4e MB |
140 | }; |
141 | ||
142 | ||
143 | ||
144 | // ------ wxGridStringArray | |
145 | // A 2-dimensional array of strings for data values | |
146 | // | |
147 | ||
2d66e025 MB |
148 | WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString, wxGridStringArray); |
149 | ||
f85afd4e MB |
150 | |
151 | ||
152 | // ------ wxGridStringTable | |
153 | // | |
154 | // Simplest type of data table for a grid for small tables of strings | |
155 | // that are stored in memory | |
156 | // | |
157 | ||
2d66e025 | 158 | class WXDLLEXPORT wxGridStringTable : public wxGridTableBase |
f85afd4e | 159 | { |
60ff3b99 | 160 | public: |
f85afd4e MB |
161 | wxGridStringTable(); |
162 | wxGridStringTable( int numRows, int numCols ); | |
163 | ~wxGridStringTable(); | |
164 | ||
165 | // these are pure virtual in wxGridTableBase | |
166 | // | |
167 | long GetNumberRows(); | |
168 | long GetNumberCols(); | |
169 | wxString GetValue( int row, int col ); | |
170 | void SetValue( int row, int col, const wxString& s ); | |
171 | bool IsEmptyCell( int row, int col ); | |
60ff3b99 | 172 | |
f85afd4e MB |
173 | // overridden functions from wxGridTableBase |
174 | // | |
175 | void Clear(); | |
176 | bool InsertRows( size_t pos = 0, size_t numRows = 1 ); | |
177 | bool AppendRows( size_t numRows = 1 ); | |
178 | bool DeleteRows( size_t pos = 0, size_t numRows = 1 ); | |
179 | bool InsertCols( size_t pos = 0, size_t numCols = 1 ); | |
180 | bool AppendCols( size_t numCols = 1 ); | |
181 | bool DeleteCols( size_t pos = 0, size_t numCols = 1 ); | |
182 | ||
183 | void SetRowLabelValue( int row, const wxString& ); | |
184 | void SetColLabelValue( int col, const wxString& ); | |
185 | wxString GetRowLabelValue( int row ); | |
186 | wxString GetColLabelValue( int col ); | |
60ff3b99 VZ |
187 | |
188 | private: | |
189 | wxGridStringArray m_data; | |
190 | ||
191 | // These only get used if you set your own labels, otherwise the | |
192 | // GetRow/ColLabelValue functions return wxGridTableBase defaults | |
193 | // | |
194 | wxArrayString m_rowLabels; | |
195 | wxArrayString m_colLabels; | |
196 | ||
f85afd4e MB |
197 | DECLARE_DYNAMIC_CLASS( wxGridStringTable ) |
198 | }; | |
199 | ||
200 | ||
201 | ||
f85afd4e MB |
202 | ////////////////////////////////////////////////////////////////////// |
203 | // | |
204 | // Grid view classes | |
205 | // | |
206 | ////////////////////////////////////////////////////////////////////// | |
207 | ||
2d66e025 | 208 | class WXDLLEXPORT wxGridCellCoords |
f85afd4e | 209 | { |
60ff3b99 | 210 | public: |
f85afd4e MB |
211 | wxGridCellCoords() { m_row = m_col = -1; } |
212 | wxGridCellCoords( int r, int c ) { m_row = r; m_col = c; } | |
213 | ||
214 | // default copy ctor is ok | |
215 | ||
216 | long GetRow() const { return m_row; } | |
217 | void SetRow( long n ) { m_row = n; } | |
218 | long GetCol() const { return m_col; } | |
219 | void SetCol( long n ) { m_col = n; } | |
220 | void Set( long row, long col ) { m_row = row; m_col = col; } | |
60ff3b99 | 221 | |
f85afd4e MB |
222 | wxGridCellCoords& operator=( const wxGridCellCoords& other ) |
223 | { | |
224 | if ( &other != this ) | |
225 | { | |
226 | m_row=other.m_row; | |
227 | m_col=other.m_col; | |
228 | } | |
229 | return *this; | |
230 | } | |
231 | ||
232 | bool operator==( const wxGridCellCoords& other ) | |
233 | { | |
234 | return (m_row == other.m_row && m_col == other.m_col); | |
235 | } | |
236 | ||
237 | bool operator!=( const wxGridCellCoords& other ) | |
238 | { | |
239 | return (m_row != other.m_row || m_col != other.m_col); | |
240 | } | |
241 | ||
242 | bool operator!() | |
243 | { | |
244 | return (m_row == -1 && m_col == -1 ); | |
245 | } | |
60ff3b99 VZ |
246 | |
247 | private: | |
248 | long m_row; | |
249 | long m_col; | |
f85afd4e MB |
250 | }; |
251 | ||
252 | ||
253 | // For comparisons... | |
254 | // | |
255 | extern wxGridCellCoords wxGridNoCellCoords; | |
256 | extern wxRect wxGridNoCellRect; | |
257 | ||
2d66e025 MB |
258 | // An array of cell coords... |
259 | // | |
260 | WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords, wxGridCellCoordsArray); | |
261 | ||
262 | ||
f85afd4e MB |
263 | |
264 | // This set of classes is to provide for the use of different types of | |
60ff3b99 | 265 | // cell edit controls in the grid while avoiding the wx class info |
f85afd4e MB |
266 | // system in deference to wxPython |
267 | ||
2d66e025 | 268 | class WXDLLEXPORT wxGridTextCtrl : public wxTextCtrl |
f85afd4e | 269 | { |
60ff3b99 | 270 | public: |
f85afd4e MB |
271 | wxGridTextCtrl() {} |
272 | wxGridTextCtrl( wxWindow *, | |
2d66e025 | 273 | wxGrid *, |
f85afd4e MB |
274 | bool isCellControl, |
275 | wxWindowID id, | |
276 | const wxString& value = wxEmptyString, | |
277 | const wxPoint& pos = wxDefaultPosition, | |
278 | const wxSize& size = wxDefaultSize, | |
279 | long style = 0 ); | |
280 | ||
281 | void SetStartValue( const wxString& ); | |
282 | wxString GetStartValue() { return startValue; } | |
60ff3b99 VZ |
283 | |
284 | private: | |
285 | wxGrid *m_grid; | |
286 | ||
287 | // TRUE for controls placed over cells, | |
288 | // FALSE for a control on a grid control panel | |
289 | bool m_isCellControl; | |
290 | ||
291 | wxString startValue; | |
292 | ||
293 | void OnKeyDown( wxKeyEvent& ); | |
294 | ||
f85afd4e MB |
295 | DECLARE_DYNAMIC_CLASS( wxGridTextCtrl ) |
296 | DECLARE_EVENT_TABLE() | |
297 | }; | |
298 | ||
299 | ||
2d66e025 | 300 | class WXDLLEXPORT wxGridRowLabelWindow : public wxWindow |
f85afd4e | 301 | { |
60ff3b99 VZ |
302 | public: |
303 | wxGridRowLabelWindow() { m_owner = (wxGrid *)NULL; } | |
304 | wxGridRowLabelWindow( wxGrid *parent, wxWindowID id, | |
305 | const wxPoint &pos, const wxSize &size ); | |
306 | ||
307 | private: | |
2d66e025 | 308 | wxGrid *m_owner; |
60ff3b99 | 309 | |
2d66e025 MB |
310 | void OnPaint( wxPaintEvent& event ); |
311 | void OnMouseEvent( wxMouseEvent& event ); | |
312 | void OnKeyDown( wxKeyEvent& event ); | |
313 | ||
2d66e025 MB |
314 | DECLARE_DYNAMIC_CLASS(wxGridRowLabelWindow) |
315 | DECLARE_EVENT_TABLE() | |
316 | }; | |
317 | ||
318 | ||
319 | class WXDLLEXPORT wxGridColLabelWindow : public wxWindow | |
320 | { | |
60ff3b99 VZ |
321 | public: |
322 | wxGridColLabelWindow() { m_owner = (wxGrid *)NULL; } | |
323 | wxGridColLabelWindow( wxGrid *parent, wxWindowID id, | |
324 | const wxPoint &pos, const wxSize &size ); | |
325 | ||
326 | private: | |
2d66e025 | 327 | wxGrid *m_owner; |
60ff3b99 | 328 | |
2d66e025 MB |
329 | void OnPaint( wxPaintEvent &event ); |
330 | void OnMouseEvent( wxMouseEvent& event ); | |
331 | void OnKeyDown( wxKeyEvent& event ); | |
332 | ||
2d66e025 MB |
333 | DECLARE_DYNAMIC_CLASS(wxGridColLabelWindow) |
334 | DECLARE_EVENT_TABLE() | |
335 | }; | |
336 | ||
337 | ||
338 | class WXDLLEXPORT wxGridCornerLabelWindow : public wxWindow | |
339 | { | |
60ff3b99 VZ |
340 | public: |
341 | wxGridCornerLabelWindow() { m_owner = (wxGrid *)NULL; } | |
342 | wxGridCornerLabelWindow( wxGrid *parent, wxWindowID id, | |
343 | const wxPoint &pos, const wxSize &size ); | |
344 | ||
345 | private: | |
2d66e025 | 346 | wxGrid *m_owner; |
60ff3b99 | 347 | |
2d66e025 MB |
348 | void OnMouseEvent( wxMouseEvent& event ); |
349 | void OnKeyDown( wxKeyEvent& event ); | |
d2fdd8d2 | 350 | void OnPaint( wxPaintEvent& event ); |
2d66e025 MB |
351 | |
352 | DECLARE_DYNAMIC_CLASS(wxGridCornerLabelWindow) | |
353 | DECLARE_EVENT_TABLE() | |
354 | }; | |
355 | ||
356 | ||
357 | ||
358 | class WXDLLEXPORT wxGridWindow : public wxPanel | |
359 | { | |
2d66e025 | 360 | public: |
60ff3b99 VZ |
361 | wxGridWindow() |
362 | { | |
363 | m_owner = (wxGrid *)NULL; | |
364 | m_rowLabelWin = (wxGridRowLabelWindow *)NULL; | |
365 | m_colLabelWin = (wxGridColLabelWindow *)NULL; | |
366 | } | |
367 | ||
368 | wxGridWindow( wxGrid *parent, | |
2d66e025 MB |
369 | wxGridRowLabelWindow *rowLblWin, |
370 | wxGridColLabelWindow *colLblWin, | |
371 | wxWindowID id, const wxPoint &pos, const wxSize &size ); | |
372 | ~wxGridWindow(); | |
f85afd4e | 373 | |
2d66e025 MB |
374 | void ScrollWindow( int dx, int dy, const wxRect *rect ); |
375 | ||
60ff3b99 VZ |
376 | private: |
377 | wxGrid *m_owner; | |
2d66e025 MB |
378 | wxGridRowLabelWindow *m_rowLabelWin; |
379 | wxGridColLabelWindow *m_colLabelWin; | |
2d66e025 | 380 | |
60ff3b99 VZ |
381 | void OnPaint( wxPaintEvent &event ); |
382 | void OnMouseEvent( wxMouseEvent& event ); | |
f85afd4e | 383 | void OnKeyDown( wxKeyEvent& ); |
f85afd4e | 384 | |
60ff3b99 VZ |
385 | DECLARE_DYNAMIC_CLASS(wxGridWindow) |
386 | DECLARE_EVENT_TABLE() | |
387 | }; | |
f85afd4e | 388 | |
f85afd4e MB |
389 | |
390 | ||
60ff3b99 VZ |
391 | class WXDLLEXPORT wxGrid : public wxScrolledWindow |
392 | { | |
393 | public: | |
f85afd4e | 394 | wxGrid() |
58dd5b3b MB |
395 | { |
396 | m_table = (wxGridTableBase *) NULL; | |
397 | m_gridWin = (wxGridWindow *) NULL; | |
398 | m_rowLabelWin = (wxGridRowLabelWindow *) NULL; | |
399 | m_colLabelWin = (wxGridColLabelWindow *) NULL; | |
400 | m_cornerLabelWin = (wxGridCornerLabelWindow *) NULL; | |
401 | m_cellEditCtrl = (wxWindow *) NULL; | |
402 | } | |
60ff3b99 | 403 | |
f85afd4e MB |
404 | wxGrid( wxWindow *parent, |
405 | wxWindowID id, | |
406 | const wxPoint& pos = wxDefaultPosition, | |
407 | const wxSize& size = wxDefaultSize, | |
408 | long style = 0, | |
2d66e025 MB |
409 | const wxString& name = wxPanelNameStr ); |
410 | ||
60ff3b99 | 411 | ~wxGrid(); |
f85afd4e | 412 | |
2d66e025 MB |
413 | bool CreateGrid( int numRows, int numCols ); |
414 | ||
60ff3b99 | 415 | |
2d66e025 MB |
416 | // ------ grid dimensions |
417 | // | |
418 | int GetNumberRows() { return m_numRows; } | |
419 | int GetNumberCols() { return m_numCols; } | |
420 | ||
60ff3b99 | 421 | |
2d66e025 MB |
422 | // ------ display update functions |
423 | // | |
60ff3b99 | 424 | void CalcRowLabelsExposed( wxRegion& reg ); |
8fb66724 | 425 | |
60ff3b99 VZ |
426 | void CalcColLabelsExposed( wxRegion& reg ); |
427 | void CalcCellsExposed( wxRegion& reg ); | |
428 | ||
2d66e025 | 429 | |
2d66e025 MB |
430 | // ------ event handlers |
431 | // | |
432 | void ProcessRowLabelMouseEvent( wxMouseEvent& event ); | |
433 | void ProcessColLabelMouseEvent( wxMouseEvent& event ); | |
434 | void ProcessCornerLabelMouseEvent( wxMouseEvent& event ); | |
60ff3b99 | 435 | void ProcessGridCellMouseEvent( wxMouseEvent& event ); |
2d66e025 | 436 | bool ProcessTableMessage( wxGridTableMessage& ); |
f85afd4e | 437 | |
60ff3b99 | 438 | |
f85afd4e MB |
439 | wxGridTableBase * GetTable() const { return m_table; } |
440 | void SetTable( wxGridTableBase *table ) { m_table = table; } | |
441 | ||
442 | void ClearGrid(); | |
443 | bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE ); | |
444 | bool AppendRows( int numRows = 1, bool updateLabels=TRUE ); | |
445 | bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE ); | |
446 | bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE ); | |
447 | bool AppendCols( int numCols = 1, bool updateLabels=TRUE ); | |
60ff3b99 | 448 | bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE ); |
f85afd4e | 449 | |
2d66e025 MB |
450 | void DrawGridCellArea( wxDC& dc ); |
451 | void DrawCellBorder( wxDC& dc, const wxGridCellCoords& ); | |
796df70a | 452 | void DrawAllGridLines( wxDC& dc, const wxRegion & reg = wxRegion() ); |
2d66e025 MB |
453 | void DrawCell( wxDC& dc, const wxGridCellCoords& ); |
454 | void DrawCellBackground( wxDC& dc, const wxGridCellCoords& ); | |
455 | void DrawCellValue( wxDC& dc, const wxGridCellCoords& ); | |
1f1ce288 | 456 | |
2d66e025 MB |
457 | void DrawRowLabels( wxDC& dc ); |
458 | void DrawRowLabel( wxDC& dc, int row ); | |
8fb66724 | 459 | |
2d66e025 MB |
460 | void DrawColLabels( wxDC& dc ); |
461 | void DrawColLabel( wxDC& dc, int col ); | |
60ff3b99 | 462 | |
f85afd4e | 463 | |
2d66e025 | 464 | // ------ Cell text drawing functions |
f85afd4e | 465 | // |
2d66e025 MB |
466 | void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&, |
467 | int horizontalAlignment = wxLEFT, | |
468 | int verticalAlignment = wxTOP ); | |
f85afd4e | 469 | |
2d66e025 MB |
470 | // Split a string containing newline chararcters into an array of |
471 | // strings and return the number of lines | |
472 | // | |
473 | void StringToLines( const wxString& value, wxArrayString& lines ); | |
60ff3b99 | 474 | |
2d66e025 MB |
475 | void GetTextBoxSize( wxDC& dc, |
476 | wxArrayString& lines, | |
477 | long *width, long *height ); | |
60ff3b99 | 478 | |
2d66e025 | 479 | |
f85afd4e MB |
480 | // ------ |
481 | // Code that does a lot of grid modification can be enclosed | |
482 | // between BeginBatch() and EndBatch() calls to avoid screen | |
483 | // flicker | |
484 | // | |
485 | void BeginBatch() { m_batchCount++; } | |
486 | void EndBatch() { if ( m_batchCount > 0 ) m_batchCount--; } | |
487 | int GetBatchCount() { return m_batchCount; } | |
488 | ||
2d66e025 MB |
489 | |
490 | // ------ edit control functions | |
491 | // | |
492 | bool IsEditable() { return m_editable; } | |
493 | void EnableEditing( bool edit ); | |
494 | ||
60ff3b99 | 495 | #if 0 // at the moment the cell edit control is always active |
2d66e025 | 496 | void EnableCellEditControl( bool enable ); |
1f1ce288 | 497 | #endif |
2d66e025 MB |
498 | |
499 | bool IsCellEditControlEnabled() | |
500 | { return (m_cellEditCtrl && m_cellEditCtrlEnabled); } | |
501 | ||
2d66e025 MB |
502 | void ShowCellEditControl(); |
503 | void HideCellEditControl(); | |
504 | void SetEditControlValue( const wxString& s = wxEmptyString ); | |
505 | void SaveEditControlValue(); | |
506 | ||
60ff3b99 | 507 | |
2d66e025 | 508 | // ------ grid location functions |
60ff3b99 | 509 | // Note that all of these functions work with the logical coordinates of |
2d66e025 MB |
510 | // grid cells and labels so you will need to convert from device |
511 | // coordinates for mouse events etc. | |
512 | // | |
513 | void XYToCell( int x, int y, wxGridCellCoords& ); | |
514 | int YToRow( int y ); | |
515 | int XToCol( int x ); | |
516 | ||
517 | int YToEdgeOfRow( int y ); | |
518 | int XToEdgeOfCol( int x ); | |
519 | ||
520 | wxRect CellToRect( int row, int col ); | |
521 | wxRect CellToRect( const wxGridCellCoords& coords ) | |
522 | { return CellToRect( coords.GetRow(), coords.GetCol() ); } | |
523 | ||
524 | int GetGridCursorRow() { return m_currentCellCoords.GetRow(); } | |
525 | int GetGridCursorCol() { return m_currentCellCoords.GetCol(); } | |
60ff3b99 | 526 | |
2d66e025 MB |
527 | // check to see if a cell is either wholly visible (the default arg) or |
528 | // at least partially visible in the grid window | |
529 | // | |
530 | bool IsVisible( int row, int col, bool wholeCellVisible = TRUE ); | |
531 | bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE ) | |
532 | { return IsVisible( coords.GetRow(), coords.GetCol(), wholeCellVisible ); } | |
533 | void MakeCellVisible( int row, int col ); | |
534 | void MakeCellVisible( const wxGridCellCoords& coords ) | |
535 | { MakeCellVisible( coords.GetRow(), coords.GetCol() ); } | |
536 | ||
60ff3b99 | 537 | |
2d66e025 MB |
538 | // ------ grid cursor movement functions |
539 | // | |
dfaf42d2 | 540 | void SetGridCursor( int row, int col ) |
b27f2615 | 541 | { SetCurrentCell( wxGridCellCoords(row, col) ); } |
dfaf42d2 | 542 | |
2d66e025 MB |
543 | bool MoveCursorUp(); |
544 | bool MoveCursorDown(); | |
545 | bool MoveCursorLeft(); | |
546 | bool MoveCursorRight(); | |
547 | bool MovePageDown(); | |
548 | bool MovePageUp(); | |
549 | bool MoveCursorUpBlock(); | |
550 | bool MoveCursorDownBlock(); | |
551 | bool MoveCursorLeftBlock(); | |
552 | bool MoveCursorRightBlock(); | |
553 | ||
60ff3b99 | 554 | |
f85afd4e MB |
555 | // ------ label and gridline formatting |
556 | // | |
557 | int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; } | |
558 | int GetRowLabelSize() { return m_rowLabelWidth; } | |
60ff3b99 | 559 | int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; } |
f85afd4e MB |
560 | int GetColLabelSize() { return m_colLabelHeight; } |
561 | wxColour GetLabelBackgroundColour() { return m_labelBackgroundColour; } | |
562 | wxColour GetLabelTextColour() { return m_labelTextColour; } | |
563 | wxFont GetLabelFont() { return m_labelFont; } | |
564 | void GetRowLabelAlignment( int *horiz, int *vert ); | |
565 | void GetColLabelAlignment( int *horiz, int *vert ); | |
566 | wxString GetRowLabelValue( int row ); | |
567 | wxString GetColLabelValue( int col ); | |
568 | wxColour GetGridLineColour() { return m_gridLineColour; } | |
569 | ||
2d66e025 | 570 | void SetRowLabelSize( int width ); |
f85afd4e MB |
571 | void SetColLabelSize( int height ); |
572 | void SetLabelBackgroundColour( const wxColour& ); | |
573 | void SetLabelTextColour( const wxColour& ); | |
574 | void SetLabelFont( const wxFont& ); | |
575 | void SetRowLabelAlignment( int horiz, int vert ); | |
576 | void SetColLabelAlignment( int horiz, int vert ); | |
577 | void SetRowLabelValue( int row, const wxString& ); | |
578 | void SetColLabelValue( int col, const wxString& ); | |
579 | void SetGridLineColour( const wxColour& ); | |
580 | ||
581 | void EnableGridLines( bool enable = TRUE ); | |
582 | bool GridLinesEnabled() { return m_gridLinesEnabled; } | |
583 | ||
2d66e025 | 584 | |
f85afd4e MB |
585 | // ------ row and col formatting |
586 | // | |
587 | int GetDefaultRowSize(); | |
588 | int GetRowSize( int row ); | |
589 | int GetDefaultColSize(); | |
590 | int GetColSize( int col ); | |
591 | wxColour GetDefaultCellBackgroundColour(); | |
592 | wxColour GetCellBackgroundColour( int row, int col ); | |
593 | wxColour GetDefaultCellTextColour(); | |
594 | wxColour GetCellTextColour( int row, int col ); | |
f85afd4e MB |
595 | wxFont GetDefaultCellFont(); |
596 | wxFont GetCellFont( int row, int col ); | |
597 | void GetDefaultCellAlignment( int *horiz, int *vert ); | |
598 | void GetCellAlignment( int row, int col, int *horiz, int *vert ); | |
60ff3b99 | 599 | |
f85afd4e MB |
600 | void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE ); |
601 | void SetRowSize( int row, int height ); | |
602 | void SetDefaultColSize( int width, bool resizeExistingCols = FALSE ); | |
8fb66724 | 603 | |
f85afd4e MB |
604 | void SetColSize( int col, int width ); |
605 | void SetDefaultCellBackgroundColour( const wxColour& ); | |
606 | void SetCellBackgroundColour( int row, int col, const wxColour& ); | |
607 | void SetDefaultCellTextColour( const wxColour& ); | |
8fb66724 | 608 | |
f85afd4e | 609 | void SetCellTextColour( int row, int col, const wxColour& ); |
f85afd4e MB |
610 | void SetDefaultCellFont( const wxFont& ); |
611 | void SetCellFont( int row, int col, const wxFont& ); | |
612 | void SetDefaultCellAlignment( int horiz, int vert ); | |
613 | void SetCellAlignment( int row, int col, int horiz, int vert ); | |
614 | ||
60a67569 | 615 | |
f85afd4e MB |
616 | // ------ cell value accessors |
617 | // | |
618 | wxString GetCellValue( int row, int col ) | |
619 | { | |
620 | if ( m_table ) | |
621 | { | |
622 | return m_table->GetValue( row, col ); | |
623 | } | |
624 | else | |
625 | { | |
626 | return wxEmptyString; | |
627 | } | |
628 | } | |
629 | ||
630 | wxString GetCellValue( const wxGridCellCoords& coords ) | |
631 | { return GetCellValue( coords.GetRow(), coords.GetCol() ); } | |
60ff3b99 | 632 | |
f85afd4e MB |
633 | void SetCellValue( int row, int col, const wxString& s ); |
634 | void SetCellValue( const wxGridCellCoords& coords, const wxString& s ) | |
635 | { SetCellValue( coords.GetRow(), coords.GetCol(), s ); } | |
f85afd4e | 636 | |
60ff3b99 | 637 | |
f85afd4e MB |
638 | |
639 | // ------ selections of blocks of cells | |
640 | // | |
641 | void SelectRow( int row, bool addToSelected = FALSE ); | |
642 | void SelectCol( int col, bool addToSelected = FALSE ); | |
60ff3b99 | 643 | |
f85afd4e MB |
644 | void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol ); |
645 | ||
646 | void SelectBlock( const wxGridCellCoords& topLeft, | |
647 | const wxGridCellCoords& bottomRight ) | |
648 | { SelectBlock( topLeft.GetRow(), topLeft.GetCol(), | |
649 | bottomRight.GetRow(), bottomRight.GetCol() ); } | |
650 | ||
651 | void SelectAll(); | |
60ff3b99 | 652 | |
f85afd4e MB |
653 | bool IsSelection() |
654 | { return ( m_selectedTopLeft != wxGridNoCellCoords && | |
655 | m_selectedBottomRight != wxGridNoCellCoords ); | |
656 | } | |
657 | ||
658 | void ClearSelection(); | |
659 | ||
660 | bool IsInSelection( int row, int col ) | |
661 | { return ( IsSelection() && | |
662 | row >= m_selectedTopLeft.GetRow() && | |
663 | col >= m_selectedTopLeft.GetCol() && | |
664 | row <= m_selectedBottomRight.GetRow() && | |
665 | col <= m_selectedBottomRight.GetCol() ); | |
666 | } | |
667 | ||
668 | bool IsInSelection( const wxGridCellCoords& coords ) | |
669 | { return IsInSelection( coords.GetRow(), coords.GetCol() ); } | |
670 | ||
671 | void GetSelection( int* topRow, int* leftCol, int* bottomRow, int* rightCol ) | |
672 | { | |
673 | // these will all be -1 if there is no selected block | |
674 | // | |
675 | *topRow = m_selectedTopLeft.GetRow(); | |
676 | *leftCol = m_selectedTopLeft.GetCol(); | |
677 | *bottomRow = m_selectedBottomRight.GetRow(); | |
678 | *rightCol = m_selectedBottomRight.GetCol(); | |
679 | } | |
680 | ||
c3baf426 SN |
681 | |
682 | // This function returns the rectangle that encloses the block of cells | |
683 | // limited by TopLeft and BottomRight cell in device coords and clipped | |
684 | // to the client size of the grid window. | |
685 | // | |
58dd5b3b MB |
686 | wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft, |
687 | const wxGridCellCoords & bottomRight ); | |
c3baf426 | 688 | |
2d66e025 MB |
689 | // This function returns the rectangle that encloses the selected cells |
690 | // in device coords and clipped to the client size of the grid window. | |
f85afd4e | 691 | // |
c3baf426 SN |
692 | wxRect SelectionToDeviceRect() |
693 | { | |
694 | return BlockToDeviceRect( m_selectedTopLeft, | |
695 | m_selectedBottomRight ); | |
696 | } | |
60ff3b99 | 697 | |
f85afd4e MB |
698 | |
699 | // ------ For compatibility with previous wxGrid only... | |
700 | // | |
701 | // ************************************************ | |
702 | // ** Don't use these in new code because they ** | |
703 | // ** are liable to disappear in a future ** | |
704 | // ** revision ** | |
705 | // ************************************************ | |
706 | // | |
707 | ||
708 | wxGrid( wxWindow *parent, | |
709 | int x = -1, int y = -1, int w = -1, int h = -1, | |
710 | long style = 0, | |
711 | const wxString& name = wxPanelNameStr ) | |
2d66e025 | 712 | : wxScrolledWindow( parent, -1, wxPoint(x,y), wxSize(w,h), style, name ) |
60ff3b99 | 713 | { |
f85afd4e | 714 | Create(); |
60ff3b99 | 715 | } |
f85afd4e MB |
716 | |
717 | void SetCellValue( const wxString& val, int row, int col ) | |
718 | { SetCellValue( row, col, val ); } | |
60ff3b99 | 719 | |
f85afd4e MB |
720 | void UpdateDimensions() |
721 | { CalcDimensions(); } | |
722 | ||
723 | int GetRows() { return GetNumberRows(); } | |
724 | int GetCols() { return GetNumberCols(); } | |
725 | int GetCursorRow() { return GetGridCursorRow(); } | |
726 | int GetCursorColumn() { return GetGridCursorCol(); } | |
60ff3b99 | 727 | |
2d66e025 MB |
728 | int GetScrollPosX() { return 0; } |
729 | int GetScrollPosY() { return 0; } | |
60ff3b99 | 730 | |
2d66e025 MB |
731 | void SetScrollX( int x ) { } |
732 | void SetScrollY( int y ) { } | |
f85afd4e MB |
733 | |
734 | void SetColumnWidth( int col, int width ) | |
735 | { SetColSize( col, width ); } | |
60ff3b99 | 736 | |
f85afd4e MB |
737 | int GetColumnWidth( int col ) |
738 | { return GetColSize( col ); } | |
60ff3b99 | 739 | |
f85afd4e MB |
740 | void SetRowHeight( int row, int height ) |
741 | { SetRowSize( row, height ); } | |
60ff3b99 | 742 | |
f85afd4e MB |
743 | int GetRowHeight( int row ) |
744 | { return GetRowSize( row ); } | |
60ff3b99 | 745 | |
2d66e025 MB |
746 | int GetViewHeight() // returned num whole rows visible |
747 | { return 0; } | |
60ff3b99 | 748 | |
2d66e025 MB |
749 | int GetViewWidth() // returned num whole cols visible |
750 | { return 0; } | |
f85afd4e MB |
751 | |
752 | void SetLabelSize( int orientation, int sz ) | |
753 | { | |
754 | if ( orientation == wxHORIZONTAL ) | |
755 | SetColLabelSize( sz ); | |
756 | else | |
757 | SetRowLabelSize( sz ); | |
758 | } | |
759 | ||
760 | int GetLabelSize( int orientation ) | |
761 | { | |
762 | if ( orientation == wxHORIZONTAL ) | |
763 | return GetColLabelSize(); | |
764 | else | |
765 | return GetRowLabelSize(); | |
766 | } | |
767 | ||
768 | void SetLabelAlignment( int orientation, int align ) | |
769 | { | |
770 | if ( orientation == wxHORIZONTAL ) | |
771 | SetColLabelAlignment( align, -1 ); | |
772 | else | |
773 | SetRowLabelAlignment( align, -1 ); | |
774 | } | |
775 | ||
af111fc3 | 776 | int GetLabelAlignment( int orientation, int WXUNUSED(align) ) |
f85afd4e MB |
777 | { |
778 | int h, v; | |
779 | if ( orientation == wxHORIZONTAL ) | |
780 | { | |
781 | GetColLabelAlignment( &h, &v ); | |
782 | return h; | |
783 | } | |
784 | else | |
785 | { | |
786 | GetRowLabelAlignment( &h, &v ); | |
787 | return h; | |
788 | } | |
789 | } | |
790 | ||
791 | void SetLabelValue( int orientation, const wxString& val, int pos ) | |
792 | { | |
793 | if ( orientation == wxHORIZONTAL ) | |
794 | SetColLabelValue( pos, val ); | |
795 | else | |
796 | SetRowLabelValue( pos, val ); | |
797 | } | |
60ff3b99 | 798 | |
f85afd4e MB |
799 | wxString GetLabelValue( int orientation, int pos) |
800 | { | |
801 | if ( orientation == wxHORIZONTAL ) | |
802 | return GetColLabelValue( pos ); | |
803 | else | |
804 | return GetRowLabelValue( pos ); | |
805 | } | |
806 | ||
60ff3b99 | 807 | wxFont GetCellTextFont() const |
f85afd4e | 808 | { return m_defaultCellFont; } |
60ff3b99 | 809 | |
af111fc3 | 810 | wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const |
f85afd4e | 811 | { return m_defaultCellFont; } |
60ff3b99 | 812 | |
f85afd4e MB |
813 | void SetCellTextFont(const wxFont& fnt) |
814 | { SetDefaultCellFont( fnt ); } | |
60ff3b99 | 815 | |
f85afd4e MB |
816 | void SetCellTextFont(const wxFont& fnt, int row, int col) |
817 | { SetCellFont( row, col, fnt ); } | |
60ff3b99 | 818 | |
f85afd4e MB |
819 | void SetCellTextColour(const wxColour& val, int row, int col) |
820 | { SetCellTextColour( row, col, val ); } | |
60ff3b99 | 821 | |
f85afd4e MB |
822 | void SetCellTextColour(const wxColour& col) |
823 | { SetDefaultCellTextColour( col ); } | |
60ff3b99 | 824 | |
f85afd4e MB |
825 | void SetCellBackgroundColour(const wxColour& col) |
826 | { SetDefaultCellBackgroundColour( col ); } | |
60ff3b99 | 827 | |
f85afd4e MB |
828 | void SetCellBackgroundColour(const wxColour& colour, int row, int col) |
829 | { SetCellBackgroundColour( row, col, colour ); } | |
60ff3b99 | 830 | |
f85afd4e MB |
831 | bool GetEditable() { return IsEditable(); } |
832 | void SetEditable( bool edit = TRUE ) { EnableEditing( edit ); } | |
833 | bool GetEditInPlace() { return IsCellEditControlEnabled(); } | |
8fb66724 | 834 | |
1f1ce288 | 835 | void SetEditInPlace(bool edit = TRUE) { } |
f85afd4e | 836 | |
60a67569 JS |
837 | void SetCellAlignment( int align, int row, int col) |
838 | { SetCellAlignment(row, col, align, wxCENTER); } | |
839 | void SetCellAlignment( int WXUNUSED(align) ) {} | |
840 | void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col)) | |
841 | { } | |
842 | void SetDividerPen(const wxPen& WXUNUSED(pen)) { } | |
843 | wxPen& GetDividerPen() const { return wxNullPen; } | |
844 | void OnActivate(bool WXUNUSED(active)) {} | |
60ff3b99 | 845 | |
f85afd4e MB |
846 | // ******** End of compatibility functions ********** |
847 | ||
2d66e025 MB |
848 | |
849 | ||
f85afd4e | 850 | // ------ control IDs |
2d66e025 | 851 | enum { wxGRID_CELLCTRL = 2000, |
f85afd4e MB |
852 | wxGRID_TOPCTRL }; |
853 | ||
854 | // ------ control types | |
2d66e025 | 855 | enum { wxGRID_TEXTCTRL = 2100, |
f85afd4e MB |
856 | wxGRID_CHECKBOX, |
857 | wxGRID_CHOICE, | |
858 | wxGRID_COMBOBOX }; | |
859 | ||
60ff3b99 VZ |
860 | protected: |
861 | bool m_created; | |
862 | ||
863 | wxGridWindow *m_gridWin; | |
864 | wxGridRowLabelWindow *m_rowLabelWin; | |
865 | wxGridColLabelWindow *m_colLabelWin; | |
866 | wxGridCornerLabelWindow *m_cornerLabelWin; | |
867 | ||
868 | wxBoxSizer *m_mainSizer; | |
869 | wxBoxSizer *m_topSizer; | |
870 | wxBoxSizer *m_middleSizer; | |
871 | ||
872 | wxGridTableBase *m_table; | |
873 | ||
874 | int m_left; | |
875 | int m_top; | |
876 | int m_right; | |
877 | int m_bottom; | |
878 | ||
879 | int m_numRows; | |
880 | int m_numCols; | |
881 | ||
882 | wxGridCellCoords m_currentCellCoords; | |
883 | ||
884 | wxGridCellCoords m_selectedTopLeft; | |
885 | wxGridCellCoords m_selectedBottomRight; | |
886 | ||
887 | int m_defaultRowHeight; | |
888 | wxArrayInt m_rowHeights; | |
889 | wxArrayInt m_rowBottoms; | |
890 | ||
891 | int m_defaultColWidth; | |
892 | wxArrayInt m_colWidths; | |
893 | wxArrayInt m_colRights; | |
894 | ||
895 | int m_rowLabelWidth; | |
896 | int m_colLabelHeight; | |
897 | ||
898 | wxColour m_labelBackgroundColour; | |
899 | wxColour m_labelTextColour; | |
900 | wxFont m_labelFont; | |
901 | ||
902 | int m_rowLabelHorizAlign; | |
903 | int m_rowLabelVertAlign; | |
904 | int m_colLabelHorizAlign; | |
905 | int m_colLabelVertAlign; | |
906 | ||
907 | bool m_defaultRowLabelValues; | |
908 | bool m_defaultColLabelValues; | |
909 | ||
910 | wxColour m_gridLineColour; | |
911 | bool m_gridLinesEnabled; | |
912 | ||
913 | wxFont m_defaultCellFont; | |
914 | ||
915 | wxGridCellCoordsArray m_cellsExposed; | |
916 | wxArrayInt m_rowsExposed; | |
917 | wxArrayInt m_colsExposed; | |
918 | wxArrayInt m_rowLabelsExposed; | |
919 | wxArrayInt m_colLabelsExposed; | |
920 | ||
921 | bool m_inOnKeyDown; | |
922 | int m_batchCount; | |
923 | ||
924 | int m_cursorMode; | |
925 | enum { WXGRID_CURSOR_DEFAULT, | |
926 | WXGRID_CURSOR_SELECT_CELL, | |
927 | WXGRID_CURSOR_RESIZE_ROW, | |
928 | WXGRID_CURSOR_RESIZE_COL, | |
929 | WXGRID_CURSOR_SELECT_ROW, | |
930 | WXGRID_CURSOR_SELECT_COL | |
931 | }; | |
932 | ||
933 | int m_dragLastPos; | |
934 | int m_dragRowOrCol; | |
935 | bool m_isDragging; | |
936 | ||
937 | wxGridCellCoords m_selectionStart; | |
938 | ||
939 | wxCursor m_rowResizeCursor; | |
940 | wxCursor m_colResizeCursor; | |
941 | ||
942 | bool m_editable; // applies to whole grid | |
943 | int m_editCtrlType; // for current cell | |
944 | wxWindow* m_cellEditCtrl; | |
945 | bool m_cellEditCtrlEnabled; | |
946 | ||
947 | ||
948 | void Create(); | |
949 | void Init(); | |
950 | void CalcDimensions(); | |
951 | bool Redimension( wxGridTableMessage& ); | |
952 | ||
953 | ||
954 | bool SendEvent( const wxEventType, | |
955 | int row, int col, | |
956 | wxMouseEvent& ); | |
957 | ||
958 | bool SendEvent( const wxEventType, | |
959 | int row, int col ); | |
960 | ||
961 | ||
962 | void OnPaint( wxPaintEvent& ); | |
963 | void OnSize( wxSizeEvent& ); | |
964 | void OnKeyDown( wxKeyEvent& ); | |
965 | ||
966 | ||
967 | void SetCurrentCell( const wxGridCellCoords& coords ); | |
968 | void SetCurrentCell( int row, int col ) | |
969 | { SetCurrentCell( wxGridCellCoords(row, col) ); } | |
970 | ||
971 | ||
972 | // ------ functions to get/send data (see also public functions) | |
973 | // | |
974 | bool GetModelValues(); | |
975 | bool SetModelValues(); | |
976 | ||
977 | ||
2d66e025 | 978 | DECLARE_DYNAMIC_CLASS( wxGrid ) |
f85afd4e MB |
979 | DECLARE_EVENT_TABLE() |
980 | }; | |
981 | ||
982 | ||
983 | ||
984 | ||
985 | ||
986 | // | |
987 | // ------ Grid event class and event types | |
988 | // | |
989 | ||
990 | class WXDLLEXPORT wxGridEvent : public wxNotifyEvent | |
991 | { | |
60ff3b99 | 992 | public: |
f85afd4e MB |
993 | wxGridEvent() |
994 | : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1), | |
995 | m_control(0), m_meta(0), m_shift(0), m_alt(0) | |
996 | { | |
997 | } | |
998 | ||
999 | wxGridEvent(int id, wxEventType type, wxObject* obj, | |
1000 | int row=-1, int col=-1, int x=-1, int y=-1, | |
1001 | bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE); | |
1002 | ||
1003 | virtual int GetRow() { return m_row; } | |
1004 | virtual int GetCol() { return m_col; } | |
1005 | wxPoint GetPosition() { return wxPoint( m_x, m_y ); } | |
1006 | bool ControlDown() { return m_control; } | |
1007 | bool MetaDown() { return m_meta; } | |
1008 | bool ShiftDown() { return m_shift; } | |
1009 | bool AltDown() { return m_alt; } | |
2d66e025 | 1010 | |
60ff3b99 VZ |
1011 | protected: |
1012 | int m_row; | |
1013 | int m_col; | |
f85afd4e MB |
1014 | int m_x; |
1015 | int m_y; | |
1016 | bool m_control; | |
1017 | bool m_meta; | |
1018 | bool m_shift; | |
1019 | bool m_alt; | |
60ff3b99 VZ |
1020 | |
1021 | DECLARE_DYNAMIC_CLASS(wxGridEvent) | |
1022 | }; | |
1023 | ||
1024 | ||
1025 | class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent | |
1026 | { | |
1027 | public: | |
f85afd4e MB |
1028 | wxGridSizeEvent() |
1029 | : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1), | |
1030 | m_control(0), m_meta(0), m_shift(0), m_alt(0) | |
1031 | { | |
1032 | } | |
1033 | ||
1034 | wxGridSizeEvent(int id, wxEventType type, wxObject* obj, | |
1035 | int rowOrCol=-1, int x=-1, int y=-1, | |
1036 | bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE); | |
1037 | ||
1038 | int GetRowOrCol() { return m_rowOrCol; } | |
1039 | wxPoint GetPosition() { return wxPoint( m_x, m_y ); } | |
1040 | bool ControlDown() { return m_control; } | |
1041 | bool MetaDown() { return m_meta; } | |
1042 | bool ShiftDown() { return m_shift; } | |
1043 | bool AltDown() { return m_alt; } | |
2d66e025 | 1044 | |
60ff3b99 VZ |
1045 | protected: |
1046 | int m_rowOrCol; | |
1047 | int m_x; | |
1048 | int m_y; | |
1049 | bool m_control; | |
1050 | bool m_meta; | |
1051 | bool m_shift; | |
1052 | bool m_alt; | |
1053 | ||
2d66e025 | 1054 | DECLARE_DYNAMIC_CLASS(wxGridSizeEvent) |
f85afd4e MB |
1055 | }; |
1056 | ||
1057 | ||
1058 | class WXDLLEXPORT wxGridRangeSelectEvent : public wxNotifyEvent | |
1059 | { | |
60ff3b99 | 1060 | public: |
f85afd4e | 1061 | wxGridRangeSelectEvent() |
60ff3b99 VZ |
1062 | : wxNotifyEvent() |
1063 | { | |
1064 | m_topLeft = wxGridNoCellCoords; | |
1065 | m_bottomRight = wxGridNoCellCoords; | |
1066 | m_control = FALSE; | |
1067 | m_meta = FALSE; | |
1068 | m_shift = FALSE; | |
1069 | m_alt = FALSE; | |
1070 | } | |
f85afd4e MB |
1071 | |
1072 | wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj, | |
60ff3b99 VZ |
1073 | const wxGridCellCoords& topLeft, |
1074 | const wxGridCellCoords& bottomRight, | |
1075 | bool control=FALSE, bool shift=FALSE, | |
1076 | bool alt=FALSE, bool meta=FALSE); | |
f85afd4e MB |
1077 | |
1078 | wxGridCellCoords GetTopLeftCoords() { return m_topLeft; } | |
1079 | wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; } | |
1080 | int GetTopRow() { return m_topLeft.GetRow(); } | |
1081 | int GetBottomRow() { return m_bottomRight.GetRow(); } | |
1082 | int GetLeftCol() { return m_topLeft.GetCol(); } | |
1083 | int GetRightCol() { return m_bottomRight.GetCol(); } | |
1084 | bool ControlDown() { return m_control; } | |
1085 | bool MetaDown() { return m_meta; } | |
1086 | bool ShiftDown() { return m_shift; } | |
1087 | bool AltDown() { return m_alt; } | |
2d66e025 | 1088 | |
60ff3b99 VZ |
1089 | protected: |
1090 | wxGridCellCoords m_topLeft; | |
1091 | wxGridCellCoords m_bottomRight; | |
1092 | bool m_control; | |
1093 | bool m_meta; | |
1094 | bool m_shift; | |
1095 | bool m_alt; | |
1096 | ||
2d66e025 | 1097 | DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent) |
f85afd4e MB |
1098 | }; |
1099 | ||
1100 | ||
b5f788a5 MB |
1101 | const wxEventType EVT_GRID_CELL_LEFT_CLICK = wxEVT_FIRST + 1580; |
1102 | const wxEventType EVT_GRID_CELL_RIGHT_CLICK = wxEVT_FIRST + 1581; | |
1103 | const wxEventType EVT_GRID_CELL_LEFT_DCLICK = wxEVT_FIRST + 1582; | |
1104 | const wxEventType EVT_GRID_CELL_RIGHT_DCLICK = wxEVT_FIRST + 1583; | |
1105 | const wxEventType EVT_GRID_LABEL_LEFT_CLICK = wxEVT_FIRST + 1584; | |
1106 | const wxEventType EVT_GRID_LABEL_RIGHT_CLICK = wxEVT_FIRST + 1585; | |
1107 | const wxEventType EVT_GRID_LABEL_LEFT_DCLICK = wxEVT_FIRST + 1586; | |
1108 | const wxEventType EVT_GRID_LABEL_RIGHT_DCLICK = wxEVT_FIRST + 1587; | |
1109 | const wxEventType EVT_GRID_ROW_SIZE = wxEVT_FIRST + 1588; | |
1110 | const wxEventType EVT_GRID_COL_SIZE = wxEVT_FIRST + 1589; | |
1111 | const wxEventType EVT_GRID_RANGE_SELECT = wxEVT_FIRST + 1590; | |
1112 | const wxEventType EVT_GRID_CELL_CHANGE = wxEVT_FIRST + 1591; | |
749692cc MB |
1113 | const wxEventType EVT_GRID_SELECT_CELL = wxEVT_FIRST + 1592; |
1114 | ||
f85afd4e MB |
1115 | |
1116 | typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&); | |
1117 | typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&); | |
1118 | typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&); | |
1119 | ||
b5f788a5 MB |
1120 | #define EVT_GRID_CELL_LEFT_CLICK(fn) { EVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, |
1121 | #define EVT_GRID_CELL_RIGHT_CLICK(fn) { EVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1122 | #define EVT_GRID_CELL_LEFT_DCLICK(fn) { EVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1123 | #define EVT_GRID_CELL_RIGHT_DCLICK(fn) { EVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1124 | #define EVT_GRID_LABEL_LEFT_CLICK(fn) { EVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1125 | #define EVT_GRID_LABEL_RIGHT_CLICK(fn) { EVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1126 | #define EVT_GRID_LABEL_LEFT_DCLICK(fn) { EVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1127 | #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) { EVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1128 | #define EVT_GRID_ROW_SIZE(fn) { EVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL }, | |
1129 | #define EVT_GRID_COL_SIZE(fn) { EVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL }, | |
1130 | #define EVT_GRID_RANGE_SELECT(fn) { EVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL }, | |
60ff3b99 | 1131 | #define EVT_GRID_CELL_CHANGE(fn) { EVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, |
749692cc | 1132 | #define EVT_GRID_SELECT_CELL(fn) { EVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, |
f85afd4e MB |
1133 | |
1134 | ||
1135 | #if 0 // TODO: implement these ? others ? | |
1136 | ||
b5f788a5 MB |
1137 | const wxEventType EVT_GRID_CREATE_CELL = wxEVT_FIRST + 1576; |
1138 | const wxEventType EVT_GRID_CHANGE_LABELS = wxEVT_FIRST + 1577; | |
1139 | const wxEventType EVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578; | |
f85afd4e | 1140 | |
b5f788a5 MB |
1141 | #define EVT_GRID_CREATE_CELL(fn) { EVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, |
1142 | #define EVT_GRID_CHANGE_LABELS(fn) { EVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1143 | #define EVT_GRID_CHANGE_SEL_LABEL(fn) { EVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
f85afd4e MB |
1144 | |
1145 | #endif | |
1146 | ||
1147 | #endif // #ifndef __WXGRID_H__ | |
1148 | ||
1149 | #endif // ifndef wxUSE_NEW_GRID | |
8fb66724 | 1150 |