1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGrid and related classes
4 // Author: Michael Bedward (based on code by Julian Smart, Robin Dunn)
8 // Copyright: (c) Michael Bedward
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID)
23 #pragma interface "grid.h"
27 #include "wx/scrolwin.h"
28 #include "wx/string.h"
29 #include "wx/scrolbar.h"
31 #include "wx/textctrl.h"
32 #include "wx/combobox.h"
33 #include "wx/dynarray.h"
36 // Default parameters for wxGrid
38 #define WXGRID_DEFAULT_NUMBER_ROWS 10
39 #define WXGRID_DEFAULT_NUMBER_COLS 10
41 #define WXGRID_DEFAULT_ROW_HEIGHT 25
43 #define WXGRID_DEFAULT_ROW_HEIGHT 30
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
53 // ----------------------------------------------------------------------------
54 // forward declarations
55 // ----------------------------------------------------------------------------
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
;
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 // ----------------------------------------------------------------------------
74 class WXDLLEXPORT wxGridCellRenderer
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.
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
,
92 // the default renderer for the cells containing string data
93 class WXDLLEXPORT wxGridCellStringRenderer
: public wxGridCellRenderer
97 virtual void Draw(wxGrid
& grid
,
106 // ----------------------------------------------------------------------------
107 // wxGridCellEditor: This class is responsible for providing and manipulating
108 // the in-place edit controls for the grid. Instances of wxGridCellEditor
109 // (actually, instances of derived classes since it is an ABC) can be
110 // associated with the cell attributes for individual cells, rows, columns, or
111 // even for the entire grid.
112 // ----------------------------------------------------------------------------
114 class WXDLLEXPORT wxGridCellEditor
118 virtual ~wxGridCellEditor();
120 bool IsCreated() { return m_control
!= NULL
; }
122 // Creates the actual edit control
123 virtual void Create(wxWindow
* parent
,
125 wxEvtHandler
* evtHandler
) = 0;
127 // Size and position the edit control
128 virtual void SetSize(const wxRect
& rect
);
130 // Show or hide the edit control
131 virtual void Show(bool show
);
133 // Fetch the value from the table and prepare the edit control
134 // to begin editing. Set the focus to the edit control.
135 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
,
136 wxGridCellAttr
* attr
) = 0;
138 // Complete the editing of the current cell. If saveValue is
139 // true then send the new value back to the table. Returns true
140 // if the value has changed. If necessary, the control may be
142 virtual bool EndEdit(int row
, int col
, bool saveValue
,
143 wxGrid
* grid
, wxGridCellAttr
* attr
) = 0;
145 // Reset the value in the control back to its starting value
146 virtual void Reset() = 0;
148 // If the editor is enabled by pressing keys on the grid,
149 // this will be called to let the editor do something about
150 // that first key if desired.
151 virtual void StartingKey(wxKeyEvent
& event
);
153 // Some types of controls on some platforms may need some help
154 // with the Return key.
155 virtual void HandleReturn(wxKeyEvent
& event
);
158 virtual void Destroy();
161 wxControl
* m_control
;
165 class WXDLLEXPORT wxGridCellTextEditor
: public wxGridCellEditor
168 wxGridCellTextEditor();
170 virtual void Create(wxWindow
* parent
,
172 wxEvtHandler
* evtHandler
);
174 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
,
175 wxGridCellAttr
* attr
);
177 virtual bool EndEdit(int row
, int col
, bool saveValue
,
178 wxGrid
* grid
, wxGridCellAttr
* attr
);
180 virtual void Reset();
181 virtual void StartingKey(wxKeyEvent
& event
);
182 virtual void HandleReturn(wxKeyEvent
& event
);
186 wxString m_startValue
;
189 // ----------------------------------------------------------------------------
190 // wxGridCellAttr: this class can be used to alter the cells appearance in
191 // the grid by changing their colour/font/... from default. An object of this
192 // class may be returned by wxGridTable::GetAttr().
193 // ----------------------------------------------------------------------------
195 class WXDLLEXPORT wxGridCellAttr
205 wxGridCellAttr(const wxColour
& colText
,
206 const wxColour
& colBack
,
210 : m_colText(colText
), m_colBack(colBack
), m_font(font
)
213 SetAlignment(hAlign
, vAlign
);
216 // default copy ctor ok
218 // this class is ref counted: it is created with ref count of 1, so
219 // calling DecRef() once will delete it. Calling IncRef() allows to lock
220 // it until the matching DecRef() is called
221 void IncRef() { m_nRef
++; }
222 void DecRef() { if ( !--m_nRef
) delete this; }
223 void SafeIncRef() { if ( this ) IncRef(); }
224 void SafeDecRef() { if ( this ) DecRef(); }
227 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
228 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
229 void SetFont(const wxFont
& font
) { m_font
= font
; }
230 void SetAlignment(int hAlign
, int vAlign
)
236 // takes ownership of the pointer
237 void SetRenderer(wxGridCellRenderer
*renderer
)
238 { delete m_renderer
; m_renderer
= renderer
; }
239 void SetEditor(wxGridCellEditor
* editor
)
240 { delete m_editor
; m_editor
= editor
; }
243 bool HasTextColour() const { return m_colText
.Ok(); }
244 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
245 bool HasFont() const { return m_font
.Ok(); }
246 bool HasAlignment() const { return m_hAlign
|| m_vAlign
; }
247 bool HasRenderer() const { return m_renderer
!= NULL
; }
248 bool HasEditor() const { return m_editor
!= NULL
; }
250 const wxColour
& GetTextColour() const;
251 const wxColour
& GetBackgroundColour() const;
252 const wxFont
& GetFont() const;
253 void GetAlignment(int *hAlign
, int *vAlign
) const;
254 wxGridCellRenderer
*GetRenderer() const;
255 wxGridCellEditor
*GetEditor() const;
257 void SetDefAttr(wxGridCellAttr
* defAttr
) { m_defGridAttr
= defAttr
; }
260 // the common part of all ctors
267 // the dtor is private because only DecRef() can delete us
268 ~wxGridCellAttr() { delete m_renderer
; delete m_editor
; }
270 // the ref count - when it goes to 0, we die
279 wxGridCellRenderer
* m_renderer
;
280 wxGridCellEditor
* m_editor
;
281 wxGridCellAttr
* m_defGridAttr
;
283 // suppress the stupid gcc warning about the class having private dtor and
285 friend class wxGridCellAttrDummyFriend
;
288 // ----------------------------------------------------------------------------
289 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
291 // ----------------------------------------------------------------------------
293 // implementation note: we separate it from wxGridTableBase because we wish to
294 // avoid deriving a new table class if possible, and sometimes it will be
295 // enough to just derive another wxGridCellAttrProvider instead
297 // the default implementation is reasonably efficient for the generic case,
298 // but you might still wish to implement your own for some specific situations
299 // if you have performance problems with the stock one
300 class WXDLLEXPORT wxGridCellAttrProvider
303 wxGridCellAttrProvider();
304 virtual ~wxGridCellAttrProvider();
306 // DecRef() must be called on the returned pointer
307 virtual wxGridCellAttr
*GetAttr(int row
, int col
) const;
309 // all these functions take ownership of the pointer, don't call DecRef()
311 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
312 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
313 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
314 void UpdateAttrRows( size_t pos
, int numRows
);
315 void UpdateAttrCols( size_t pos
, int numCols
);
320 wxGridCellAttrProviderData
*m_data
;
323 //////////////////////////////////////////////////////////////////////
325 // Grid table classes
327 //////////////////////////////////////////////////////////////////////
330 class WXDLLEXPORT wxGridTableBase
: public wxObject
334 virtual ~wxGridTableBase();
336 // You must override these functions in a derived table class
338 virtual long GetNumberRows() = 0;
339 virtual long GetNumberCols() = 0;
340 virtual wxString
GetValue( int row
, int col
) = 0;
341 virtual void SetValue( int row
, int col
, const wxString
& s
) = 0;
342 virtual bool IsEmptyCell( int row
, int col
) = 0;
344 // Overriding these is optional
346 virtual void SetView( wxGrid
*grid
) { m_view
= grid
; }
347 virtual wxGrid
* GetView() const { return m_view
; }
349 virtual void Clear() {}
350 virtual bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
351 virtual bool AppendRows( size_t numRows
= 1 );
352 virtual bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
353 virtual bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
354 virtual bool AppendCols( size_t numCols
= 1 );
355 virtual bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
357 virtual wxString
GetRowLabelValue( int row
);
358 virtual wxString
GetColLabelValue( int col
);
359 virtual void SetRowLabelValue( int WXUNUSED(row
), const wxString
& ) {}
360 virtual void SetColLabelValue( int WXUNUSED(col
), const wxString
& ) {}
362 // Attribute handling
365 // give us the attr provider to use - we take ownership of the pointer
366 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
368 // get the currently used attr provider (may be NULL)
369 wxGridCellAttrProvider
*GetAttrProvider() const { return m_attrProvider
; }
371 // change row/col number in attribute if needed
372 void UpdateAttrRows( size_t pos
, int numRows
);
373 void UpdateAttrCols( size_t pos
, int numCols
);
375 // by default forwarded to wxGridCellAttrProvider if any. May be
376 // overridden to handle attributes directly in this class.
377 virtual wxGridCellAttr
*GetAttr( int row
, int col
);
379 // these functions take ownership of the pointer
380 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
381 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
382 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
386 wxGridCellAttrProvider
*m_attrProvider
;
388 DECLARE_ABSTRACT_CLASS( wxGridTableBase
);
392 // ----------------------------------------------------------------------------
393 // wxGridTableMessage
394 // ----------------------------------------------------------------------------
396 // IDs for messages sent from grid table to view
398 enum wxGridTableRequest
400 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
401 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
402 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
403 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
404 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
405 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
406 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
407 wxGRIDTABLE_NOTIFY_COLS_DELETED
410 class WXDLLEXPORT wxGridTableMessage
413 wxGridTableMessage();
414 wxGridTableMessage( wxGridTableBase
*table
, int id
,
418 void SetTableObject( wxGridTableBase
*table
) { m_table
= table
; }
419 wxGridTableBase
* GetTableObject() const { return m_table
; }
420 void SetId( int id
) { m_id
= id
; }
421 int GetId() { return m_id
; }
422 void SetCommandInt( int comInt1
) { m_comInt1
= comInt1
; }
423 int GetCommandInt() { return m_comInt1
; }
424 void SetCommandInt2( int comInt2
) { m_comInt2
= comInt2
; }
425 int GetCommandInt2() { return m_comInt2
; }
428 wxGridTableBase
*m_table
;
436 // ------ wxGridStringArray
437 // A 2-dimensional array of strings for data values
440 WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString
, wxGridStringArray
);
444 // ------ wxGridStringTable
446 // Simplest type of data table for a grid for small tables of strings
447 // that are stored in memory
450 class WXDLLEXPORT wxGridStringTable
: public wxGridTableBase
454 wxGridStringTable( int numRows
, int numCols
);
455 ~wxGridStringTable();
457 // these are pure virtual in wxGridTableBase
459 long GetNumberRows();
460 long GetNumberCols();
461 wxString
GetValue( int row
, int col
);
462 void SetValue( int row
, int col
, const wxString
& s
);
463 bool IsEmptyCell( int row
, int col
);
465 // overridden functions from wxGridTableBase
468 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
469 bool AppendRows( size_t numRows
= 1 );
470 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
471 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
472 bool AppendCols( size_t numCols
= 1 );
473 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
475 void SetRowLabelValue( int row
, const wxString
& );
476 void SetColLabelValue( int col
, const wxString
& );
477 wxString
GetRowLabelValue( int row
);
478 wxString
GetColLabelValue( int col
);
481 wxGridStringArray m_data
;
483 // These only get used if you set your own labels, otherwise the
484 // GetRow/ColLabelValue functions return wxGridTableBase defaults
486 wxArrayString m_rowLabels
;
487 wxArrayString m_colLabels
;
489 DECLARE_DYNAMIC_CLASS( wxGridStringTable
)
494 //////////////////////////////////////////////////////////////////////
498 //////////////////////////////////////////////////////////////////////
500 class WXDLLEXPORT wxGridCellCoords
503 wxGridCellCoords() { m_row
= m_col
= -1; }
504 wxGridCellCoords( int r
, int c
) { m_row
= r
; m_col
= c
; }
506 // default copy ctor is ok
508 long GetRow() const { return m_row
; }
509 void SetRow( long n
) { m_row
= n
; }
510 long GetCol() const { return m_col
; }
511 void SetCol( long n
) { m_col
= n
; }
512 void Set( long row
, long col
) { m_row
= row
; m_col
= col
; }
514 wxGridCellCoords
& operator=( const wxGridCellCoords
& other
)
516 if ( &other
!= this )
524 bool operator==( const wxGridCellCoords
& other
)
526 return (m_row
== other
.m_row
&& m_col
== other
.m_col
);
529 bool operator!=( const wxGridCellCoords
& other
)
531 return (m_row
!= other
.m_row
|| m_col
!= other
.m_col
);
536 return (m_row
== -1 && m_col
== -1 );
545 // For comparisons...
547 extern wxGridCellCoords wxGridNoCellCoords
;
548 extern wxRect wxGridNoCellRect
;
550 // An array of cell coords...
552 WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords
, wxGridCellCoordsArray
);
556 // ----------------------------------------------------------------------------
558 // ----------------------------------------------------------------------------
560 class WXDLLEXPORT wxGrid
: public wxScrolledWindow
568 wxGrid( wxWindow
*parent
,
570 const wxPoint
& pos
= wxDefaultPosition
,
571 const wxSize
& size
= wxDefaultSize
,
573 const wxString
& name
= wxPanelNameStr
);
577 bool CreateGrid( int numRows
, int numCols
);
580 // ------ grid dimensions
582 int GetNumberRows() { return m_numRows
; }
583 int GetNumberCols() { return m_numCols
; }
586 // ------ display update functions
588 void CalcRowLabelsExposed( wxRegion
& reg
);
590 void CalcColLabelsExposed( wxRegion
& reg
);
591 void CalcCellsExposed( wxRegion
& reg
);
594 // ------ event handlers
596 void ProcessRowLabelMouseEvent( wxMouseEvent
& event
);
597 void ProcessColLabelMouseEvent( wxMouseEvent
& event
);
598 void ProcessCornerLabelMouseEvent( wxMouseEvent
& event
);
599 void ProcessGridCellMouseEvent( wxMouseEvent
& event
);
600 bool ProcessTableMessage( wxGridTableMessage
& );
602 void DoEndDragResizeRow();
603 void DoEndDragResizeCol();
605 wxGridTableBase
* GetTable() const { return m_table
; }
606 bool SetTable( wxGridTableBase
*table
, bool takeOwnership
=FALSE
);
609 bool InsertRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
610 bool AppendRows( int numRows
= 1, bool updateLabels
=TRUE
);
611 bool DeleteRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
612 bool InsertCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
613 bool AppendCols( int numCols
= 1, bool updateLabels
=TRUE
);
614 bool DeleteCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
616 void DrawGridCellArea( wxDC
& dc
);
617 void DrawCellBorder( wxDC
& dc
, const wxGridCellCoords
& );
618 void DrawAllGridLines( wxDC
& dc
, const wxRegion
& reg
);
619 void DrawCell( wxDC
& dc
, const wxGridCellCoords
& );
620 void DrawCellHighlight( wxDC
& dc
);
622 void DrawRowLabels( wxDC
& dc
);
623 void DrawRowLabel( wxDC
& dc
, int row
);
625 void DrawColLabels( wxDC
& dc
);
626 void DrawColLabel( wxDC
& dc
, int col
);
629 // ------ Cell text drawing functions
631 void DrawTextRectangle( wxDC
& dc
, const wxString
&, const wxRect
&,
632 int horizontalAlignment
= wxLEFT
,
633 int verticalAlignment
= wxTOP
);
635 // Split a string containing newline chararcters into an array of
636 // strings and return the number of lines
638 void StringToLines( const wxString
& value
, wxArrayString
& lines
);
640 void GetTextBoxSize( wxDC
& dc
,
641 wxArrayString
& lines
,
642 long *width
, long *height
);
646 // Code that does a lot of grid modification can be enclosed
647 // between BeginBatch() and EndBatch() calls to avoid screen
650 void BeginBatch() { m_batchCount
++; }
651 void EndBatch() { if ( m_batchCount
> 0 ) m_batchCount
--; }
652 int GetBatchCount() { return m_batchCount
; }
655 // ------ edit control functions
657 bool IsEditable() { return m_editable
; }
658 void EnableEditing( bool edit
);
660 void EnableCellEditControl( bool enable
);
662 bool IsCellEditControlEnabled()
663 { return m_cellEditCtrlEnabled
; }
665 void ShowCellEditControl();
666 void HideCellEditControl();
667 void SetEditControlValue( const wxString
& s
= wxEmptyString
);
668 void SaveEditControlValue();
671 // ------ grid location functions
672 // Note that all of these functions work with the logical coordinates of
673 // grid cells and labels so you will need to convert from device
674 // coordinates for mouse events etc.
676 void XYToCell( int x
, int y
, wxGridCellCoords
& );
680 int YToEdgeOfRow( int y
);
681 int XToEdgeOfCol( int x
);
683 wxRect
CellToRect( int row
, int col
);
684 wxRect
CellToRect( const wxGridCellCoords
& coords
)
685 { return CellToRect( coords
.GetRow(), coords
.GetCol() ); }
687 int GetGridCursorRow() { return m_currentCellCoords
.GetRow(); }
688 int GetGridCursorCol() { return m_currentCellCoords
.GetCol(); }
690 // check to see if a cell is either wholly visible (the default arg) or
691 // at least partially visible in the grid window
693 bool IsVisible( int row
, int col
, bool wholeCellVisible
= TRUE
);
694 bool IsVisible( const wxGridCellCoords
& coords
, bool wholeCellVisible
= TRUE
)
695 { return IsVisible( coords
.GetRow(), coords
.GetCol(), wholeCellVisible
); }
696 void MakeCellVisible( int row
, int col
);
697 void MakeCellVisible( const wxGridCellCoords
& coords
)
698 { MakeCellVisible( coords
.GetRow(), coords
.GetCol() ); }
701 // ------ grid cursor movement functions
703 void SetGridCursor( int row
, int col
)
704 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
707 bool MoveCursorDown();
708 bool MoveCursorLeft();
709 bool MoveCursorRight();
712 bool MoveCursorUpBlock();
713 bool MoveCursorDownBlock();
714 bool MoveCursorLeftBlock();
715 bool MoveCursorRightBlock();
718 // ------ label and gridline formatting
720 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH
; }
721 int GetRowLabelSize() { return m_rowLabelWidth
; }
722 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT
; }
723 int GetColLabelSize() { return m_colLabelHeight
; }
724 wxColour
GetLabelBackgroundColour() { return m_labelBackgroundColour
; }
725 wxColour
GetLabelTextColour() { return m_labelTextColour
; }
726 wxFont
GetLabelFont() { return m_labelFont
; }
727 void GetRowLabelAlignment( int *horiz
, int *vert
);
728 void GetColLabelAlignment( int *horiz
, int *vert
);
729 wxString
GetRowLabelValue( int row
);
730 wxString
GetColLabelValue( int col
);
731 wxColour
GetGridLineColour() { return m_gridLineColour
; }
733 void SetRowLabelSize( int width
);
734 void SetColLabelSize( int height
);
735 void SetLabelBackgroundColour( const wxColour
& );
736 void SetLabelTextColour( const wxColour
& );
737 void SetLabelFont( const wxFont
& );
738 void SetRowLabelAlignment( int horiz
, int vert
);
739 void SetColLabelAlignment( int horiz
, int vert
);
740 void SetRowLabelValue( int row
, const wxString
& );
741 void SetColLabelValue( int col
, const wxString
& );
742 void SetGridLineColour( const wxColour
& );
744 // this sets the specified attribute for all cells in this row/col
745 void SetRowAttr(int row
, wxGridCellAttr
*attr
);
746 void SetColAttr(int col
, wxGridCellAttr
*attr
);
748 void EnableGridLines( bool enable
= TRUE
);
749 bool GridLinesEnabled() { return m_gridLinesEnabled
; }
751 // ------ row and col formatting
753 int GetDefaultRowSize();
754 int GetRowSize( int row
);
755 int GetDefaultColSize();
756 int GetColSize( int col
);
757 wxColour
GetDefaultCellBackgroundColour();
758 wxColour
GetCellBackgroundColour( int row
, int col
);
759 wxColour
GetDefaultCellTextColour();
760 wxColour
GetCellTextColour( int row
, int col
);
761 wxFont
GetDefaultCellFont();
762 wxFont
GetCellFont( int row
, int col
);
763 void GetDefaultCellAlignment( int *horiz
, int *vert
);
764 void GetCellAlignment( int row
, int col
, int *horiz
, int *vert
);
766 void SetDefaultRowSize( int height
, bool resizeExistingRows
= FALSE
);
767 void SetRowSize( int row
, int height
);
768 void SetDefaultColSize( int width
, bool resizeExistingCols
= FALSE
);
770 void SetColSize( int col
, int width
);
771 void SetDefaultCellBackgroundColour( const wxColour
& );
772 void SetCellBackgroundColour( int row
, int col
, const wxColour
& );
773 void SetDefaultCellTextColour( const wxColour
& );
775 void SetCellTextColour( int row
, int col
, const wxColour
& );
776 void SetDefaultCellFont( const wxFont
& );
777 void SetCellFont( int row
, int col
, const wxFont
& );
778 void SetDefaultCellAlignment( int horiz
, int vert
);
779 void SetCellAlignment( int row
, int col
, int horiz
, int vert
);
781 // takes ownership of the pointer
782 void SetDefaultRenderer(wxGridCellRenderer
*renderer
);
783 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
*renderer
);
784 wxGridCellRenderer
*GetDefaultRenderer() const;
785 wxGridCellRenderer
* GetCellRenderer(int row
, int col
);
787 // takes ownership of the pointer
788 void SetDefaultEditor(wxGridCellEditor
*editor
);
789 void SetCellEditor(int row
, int col
, wxGridCellEditor
*editor
);
790 wxGridCellEditor
*GetDefaultEditor() const;
791 wxGridCellEditor
* GetCellEditor(int row
, int col
);
794 // ------ cell value accessors
796 wxString
GetCellValue( int row
, int col
)
800 return m_table
->GetValue( row
, col
);
804 return wxEmptyString
;
808 wxString
GetCellValue( const wxGridCellCoords
& coords
)
809 { return GetCellValue( coords
.GetRow(), coords
.GetCol() ); }
811 void SetCellValue( int row
, int col
, const wxString
& s
);
812 void SetCellValue( const wxGridCellCoords
& coords
, const wxString
& s
)
813 { SetCellValue( coords
.GetRow(), coords
.GetCol(), s
); }
817 // ------ selections of blocks of cells
819 void SelectRow( int row
, bool addToSelected
= FALSE
);
820 void SelectCol( int col
, bool addToSelected
= FALSE
);
822 void SelectBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
);
824 void SelectBlock( const wxGridCellCoords
& topLeft
,
825 const wxGridCellCoords
& bottomRight
)
826 { SelectBlock( topLeft
.GetRow(), topLeft
.GetCol(),
827 bottomRight
.GetRow(), bottomRight
.GetCol() ); }
832 { return ( m_selectedTopLeft
!= wxGridNoCellCoords
&&
833 m_selectedBottomRight
!= wxGridNoCellCoords
);
836 void ClearSelection();
838 bool IsInSelection( int row
, int col
)
839 { return ( IsSelection() &&
840 row
>= m_selectedTopLeft
.GetRow() &&
841 col
>= m_selectedTopLeft
.GetCol() &&
842 row
<= m_selectedBottomRight
.GetRow() &&
843 col
<= m_selectedBottomRight
.GetCol() );
846 bool IsInSelection( const wxGridCellCoords
& coords
)
847 { return IsInSelection( coords
.GetRow(), coords
.GetCol() ); }
849 void GetSelection( int* topRow
, int* leftCol
, int* bottomRow
, int* rightCol
)
851 // these will all be -1 if there is no selected block
853 *topRow
= m_selectedTopLeft
.GetRow();
854 *leftCol
= m_selectedTopLeft
.GetCol();
855 *bottomRow
= m_selectedBottomRight
.GetRow();
856 *rightCol
= m_selectedBottomRight
.GetCol();
860 // This function returns the rectangle that encloses the block of cells
861 // limited by TopLeft and BottomRight cell in device coords and clipped
862 // to the client size of the grid window.
864 wxRect
BlockToDeviceRect( const wxGridCellCoords
& topLeft
,
865 const wxGridCellCoords
& bottomRight
);
867 // This function returns the rectangle that encloses the selected cells
868 // in device coords and clipped to the client size of the grid window.
870 wxRect
SelectionToDeviceRect()
872 return BlockToDeviceRect( m_selectedTopLeft
,
873 m_selectedBottomRight
);
876 // Access or update the selection fore/back colours
877 wxColour
GetSelectionBackground() const
878 { return m_selectionBackground
; }
879 wxColour
GetSelectionForeground() const
880 { return m_selectionForeground
; }
882 void SetSelectionBackground(const wxColour
& c
) { m_selectionBackground
= c
; }
883 void SetSelectionForeground(const wxColour
& c
) { m_selectionForeground
= c
; }
887 // ------ For compatibility with previous wxGrid only...
889 // ************************************************
890 // ** Don't use these in new code because they **
891 // ** are liable to disappear in a future **
893 // ************************************************
896 wxGrid( wxWindow
*parent
,
897 int x
= -1, int y
= -1, int w
= -1, int h
= -1,
899 const wxString
& name
= wxPanelNameStr
)
900 : wxScrolledWindow( parent
, -1, wxPoint(x
,y
), wxSize(w
,h
), style
, name
)
905 void SetCellValue( const wxString
& val
, int row
, int col
)
906 { SetCellValue( row
, col
, val
); }
908 void UpdateDimensions()
909 { CalcDimensions(); }
911 int GetRows() { return GetNumberRows(); }
912 int GetCols() { return GetNumberCols(); }
913 int GetCursorRow() { return GetGridCursorRow(); }
914 int GetCursorColumn() { return GetGridCursorCol(); }
916 int GetScrollPosX() { return 0; }
917 int GetScrollPosY() { return 0; }
919 void SetScrollX( int x
) { }
920 void SetScrollY( int y
) { }
922 void SetColumnWidth( int col
, int width
)
923 { SetColSize( col
, width
); }
925 int GetColumnWidth( int col
)
926 { return GetColSize( col
); }
928 void SetRowHeight( int row
, int height
)
929 { SetRowSize( row
, height
); }
931 int GetRowHeight( int row
)
932 { return GetRowSize( row
); }
934 int GetViewHeight() // returned num whole rows visible
937 int GetViewWidth() // returned num whole cols visible
940 void SetLabelSize( int orientation
, int sz
)
942 if ( orientation
== wxHORIZONTAL
)
943 SetColLabelSize( sz
);
945 SetRowLabelSize( sz
);
948 int GetLabelSize( int orientation
)
950 if ( orientation
== wxHORIZONTAL
)
951 return GetColLabelSize();
953 return GetRowLabelSize();
956 void SetLabelAlignment( int orientation
, int align
)
958 if ( orientation
== wxHORIZONTAL
)
959 SetColLabelAlignment( align
, -1 );
961 SetRowLabelAlignment( align
, -1 );
964 int GetLabelAlignment( int orientation
, int WXUNUSED(align
) )
967 if ( orientation
== wxHORIZONTAL
)
969 GetColLabelAlignment( &h
, &v
);
974 GetRowLabelAlignment( &h
, &v
);
979 void SetLabelValue( int orientation
, const wxString
& val
, int pos
)
981 if ( orientation
== wxHORIZONTAL
)
982 SetColLabelValue( pos
, val
);
984 SetRowLabelValue( pos
, val
);
987 wxString
GetLabelValue( int orientation
, int pos
)
989 if ( orientation
== wxHORIZONTAL
)
990 return GetColLabelValue( pos
);
992 return GetRowLabelValue( pos
);
995 wxFont
GetCellTextFont() const
996 { return m_defaultCellAttr
->GetFont(); }
998 wxFont
GetCellTextFont(int WXUNUSED(row
), int WXUNUSED(col
)) const
999 { return m_defaultCellAttr
->GetFont(); }
1001 void SetCellTextFont(const wxFont
& fnt
)
1002 { SetDefaultCellFont( fnt
); }
1004 void SetCellTextFont(const wxFont
& fnt
, int row
, int col
)
1005 { SetCellFont( row
, col
, fnt
); }
1007 void SetCellTextColour(const wxColour
& val
, int row
, int col
)
1008 { SetCellTextColour( row
, col
, val
); }
1010 void SetCellTextColour(const wxColour
& col
)
1011 { SetDefaultCellTextColour( col
); }
1013 void SetCellBackgroundColour(const wxColour
& col
)
1014 { SetDefaultCellBackgroundColour( col
); }
1016 void SetCellBackgroundColour(const wxColour
& colour
, int row
, int col
)
1017 { SetCellBackgroundColour( row
, col
, colour
); }
1019 bool GetEditable() { return IsEditable(); }
1020 void SetEditable( bool edit
= TRUE
) { EnableEditing( edit
); }
1021 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
1023 void SetEditInPlace(bool edit
= TRUE
) { }
1025 void SetCellAlignment( int align
, int row
, int col
)
1026 { SetCellAlignment(row
, col
, align
, wxCENTER
); }
1027 void SetCellAlignment( int WXUNUSED(align
) ) {}
1028 void SetCellBitmap(wxBitmap
*WXUNUSED(bitmap
), int WXUNUSED(row
), int WXUNUSED(col
))
1030 void SetDividerPen(const wxPen
& WXUNUSED(pen
)) { }
1031 wxPen
& GetDividerPen() const { return wxNullPen
; }
1032 void OnActivate(bool WXUNUSED(active
)) {}
1034 // ******** End of compatibility functions **********
1038 // ------ control IDs
1039 enum { wxGRID_CELLCTRL
= 2000,
1042 // ------ control types
1043 enum { wxGRID_TEXTCTRL
= 2100,
1052 wxGridWindow
*m_gridWin
;
1053 wxGridRowLabelWindow
*m_rowLabelWin
;
1054 wxGridColLabelWindow
*m_colLabelWin
;
1055 wxGridCornerLabelWindow
*m_cornerLabelWin
;
1057 wxGridTableBase
*m_table
;
1068 wxGridCellCoords m_currentCellCoords
;
1070 wxGridCellCoords m_selectedTopLeft
;
1071 wxGridCellCoords m_selectedBottomRight
;
1072 wxColour m_selectionBackground
;
1073 wxColour m_selectionForeground
;
1075 int m_defaultRowHeight
;
1076 wxArrayInt m_rowHeights
;
1077 wxArrayInt m_rowBottoms
;
1079 int m_defaultColWidth
;
1080 wxArrayInt m_colWidths
;
1081 wxArrayInt m_colRights
;
1082 int m_rowLabelWidth
;
1083 int m_colLabelHeight
;
1085 wxColour m_labelBackgroundColour
;
1086 wxColour m_labelTextColour
;
1089 int m_rowLabelHorizAlign
;
1090 int m_rowLabelVertAlign
;
1091 int m_colLabelHorizAlign
;
1092 int m_colLabelVertAlign
;
1094 bool m_defaultRowLabelValues
;
1095 bool m_defaultColLabelValues
;
1097 wxColour m_gridLineColour
;
1098 bool m_gridLinesEnabled
;
1101 // do we have some place to store attributes in?
1102 bool CanHaveAttributes();
1104 // returns the attribute we may modify in place: a new one if this cell
1105 // doesn't have any yet or the existing one if it does
1107 // DecRef() must be called on the returned pointer, as usual
1108 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
1110 // cell attribute cache (currently we only cache 1, may be will do
1111 // more/better later)
1115 wxGridCellAttr
*attr
;
1118 // invalidates the attribute cache
1119 void ClearAttrCache();
1121 // adds an attribute to cache
1122 void CacheAttr(int row
, int col
, wxGridCellAttr
*attr
) const;
1124 // looks for an attr in cache, returns TRUE if found
1125 bool LookupAttr(int row
, int col
, wxGridCellAttr
**attr
) const;
1127 // looks for the attr in cache, if not found asks the table and caches the
1129 wxGridCellAttr
*GetCellAttr(int row
, int col
) const;
1130 wxGridCellAttr
*GetCellAttr(const wxGridCellCoords
& coords
)
1131 { return GetCellAttr( coords
.GetRow(), coords
.GetCol() ); }
1133 // the default cell attr object for cells that don't have their own
1134 wxGridCellAttr
* m_defaultCellAttr
;
1137 wxGridCellCoordsArray m_cellsExposed
;
1138 wxArrayInt m_rowsExposed
;
1139 wxArrayInt m_colsExposed
;
1140 wxArrayInt m_rowLabelsExposed
;
1141 wxArrayInt m_colLabelsExposed
;
1148 WXGRID_CURSOR_SELECT_CELL
,
1149 WXGRID_CURSOR_RESIZE_ROW
,
1150 WXGRID_CURSOR_RESIZE_COL
,
1151 WXGRID_CURSOR_SELECT_ROW
,
1152 WXGRID_CURSOR_SELECT_COL
1155 // this method not only sets m_cursorMode but also sets the correct cursor
1156 // for the given mode and, if captureMouse is not FALSE releases the mouse
1157 // if it was captured and captures it if it must be captured
1159 // for this to work, you should always use it and not set m_cursorMode
1161 void ChangeCursorMode(CursorMode mode
,
1162 wxWindow
*win
= (wxWindow
*)NULL
,
1163 bool captureMouse
= TRUE
);
1165 wxWindow
*m_winCapture
; // the window which captured the mouse
1166 CursorMode m_cursorMode
;
1171 wxPoint m_startDragPos
;
1173 bool m_waitForSlowClick
;
1175 wxGridCellCoords m_selectionStart
;
1177 wxCursor m_rowResizeCursor
;
1178 wxCursor m_colResizeCursor
;
1180 bool m_editable
; // applies to whole grid
1181 bool m_cellEditCtrlEnabled
;
1186 void CalcDimensions();
1187 void CalcWindowSizes();
1188 bool Redimension( wxGridTableMessage
& );
1191 bool SendEvent( const wxEventType
,
1195 bool SendEvent( const wxEventType
,
1199 void OnPaint( wxPaintEvent
& );
1200 void OnSize( wxSizeEvent
& );
1201 void OnKeyDown( wxKeyEvent
& );
1202 void OnEraseBackground( wxEraseEvent
& );
1205 void SetCurrentCell( const wxGridCellCoords
& coords
);
1206 void SetCurrentCell( int row
, int col
)
1207 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1210 // ------ functions to get/send data (see also public functions)
1212 bool GetModelValues();
1213 bool SetModelValues();
1216 DECLARE_DYNAMIC_CLASS( wxGrid
)
1217 DECLARE_EVENT_TABLE()
1225 // ------ Grid event class and event types
1228 class WXDLLEXPORT wxGridEvent
: public wxNotifyEvent
1232 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
1233 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1237 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
1238 int row
=-1, int col
=-1, int x
=-1, int y
=-1,
1239 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1241 virtual int GetRow() { return m_row
; }
1242 virtual int GetCol() { return m_col
; }
1243 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1244 bool ControlDown() { return m_control
; }
1245 bool MetaDown() { return m_meta
; }
1246 bool ShiftDown() { return m_shift
; }
1247 bool AltDown() { return m_alt
; }
1259 DECLARE_DYNAMIC_CLASS(wxGridEvent
)
1263 class WXDLLEXPORT wxGridSizeEvent
: public wxNotifyEvent
1267 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1268 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1272 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
1273 int rowOrCol
=-1, int x
=-1, int y
=-1,
1274 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1276 int GetRowOrCol() { return m_rowOrCol
; }
1277 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1278 bool ControlDown() { return m_control
; }
1279 bool MetaDown() { return m_meta
; }
1280 bool ShiftDown() { return m_shift
; }
1281 bool AltDown() { return m_alt
; }
1292 DECLARE_DYNAMIC_CLASS(wxGridSizeEvent
)
1296 class WXDLLEXPORT wxGridRangeSelectEvent
: public wxNotifyEvent
1299 wxGridRangeSelectEvent()
1302 m_topLeft
= wxGridNoCellCoords
;
1303 m_bottomRight
= wxGridNoCellCoords
;
1310 wxGridRangeSelectEvent(int id
, wxEventType type
, wxObject
* obj
,
1311 const wxGridCellCoords
& topLeft
,
1312 const wxGridCellCoords
& bottomRight
,
1313 bool control
=FALSE
, bool shift
=FALSE
,
1314 bool alt
=FALSE
, bool meta
=FALSE
);
1316 wxGridCellCoords
GetTopLeftCoords() { return m_topLeft
; }
1317 wxGridCellCoords
GetBottomRightCoords() { return m_bottomRight
; }
1318 int GetTopRow() { return m_topLeft
.GetRow(); }
1319 int GetBottomRow() { return m_bottomRight
.GetRow(); }
1320 int GetLeftCol() { return m_topLeft
.GetCol(); }
1321 int GetRightCol() { return m_bottomRight
.GetCol(); }
1322 bool ControlDown() { return m_control
; }
1323 bool MetaDown() { return m_meta
; }
1324 bool ShiftDown() { return m_shift
; }
1325 bool AltDown() { return m_alt
; }
1328 wxGridCellCoords m_topLeft
;
1329 wxGridCellCoords m_bottomRight
;
1335 DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent
)
1339 const wxEventType EVT_GRID_CELL_LEFT_CLICK
= wxEVT_FIRST
+ 1580;
1340 const wxEventType EVT_GRID_CELL_RIGHT_CLICK
= wxEVT_FIRST
+ 1581;
1341 const wxEventType EVT_GRID_CELL_LEFT_DCLICK
= wxEVT_FIRST
+ 1582;
1342 const wxEventType EVT_GRID_CELL_RIGHT_DCLICK
= wxEVT_FIRST
+ 1583;
1343 const wxEventType EVT_GRID_LABEL_LEFT_CLICK
= wxEVT_FIRST
+ 1584;
1344 const wxEventType EVT_GRID_LABEL_RIGHT_CLICK
= wxEVT_FIRST
+ 1585;
1345 const wxEventType EVT_GRID_LABEL_LEFT_DCLICK
= wxEVT_FIRST
+ 1586;
1346 const wxEventType EVT_GRID_LABEL_RIGHT_DCLICK
= wxEVT_FIRST
+ 1587;
1347 const wxEventType EVT_GRID_ROW_SIZE
= wxEVT_FIRST
+ 1588;
1348 const wxEventType EVT_GRID_COL_SIZE
= wxEVT_FIRST
+ 1589;
1349 const wxEventType EVT_GRID_RANGE_SELECT
= wxEVT_FIRST
+ 1590;
1350 const wxEventType EVT_GRID_CELL_CHANGE
= wxEVT_FIRST
+ 1591;
1351 const wxEventType EVT_GRID_SELECT_CELL
= wxEVT_FIRST
+ 1592;
1354 typedef void (wxEvtHandler::*wxGridEventFunction
)(wxGridEvent
&);
1355 typedef void (wxEvtHandler::*wxGridSizeEventFunction
)(wxGridSizeEvent
&);
1356 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction
)(wxGridRangeSelectEvent
&);
1358 #define EVT_GRID_CELL_LEFT_CLICK(fn) { EVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1359 #define EVT_GRID_CELL_RIGHT_CLICK(fn) { EVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1360 #define EVT_GRID_CELL_LEFT_DCLICK(fn) { EVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1361 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) { EVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1362 #define EVT_GRID_LABEL_LEFT_CLICK(fn) { EVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1363 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) { EVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1364 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) { EVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1365 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) { EVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1366 #define EVT_GRID_ROW_SIZE(fn) { EVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1367 #define EVT_GRID_COL_SIZE(fn) { EVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1368 #define EVT_GRID_RANGE_SELECT(fn) { EVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL },
1369 #define EVT_GRID_CELL_CHANGE(fn) { EVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1370 #define EVT_GRID_SELECT_CELL(fn) { EVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1373 #if 0 // TODO: implement these ? others ?
1375 const wxEventType EVT_GRID_CREATE_CELL
= wxEVT_FIRST
+ 1576;
1376 const wxEventType EVT_GRID_CHANGE_LABELS
= wxEVT_FIRST
+ 1577;
1377 const wxEventType EVT_GRID_CHANGE_SEL_LABEL
= wxEVT_FIRST
+ 1578;
1379 #define EVT_GRID_CREATE_CELL(fn) { EVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1380 #define EVT_GRID_CHANGE_LABELS(fn) { EVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1381 #define EVT_GRID_CHANGE_SEL_LABEL(fn) { EVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1385 #endif // #ifndef __WXGRID_H__
1387 #endif // ifndef wxUSE_NEW_GRID