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