]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/grid.h
Fixed thread state problem in wxTreeCtrl.GetBoundingBox
[wxWidgets.git] / include / wx / generic / grid.h
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"
27 #include "wx/scrolwin.h"
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
52
53 // ----------------------------------------------------------------------------
54 // forward declarations
55 // ----------------------------------------------------------------------------
56
57 class WXDLLEXPORT wxGrid;
58 class WXDLLEXPORT wxGridCellAttr;
59 class WXDLLEXPORT wxGridCellAttrProviderData;
60 class WXDLLEXPORT wxGridColLabelWindow;
61 class WXDLLEXPORT wxGridCornerLabelWindow;
62 class WXDLLEXPORT wxGridRowLabelWindow;
63 class WXDLLEXPORT wxGridTableBase;
64 class WXDLLEXPORT wxGridWindow;
65
66 // ----------------------------------------------------------------------------
67 // wxGridCellRenderer: this class is responsible for actually drawing the cell
68 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
69 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
70 // view of all cells. This is an ABC, you will normally use one of the
71 // predefined derived classes or derive oyur own class from it.
72 // ----------------------------------------------------------------------------
73
74 class WXDLLEXPORT wxGridCellRenderer
75 {
76 public:
77 // draw the given cell on the provided DC inside the given rectangle
78 // using the style specified by the attribute and the default or selected
79 // state corresponding to the isSelected value.
80 //
81 // this pure virtual function has a default implementation which will
82 // prepare the DC using the given attribute: it will draw the rectangle
83 // with the bg colour from attr and set the text colour and font
84 virtual void Draw(wxGrid& grid,
85 wxDC& dc,
86 const wxRect& rect,
87 int row, int col,
88 bool isSelected) = 0;
89 };
90
91 // the default renderer for the cells containing string data
92 class WXDLLEXPORT wxGridCellStringRenderer : public wxGridCellRenderer
93 {
94 public:
95 // draw the string
96 virtual void Draw(wxGrid& grid,
97 wxDC& dc,
98 const wxRect& rect,
99 int row, int col,
100 bool isSelected);
101 };
102
103 // ----------------------------------------------------------------------------
104 // wxGridCellAttr: this class can be used to alter the cells appearance in
105 // the grid by changing their colour/font/... from default. An object of this
106 // class may be returned by wxGridTable::GetAttr().
107 // ----------------------------------------------------------------------------
108
109 class WXDLLEXPORT wxGridCellAttr
110 {
111 public:
112 // ctors
113 wxGridCellAttr()
114 {
115 Init();
116 SetAlignment(0, 0);
117 }
118
119 wxGridCellAttr(const wxColour& colText,
120 const wxColour& colBack,
121 const wxFont& font,
122 int hAlign,
123 int vAlign)
124 : m_colText(colText), m_colBack(colBack), m_font(font)
125 {
126 Init();
127 SetAlignment(hAlign, vAlign);
128 }
129
130 // default copy ctor ok
131
132 // this class is ref counted: it is created with ref count of 1, so
133 // calling DecRef() once will delete it. Calling IncRef() allows to lock
134 // it until the matching DecRef() is called
135 void IncRef() { m_nRef++; }
136 void DecRef() { if ( !--m_nRef ) delete this; }
137 void SafeIncRef() { if ( this ) IncRef(); }
138 void SafeDecRef() { if ( this ) DecRef(); }
139
140 // setters
141 void SetTextColour(const wxColour& colText) { m_colText = colText; }
142 void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
143 void SetFont(const wxFont& font) { m_font = font; }
144 void SetAlignment(int hAlign, int vAlign)
145 {
146 m_hAlign = hAlign;
147 m_vAlign = vAlign;
148 }
149
150 // takes ownership of the pointer
151 void SetRenderer(wxGridCellRenderer *renderer)
152 { delete m_renderer; m_renderer = renderer; }
153
154 // accessors
155 bool HasTextColour() const { return m_colText.Ok(); }
156 bool HasBackgroundColour() const { return m_colBack.Ok(); }
157 bool HasFont() const { return m_font.Ok(); }
158 bool HasAlignment() const { return m_hAlign || m_vAlign; }
159
160 const wxColour& GetTextColour() const { return m_colText; }
161 const wxColour& GetBackgroundColour() const { return m_colBack; }
162 const wxFont& GetFont() const { return m_font; }
163 void GetAlignment(int *hAlign, int *vAlign)
164 {
165 if ( hAlign ) *hAlign = m_hAlign;
166 if ( vAlign ) *vAlign = m_vAlign;
167 }
168
169 wxGridCellRenderer *GetRenderer() const { return m_renderer; }
170
171 private:
172 // the common part of all ctors
173 void Init() { m_nRef = 1; m_renderer = (wxGridCellRenderer *)NULL; }
174
175 // the dtor is private because only DecRef() can delete us
176 ~wxGridCellAttr() { delete m_renderer; }
177
178 // the ref count - when it goes to 0, we die
179 size_t m_nRef;
180
181 wxColour m_colText,
182 m_colBack;
183 wxFont m_font;
184 int m_hAlign,
185 m_vAlign;
186
187 wxGridCellRenderer *m_renderer;
188
189 // suppress the stupid gcc warning about the class having private dtor and
190 // no friends
191 friend class wxGridCellAttrDummyFriend;
192 };
193
194 // ----------------------------------------------------------------------------
195 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
196 // cell attributes.
197 // ----------------------------------------------------------------------------
198
199 // implementation note: we separate it from wxGridTableBase because we wish to
200 // avoid deriving a new table class if possible, and sometimes it will be
201 // enough to just derive another wxGridCellAttrProvider instead
202 //
203 // the default implementation is reasonably efficient for the generic case,
204 // but you might still wish to implement your own for some specific situations
205 // if you have performance problems with the stock one
206 class WXDLLEXPORT wxGridCellAttrProvider
207 {
208 public:
209 wxGridCellAttrProvider();
210 virtual ~wxGridCellAttrProvider();
211
212 // DecRef() must be called on the returned pointer
213 virtual wxGridCellAttr *GetAttr(int row, int col) const;
214
215 // all these functions take ownership of the pointer, don't call DecRef()
216 // on it
217 virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
218 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
219 virtual void SetColAttr(wxGridCellAttr *attr, int col);
220
221 private:
222 void InitData();
223
224 wxGridCellAttrProviderData *m_data;
225 };
226
227 //////////////////////////////////////////////////////////////////////
228 //
229 // Grid table classes
230 //
231 //////////////////////////////////////////////////////////////////////
232
233
234 class WXDLLEXPORT wxGridTableBase : public wxObject
235 {
236 public:
237 wxGridTableBase();
238 virtual ~wxGridTableBase();
239
240 // You must override these functions in a derived table class
241 //
242 virtual long GetNumberRows() = 0;
243 virtual long GetNumberCols() = 0;
244 virtual wxString GetValue( int row, int col ) = 0;
245 virtual void SetValue( int row, int col, const wxString& s ) = 0;
246 virtual bool IsEmptyCell( int row, int col ) = 0;
247
248 // Overriding these is optional
249 //
250 virtual void SetView( wxGrid *grid ) { m_view = grid; }
251 virtual wxGrid * GetView() const { return m_view; }
252
253 virtual void Clear() {}
254 virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
255 virtual bool AppendRows( size_t numRows = 1 );
256 virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
257 virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
258 virtual bool AppendCols( size_t numCols = 1 );
259 virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
260
261 virtual wxString GetRowLabelValue( int row );
262 virtual wxString GetColLabelValue( int col );
263 virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {}
264 virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {}
265
266 // Attribute handling
267 //
268
269 // give us the attr provider to use - we take ownership of the pointer
270 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
271
272 // get the currently used attr provider (may be NULL)
273 wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; }
274
275 // by default forwarded to wxGridCellAttrProvider if any. May be
276 // overridden to handle attributes directly in this class.
277 virtual wxGridCellAttr *GetAttr( int row, int col );
278
279 // these functions take ownership of the pointer
280 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
281 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
282 virtual void SetColAttr(wxGridCellAttr *attr, int col);
283
284 private:
285 wxGrid * m_view;
286 wxGridCellAttrProvider *m_attrProvider;
287
288 DECLARE_ABSTRACT_CLASS( wxGridTableBase );
289 };
290
291
292 // ----------------------------------------------------------------------------
293 // wxGridTableMessage
294 // ----------------------------------------------------------------------------
295
296 // IDs for messages sent from grid table to view
297 //
298 enum wxGridTableRequest
299 {
300 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
301 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
302 wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
303 wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
304 wxGRIDTABLE_NOTIFY_ROWS_DELETED,
305 wxGRIDTABLE_NOTIFY_COLS_INSERTED,
306 wxGRIDTABLE_NOTIFY_COLS_APPENDED,
307 wxGRIDTABLE_NOTIFY_COLS_DELETED
308 };
309
310 class WXDLLEXPORT wxGridTableMessage
311 {
312 public:
313 wxGridTableMessage();
314 wxGridTableMessage( wxGridTableBase *table, int id,
315 int comInt1 = -1,
316 int comInt2 = -1 );
317
318 void SetTableObject( wxGridTableBase *table ) { m_table = table; }
319 wxGridTableBase * GetTableObject() const { return m_table; }
320 void SetId( int id ) { m_id = id; }
321 int GetId() { return m_id; }
322 void SetCommandInt( int comInt1 ) { m_comInt1 = comInt1; }
323 int GetCommandInt() { return m_comInt1; }
324 void SetCommandInt2( int comInt2 ) { m_comInt2 = comInt2; }
325 int GetCommandInt2() { return m_comInt2; }
326
327 private:
328 wxGridTableBase *m_table;
329 int m_id;
330 int m_comInt1;
331 int m_comInt2;
332 };
333
334
335
336 // ------ wxGridStringArray
337 // A 2-dimensional array of strings for data values
338 //
339
340 WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString, wxGridStringArray);
341
342
343
344 // ------ wxGridStringTable
345 //
346 // Simplest type of data table for a grid for small tables of strings
347 // that are stored in memory
348 //
349
350 class WXDLLEXPORT wxGridStringTable : public wxGridTableBase
351 {
352 public:
353 wxGridStringTable();
354 wxGridStringTable( int numRows, int numCols );
355 ~wxGridStringTable();
356
357 // these are pure virtual in wxGridTableBase
358 //
359 long GetNumberRows();
360 long GetNumberCols();
361 wxString GetValue( int row, int col );
362 void SetValue( int row, int col, const wxString& s );
363 bool IsEmptyCell( int row, int col );
364
365 // overridden functions from wxGridTableBase
366 //
367 void Clear();
368 bool InsertRows( size_t pos = 0, size_t numRows = 1 );
369 bool AppendRows( size_t numRows = 1 );
370 bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
371 bool InsertCols( size_t pos = 0, size_t numCols = 1 );
372 bool AppendCols( size_t numCols = 1 );
373 bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
374
375 void SetRowLabelValue( int row, const wxString& );
376 void SetColLabelValue( int col, const wxString& );
377 wxString GetRowLabelValue( int row );
378 wxString GetColLabelValue( int col );
379
380 private:
381 wxGridStringArray m_data;
382
383 // These only get used if you set your own labels, otherwise the
384 // GetRow/ColLabelValue functions return wxGridTableBase defaults
385 //
386 wxArrayString m_rowLabels;
387 wxArrayString m_colLabels;
388
389 DECLARE_DYNAMIC_CLASS( wxGridStringTable )
390 };
391
392
393
394 //////////////////////////////////////////////////////////////////////
395 //
396 // Grid view classes
397 //
398 //////////////////////////////////////////////////////////////////////
399
400 class WXDLLEXPORT wxGridCellCoords
401 {
402 public:
403 wxGridCellCoords() { m_row = m_col = -1; }
404 wxGridCellCoords( int r, int c ) { m_row = r; m_col = c; }
405
406 // default copy ctor is ok
407
408 long GetRow() const { return m_row; }
409 void SetRow( long n ) { m_row = n; }
410 long GetCol() const { return m_col; }
411 void SetCol( long n ) { m_col = n; }
412 void Set( long row, long col ) { m_row = row; m_col = col; }
413
414 wxGridCellCoords& operator=( const wxGridCellCoords& other )
415 {
416 if ( &other != this )
417 {
418 m_row=other.m_row;
419 m_col=other.m_col;
420 }
421 return *this;
422 }
423
424 bool operator==( const wxGridCellCoords& other )
425 {
426 return (m_row == other.m_row && m_col == other.m_col);
427 }
428
429 bool operator!=( const wxGridCellCoords& other )
430 {
431 return (m_row != other.m_row || m_col != other.m_col);
432 }
433
434 bool operator!()
435 {
436 return (m_row == -1 && m_col == -1 );
437 }
438
439 private:
440 long m_row;
441 long m_col;
442 };
443
444
445 // For comparisons...
446 //
447 extern wxGridCellCoords wxGridNoCellCoords;
448 extern wxRect wxGridNoCellRect;
449
450 // An array of cell coords...
451 //
452 WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords, wxGridCellCoordsArray);
453
454
455
456 // This set of classes is to provide for the use of different types of
457 // cell edit controls in the grid while avoiding the wx class info
458 // system in deference to wxPython
459
460 class WXDLLEXPORT wxGridTextCtrl : public wxTextCtrl
461 {
462 public:
463 wxGridTextCtrl() {}
464 wxGridTextCtrl( wxWindow *,
465 wxGrid *,
466 bool isCellControl,
467 wxWindowID id,
468 const wxString& value = wxEmptyString,
469 const wxPoint& pos = wxDefaultPosition,
470 const wxSize& size = wxDefaultSize,
471 long style = 0 );
472
473 void SetStartValue( const wxString& );
474 wxString GetStartValue() { return startValue; }
475
476 private:
477 wxGrid *m_grid;
478
479 // TRUE for controls placed over cells,
480 // FALSE for a control on a grid control panel
481 bool m_isCellControl;
482
483 wxString startValue;
484
485 void OnKeyDown( wxKeyEvent& );
486
487 DECLARE_DYNAMIC_CLASS( wxGridTextCtrl )
488 DECLARE_EVENT_TABLE()
489 };
490
491 // ----------------------------------------------------------------------------
492 // wxGrid
493 // ----------------------------------------------------------------------------
494
495 class WXDLLEXPORT wxGrid : public wxScrolledWindow
496 {
497 public:
498 wxGrid()
499 {
500 m_table = (wxGridTableBase *) NULL;
501 m_gridWin = (wxGridWindow *) NULL;
502 m_rowLabelWin = (wxGridRowLabelWindow *) NULL;
503 m_colLabelWin = (wxGridColLabelWindow *) NULL;
504 m_cornerLabelWin = (wxGridCornerLabelWindow *) NULL;
505 m_cellEditCtrl = (wxWindow *) NULL;
506 }
507
508 wxGrid( wxWindow *parent,
509 wxWindowID id,
510 const wxPoint& pos = wxDefaultPosition,
511 const wxSize& size = wxDefaultSize,
512 long style = 0,
513 const wxString& name = wxPanelNameStr );
514
515 ~wxGrid();
516
517 bool CreateGrid( int numRows, int numCols );
518
519
520 // ------ grid dimensions
521 //
522 int GetNumberRows() { return m_numRows; }
523 int GetNumberCols() { return m_numCols; }
524
525
526 // ------ display update functions
527 //
528 void CalcRowLabelsExposed( wxRegion& reg );
529
530 void CalcColLabelsExposed( wxRegion& reg );
531 void CalcCellsExposed( wxRegion& reg );
532
533
534 // ------ event handlers
535 //
536 void ProcessRowLabelMouseEvent( wxMouseEvent& event );
537 void ProcessColLabelMouseEvent( wxMouseEvent& event );
538 void ProcessCornerLabelMouseEvent( wxMouseEvent& event );
539 void ProcessGridCellMouseEvent( wxMouseEvent& event );
540 bool ProcessTableMessage( wxGridTableMessage& );
541
542 void DoEndDragResizeRow();
543 void DoEndDragResizeCol();
544
545 wxGridTableBase * GetTable() const { return m_table; }
546 void SetTable( wxGridTableBase *table ) { m_table = table; }
547
548 void ClearGrid();
549 bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
550 bool AppendRows( int numRows = 1, bool updateLabels=TRUE );
551 bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
552 bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
553 bool AppendCols( int numCols = 1, bool updateLabels=TRUE );
554 bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
555
556 void DrawGridCellArea( wxDC& dc );
557 void DrawCellBorder( wxDC& dc, const wxGridCellCoords& );
558 void DrawAllGridLines( wxDC& dc, const wxRegion & reg );
559 void DrawCell( wxDC& dc, const wxGridCellCoords& );
560
561 void DrawRowLabels( wxDC& dc );
562 void DrawRowLabel( wxDC& dc, int row );
563
564 void DrawColLabels( wxDC& dc );
565 void DrawColLabel( wxDC& dc, int col );
566
567
568 // ------ Cell text drawing functions
569 //
570 void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
571 int horizontalAlignment = wxLEFT,
572 int verticalAlignment = wxTOP );
573
574 // Split a string containing newline chararcters into an array of
575 // strings and return the number of lines
576 //
577 void StringToLines( const wxString& value, wxArrayString& lines );
578
579 void GetTextBoxSize( wxDC& dc,
580 wxArrayString& lines,
581 long *width, long *height );
582
583
584 // ------
585 // Code that does a lot of grid modification can be enclosed
586 // between BeginBatch() and EndBatch() calls to avoid screen
587 // flicker
588 //
589 void BeginBatch() { m_batchCount++; }
590 void EndBatch() { if ( m_batchCount > 0 ) m_batchCount--; }
591 int GetBatchCount() { return m_batchCount; }
592
593
594 // ------ edit control functions
595 //
596 bool IsEditable() { return m_editable; }
597 void EnableEditing( bool edit );
598
599 #if 0 // at the moment the cell edit control is always active
600 void EnableCellEditControl( bool enable );
601 #endif
602
603 bool IsCellEditControlEnabled()
604 { return (m_cellEditCtrl && m_cellEditCtrlEnabled); }
605
606 void ShowCellEditControl();
607 void HideCellEditControl();
608 void SetEditControlValue( const wxString& s = wxEmptyString );
609 void SaveEditControlValue();
610
611
612 // ------ grid location functions
613 // Note that all of these functions work with the logical coordinates of
614 // grid cells and labels so you will need to convert from device
615 // coordinates for mouse events etc.
616 //
617 void XYToCell( int x, int y, wxGridCellCoords& );
618 int YToRow( int y );
619 int XToCol( int x );
620
621 int YToEdgeOfRow( int y );
622 int XToEdgeOfCol( int x );
623
624 wxRect CellToRect( int row, int col );
625 wxRect CellToRect( const wxGridCellCoords& coords )
626 { return CellToRect( coords.GetRow(), coords.GetCol() ); }
627
628 int GetGridCursorRow() { return m_currentCellCoords.GetRow(); }
629 int GetGridCursorCol() { return m_currentCellCoords.GetCol(); }
630
631 // check to see if a cell is either wholly visible (the default arg) or
632 // at least partially visible in the grid window
633 //
634 bool IsVisible( int row, int col, bool wholeCellVisible = TRUE );
635 bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE )
636 { return IsVisible( coords.GetRow(), coords.GetCol(), wholeCellVisible ); }
637 void MakeCellVisible( int row, int col );
638 void MakeCellVisible( const wxGridCellCoords& coords )
639 { MakeCellVisible( coords.GetRow(), coords.GetCol() ); }
640
641
642 // ------ grid cursor movement functions
643 //
644 void SetGridCursor( int row, int col )
645 { SetCurrentCell( wxGridCellCoords(row, col) ); }
646
647 bool MoveCursorUp();
648 bool MoveCursorDown();
649 bool MoveCursorLeft();
650 bool MoveCursorRight();
651 bool MovePageDown();
652 bool MovePageUp();
653 bool MoveCursorUpBlock();
654 bool MoveCursorDownBlock();
655 bool MoveCursorLeftBlock();
656 bool MoveCursorRightBlock();
657
658
659 // ------ label and gridline formatting
660 //
661 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; }
662 int GetRowLabelSize() { return m_rowLabelWidth; }
663 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; }
664 int GetColLabelSize() { return m_colLabelHeight; }
665 wxColour GetLabelBackgroundColour() { return m_labelBackgroundColour; }
666 wxColour GetLabelTextColour() { return m_labelTextColour; }
667 wxFont GetLabelFont() { return m_labelFont; }
668 void GetRowLabelAlignment( int *horiz, int *vert );
669 void GetColLabelAlignment( int *horiz, int *vert );
670 wxString GetRowLabelValue( int row );
671 wxString GetColLabelValue( int col );
672 wxColour GetGridLineColour() { return m_gridLineColour; }
673
674 void SetRowLabelSize( int width );
675 void SetColLabelSize( int height );
676 void SetLabelBackgroundColour( const wxColour& );
677 void SetLabelTextColour( const wxColour& );
678 void SetLabelFont( const wxFont& );
679 void SetRowLabelAlignment( int horiz, int vert );
680 void SetColLabelAlignment( int horiz, int vert );
681 void SetRowLabelValue( int row, const wxString& );
682 void SetColLabelValue( int col, const wxString& );
683 void SetGridLineColour( const wxColour& );
684
685 // this sets the specified attribute for all cells in this row/col
686 void SetRowAttr(int row, wxGridCellAttr *attr);
687 void SetColAttr(int col, wxGridCellAttr *attr);
688
689 void EnableGridLines( bool enable = TRUE );
690 bool GridLinesEnabled() { return m_gridLinesEnabled; }
691
692 // ------ row and col formatting
693 //
694 int GetDefaultRowSize();
695 int GetRowSize( int row );
696 int GetDefaultColSize();
697 int GetColSize( int col );
698 wxColour GetDefaultCellBackgroundColour();
699 wxColour GetCellBackgroundColour( int row, int col );
700 wxColour GetDefaultCellTextColour();
701 wxColour GetCellTextColour( int row, int col );
702 wxFont GetDefaultCellFont();
703 wxFont GetCellFont( int row, int col );
704 void GetDefaultCellAlignment( int *horiz, int *vert );
705 void GetCellAlignment( int row, int col, int *horiz, int *vert );
706
707 void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE );
708 void SetRowSize( int row, int height );
709 void SetDefaultColSize( int width, bool resizeExistingCols = FALSE );
710
711 void SetColSize( int col, int width );
712 void SetDefaultCellBackgroundColour( const wxColour& );
713 void SetCellBackgroundColour( int row, int col, const wxColour& );
714 void SetDefaultCellTextColour( const wxColour& );
715
716 void SetCellTextColour( int row, int col, const wxColour& );
717 void SetDefaultCellFont( const wxFont& );
718 void SetCellFont( int row, int col, const wxFont& );
719 void SetDefaultCellAlignment( int horiz, int vert );
720 void SetCellAlignment( int row, int col, int horiz, int vert );
721
722 // takes ownership of the pointer
723 void SetDefaultRenderer(wxGridCellRenderer *renderer)
724 { delete m_defaultRenderer; m_defaultRenderer = renderer; }
725 wxGridCellRenderer *GetDefaultRenderer() const
726 { return m_defaultRenderer; }
727
728 void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
729
730 // ------ cell value accessors
731 //
732 wxString GetCellValue( int row, int col )
733 {
734 if ( m_table )
735 {
736 return m_table->GetValue( row, col );
737 }
738 else
739 {
740 return wxEmptyString;
741 }
742 }
743
744 wxString GetCellValue( const wxGridCellCoords& coords )
745 { return GetCellValue( coords.GetRow(), coords.GetCol() ); }
746
747 void SetCellValue( int row, int col, const wxString& s );
748 void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
749 { SetCellValue( coords.GetRow(), coords.GetCol(), s ); }
750
751
752
753 // ------ selections of blocks of cells
754 //
755 void SelectRow( int row, bool addToSelected = FALSE );
756 void SelectCol( int col, bool addToSelected = FALSE );
757
758 void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol );
759
760 void SelectBlock( const wxGridCellCoords& topLeft,
761 const wxGridCellCoords& bottomRight )
762 { SelectBlock( topLeft.GetRow(), topLeft.GetCol(),
763 bottomRight.GetRow(), bottomRight.GetCol() ); }
764
765 void SelectAll();
766
767 bool IsSelection()
768 { return ( m_selectedTopLeft != wxGridNoCellCoords &&
769 m_selectedBottomRight != wxGridNoCellCoords );
770 }
771
772 void ClearSelection();
773
774 bool IsInSelection( int row, int col )
775 { return ( IsSelection() &&
776 row >= m_selectedTopLeft.GetRow() &&
777 col >= m_selectedTopLeft.GetCol() &&
778 row <= m_selectedBottomRight.GetRow() &&
779 col <= m_selectedBottomRight.GetCol() );
780 }
781
782 bool IsInSelection( const wxGridCellCoords& coords )
783 { return IsInSelection( coords.GetRow(), coords.GetCol() ); }
784
785 void GetSelection( int* topRow, int* leftCol, int* bottomRow, int* rightCol )
786 {
787 // these will all be -1 if there is no selected block
788 //
789 *topRow = m_selectedTopLeft.GetRow();
790 *leftCol = m_selectedTopLeft.GetCol();
791 *bottomRow = m_selectedBottomRight.GetRow();
792 *rightCol = m_selectedBottomRight.GetCol();
793 }
794
795
796 // This function returns the rectangle that encloses the block of cells
797 // limited by TopLeft and BottomRight cell in device coords and clipped
798 // to the client size of the grid window.
799 //
800 wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
801 const wxGridCellCoords & bottomRight );
802
803 // This function returns the rectangle that encloses the selected cells
804 // in device coords and clipped to the client size of the grid window.
805 //
806 wxRect SelectionToDeviceRect()
807 {
808 return BlockToDeviceRect( m_selectedTopLeft,
809 m_selectedBottomRight );
810 }
811
812
813 // ------ For compatibility with previous wxGrid only...
814 //
815 // ************************************************
816 // ** Don't use these in new code because they **
817 // ** are liable to disappear in a future **
818 // ** revision **
819 // ************************************************
820 //
821
822 wxGrid( wxWindow *parent,
823 int x = -1, int y = -1, int w = -1, int h = -1,
824 long style = 0,
825 const wxString& name = wxPanelNameStr )
826 : wxScrolledWindow( parent, -1, wxPoint(x,y), wxSize(w,h), style, name )
827 {
828 Create();
829 }
830
831 void SetCellValue( const wxString& val, int row, int col )
832 { SetCellValue( row, col, val ); }
833
834 void UpdateDimensions()
835 { CalcDimensions(); }
836
837 int GetRows() { return GetNumberRows(); }
838 int GetCols() { return GetNumberCols(); }
839 int GetCursorRow() { return GetGridCursorRow(); }
840 int GetCursorColumn() { return GetGridCursorCol(); }
841
842 int GetScrollPosX() { return 0; }
843 int GetScrollPosY() { return 0; }
844
845 void SetScrollX( int x ) { }
846 void SetScrollY( int y ) { }
847
848 void SetColumnWidth( int col, int width )
849 { SetColSize( col, width ); }
850
851 int GetColumnWidth( int col )
852 { return GetColSize( col ); }
853
854 void SetRowHeight( int row, int height )
855 { SetRowSize( row, height ); }
856
857 int GetRowHeight( int row )
858 { return GetRowSize( row ); }
859
860 int GetViewHeight() // returned num whole rows visible
861 { return 0; }
862
863 int GetViewWidth() // returned num whole cols visible
864 { return 0; }
865
866 void SetLabelSize( int orientation, int sz )
867 {
868 if ( orientation == wxHORIZONTAL )
869 SetColLabelSize( sz );
870 else
871 SetRowLabelSize( sz );
872 }
873
874 int GetLabelSize( int orientation )
875 {
876 if ( orientation == wxHORIZONTAL )
877 return GetColLabelSize();
878 else
879 return GetRowLabelSize();
880 }
881
882 void SetLabelAlignment( int orientation, int align )
883 {
884 if ( orientation == wxHORIZONTAL )
885 SetColLabelAlignment( align, -1 );
886 else
887 SetRowLabelAlignment( align, -1 );
888 }
889
890 int GetLabelAlignment( int orientation, int WXUNUSED(align) )
891 {
892 int h, v;
893 if ( orientation == wxHORIZONTAL )
894 {
895 GetColLabelAlignment( &h, &v );
896 return h;
897 }
898 else
899 {
900 GetRowLabelAlignment( &h, &v );
901 return h;
902 }
903 }
904
905 void SetLabelValue( int orientation, const wxString& val, int pos )
906 {
907 if ( orientation == wxHORIZONTAL )
908 SetColLabelValue( pos, val );
909 else
910 SetRowLabelValue( pos, val );
911 }
912
913 wxString GetLabelValue( int orientation, int pos)
914 {
915 if ( orientation == wxHORIZONTAL )
916 return GetColLabelValue( pos );
917 else
918 return GetRowLabelValue( pos );
919 }
920
921 wxFont GetCellTextFont() const
922 { return m_defaultCellFont; }
923
924 wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const
925 { return m_defaultCellFont; }
926
927 void SetCellTextFont(const wxFont& fnt)
928 { SetDefaultCellFont( fnt ); }
929
930 void SetCellTextFont(const wxFont& fnt, int row, int col)
931 { SetCellFont( row, col, fnt ); }
932
933 void SetCellTextColour(const wxColour& val, int row, int col)
934 { SetCellTextColour( row, col, val ); }
935
936 void SetCellTextColour(const wxColour& col)
937 { SetDefaultCellTextColour( col ); }
938
939 void SetCellBackgroundColour(const wxColour& col)
940 { SetDefaultCellBackgroundColour( col ); }
941
942 void SetCellBackgroundColour(const wxColour& colour, int row, int col)
943 { SetCellBackgroundColour( row, col, colour ); }
944
945 bool GetEditable() { return IsEditable(); }
946 void SetEditable( bool edit = TRUE ) { EnableEditing( edit ); }
947 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
948
949 void SetEditInPlace(bool edit = TRUE) { }
950
951 void SetCellAlignment( int align, int row, int col)
952 { SetCellAlignment(row, col, align, wxCENTER); }
953 void SetCellAlignment( int WXUNUSED(align) ) {}
954 void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col))
955 { }
956 void SetDividerPen(const wxPen& WXUNUSED(pen)) { }
957 wxPen& GetDividerPen() const { return wxNullPen; }
958 void OnActivate(bool WXUNUSED(active)) {}
959
960 // ******** End of compatibility functions **********
961
962
963
964 // ------ control IDs
965 enum { wxGRID_CELLCTRL = 2000,
966 wxGRID_TOPCTRL };
967
968 // ------ control types
969 enum { wxGRID_TEXTCTRL = 2100,
970 wxGRID_CHECKBOX,
971 wxGRID_CHOICE,
972 wxGRID_COMBOBOX };
973
974 protected:
975 bool m_created;
976 bool m_displayed;
977
978 wxGridWindow *m_gridWin;
979 wxGridRowLabelWindow *m_rowLabelWin;
980 wxGridColLabelWindow *m_colLabelWin;
981 wxGridCornerLabelWindow *m_cornerLabelWin;
982
983 wxGridTableBase *m_table;
984
985 int m_left;
986 int m_top;
987 int m_right;
988 int m_bottom;
989
990 int m_numRows;
991 int m_numCols;
992
993 wxGridCellCoords m_currentCellCoords;
994
995 wxGridCellCoords m_selectedTopLeft;
996 wxGridCellCoords m_selectedBottomRight;
997
998 int m_defaultRowHeight;
999 wxArrayInt m_rowHeights;
1000 wxArrayInt m_rowBottoms;
1001
1002 int m_defaultColWidth;
1003 wxArrayInt m_colWidths;
1004 wxArrayInt m_colRights;
1005
1006 int m_rowLabelWidth;
1007 int m_colLabelHeight;
1008
1009 wxColour m_labelBackgroundColour;
1010 wxColour m_labelTextColour;
1011 wxFont m_labelFont;
1012
1013 int m_rowLabelHorizAlign;
1014 int m_rowLabelVertAlign;
1015 int m_colLabelHorizAlign;
1016 int m_colLabelVertAlign;
1017
1018 bool m_defaultRowLabelValues;
1019 bool m_defaultColLabelValues;
1020
1021 wxColour m_gridLineColour;
1022 bool m_gridLinesEnabled;
1023
1024 // get the renderer for the given cell - if it has no special one, the
1025 // default one will be returned, never NULL
1026 wxGridCellRenderer *GetCellRenderer(int row, int col);
1027
1028 wxGridCellRenderer *m_defaultRenderer;
1029
1030 // default cell attributes
1031 wxFont m_defaultCellFont;
1032 int m_defaultCellHAlign,
1033 m_defaultCellVAlign;
1034
1035 // do we have some place to store attributes in?
1036 bool CanHaveAttributes();
1037
1038 // returns the attribute we may modify in place: a new one if this cell
1039 // doesn't have any yet or the existing one if it does
1040 //
1041 // DecRef() must be called on the returned pointer, as usual
1042 wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
1043
1044 // cell attribute cache (currently we only cache 1, may be will do
1045 // more/better later)
1046 struct CachedAttr
1047 {
1048 int row, col;
1049 wxGridCellAttr *attr;
1050 } m_attrCache;
1051
1052 // invalidates the attribute cache
1053 void ClearAttrCache();
1054
1055 // adds an attribute to cache
1056 void CacheAttr(int row, int col, wxGridCellAttr *attr) const;
1057
1058 // looks for an attr in cache, returns TRUE if found
1059 bool LookupAttr(int row, int col, wxGridCellAttr **attr) const;
1060
1061 // looks for the attr in cache, if not found asks the table and caches the
1062 // result
1063 wxGridCellAttr *GetCellAttr(int row, int col) const;
1064
1065 wxGridCellCoordsArray m_cellsExposed;
1066 wxArrayInt m_rowsExposed;
1067 wxArrayInt m_colsExposed;
1068 wxArrayInt m_rowLabelsExposed;
1069 wxArrayInt m_colLabelsExposed;
1070
1071 bool m_inOnKeyDown;
1072 int m_batchCount;
1073
1074 enum CursorMode
1075 {
1076 WXGRID_CURSOR_SELECT_CELL,
1077 WXGRID_CURSOR_RESIZE_ROW,
1078 WXGRID_CURSOR_RESIZE_COL,
1079 WXGRID_CURSOR_SELECT_ROW,
1080 WXGRID_CURSOR_SELECT_COL
1081 };
1082
1083 // this method not only sets m_cursorMode but also sets the correct cursor
1084 // for the given mode and, if captureMouse is not FALSE releases the mouse
1085 // if it was captured and captures it if it must be captured
1086 //
1087 // for this to work, you should always use it and not set m_cursorMode
1088 // directly!
1089 void ChangeCursorMode(CursorMode mode,
1090 wxWindow *win = (wxWindow *)NULL,
1091 bool captureMouse = TRUE);
1092
1093 wxWindow *m_winCapture; // the window which captured the mouse
1094 CursorMode m_cursorMode;
1095
1096 int m_dragLastPos;
1097 int m_dragRowOrCol;
1098 bool m_isDragging;
1099
1100 wxGridCellCoords m_selectionStart;
1101
1102 wxCursor m_rowResizeCursor;
1103 wxCursor m_colResizeCursor;
1104
1105 bool m_editable; // applies to whole grid
1106 int m_editCtrlType; // for current cell
1107 wxWindow* m_cellEditCtrl;
1108 bool m_cellEditCtrlEnabled;
1109
1110
1111 void Create();
1112 void Init();
1113 void CalcDimensions();
1114 void CalcWindowSizes();
1115 bool Redimension( wxGridTableMessage& );
1116
1117
1118 bool SendEvent( const wxEventType,
1119 int row, int col,
1120 wxMouseEvent& );
1121
1122 bool SendEvent( const wxEventType,
1123 int row, int col );
1124
1125
1126 void OnPaint( wxPaintEvent& );
1127 void OnSize( wxSizeEvent& );
1128 void OnKeyDown( wxKeyEvent& );
1129
1130
1131 void SetCurrentCell( const wxGridCellCoords& coords );
1132 void SetCurrentCell( int row, int col )
1133 { SetCurrentCell( wxGridCellCoords(row, col) ); }
1134
1135
1136 // ------ functions to get/send data (see also public functions)
1137 //
1138 bool GetModelValues();
1139 bool SetModelValues();
1140
1141
1142 DECLARE_DYNAMIC_CLASS( wxGrid )
1143 DECLARE_EVENT_TABLE()
1144 };
1145
1146
1147
1148
1149
1150 //
1151 // ------ Grid event class and event types
1152 //
1153
1154 class WXDLLEXPORT wxGridEvent : public wxNotifyEvent
1155 {
1156 public:
1157 wxGridEvent()
1158 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
1159 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1160 {
1161 }
1162
1163 wxGridEvent(int id, wxEventType type, wxObject* obj,
1164 int row=-1, int col=-1, int x=-1, int y=-1,
1165 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1166
1167 virtual int GetRow() { return m_row; }
1168 virtual int GetCol() { return m_col; }
1169 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
1170 bool ControlDown() { return m_control; }
1171 bool MetaDown() { return m_meta; }
1172 bool ShiftDown() { return m_shift; }
1173 bool AltDown() { return m_alt; }
1174
1175 protected:
1176 int m_row;
1177 int m_col;
1178 int m_x;
1179 int m_y;
1180 bool m_control;
1181 bool m_meta;
1182 bool m_shift;
1183 bool m_alt;
1184
1185 DECLARE_DYNAMIC_CLASS(wxGridEvent)
1186 };
1187
1188
1189 class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent
1190 {
1191 public:
1192 wxGridSizeEvent()
1193 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1194 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1195 {
1196 }
1197
1198 wxGridSizeEvent(int id, wxEventType type, wxObject* obj,
1199 int rowOrCol=-1, int x=-1, int y=-1,
1200 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1201
1202 int GetRowOrCol() { return m_rowOrCol; }
1203 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
1204 bool ControlDown() { return m_control; }
1205 bool MetaDown() { return m_meta; }
1206 bool ShiftDown() { return m_shift; }
1207 bool AltDown() { return m_alt; }
1208
1209 protected:
1210 int m_rowOrCol;
1211 int m_x;
1212 int m_y;
1213 bool m_control;
1214 bool m_meta;
1215 bool m_shift;
1216 bool m_alt;
1217
1218 DECLARE_DYNAMIC_CLASS(wxGridSizeEvent)
1219 };
1220
1221
1222 class WXDLLEXPORT wxGridRangeSelectEvent : public wxNotifyEvent
1223 {
1224 public:
1225 wxGridRangeSelectEvent()
1226 : wxNotifyEvent()
1227 {
1228 m_topLeft = wxGridNoCellCoords;
1229 m_bottomRight = wxGridNoCellCoords;
1230 m_control = FALSE;
1231 m_meta = FALSE;
1232 m_shift = FALSE;
1233 m_alt = FALSE;
1234 }
1235
1236 wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj,
1237 const wxGridCellCoords& topLeft,
1238 const wxGridCellCoords& bottomRight,
1239 bool control=FALSE, bool shift=FALSE,
1240 bool alt=FALSE, bool meta=FALSE);
1241
1242 wxGridCellCoords GetTopLeftCoords() { return m_topLeft; }
1243 wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; }
1244 int GetTopRow() { return m_topLeft.GetRow(); }
1245 int GetBottomRow() { return m_bottomRight.GetRow(); }
1246 int GetLeftCol() { return m_topLeft.GetCol(); }
1247 int GetRightCol() { return m_bottomRight.GetCol(); }
1248 bool ControlDown() { return m_control; }
1249 bool MetaDown() { return m_meta; }
1250 bool ShiftDown() { return m_shift; }
1251 bool AltDown() { return m_alt; }
1252
1253 protected:
1254 wxGridCellCoords m_topLeft;
1255 wxGridCellCoords m_bottomRight;
1256 bool m_control;
1257 bool m_meta;
1258 bool m_shift;
1259 bool m_alt;
1260
1261 DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent)
1262 };
1263
1264
1265 const wxEventType EVT_GRID_CELL_LEFT_CLICK = wxEVT_FIRST + 1580;
1266 const wxEventType EVT_GRID_CELL_RIGHT_CLICK = wxEVT_FIRST + 1581;
1267 const wxEventType EVT_GRID_CELL_LEFT_DCLICK = wxEVT_FIRST + 1582;
1268 const wxEventType EVT_GRID_CELL_RIGHT_DCLICK = wxEVT_FIRST + 1583;
1269 const wxEventType EVT_GRID_LABEL_LEFT_CLICK = wxEVT_FIRST + 1584;
1270 const wxEventType EVT_GRID_LABEL_RIGHT_CLICK = wxEVT_FIRST + 1585;
1271 const wxEventType EVT_GRID_LABEL_LEFT_DCLICK = wxEVT_FIRST + 1586;
1272 const wxEventType EVT_GRID_LABEL_RIGHT_DCLICK = wxEVT_FIRST + 1587;
1273 const wxEventType EVT_GRID_ROW_SIZE = wxEVT_FIRST + 1588;
1274 const wxEventType EVT_GRID_COL_SIZE = wxEVT_FIRST + 1589;
1275 const wxEventType EVT_GRID_RANGE_SELECT = wxEVT_FIRST + 1590;
1276 const wxEventType EVT_GRID_CELL_CHANGE = wxEVT_FIRST + 1591;
1277 const wxEventType EVT_GRID_SELECT_CELL = wxEVT_FIRST + 1592;
1278
1279
1280 typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&);
1281 typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&);
1282 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&);
1283
1284 #define EVT_GRID_CELL_LEFT_CLICK(fn) { EVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1285 #define EVT_GRID_CELL_RIGHT_CLICK(fn) { EVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1286 #define EVT_GRID_CELL_LEFT_DCLICK(fn) { EVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1287 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) { EVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1288 #define EVT_GRID_LABEL_LEFT_CLICK(fn) { EVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1289 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) { EVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1290 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) { EVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1291 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) { EVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1292 #define EVT_GRID_ROW_SIZE(fn) { EVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1293 #define EVT_GRID_COL_SIZE(fn) { EVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1294 #define EVT_GRID_RANGE_SELECT(fn) { EVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL },
1295 #define EVT_GRID_CELL_CHANGE(fn) { EVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1296 #define EVT_GRID_SELECT_CELL(fn) { EVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1297
1298
1299 #if 0 // TODO: implement these ? others ?
1300
1301 const wxEventType EVT_GRID_CREATE_CELL = wxEVT_FIRST + 1576;
1302 const wxEventType EVT_GRID_CHANGE_LABELS = wxEVT_FIRST + 1577;
1303 const wxEventType EVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578;
1304
1305 #define EVT_GRID_CREATE_CELL(fn) { EVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1306 #define EVT_GRID_CHANGE_LABELS(fn) { EVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1307 #define EVT_GRID_CHANGE_SEL_LABEL(fn) { EVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1308
1309 #endif
1310
1311 #endif // #ifndef __WXGRID_H__
1312
1313 #endif // ifndef wxUSE_NEW_GRID
1314