]>
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 ); | |
2d66e025 MB |
350 | |
351 | DECLARE_DYNAMIC_CLASS(wxGridCornerLabelWindow) | |
352 | DECLARE_EVENT_TABLE() | |
353 | }; | |
354 | ||
355 | ||
356 | ||
357 | class WXDLLEXPORT wxGridWindow : public wxPanel | |
358 | { | |
2d66e025 | 359 | public: |
60ff3b99 VZ |
360 | wxGridWindow() |
361 | { | |
362 | m_owner = (wxGrid *)NULL; | |
363 | m_rowLabelWin = (wxGridRowLabelWindow *)NULL; | |
364 | m_colLabelWin = (wxGridColLabelWindow *)NULL; | |
365 | } | |
366 | ||
367 | wxGridWindow( wxGrid *parent, | |
2d66e025 MB |
368 | wxGridRowLabelWindow *rowLblWin, |
369 | wxGridColLabelWindow *colLblWin, | |
370 | wxWindowID id, const wxPoint &pos, const wxSize &size ); | |
371 | ~wxGridWindow(); | |
f85afd4e | 372 | |
2d66e025 MB |
373 | void ScrollWindow( int dx, int dy, const wxRect *rect ); |
374 | ||
60ff3b99 VZ |
375 | private: |
376 | wxGrid *m_owner; | |
2d66e025 MB |
377 | wxGridRowLabelWindow *m_rowLabelWin; |
378 | wxGridColLabelWindow *m_colLabelWin; | |
2d66e025 | 379 | |
60ff3b99 VZ |
380 | void OnPaint( wxPaintEvent &event ); |
381 | void OnMouseEvent( wxMouseEvent& event ); | |
f85afd4e | 382 | void OnKeyDown( wxKeyEvent& ); |
f85afd4e | 383 | |
60ff3b99 VZ |
384 | DECLARE_DYNAMIC_CLASS(wxGridWindow) |
385 | DECLARE_EVENT_TABLE() | |
386 | }; | |
f85afd4e | 387 | |
f85afd4e MB |
388 | |
389 | ||
60ff3b99 VZ |
390 | class WXDLLEXPORT wxGrid : public wxScrolledWindow |
391 | { | |
392 | public: | |
f85afd4e MB |
393 | wxGrid() |
394 | { Create(); } | |
60ff3b99 | 395 | |
f85afd4e MB |
396 | wxGrid( wxWindow *parent, |
397 | wxWindowID id, | |
398 | const wxPoint& pos = wxDefaultPosition, | |
399 | const wxSize& size = wxDefaultSize, | |
400 | long style = 0, | |
2d66e025 MB |
401 | const wxString& name = wxPanelNameStr ); |
402 | ||
60ff3b99 | 403 | ~wxGrid(); |
f85afd4e | 404 | |
2d66e025 MB |
405 | bool CreateGrid( int numRows, int numCols ); |
406 | ||
60ff3b99 | 407 | |
2d66e025 MB |
408 | // ------ grid dimensions |
409 | // | |
410 | int GetNumberRows() { return m_numRows; } | |
411 | int GetNumberCols() { return m_numCols; } | |
412 | ||
60ff3b99 | 413 | |
2d66e025 MB |
414 | // ------ display update functions |
415 | // | |
60ff3b99 VZ |
416 | void CalcRowLabelsExposed( wxRegion& reg ); |
417 | void CalcColLabelsExposed( wxRegion& reg ); | |
418 | void CalcCellsExposed( wxRegion& reg ); | |
419 | ||
2d66e025 | 420 | |
2d66e025 MB |
421 | // ------ event handlers |
422 | // | |
423 | void ProcessRowLabelMouseEvent( wxMouseEvent& event ); | |
424 | void ProcessColLabelMouseEvent( wxMouseEvent& event ); | |
425 | void ProcessCornerLabelMouseEvent( wxMouseEvent& event ); | |
60ff3b99 | 426 | void ProcessGridCellMouseEvent( wxMouseEvent& event ); |
2d66e025 | 427 | bool ProcessTableMessage( wxGridTableMessage& ); |
f85afd4e | 428 | |
60ff3b99 | 429 | |
f85afd4e MB |
430 | wxGridTableBase * GetTable() const { return m_table; } |
431 | void SetTable( wxGridTableBase *table ) { m_table = table; } | |
432 | ||
433 | void ClearGrid(); | |
434 | bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE ); | |
435 | bool AppendRows( int numRows = 1, bool updateLabels=TRUE ); | |
436 | bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE ); | |
437 | bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE ); | |
438 | bool AppendCols( int numCols = 1, bool updateLabels=TRUE ); | |
60ff3b99 | 439 | bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE ); |
f85afd4e | 440 | |
2d66e025 MB |
441 | void DrawGridCellArea( wxDC& dc ); |
442 | void DrawCellBorder( wxDC& dc, const wxGridCellCoords& ); | |
443 | void DrawAllGridLines( wxDC& dc ); // TODO - delete this ? | |
444 | void DrawCell( wxDC& dc, const wxGridCellCoords& ); | |
445 | void DrawCellBackground( wxDC& dc, const wxGridCellCoords& ); | |
446 | void DrawCellValue( wxDC& dc, const wxGridCellCoords& ); | |
1f1ce288 | 447 | |
2d66e025 MB |
448 | void DrawRowLabels( wxDC& dc ); |
449 | void DrawRowLabel( wxDC& dc, int row ); | |
450 | void DrawColLabels( wxDC& dc ); | |
451 | void DrawColLabel( wxDC& dc, int col ); | |
60ff3b99 | 452 | |
f85afd4e | 453 | |
2d66e025 | 454 | // ------ Cell text drawing functions |
f85afd4e | 455 | // |
2d66e025 MB |
456 | void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&, |
457 | int horizontalAlignment = wxLEFT, | |
458 | int verticalAlignment = wxTOP ); | |
f85afd4e | 459 | |
2d66e025 MB |
460 | // Split a string containing newline chararcters into an array of |
461 | // strings and return the number of lines | |
462 | // | |
463 | void StringToLines( const wxString& value, wxArrayString& lines ); | |
60ff3b99 | 464 | |
2d66e025 MB |
465 | void GetTextBoxSize( wxDC& dc, |
466 | wxArrayString& lines, | |
467 | long *width, long *height ); | |
60ff3b99 | 468 | |
2d66e025 | 469 | |
f85afd4e MB |
470 | // ------ |
471 | // Code that does a lot of grid modification can be enclosed | |
472 | // between BeginBatch() and EndBatch() calls to avoid screen | |
473 | // flicker | |
474 | // | |
475 | void BeginBatch() { m_batchCount++; } | |
476 | void EndBatch() { if ( m_batchCount > 0 ) m_batchCount--; } | |
477 | int GetBatchCount() { return m_batchCount; } | |
478 | ||
2d66e025 MB |
479 | |
480 | // ------ edit control functions | |
481 | // | |
482 | bool IsEditable() { return m_editable; } | |
483 | void EnableEditing( bool edit ); | |
484 | ||
60ff3b99 | 485 | #if 0 // at the moment the cell edit control is always active |
2d66e025 | 486 | void EnableCellEditControl( bool enable ); |
1f1ce288 | 487 | #endif |
2d66e025 MB |
488 | |
489 | bool IsCellEditControlEnabled() | |
490 | { return (m_cellEditCtrl && m_cellEditCtrlEnabled); } | |
491 | ||
2d66e025 MB |
492 | void ShowCellEditControl(); |
493 | void HideCellEditControl(); | |
494 | void SetEditControlValue( const wxString& s = wxEmptyString ); | |
495 | void SaveEditControlValue(); | |
496 | ||
60ff3b99 | 497 | |
2d66e025 | 498 | // ------ grid location functions |
60ff3b99 | 499 | // Note that all of these functions work with the logical coordinates of |
2d66e025 MB |
500 | // grid cells and labels so you will need to convert from device |
501 | // coordinates for mouse events etc. | |
502 | // | |
503 | void XYToCell( int x, int y, wxGridCellCoords& ); | |
504 | int YToRow( int y ); | |
505 | int XToCol( int x ); | |
506 | ||
507 | int YToEdgeOfRow( int y ); | |
508 | int XToEdgeOfCol( int x ); | |
509 | ||
510 | wxRect CellToRect( int row, int col ); | |
511 | wxRect CellToRect( const wxGridCellCoords& coords ) | |
512 | { return CellToRect( coords.GetRow(), coords.GetCol() ); } | |
513 | ||
514 | int GetGridCursorRow() { return m_currentCellCoords.GetRow(); } | |
515 | int GetGridCursorCol() { return m_currentCellCoords.GetCol(); } | |
60ff3b99 | 516 | |
2d66e025 MB |
517 | // check to see if a cell is either wholly visible (the default arg) or |
518 | // at least partially visible in the grid window | |
519 | // | |
520 | bool IsVisible( int row, int col, bool wholeCellVisible = TRUE ); | |
521 | bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE ) | |
522 | { return IsVisible( coords.GetRow(), coords.GetCol(), wholeCellVisible ); } | |
523 | void MakeCellVisible( int row, int col ); | |
524 | void MakeCellVisible( const wxGridCellCoords& coords ) | |
525 | { MakeCellVisible( coords.GetRow(), coords.GetCol() ); } | |
526 | ||
60ff3b99 | 527 | |
2d66e025 MB |
528 | // ------ grid cursor movement functions |
529 | // | |
dfaf42d2 | 530 | void SetGridCursor( int row, int col ) |
b27f2615 | 531 | { SetCurrentCell( wxGridCellCoords(row, col) ); } |
dfaf42d2 | 532 | |
2d66e025 MB |
533 | bool MoveCursorUp(); |
534 | bool MoveCursorDown(); | |
535 | bool MoveCursorLeft(); | |
536 | bool MoveCursorRight(); | |
537 | bool MovePageDown(); | |
538 | bool MovePageUp(); | |
539 | bool MoveCursorUpBlock(); | |
540 | bool MoveCursorDownBlock(); | |
541 | bool MoveCursorLeftBlock(); | |
542 | bool MoveCursorRightBlock(); | |
543 | ||
60ff3b99 | 544 | |
f85afd4e MB |
545 | // ------ label and gridline formatting |
546 | // | |
547 | int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; } | |
548 | int GetRowLabelSize() { return m_rowLabelWidth; } | |
60ff3b99 | 549 | int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; } |
f85afd4e MB |
550 | int GetColLabelSize() { return m_colLabelHeight; } |
551 | wxColour GetLabelBackgroundColour() { return m_labelBackgroundColour; } | |
552 | wxColour GetLabelTextColour() { return m_labelTextColour; } | |
553 | wxFont GetLabelFont() { return m_labelFont; } | |
554 | void GetRowLabelAlignment( int *horiz, int *vert ); | |
555 | void GetColLabelAlignment( int *horiz, int *vert ); | |
556 | wxString GetRowLabelValue( int row ); | |
557 | wxString GetColLabelValue( int col ); | |
558 | wxColour GetGridLineColour() { return m_gridLineColour; } | |
559 | ||
2d66e025 | 560 | void SetRowLabelSize( int width ); |
f85afd4e MB |
561 | void SetColLabelSize( int height ); |
562 | void SetLabelBackgroundColour( const wxColour& ); | |
563 | void SetLabelTextColour( const wxColour& ); | |
564 | void SetLabelFont( const wxFont& ); | |
565 | void SetRowLabelAlignment( int horiz, int vert ); | |
566 | void SetColLabelAlignment( int horiz, int vert ); | |
567 | void SetRowLabelValue( int row, const wxString& ); | |
568 | void SetColLabelValue( int col, const wxString& ); | |
569 | void SetGridLineColour( const wxColour& ); | |
570 | ||
571 | void EnableGridLines( bool enable = TRUE ); | |
572 | bool GridLinesEnabled() { return m_gridLinesEnabled; } | |
573 | ||
2d66e025 | 574 | |
f85afd4e MB |
575 | // ------ row and col formatting |
576 | // | |
577 | int GetDefaultRowSize(); | |
578 | int GetRowSize( int row ); | |
579 | int GetDefaultColSize(); | |
580 | int GetColSize( int col ); | |
581 | wxColour GetDefaultCellBackgroundColour(); | |
582 | wxColour GetCellBackgroundColour( int row, int col ); | |
583 | wxColour GetDefaultCellTextColour(); | |
584 | wxColour GetCellTextColour( int row, int col ); | |
f85afd4e MB |
585 | wxFont GetDefaultCellFont(); |
586 | wxFont GetCellFont( int row, int col ); | |
587 | void GetDefaultCellAlignment( int *horiz, int *vert ); | |
588 | void GetCellAlignment( int row, int col, int *horiz, int *vert ); | |
60ff3b99 | 589 | |
f85afd4e MB |
590 | void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE ); |
591 | void SetRowSize( int row, int height ); | |
592 | void SetDefaultColSize( int width, bool resizeExistingCols = FALSE ); | |
593 | void SetColSize( int col, int width ); | |
594 | void SetDefaultCellBackgroundColour( const wxColour& ); | |
595 | void SetCellBackgroundColour( int row, int col, const wxColour& ); | |
596 | void SetDefaultCellTextColour( const wxColour& ); | |
597 | void SetCellTextColour( int row, int col, const wxColour& ); | |
f85afd4e MB |
598 | void SetDefaultCellFont( const wxFont& ); |
599 | void SetCellFont( int row, int col, const wxFont& ); | |
600 | void SetDefaultCellAlignment( int horiz, int vert ); | |
601 | void SetCellAlignment( int row, int col, int horiz, int vert ); | |
602 | ||
60a67569 | 603 | |
f85afd4e MB |
604 | // ------ cell value accessors |
605 | // | |
606 | wxString GetCellValue( int row, int col ) | |
607 | { | |
608 | if ( m_table ) | |
609 | { | |
610 | return m_table->GetValue( row, col ); | |
611 | } | |
612 | else | |
613 | { | |
614 | return wxEmptyString; | |
615 | } | |
616 | } | |
617 | ||
618 | wxString GetCellValue( const wxGridCellCoords& coords ) | |
619 | { return GetCellValue( coords.GetRow(), coords.GetCol() ); } | |
60ff3b99 | 620 | |
f85afd4e MB |
621 | void SetCellValue( int row, int col, const wxString& s ); |
622 | void SetCellValue( const wxGridCellCoords& coords, const wxString& s ) | |
623 | { SetCellValue( coords.GetRow(), coords.GetCol(), s ); } | |
f85afd4e | 624 | |
60ff3b99 | 625 | |
f85afd4e MB |
626 | |
627 | // ------ selections of blocks of cells | |
628 | // | |
629 | void SelectRow( int row, bool addToSelected = FALSE ); | |
630 | void SelectCol( int col, bool addToSelected = FALSE ); | |
60ff3b99 | 631 | |
f85afd4e MB |
632 | void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol ); |
633 | ||
634 | void SelectBlock( const wxGridCellCoords& topLeft, | |
635 | const wxGridCellCoords& bottomRight ) | |
636 | { SelectBlock( topLeft.GetRow(), topLeft.GetCol(), | |
637 | bottomRight.GetRow(), bottomRight.GetCol() ); } | |
638 | ||
639 | void SelectAll(); | |
60ff3b99 | 640 | |
f85afd4e MB |
641 | bool IsSelection() |
642 | { return ( m_selectedTopLeft != wxGridNoCellCoords && | |
643 | m_selectedBottomRight != wxGridNoCellCoords ); | |
644 | } | |
645 | ||
646 | void ClearSelection(); | |
647 | ||
648 | bool IsInSelection( int row, int col ) | |
649 | { return ( IsSelection() && | |
650 | row >= m_selectedTopLeft.GetRow() && | |
651 | col >= m_selectedTopLeft.GetCol() && | |
652 | row <= m_selectedBottomRight.GetRow() && | |
653 | col <= m_selectedBottomRight.GetCol() ); | |
654 | } | |
655 | ||
656 | bool IsInSelection( const wxGridCellCoords& coords ) | |
657 | { return IsInSelection( coords.GetRow(), coords.GetCol() ); } | |
658 | ||
659 | void GetSelection( int* topRow, int* leftCol, int* bottomRow, int* rightCol ) | |
660 | { | |
661 | // these will all be -1 if there is no selected block | |
662 | // | |
663 | *topRow = m_selectedTopLeft.GetRow(); | |
664 | *leftCol = m_selectedTopLeft.GetCol(); | |
665 | *bottomRow = m_selectedBottomRight.GetRow(); | |
666 | *rightCol = m_selectedBottomRight.GetCol(); | |
667 | } | |
668 | ||
c3baf426 SN |
669 | |
670 | // This function returns the rectangle that encloses the block of cells | |
671 | // limited by TopLeft and BottomRight cell in device coords and clipped | |
672 | // to the client size of the grid window. | |
673 | // | |
674 | wxRect BlockToDeviceRect( const wxGridCellCoords & TopLeft, | |
675 | const wxGridCellCoords & BottomRight ); | |
676 | ||
2d66e025 MB |
677 | // This function returns the rectangle that encloses the selected cells |
678 | // in device coords and clipped to the client size of the grid window. | |
f85afd4e | 679 | // |
c3baf426 SN |
680 | wxRect SelectionToDeviceRect() |
681 | { | |
682 | return BlockToDeviceRect( m_selectedTopLeft, | |
683 | m_selectedBottomRight ); | |
684 | } | |
60ff3b99 | 685 | |
f85afd4e MB |
686 | |
687 | // ------ For compatibility with previous wxGrid only... | |
688 | // | |
689 | // ************************************************ | |
690 | // ** Don't use these in new code because they ** | |
691 | // ** are liable to disappear in a future ** | |
692 | // ** revision ** | |
693 | // ************************************************ | |
694 | // | |
695 | ||
696 | wxGrid( wxWindow *parent, | |
697 | int x = -1, int y = -1, int w = -1, int h = -1, | |
698 | long style = 0, | |
699 | const wxString& name = wxPanelNameStr ) | |
2d66e025 | 700 | : wxScrolledWindow( parent, -1, wxPoint(x,y), wxSize(w,h), style, name ) |
60ff3b99 | 701 | { |
f85afd4e | 702 | Create(); |
60ff3b99 | 703 | } |
f85afd4e MB |
704 | |
705 | void SetCellValue( const wxString& val, int row, int col ) | |
706 | { SetCellValue( row, col, val ); } | |
60ff3b99 | 707 | |
f85afd4e MB |
708 | void UpdateDimensions() |
709 | { CalcDimensions(); } | |
710 | ||
711 | int GetRows() { return GetNumberRows(); } | |
712 | int GetCols() { return GetNumberCols(); } | |
713 | int GetCursorRow() { return GetGridCursorRow(); } | |
714 | int GetCursorColumn() { return GetGridCursorCol(); } | |
60ff3b99 | 715 | |
2d66e025 MB |
716 | int GetScrollPosX() { return 0; } |
717 | int GetScrollPosY() { return 0; } | |
60ff3b99 | 718 | |
2d66e025 MB |
719 | void SetScrollX( int x ) { } |
720 | void SetScrollY( int y ) { } | |
f85afd4e MB |
721 | |
722 | void SetColumnWidth( int col, int width ) | |
723 | { SetColSize( col, width ); } | |
60ff3b99 | 724 | |
f85afd4e MB |
725 | int GetColumnWidth( int col ) |
726 | { return GetColSize( col ); } | |
60ff3b99 | 727 | |
f85afd4e MB |
728 | void SetRowHeight( int row, int height ) |
729 | { SetRowSize( row, height ); } | |
60ff3b99 | 730 | |
f85afd4e MB |
731 | int GetRowHeight( int row ) |
732 | { return GetRowSize( row ); } | |
60ff3b99 | 733 | |
2d66e025 MB |
734 | int GetViewHeight() // returned num whole rows visible |
735 | { return 0; } | |
60ff3b99 | 736 | |
2d66e025 MB |
737 | int GetViewWidth() // returned num whole cols visible |
738 | { return 0; } | |
f85afd4e MB |
739 | |
740 | void SetLabelSize( int orientation, int sz ) | |
741 | { | |
742 | if ( orientation == wxHORIZONTAL ) | |
743 | SetColLabelSize( sz ); | |
744 | else | |
745 | SetRowLabelSize( sz ); | |
746 | } | |
747 | ||
748 | int GetLabelSize( int orientation ) | |
749 | { | |
750 | if ( orientation == wxHORIZONTAL ) | |
751 | return GetColLabelSize(); | |
752 | else | |
753 | return GetRowLabelSize(); | |
754 | } | |
755 | ||
756 | void SetLabelAlignment( int orientation, int align ) | |
757 | { | |
758 | if ( orientation == wxHORIZONTAL ) | |
759 | SetColLabelAlignment( align, -1 ); | |
760 | else | |
761 | SetRowLabelAlignment( align, -1 ); | |
762 | } | |
763 | ||
af111fc3 | 764 | int GetLabelAlignment( int orientation, int WXUNUSED(align) ) |
f85afd4e MB |
765 | { |
766 | int h, v; | |
767 | if ( orientation == wxHORIZONTAL ) | |
768 | { | |
769 | GetColLabelAlignment( &h, &v ); | |
770 | return h; | |
771 | } | |
772 | else | |
773 | { | |
774 | GetRowLabelAlignment( &h, &v ); | |
775 | return h; | |
776 | } | |
777 | } | |
778 | ||
779 | void SetLabelValue( int orientation, const wxString& val, int pos ) | |
780 | { | |
781 | if ( orientation == wxHORIZONTAL ) | |
782 | SetColLabelValue( pos, val ); | |
783 | else | |
784 | SetRowLabelValue( pos, val ); | |
785 | } | |
60ff3b99 | 786 | |
f85afd4e MB |
787 | wxString GetLabelValue( int orientation, int pos) |
788 | { | |
789 | if ( orientation == wxHORIZONTAL ) | |
790 | return GetColLabelValue( pos ); | |
791 | else | |
792 | return GetRowLabelValue( pos ); | |
793 | } | |
794 | ||
60ff3b99 | 795 | wxFont GetCellTextFont() const |
f85afd4e | 796 | { return m_defaultCellFont; } |
60ff3b99 | 797 | |
af111fc3 | 798 | wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const |
f85afd4e | 799 | { return m_defaultCellFont; } |
60ff3b99 | 800 | |
f85afd4e MB |
801 | void SetCellTextFont(const wxFont& fnt) |
802 | { SetDefaultCellFont( fnt ); } | |
60ff3b99 | 803 | |
f85afd4e MB |
804 | void SetCellTextFont(const wxFont& fnt, int row, int col) |
805 | { SetCellFont( row, col, fnt ); } | |
60ff3b99 | 806 | |
f85afd4e MB |
807 | void SetCellTextColour(const wxColour& val, int row, int col) |
808 | { SetCellTextColour( row, col, val ); } | |
60ff3b99 | 809 | |
f85afd4e MB |
810 | void SetCellTextColour(const wxColour& col) |
811 | { SetDefaultCellTextColour( col ); } | |
60ff3b99 | 812 | |
f85afd4e MB |
813 | void SetCellBackgroundColour(const wxColour& col) |
814 | { SetDefaultCellBackgroundColour( col ); } | |
60ff3b99 | 815 | |
f85afd4e MB |
816 | void SetCellBackgroundColour(const wxColour& colour, int row, int col) |
817 | { SetCellBackgroundColour( row, col, colour ); } | |
60ff3b99 | 818 | |
f85afd4e MB |
819 | bool GetEditable() { return IsEditable(); } |
820 | void SetEditable( bool edit = TRUE ) { EnableEditing( edit ); } | |
821 | bool GetEditInPlace() { return IsCellEditControlEnabled(); } | |
1f1ce288 | 822 | void SetEditInPlace(bool edit = TRUE) { } |
f85afd4e | 823 | |
60a67569 JS |
824 | void SetCellAlignment( int align, int row, int col) |
825 | { SetCellAlignment(row, col, align, wxCENTER); } | |
826 | void SetCellAlignment( int WXUNUSED(align) ) {} | |
827 | void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col)) | |
828 | { } | |
829 | void SetDividerPen(const wxPen& WXUNUSED(pen)) { } | |
830 | wxPen& GetDividerPen() const { return wxNullPen; } | |
831 | void OnActivate(bool WXUNUSED(active)) {} | |
60ff3b99 | 832 | |
f85afd4e MB |
833 | // ******** End of compatibility functions ********** |
834 | ||
2d66e025 MB |
835 | |
836 | ||
f85afd4e | 837 | // ------ control IDs |
2d66e025 | 838 | enum { wxGRID_CELLCTRL = 2000, |
f85afd4e MB |
839 | wxGRID_TOPCTRL }; |
840 | ||
841 | // ------ control types | |
2d66e025 | 842 | enum { wxGRID_TEXTCTRL = 2100, |
f85afd4e MB |
843 | wxGRID_CHECKBOX, |
844 | wxGRID_CHOICE, | |
845 | wxGRID_COMBOBOX }; | |
846 | ||
60ff3b99 VZ |
847 | protected: |
848 | bool m_created; | |
849 | ||
850 | wxGridWindow *m_gridWin; | |
851 | wxGridRowLabelWindow *m_rowLabelWin; | |
852 | wxGridColLabelWindow *m_colLabelWin; | |
853 | wxGridCornerLabelWindow *m_cornerLabelWin; | |
854 | ||
855 | wxBoxSizer *m_mainSizer; | |
856 | wxBoxSizer *m_topSizer; | |
857 | wxBoxSizer *m_middleSizer; | |
858 | ||
859 | wxGridTableBase *m_table; | |
860 | ||
861 | int m_left; | |
862 | int m_top; | |
863 | int m_right; | |
864 | int m_bottom; | |
865 | ||
866 | int m_numRows; | |
867 | int m_numCols; | |
868 | ||
869 | wxGridCellCoords m_currentCellCoords; | |
870 | ||
871 | wxGridCellCoords m_selectedTopLeft; | |
872 | wxGridCellCoords m_selectedBottomRight; | |
873 | ||
874 | int m_defaultRowHeight; | |
875 | wxArrayInt m_rowHeights; | |
876 | wxArrayInt m_rowBottoms; | |
877 | ||
878 | int m_defaultColWidth; | |
879 | wxArrayInt m_colWidths; | |
880 | wxArrayInt m_colRights; | |
881 | ||
882 | int m_rowLabelWidth; | |
883 | int m_colLabelHeight; | |
884 | ||
885 | wxColour m_labelBackgroundColour; | |
886 | wxColour m_labelTextColour; | |
887 | wxFont m_labelFont; | |
888 | ||
889 | int m_rowLabelHorizAlign; | |
890 | int m_rowLabelVertAlign; | |
891 | int m_colLabelHorizAlign; | |
892 | int m_colLabelVertAlign; | |
893 | ||
894 | bool m_defaultRowLabelValues; | |
895 | bool m_defaultColLabelValues; | |
896 | ||
897 | wxColour m_gridLineColour; | |
898 | bool m_gridLinesEnabled; | |
899 | ||
900 | wxFont m_defaultCellFont; | |
901 | ||
902 | wxGridCellCoordsArray m_cellsExposed; | |
903 | wxArrayInt m_rowsExposed; | |
904 | wxArrayInt m_colsExposed; | |
905 | wxArrayInt m_rowLabelsExposed; | |
906 | wxArrayInt m_colLabelsExposed; | |
907 | ||
908 | bool m_inOnKeyDown; | |
909 | int m_batchCount; | |
910 | ||
911 | int m_cursorMode; | |
912 | enum { WXGRID_CURSOR_DEFAULT, | |
913 | WXGRID_CURSOR_SELECT_CELL, | |
914 | WXGRID_CURSOR_RESIZE_ROW, | |
915 | WXGRID_CURSOR_RESIZE_COL, | |
916 | WXGRID_CURSOR_SELECT_ROW, | |
917 | WXGRID_CURSOR_SELECT_COL | |
918 | }; | |
919 | ||
920 | int m_dragLastPos; | |
921 | int m_dragRowOrCol; | |
922 | bool m_isDragging; | |
923 | ||
924 | wxGridCellCoords m_selectionStart; | |
925 | ||
926 | wxCursor m_rowResizeCursor; | |
927 | wxCursor m_colResizeCursor; | |
928 | ||
929 | bool m_editable; // applies to whole grid | |
930 | int m_editCtrlType; // for current cell | |
931 | wxWindow* m_cellEditCtrl; | |
932 | bool m_cellEditCtrlEnabled; | |
933 | ||
934 | ||
935 | void Create(); | |
936 | void Init(); | |
937 | void CalcDimensions(); | |
938 | bool Redimension( wxGridTableMessage& ); | |
939 | ||
940 | ||
941 | bool SendEvent( const wxEventType, | |
942 | int row, int col, | |
943 | wxMouseEvent& ); | |
944 | ||
945 | bool SendEvent( const wxEventType, | |
946 | int row, int col ); | |
947 | ||
948 | ||
949 | void OnPaint( wxPaintEvent& ); | |
950 | void OnSize( wxSizeEvent& ); | |
951 | void OnKeyDown( wxKeyEvent& ); | |
952 | ||
953 | ||
954 | void SetCurrentCell( const wxGridCellCoords& coords ); | |
955 | void SetCurrentCell( int row, int col ) | |
956 | { SetCurrentCell( wxGridCellCoords(row, col) ); } | |
957 | ||
958 | ||
959 | // ------ functions to get/send data (see also public functions) | |
960 | // | |
961 | bool GetModelValues(); | |
962 | bool SetModelValues(); | |
963 | ||
964 | ||
965 | ////////////////////// Public section //////////////////// | |
966 | ||
967 | ||
2d66e025 | 968 | DECLARE_DYNAMIC_CLASS( wxGrid ) |
f85afd4e MB |
969 | DECLARE_EVENT_TABLE() |
970 | }; | |
971 | ||
972 | ||
973 | ||
974 | ||
975 | ||
976 | // | |
977 | // ------ Grid event class and event types | |
978 | // | |
979 | ||
980 | class WXDLLEXPORT wxGridEvent : public wxNotifyEvent | |
981 | { | |
60ff3b99 | 982 | public: |
f85afd4e MB |
983 | wxGridEvent() |
984 | : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1), | |
985 | m_control(0), m_meta(0), m_shift(0), m_alt(0) | |
986 | { | |
987 | } | |
988 | ||
989 | wxGridEvent(int id, wxEventType type, wxObject* obj, | |
990 | int row=-1, int col=-1, int x=-1, int y=-1, | |
991 | bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE); | |
992 | ||
993 | virtual int GetRow() { return m_row; } | |
994 | virtual int GetCol() { return m_col; } | |
995 | wxPoint GetPosition() { return wxPoint( m_x, m_y ); } | |
996 | bool ControlDown() { return m_control; } | |
997 | bool MetaDown() { return m_meta; } | |
998 | bool ShiftDown() { return m_shift; } | |
999 | bool AltDown() { return m_alt; } | |
2d66e025 | 1000 | |
60ff3b99 VZ |
1001 | protected: |
1002 | int m_row; | |
1003 | int m_col; | |
f85afd4e MB |
1004 | int m_x; |
1005 | int m_y; | |
1006 | bool m_control; | |
1007 | bool m_meta; | |
1008 | bool m_shift; | |
1009 | bool m_alt; | |
60ff3b99 VZ |
1010 | |
1011 | DECLARE_DYNAMIC_CLASS(wxGridEvent) | |
1012 | }; | |
1013 | ||
1014 | ||
1015 | class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent | |
1016 | { | |
1017 | public: | |
f85afd4e MB |
1018 | wxGridSizeEvent() |
1019 | : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1), | |
1020 | m_control(0), m_meta(0), m_shift(0), m_alt(0) | |
1021 | { | |
1022 | } | |
1023 | ||
1024 | wxGridSizeEvent(int id, wxEventType type, wxObject* obj, | |
1025 | int rowOrCol=-1, int x=-1, int y=-1, | |
1026 | bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE); | |
1027 | ||
1028 | int GetRowOrCol() { return m_rowOrCol; } | |
1029 | wxPoint GetPosition() { return wxPoint( m_x, m_y ); } | |
1030 | bool ControlDown() { return m_control; } | |
1031 | bool MetaDown() { return m_meta; } | |
1032 | bool ShiftDown() { return m_shift; } | |
1033 | bool AltDown() { return m_alt; } | |
2d66e025 | 1034 | |
60ff3b99 VZ |
1035 | protected: |
1036 | int m_rowOrCol; | |
1037 | int m_x; | |
1038 | int m_y; | |
1039 | bool m_control; | |
1040 | bool m_meta; | |
1041 | bool m_shift; | |
1042 | bool m_alt; | |
1043 | ||
2d66e025 | 1044 | DECLARE_DYNAMIC_CLASS(wxGridSizeEvent) |
f85afd4e MB |
1045 | }; |
1046 | ||
1047 | ||
1048 | class WXDLLEXPORT wxGridRangeSelectEvent : public wxNotifyEvent | |
1049 | { | |
60ff3b99 | 1050 | public: |
f85afd4e | 1051 | wxGridRangeSelectEvent() |
60ff3b99 VZ |
1052 | : wxNotifyEvent() |
1053 | { | |
1054 | m_topLeft = wxGridNoCellCoords; | |
1055 | m_bottomRight = wxGridNoCellCoords; | |
1056 | m_control = FALSE; | |
1057 | m_meta = FALSE; | |
1058 | m_shift = FALSE; | |
1059 | m_alt = FALSE; | |
1060 | } | |
f85afd4e MB |
1061 | |
1062 | wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj, | |
60ff3b99 VZ |
1063 | const wxGridCellCoords& topLeft, |
1064 | const wxGridCellCoords& bottomRight, | |
1065 | bool control=FALSE, bool shift=FALSE, | |
1066 | bool alt=FALSE, bool meta=FALSE); | |
f85afd4e MB |
1067 | |
1068 | wxGridCellCoords GetTopLeftCoords() { return m_topLeft; } | |
1069 | wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; } | |
1070 | int GetTopRow() { return m_topLeft.GetRow(); } | |
1071 | int GetBottomRow() { return m_bottomRight.GetRow(); } | |
1072 | int GetLeftCol() { return m_topLeft.GetCol(); } | |
1073 | int GetRightCol() { return m_bottomRight.GetCol(); } | |
1074 | bool ControlDown() { return m_control; } | |
1075 | bool MetaDown() { return m_meta; } | |
1076 | bool ShiftDown() { return m_shift; } | |
1077 | bool AltDown() { return m_alt; } | |
2d66e025 | 1078 | |
60ff3b99 VZ |
1079 | protected: |
1080 | wxGridCellCoords m_topLeft; | |
1081 | wxGridCellCoords m_bottomRight; | |
1082 | bool m_control; | |
1083 | bool m_meta; | |
1084 | bool m_shift; | |
1085 | bool m_alt; | |
1086 | ||
2d66e025 | 1087 | DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent) |
f85afd4e MB |
1088 | }; |
1089 | ||
1090 | ||
b5f788a5 MB |
1091 | const wxEventType EVT_GRID_CELL_LEFT_CLICK = wxEVT_FIRST + 1580; |
1092 | const wxEventType EVT_GRID_CELL_RIGHT_CLICK = wxEVT_FIRST + 1581; | |
1093 | const wxEventType EVT_GRID_CELL_LEFT_DCLICK = wxEVT_FIRST + 1582; | |
1094 | const wxEventType EVT_GRID_CELL_RIGHT_DCLICK = wxEVT_FIRST + 1583; | |
1095 | const wxEventType EVT_GRID_LABEL_LEFT_CLICK = wxEVT_FIRST + 1584; | |
1096 | const wxEventType EVT_GRID_LABEL_RIGHT_CLICK = wxEVT_FIRST + 1585; | |
1097 | const wxEventType EVT_GRID_LABEL_LEFT_DCLICK = wxEVT_FIRST + 1586; | |
1098 | const wxEventType EVT_GRID_LABEL_RIGHT_DCLICK = wxEVT_FIRST + 1587; | |
1099 | const wxEventType EVT_GRID_ROW_SIZE = wxEVT_FIRST + 1588; | |
1100 | const wxEventType EVT_GRID_COL_SIZE = wxEVT_FIRST + 1589; | |
1101 | const wxEventType EVT_GRID_RANGE_SELECT = wxEVT_FIRST + 1590; | |
1102 | const wxEventType EVT_GRID_CELL_CHANGE = wxEVT_FIRST + 1591; | |
749692cc MB |
1103 | const wxEventType EVT_GRID_SELECT_CELL = wxEVT_FIRST + 1592; |
1104 | ||
f85afd4e MB |
1105 | |
1106 | typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&); | |
1107 | typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&); | |
1108 | typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&); | |
1109 | ||
b5f788a5 MB |
1110 | #define EVT_GRID_CELL_LEFT_CLICK(fn) { EVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, |
1111 | #define EVT_GRID_CELL_RIGHT_CLICK(fn) { EVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1112 | #define EVT_GRID_CELL_LEFT_DCLICK(fn) { EVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1113 | #define EVT_GRID_CELL_RIGHT_DCLICK(fn) { EVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1114 | #define EVT_GRID_LABEL_LEFT_CLICK(fn) { EVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1115 | #define EVT_GRID_LABEL_RIGHT_CLICK(fn) { EVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1116 | #define EVT_GRID_LABEL_LEFT_DCLICK(fn) { EVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1117 | #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) { EVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1118 | #define EVT_GRID_ROW_SIZE(fn) { EVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL }, | |
1119 | #define EVT_GRID_COL_SIZE(fn) { EVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL }, | |
1120 | #define EVT_GRID_RANGE_SELECT(fn) { EVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL }, | |
60ff3b99 | 1121 | #define EVT_GRID_CELL_CHANGE(fn) { EVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, |
749692cc | 1122 | #define EVT_GRID_SELECT_CELL(fn) { EVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, |
f85afd4e MB |
1123 | |
1124 | ||
1125 | #if 0 // TODO: implement these ? others ? | |
1126 | ||
b5f788a5 MB |
1127 | const wxEventType EVT_GRID_CREATE_CELL = wxEVT_FIRST + 1576; |
1128 | const wxEventType EVT_GRID_CHANGE_LABELS = wxEVT_FIRST + 1577; | |
1129 | const wxEventType EVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578; | |
f85afd4e | 1130 | |
b5f788a5 MB |
1131 | #define EVT_GRID_CREATE_CELL(fn) { EVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, |
1132 | #define EVT_GRID_CHANGE_LABELS(fn) { EVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
1133 | #define EVT_GRID_CHANGE_SEL_LABEL(fn) { EVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, | |
f85afd4e MB |
1134 | |
1135 | #endif | |
1136 | ||
1137 | #endif // #ifndef __WXGRID_H__ | |
1138 | ||
1139 | #endif // ifndef wxUSE_NEW_GRID |