1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/grid.h
3 // Purpose: wxGrid and related classes
4 // Author: Michael Bedward (based on code by Julian Smart, Robin Dunn)
5 // Modified by: Santiago Palacios
8 // Copyright: (c) Michael Bedward
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GENERIC_GRID_H_
13 #define _WX_GENERIC_GRID_H_
19 #include "wx/hashmap.h"
21 #include "wx/scrolwin.h"
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 extern WXDLLIMPEXP_DATA_ADV(const char) wxGridNameStr
[];
29 // Default parameters for wxGrid
31 #define WXGRID_DEFAULT_NUMBER_ROWS 10
32 #define WXGRID_DEFAULT_NUMBER_COLS 10
33 #if defined(__WXMSW__) || defined(__WXGTK20__)
34 #define WXGRID_DEFAULT_ROW_HEIGHT 25
36 #define WXGRID_DEFAULT_ROW_HEIGHT 30
38 #define WXGRID_DEFAULT_COL_WIDTH 80
39 #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
40 #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
41 #define WXGRID_LABEL_EDGE_ZONE 2
42 #define WXGRID_MIN_ROW_HEIGHT 15
43 #define WXGRID_MIN_COL_WIDTH 15
44 #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
46 // type names for grid table values
47 #define wxGRID_VALUE_STRING _T("string")
48 #define wxGRID_VALUE_BOOL _T("bool")
49 #define wxGRID_VALUE_NUMBER _T("long")
50 #define wxGRID_VALUE_FLOAT _T("double")
51 #define wxGRID_VALUE_CHOICE _T("choice")
53 #define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
54 #define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
56 // magic constant which tells (to some functions) to automatically calculate
57 // the appropriate size
58 #define wxGRID_AUTOSIZE (-1)
60 // many wxGrid methods work either with columns or rows, this enum is used for
61 // the parameter indicating which one should it be
68 // ----------------------------------------------------------------------------
69 // forward declarations
70 // ----------------------------------------------------------------------------
72 class WXDLLIMPEXP_FWD_ADV wxGrid
;
73 class WXDLLIMPEXP_FWD_ADV wxGridCellAttr
;
74 class WXDLLIMPEXP_FWD_ADV wxGridCellAttrProviderData
;
75 class WXDLLIMPEXP_FWD_ADV wxGridColLabelWindow
;
76 class WXDLLIMPEXP_FWD_ADV wxGridCornerLabelWindow
;
77 class WXDLLIMPEXP_FWD_ADV wxGridRowLabelWindow
;
78 class WXDLLIMPEXP_FWD_ADV wxGridWindow
;
79 class WXDLLIMPEXP_FWD_ADV wxGridTypeRegistry
;
80 class WXDLLIMPEXP_FWD_ADV wxGridSelection
;
82 class WXDLLIMPEXP_FWD_CORE wxHeaderCtrl
;
83 class WXDLLIMPEXP_FWD_CORE wxCheckBox
;
84 class WXDLLIMPEXP_FWD_CORE wxComboBox
;
85 class WXDLLIMPEXP_FWD_CORE wxTextCtrl
;
87 class WXDLLIMPEXP_FWD_CORE wxSpinCtrl
;
90 class wxGridFixedIndicesSet
;
92 class wxGridOperations
;
93 class wxGridRowOperations
;
94 class wxGridColumnOperations
;
95 class wxGridDirectionOperations
;
98 // ----------------------------------------------------------------------------
100 // ----------------------------------------------------------------------------
102 #define wxSafeIncRef(p) if ( p ) (p)->IncRef()
103 #define wxSafeDecRef(p) if ( p ) (p)->DecRef()
105 // ----------------------------------------------------------------------------
106 // wxGridCellWorker: common base class for wxGridCellRenderer and
109 // NB: this is more an implementation convenience than a design issue, so this
110 // class is not documented and is not public at all
111 // ----------------------------------------------------------------------------
113 class WXDLLIMPEXP_ADV wxGridCellWorker
: public wxClientDataContainer
116 wxGridCellWorker() { m_nRef
= 1; }
118 // this class is ref counted: it is created with ref count of 1, so
119 // calling DecRef() once will delete it. Calling IncRef() allows to lock
120 // it until the matching DecRef() is called
121 void IncRef() { m_nRef
++; }
122 void DecRef() { if ( --m_nRef
== 0 ) delete this; }
124 // interpret renderer parameters: arbitrary string whose interpretatin is
125 // left to the derived classes
126 virtual void SetParameters(const wxString
& params
);
129 // virtual dtor for any base class - private because only DecRef() can
131 virtual ~wxGridCellWorker();
136 // suppress the stupid gcc warning about the class having private dtor and
138 friend class wxGridCellWorkerDummyFriend
;
141 // ----------------------------------------------------------------------------
142 // wxGridCellRenderer: this class is responsible for actually drawing the cell
143 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
144 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
145 // view of all cells. This is an ABC, you will normally use one of the
146 // predefined derived classes or derive your own class from it.
147 // ----------------------------------------------------------------------------
149 class WXDLLIMPEXP_ADV wxGridCellRenderer
: public wxGridCellWorker
152 // draw the given cell on the provided DC inside the given rectangle
153 // using the style specified by the attribute and the default or selected
154 // state corresponding to the isSelected value.
156 // this pure virtual function has a default implementation which will
157 // prepare the DC using the given attribute: it will draw the rectangle
158 // with the bg colour from attr and set the text colour and font
159 virtual void Draw(wxGrid
& grid
,
160 wxGridCellAttr
& attr
,
164 bool isSelected
) = 0;
166 // get the preferred size of the cell for its contents
167 virtual wxSize
GetBestSize(wxGrid
& grid
,
168 wxGridCellAttr
& attr
,
170 int row
, int col
) = 0;
172 // create a new object which is the copy of this one
173 virtual wxGridCellRenderer
*Clone() const = 0;
176 // ----------------------------------------------------------------------------
177 // wxGridCellEditor: This class is responsible for providing and manipulating
178 // the in-place edit controls for the grid. Instances of wxGridCellEditor
179 // (actually, instances of derived classes since it is an ABC) can be
180 // associated with the cell attributes for individual cells, rows, columns, or
181 // even for the entire grid.
182 // ----------------------------------------------------------------------------
184 class WXDLLIMPEXP_ADV wxGridCellEditor
: public wxGridCellWorker
189 bool IsCreated() { return m_control
!= NULL
; }
190 wxControl
* GetControl() { return m_control
; }
191 void SetControl(wxControl
* control
) { m_control
= control
; }
193 wxGridCellAttr
* GetCellAttr() { return m_attr
; }
194 void SetCellAttr(wxGridCellAttr
* attr
) { m_attr
= attr
; }
196 // Creates the actual edit control
197 virtual void Create(wxWindow
* parent
,
199 wxEvtHandler
* evtHandler
) = 0;
201 // Size and position the edit control
202 virtual void SetSize(const wxRect
& rect
);
204 // Show or hide the edit control, use the specified attributes to set
205 // colours/fonts for it
206 virtual void Show(bool show
, wxGridCellAttr
*attr
= NULL
);
208 // Draws the part of the cell not occupied by the control: the base class
209 // version just fills it with background colour from the attribute
210 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
213 // The methods called by wxGrid when a cell is edited: first BeginEdit() is
214 // called, then EndEdit() is and if it returns true and if the change is
215 // not vetoed by a user-defined event handler, finally ApplyEdit() is called
217 // Fetch the value from the table and prepare the edit control
218 // to begin editing. Set the focus to the edit control.
219 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
221 // Returns false if nothing changed, otherwise returns true and return the
222 // new value in its string form in the newval output parameter.
224 // This should also store the new value in its real type internally so that
225 // it could be used by ApplyEdit() but it must not modify the grid as the
226 // change could still be vetoed.
227 virtual bool EndEdit(int row
, int col
, const wxGrid
*grid
,
228 const wxString
& oldval
, wxString
*newval
) = 0;
230 // Complete the editing of the current cell by storing the value saved by
231 // the previous call to EndEdit() in the grid
232 virtual void ApplyEdit(int row
, int col
, wxGrid
* grid
) = 0;
235 // Reset the value in the control back to its starting value
236 virtual void Reset() = 0;
238 // return true to allow the given key to start editing: the base class
239 // version only checks that the event has no modifiers. The derived
240 // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in
241 // their IsAcceptedKey() implementation, although, of course, it is not a
242 // mandatory requirment.
244 // NB: if the key is F2 (special), editing will always start and this
245 // method will not be called at all (but StartingKey() will)
246 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
248 // If the editor is enabled by pressing keys on the grid, this will be
249 // called to let the editor do something about that first key if desired
250 virtual void StartingKey(wxKeyEvent
& event
);
252 // if the editor is enabled by clicking on the cell, this method will be
254 virtual void StartingClick();
256 // Some types of controls on some platforms may need some help
257 // with the Return key.
258 virtual void HandleReturn(wxKeyEvent
& event
);
261 virtual void Destroy();
263 // create a new object which is the copy of this one
264 virtual wxGridCellEditor
*Clone() const = 0;
266 // added GetValue so we can get the value which is in the control
267 virtual wxString
GetValue() const = 0;
270 // the dtor is private because only DecRef() can delete us
271 virtual ~wxGridCellEditor();
273 // the control we show on screen
274 wxControl
* m_control
;
276 // a temporary pointer to the attribute being edited
277 wxGridCellAttr
* m_attr
;
279 // if we change the colours/font of the control from the default ones, we
280 // must restore the default later and we save them here between calls to
281 // Show(true) and Show(false)
286 // suppress the stupid gcc warning about the class having private dtor and
288 friend class wxGridCellEditorDummyFriend
;
290 wxDECLARE_NO_COPY_CLASS(wxGridCellEditor
);
294 // ----------------------------------------------------------------------------
295 // wxGridCellAttr: this class can be used to alter the cells appearance in
296 // the grid by changing their colour/font/... from default. An object of this
297 // class may be returned by wxGridTable::GetAttr().
298 // ----------------------------------------------------------------------------
300 class WXDLLIMPEXP_ADV wxGridCellAttr
: public wxClientDataContainer
314 wxGridCellAttr(wxGridCellAttr
*attrDefault
= NULL
)
318 // MB: args used to be 0,0 here but wxALIGN_LEFT is 0
319 SetAlignment(-1, -1);
322 // VZ: considering the number of members wxGridCellAttr has now, this ctor
323 // seems to be pretty useless... may be we should just remove it?
324 wxGridCellAttr(const wxColour
& colText
,
325 const wxColour
& colBack
,
329 : m_colText(colText
), m_colBack(colBack
), m_font(font
)
332 SetAlignment(hAlign
, vAlign
);
335 // creates a new copy of this object
336 wxGridCellAttr
*Clone() const;
337 void MergeWith(wxGridCellAttr
*mergefrom
);
339 // this class is ref counted: it is created with ref count of 1, so
340 // calling DecRef() once will delete it. Calling IncRef() allows to lock
341 // it until the matching DecRef() is called
342 void IncRef() { m_nRef
++; }
343 void DecRef() { if ( --m_nRef
== 0 ) delete this; }
346 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
347 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
348 void SetFont(const wxFont
& font
) { m_font
= font
; }
349 void SetAlignment(int hAlign
, int vAlign
)
354 void SetSize(int num_rows
, int num_cols
);
355 void SetOverflow(bool allow
= true)
356 { m_overflow
= allow
? Overflow
: SingleCell
; }
357 void SetReadOnly(bool isReadOnly
= true)
358 { m_isReadOnly
= isReadOnly
? ReadOnly
: ReadWrite
; }
360 // takes ownership of the pointer
361 void SetRenderer(wxGridCellRenderer
*renderer
)
362 { wxSafeDecRef(m_renderer
); m_renderer
= renderer
; }
363 void SetEditor(wxGridCellEditor
* editor
)
364 { wxSafeDecRef(m_editor
); m_editor
= editor
; }
366 void SetKind(wxAttrKind kind
) { m_attrkind
= kind
; }
369 bool HasTextColour() const { return m_colText
.Ok(); }
370 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
371 bool HasFont() const { return m_font
.Ok(); }
372 bool HasAlignment() const { return (m_hAlign
!= -1 || m_vAlign
!= -1); }
373 bool HasRenderer() const { return m_renderer
!= NULL
; }
374 bool HasEditor() const { return m_editor
!= NULL
; }
375 bool HasReadWriteMode() const { return m_isReadOnly
!= Unset
; }
376 bool HasOverflowMode() const { return m_overflow
!= UnsetOverflow
; }
377 bool HasSize() const { return m_sizeRows
!= 1 || m_sizeCols
!= 1; }
379 const wxColour
& GetTextColour() const;
380 const wxColour
& GetBackgroundColour() const;
381 const wxFont
& GetFont() const;
382 void GetAlignment(int *hAlign
, int *vAlign
) const;
383 void GetSize(int *num_rows
, int *num_cols
) const;
384 bool GetOverflow() const
385 { return m_overflow
!= SingleCell
; }
386 wxGridCellRenderer
*GetRenderer(const wxGrid
* grid
, int row
, int col
) const;
387 wxGridCellEditor
*GetEditor(const wxGrid
* grid
, int row
, int col
) const;
389 bool IsReadOnly() const { return m_isReadOnly
== wxGridCellAttr::ReadOnly
; }
391 wxAttrKind
GetKind() { return m_attrkind
; }
393 void SetDefAttr(wxGridCellAttr
* defAttr
) { m_defGridAttr
= defAttr
; }
396 // the dtor is private because only DecRef() can delete us
397 virtual ~wxGridCellAttr()
399 wxSafeDecRef(m_renderer
);
400 wxSafeDecRef(m_editor
);
411 enum wxAttrOverflowMode
418 // the common part of all ctors
419 void Init(wxGridCellAttr
*attrDefault
= NULL
);
422 // the ref count - when it goes to 0, we die
433 wxAttrOverflowMode m_overflow
;
435 wxGridCellRenderer
* m_renderer
;
436 wxGridCellEditor
* m_editor
;
437 wxGridCellAttr
* m_defGridAttr
;
439 wxAttrReadMode m_isReadOnly
;
441 wxAttrKind m_attrkind
;
443 // use Clone() instead
444 wxDECLARE_NO_COPY_CLASS(wxGridCellAttr
);
446 // suppress the stupid gcc warning about the class having private dtor and
448 friend class wxGridCellAttrDummyFriend
;
451 // ----------------------------------------------------------------------------
452 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
454 // ----------------------------------------------------------------------------
456 // implementation note: we separate it from wxGridTableBase because we wish to
457 // avoid deriving a new table class if possible, and sometimes it will be
458 // enough to just derive another wxGridCellAttrProvider instead
460 // the default implementation is reasonably efficient for the generic case,
461 // but you might still wish to implement your own for some specific situations
462 // if you have performance problems with the stock one
463 class WXDLLIMPEXP_ADV wxGridCellAttrProvider
: public wxClientDataContainer
466 wxGridCellAttrProvider();
467 virtual ~wxGridCellAttrProvider();
469 // DecRef() must be called on the returned pointer
470 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
471 wxGridCellAttr::wxAttrKind kind
) const;
473 // all these functions take ownership of the pointer, don't call DecRef()
475 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
476 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
477 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
479 // these functions must be called whenever some rows/cols are deleted
480 // because the internal data must be updated then
481 void UpdateAttrRows( size_t pos
, int numRows
);
482 void UpdateAttrCols( size_t pos
, int numCols
);
487 wxGridCellAttrProviderData
*m_data
;
489 wxDECLARE_NO_COPY_CLASS(wxGridCellAttrProvider
);
492 // ----------------------------------------------------------------------------
493 // wxGridCellCoords: location of a cell in the grid
494 // ----------------------------------------------------------------------------
496 class WXDLLIMPEXP_ADV wxGridCellCoords
499 wxGridCellCoords() { m_row
= m_col
= -1; }
500 wxGridCellCoords( int r
, int c
) { m_row
= r
; m_col
= c
; }
502 // default copy ctor is ok
504 int GetRow() const { return m_row
; }
505 void SetRow( int n
) { m_row
= n
; }
506 int GetCol() const { return m_col
; }
507 void SetCol( int n
) { m_col
= n
; }
508 void Set( int row
, int col
) { m_row
= row
; m_col
= col
; }
510 wxGridCellCoords
& operator=( const wxGridCellCoords
& other
)
512 if ( &other
!= this )
520 bool operator==( const wxGridCellCoords
& other
) const
522 return (m_row
== other
.m_row
&& m_col
== other
.m_col
);
525 bool operator!=( const wxGridCellCoords
& other
) const
527 return (m_row
!= other
.m_row
|| m_col
!= other
.m_col
);
530 bool operator!() const
532 return (m_row
== -1 && m_col
== -1 );
541 // For comparisons...
543 extern WXDLLIMPEXP_ADV wxGridCellCoords wxGridNoCellCoords
;
544 extern WXDLLIMPEXP_ADV wxRect wxGridNoCellRect
;
546 // An array of cell coords...
548 WX_DECLARE_OBJARRAY_WITH_DECL(wxGridCellCoords
, wxGridCellCoordsArray
,
549 class WXDLLIMPEXP_ADV
);
551 // ----------------------------------------------------------------------------
552 // Grid table classes
553 // ----------------------------------------------------------------------------
555 // the abstract base class
556 class WXDLLIMPEXP_ADV wxGridTableBase
: public wxObject
,
557 public wxClientDataContainer
561 virtual ~wxGridTableBase();
563 // You must override these functions in a derived table class
566 // return the number of rows and columns in this table
567 virtual int GetNumberRows() = 0;
568 virtual int GetNumberCols() = 0;
570 // the methods above are unfortunately non-const even though they should
571 // have been const -- but changing it now is not possible any longer as it
572 // would break the existing code overriding them, so instead we provide
573 // these const synonyms which can be used from const-correct code
574 int GetRowsCount() const
575 { return const_cast<wxGridTableBase
*>(this)->GetNumberRows(); }
576 int GetColsCount() const
577 { return const_cast<wxGridTableBase
*>(this)->GetNumberCols(); }
580 virtual bool IsEmptyCell( int row
, int col
)
582 return GetValue(row
, col
).empty();
585 bool IsEmpty(const wxGridCellCoords
& coord
)
587 return IsEmptyCell(coord
.GetRow(), coord
.GetCol());
590 virtual wxString
GetValue( int row
, int col
) = 0;
591 virtual void SetValue( int row
, int col
, const wxString
& value
) = 0;
593 // Data type determination and value access
594 virtual wxString
GetTypeName( int row
, int col
);
595 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
596 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
598 virtual long GetValueAsLong( int row
, int col
);
599 virtual double GetValueAsDouble( int row
, int col
);
600 virtual bool GetValueAsBool( int row
, int col
);
602 virtual void SetValueAsLong( int row
, int col
, long value
);
603 virtual void SetValueAsDouble( int row
, int col
, double value
);
604 virtual void SetValueAsBool( int row
, int col
, bool value
);
606 // For user defined types
607 virtual void* GetValueAsCustom( int row
, int col
, const wxString
& typeName
);
608 virtual void SetValueAsCustom( int row
, int col
, const wxString
& typeName
, void* value
);
611 // Overriding these is optional
613 virtual void SetView( wxGrid
*grid
) { m_view
= grid
; }
614 virtual wxGrid
* GetView() const { return m_view
; }
616 virtual void Clear() {}
617 virtual bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
618 virtual bool AppendRows( size_t numRows
= 1 );
619 virtual bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
620 virtual bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
621 virtual bool AppendCols( size_t numCols
= 1 );
622 virtual bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
624 virtual wxString
GetRowLabelValue( int row
);
625 virtual wxString
GetColLabelValue( int col
);
626 virtual void SetRowLabelValue( int WXUNUSED(row
), const wxString
& ) {}
627 virtual void SetColLabelValue( int WXUNUSED(col
), const wxString
& ) {}
629 // Attribute handling
632 // give us the attr provider to use - we take ownership of the pointer
633 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
635 // get the currently used attr provider (may be NULL)
636 wxGridCellAttrProvider
*GetAttrProvider() const { return m_attrProvider
; }
638 // Does this table allow attributes? Default implementation creates
639 // a wxGridCellAttrProvider if necessary.
640 virtual bool CanHaveAttributes();
642 // by default forwarded to wxGridCellAttrProvider if any. May be
643 // overridden to handle attributes directly in the table.
644 virtual wxGridCellAttr
*GetAttr( int row
, int col
,
645 wxGridCellAttr::wxAttrKind kind
);
648 // these functions take ownership of the pointer
649 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
650 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
651 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
655 wxGridCellAttrProvider
*m_attrProvider
;
657 DECLARE_ABSTRACT_CLASS(wxGridTableBase
)
658 wxDECLARE_NO_COPY_CLASS(wxGridTableBase
);
662 // ----------------------------------------------------------------------------
663 // wxGridTableMessage
664 // ----------------------------------------------------------------------------
666 // IDs for messages sent from grid table to view
668 enum wxGridTableRequest
670 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
671 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
672 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
673 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
674 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
675 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
676 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
677 wxGRIDTABLE_NOTIFY_COLS_DELETED
680 class WXDLLIMPEXP_ADV wxGridTableMessage
683 wxGridTableMessage();
684 wxGridTableMessage( wxGridTableBase
*table
, int id
,
688 void SetTableObject( wxGridTableBase
*table
) { m_table
= table
; }
689 wxGridTableBase
* GetTableObject() const { return m_table
; }
690 void SetId( int id
) { m_id
= id
; }
691 int GetId() { return m_id
; }
692 void SetCommandInt( int comInt1
) { m_comInt1
= comInt1
; }
693 int GetCommandInt() { return m_comInt1
; }
694 void SetCommandInt2( int comInt2
) { m_comInt2
= comInt2
; }
695 int GetCommandInt2() { return m_comInt2
; }
698 wxGridTableBase
*m_table
;
703 wxDECLARE_NO_COPY_CLASS(wxGridTableMessage
);
708 // ------ wxGridStringArray
709 // A 2-dimensional array of strings for data values
712 WX_DECLARE_OBJARRAY_WITH_DECL(wxArrayString
, wxGridStringArray
,
713 class WXDLLIMPEXP_ADV
);
717 // ------ wxGridStringTable
719 // Simplest type of data table for a grid for small tables of strings
720 // that are stored in memory
723 class WXDLLIMPEXP_ADV wxGridStringTable
: public wxGridTableBase
727 wxGridStringTable( int numRows
, int numCols
);
728 virtual ~wxGridStringTable();
730 // these are pure virtual in wxGridTableBase
734 wxString
GetValue( int row
, int col
);
735 void SetValue( int row
, int col
, const wxString
& s
);
737 // overridden functions from wxGridTableBase
740 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
741 bool AppendRows( size_t numRows
= 1 );
742 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
743 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
744 bool AppendCols( size_t numCols
= 1 );
745 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
747 void SetRowLabelValue( int row
, const wxString
& );
748 void SetColLabelValue( int col
, const wxString
& );
749 wxString
GetRowLabelValue( int row
);
750 wxString
GetColLabelValue( int col
);
753 wxGridStringArray m_data
;
755 // These only get used if you set your own labels, otherwise the
756 // GetRow/ColLabelValue functions return wxGridTableBase defaults
758 wxArrayString m_rowLabels
;
759 wxArrayString m_colLabels
;
761 DECLARE_DYNAMIC_CLASS_NO_COPY( wxGridStringTable
)
766 // ============================================================================
768 // ============================================================================
770 // ----------------------------------------------------------------------------
771 // wxGridSizesInfo stores information about sizes of the rows or columns.
773 // It assumes that most of the columns or rows have default size and so stores
774 // the default size separately and uses a hash to map column or row numbers to
775 // their non default size for those which don't have the default size.
776 // ----------------------------------------------------------------------------
778 // hash map to store positions as the keys and sizes as the values
779 WX_DECLARE_HASH_MAP_WITH_DECL( unsigned, int, wxIntegerHash
, wxIntegerEqual
,
780 wxUnsignedToIntHashMap
, class WXDLLIMPEXP_ADV
);
782 struct WXDLLIMPEXP_ADV wxGridSizesInfo
784 // default ctor, initialize m_sizeDefault and m_customSizes later
785 wxGridSizesInfo() { }
787 // ctor used by wxGrid::Get{Col,Row}Sizes()
788 wxGridSizesInfo(int defSize
, const wxArrayInt
& allSizes
);
790 // default copy ctor, assignment operator and dtor are ok
792 // Get the size of the element with the given index
793 int GetSize(unsigned pos
) const;
799 // position -> size map containing all elements with non-default size
800 wxUnsignedToIntHashMap m_customSizes
;
803 // ----------------------------------------------------------------------------
805 // ----------------------------------------------------------------------------
807 class WXDLLIMPEXP_ADV wxGrid
: public wxScrolledWindow
810 // possible selection modes
811 enum wxGridSelectionModes
813 wxGridSelectCells
= 0, // allow selecting anything
814 wxGridSelectRows
= 1, // allow selecting only entire rows
815 wxGridSelectColumns
= 2, // allow selecting only entire columns
816 wxGridSelectRowsOrColumns
= wxGridSelectRows
| wxGridSelectColumns
819 // creation and destruction
820 // ------------------------
822 // ctor and Create() create the grid window, as with the other controls
825 wxGrid(wxWindow
*parent
,
827 const wxPoint
& pos
= wxDefaultPosition
,
828 const wxSize
& size
= wxDefaultSize
,
829 long style
= wxWANTS_CHARS
,
830 const wxString
& name
= wxGridNameStr
)
834 Create(parent
, id
, pos
, size
, style
, name
);
837 bool Create(wxWindow
*parent
,
839 const wxPoint
& pos
= wxDefaultPosition
,
840 const wxSize
& size
= wxDefaultSize
,
841 long style
= wxWANTS_CHARS
,
842 const wxString
& name
= wxGridNameStr
);
846 // however to initialize grid data either CreateGrid() or SetTable() must
849 // this is basically equivalent to
851 // SetTable(new wxGridStringTable(numRows, numCols), true, selmode)
853 bool CreateGrid( int numRows
, int numCols
,
854 wxGridSelectionModes selmode
= wxGridSelectCells
);
856 bool SetTable( wxGridTableBase
*table
,
857 bool takeOwnership
= false,
858 wxGridSelectionModes selmode
= wxGridSelectCells
);
860 bool ProcessTableMessage(wxGridTableMessage
&);
862 wxGridTableBase
*GetTable() const { return m_table
; }
865 void SetSelectionMode(wxGridSelectionModes selmode
);
866 wxGridSelectionModes
GetSelectionMode() const;
868 // ------ grid dimensions
870 int GetNumberRows() const { return m_numRows
; }
871 int GetNumberCols() const { return m_numCols
; }
874 // ------ display update functions
876 wxArrayInt
CalcRowLabelsExposed( const wxRegion
& reg
) const;
878 wxArrayInt
CalcColLabelsExposed( const wxRegion
& reg
) const;
879 wxGridCellCoordsArray
CalcCellsExposed( const wxRegion
& reg
) const;
883 bool InsertRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true)
885 return DoModifyLines(&wxGridTableBase::InsertRows
,
886 pos
, numRows
, updateLabels
);
888 bool InsertCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true)
890 return DoModifyLines(&wxGridTableBase::InsertCols
,
891 pos
, numCols
, updateLabels
);
894 bool AppendRows(int numRows
= 1, bool updateLabels
= true)
896 return DoAppendLines(&wxGridTableBase::AppendRows
, numRows
, updateLabels
);
898 bool AppendCols(int numCols
= 1, bool updateLabels
= true)
900 return DoAppendLines(&wxGridTableBase::AppendCols
, numCols
, updateLabels
);
903 bool DeleteRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true)
905 return DoModifyLines(&wxGridTableBase::DeleteRows
,
906 pos
, numRows
, updateLabels
);
908 bool DeleteCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true)
910 return DoModifyLines(&wxGridTableBase::DeleteCols
,
911 pos
, numCols
, updateLabels
);
914 void DrawGridCellArea( wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
915 void DrawGridSpace( wxDC
& dc
);
916 void DrawCellBorder( wxDC
& dc
, const wxGridCellCoords
& );
917 void DrawAllGridLines( wxDC
& dc
, const wxRegion
& reg
);
918 void DrawCell( wxDC
& dc
, const wxGridCellCoords
& );
919 void DrawHighlight(wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
921 // this function is called when the current cell highlight must be redrawn
922 // and may be overridden by the user
923 virtual void DrawCellHighlight( wxDC
& dc
, const wxGridCellAttr
*attr
);
925 virtual void DrawRowLabels( wxDC
& dc
, const wxArrayInt
& rows
);
926 virtual void DrawRowLabel( wxDC
& dc
, int row
);
928 virtual void DrawColLabels( wxDC
& dc
, const wxArrayInt
& cols
);
929 virtual void DrawColLabel( wxDC
& dc
, int col
);
931 virtual void DrawCornerLabel(wxDC
& dc
);
933 // ------ Cell text drawing functions
935 void DrawTextRectangle( wxDC
& dc
, const wxString
&, const wxRect
&,
936 int horizontalAlignment
= wxALIGN_LEFT
,
937 int verticalAlignment
= wxALIGN_TOP
,
938 int textOrientation
= wxHORIZONTAL
);
940 void DrawTextRectangle( wxDC
& dc
, const wxArrayString
& lines
, const wxRect
&,
941 int horizontalAlignment
= wxALIGN_LEFT
,
942 int verticalAlignment
= wxALIGN_TOP
,
943 int textOrientation
= wxHORIZONTAL
);
946 // Split a string containing newline characters into an array of
947 // strings and return the number of lines
949 void StringToLines( const wxString
& value
, wxArrayString
& lines
) const;
951 void GetTextBoxSize( const wxDC
& dc
,
952 const wxArrayString
& lines
,
953 long *width
, long *height
) const;
957 // Code that does a lot of grid modification can be enclosed
958 // between BeginBatch() and EndBatch() calls to avoid screen
961 void BeginBatch() { m_batchCount
++; }
964 int GetBatchCount() { return m_batchCount
; }
966 virtual void Refresh(bool eraseb
= true, const wxRect
* rect
= NULL
);
968 // Use this, rather than wxWindow::Refresh(), to force an
969 // immediate repainting of the grid. Has no effect if you are
970 // already inside a BeginBatch / EndBatch block.
972 // This function is necessary because wxGrid has a minimal OnPaint()
973 // handler to reduce screen flicker.
978 // ------ edit control functions
980 bool IsEditable() const { return m_editable
; }
981 void EnableEditing( bool edit
);
983 void EnableCellEditControl( bool enable
= true );
984 void DisableCellEditControl() { EnableCellEditControl(false); }
985 bool CanEnableCellControl() const;
986 bool IsCellEditControlEnabled() const;
987 bool IsCellEditControlShown() const;
989 bool IsCurrentCellReadOnly() const;
991 void ShowCellEditControl();
992 void HideCellEditControl();
993 void SaveEditControlValue();
996 // ------ grid location functions
997 // Note that all of these functions work with the logical coordinates of
998 // grid cells and labels so you will need to convert from device
999 // coordinates for mouse events etc.
1001 wxGridCellCoords
XYToCell(int x
, int y
) const;
1002 void XYToCell(int x
, int y
, wxGridCellCoords
& coords
) const
1003 { coords
= XYToCell(x
, y
); }
1004 wxGridCellCoords
XYToCell(const wxPoint
& pos
) const
1005 { return XYToCell(pos
.x
, pos
.y
); }
1007 // these functions return the index of the row/columns corresponding to the
1008 // given logical position in pixels
1010 // if clipToMinMax is false (default, wxNOT_FOUND is returned if the
1011 // position is outside any row/column, otherwise the first/last element is
1012 // returned in this case
1013 int YToRow( int y
, bool clipToMinMax
= false ) const;
1014 int XToCol( int x
, bool clipToMinMax
= false ) const;
1016 int YToEdgeOfRow( int y
) const;
1017 int XToEdgeOfCol( int x
) const;
1019 wxRect
CellToRect( int row
, int col
) const;
1020 wxRect
CellToRect( const wxGridCellCoords
& coords
) const
1021 { return CellToRect( coords
.GetRow(), coords
.GetCol() ); }
1023 int GetGridCursorRow() const { return m_currentCellCoords
.GetRow(); }
1024 int GetGridCursorCol() const { return m_currentCellCoords
.GetCol(); }
1026 // check to see if a cell is either wholly visible (the default arg) or
1027 // at least partially visible in the grid window
1029 bool IsVisible( int row
, int col
, bool wholeCellVisible
= true ) const;
1030 bool IsVisible( const wxGridCellCoords
& coords
, bool wholeCellVisible
= true ) const
1031 { return IsVisible( coords
.GetRow(), coords
.GetCol(), wholeCellVisible
); }
1032 void MakeCellVisible( int row
, int col
);
1033 void MakeCellVisible( const wxGridCellCoords
& coords
)
1034 { MakeCellVisible( coords
.GetRow(), coords
.GetCol() ); }
1037 // ------ grid cursor movement functions
1039 void SetGridCursor(int row
, int col
) { SetCurrentCell(row
, col
); }
1040 void SetGridCursor(const wxGridCellCoords
& c
) { SetCurrentCell(c
); }
1042 void GoToCell(int row
, int col
)
1044 if ( SetCurrentCell(row
, col
) )
1045 MakeCellVisible(row
, col
);
1048 void GoToCell(const wxGridCellCoords
& coords
)
1050 if ( SetCurrentCell(coords
) )
1051 MakeCellVisible(coords
);
1054 bool MoveCursorUp( bool expandSelection
);
1055 bool MoveCursorDown( bool expandSelection
);
1056 bool MoveCursorLeft( bool expandSelection
);
1057 bool MoveCursorRight( bool expandSelection
);
1058 bool MovePageDown();
1060 bool MoveCursorUpBlock( bool expandSelection
);
1061 bool MoveCursorDownBlock( bool expandSelection
);
1062 bool MoveCursorLeftBlock( bool expandSelection
);
1063 bool MoveCursorRightBlock( bool expandSelection
);
1066 // ------ label and gridline formatting
1068 int GetDefaultRowLabelSize() const { return WXGRID_DEFAULT_ROW_LABEL_WIDTH
; }
1069 int GetRowLabelSize() const { return m_rowLabelWidth
; }
1070 int GetDefaultColLabelSize() const { return WXGRID_DEFAULT_COL_LABEL_HEIGHT
; }
1071 int GetColLabelSize() const { return m_colLabelHeight
; }
1072 wxColour
GetLabelBackgroundColour() const { return m_labelBackgroundColour
; }
1073 wxColour
GetLabelTextColour() const { return m_labelTextColour
; }
1074 wxFont
GetLabelFont() const { return m_labelFont
; }
1075 void GetRowLabelAlignment( int *horiz
, int *vert
) const;
1076 void GetColLabelAlignment( int *horiz
, int *vert
) const;
1077 int GetColLabelTextOrientation() const;
1078 wxString
GetRowLabelValue( int row
) const;
1079 wxString
GetColLabelValue( int col
) const;
1081 wxColour
GetCellHighlightColour() const { return m_cellHighlightColour
; }
1082 int GetCellHighlightPenWidth() const { return m_cellHighlightPenWidth
; }
1083 int GetCellHighlightROPenWidth() const { return m_cellHighlightROPenWidth
; }
1085 // this one will use wxHeaderCtrl for the column labels
1086 void UseNativeColHeader(bool native
= true);
1088 // this one will still draw them manually but using the native renderer
1089 // instead of using the same appearance as for the row labels
1090 void SetUseNativeColLabels( bool native
= true );
1092 void SetRowLabelSize( int width
);
1093 void SetColLabelSize( int height
);
1094 void HideRowLabels() { SetRowLabelSize( 0 ); }
1095 void HideColLabels() { SetColLabelSize( 0 ); }
1096 void SetLabelBackgroundColour( const wxColour
& );
1097 void SetLabelTextColour( const wxColour
& );
1098 void SetLabelFont( const wxFont
& );
1099 void SetRowLabelAlignment( int horiz
, int vert
);
1100 void SetColLabelAlignment( int horiz
, int vert
);
1101 void SetColLabelTextOrientation( int textOrientation
);
1102 void SetRowLabelValue( int row
, const wxString
& );
1103 void SetColLabelValue( int col
, const wxString
& );
1104 void SetCellHighlightColour( const wxColour
& );
1105 void SetCellHighlightPenWidth(int width
);
1106 void SetCellHighlightROPenWidth(int width
);
1109 // interactive grid mouse operations control
1110 // -----------------------------------------
1112 // functions globally enabling row/column interactive resizing (enabled by
1114 void EnableDragRowSize( bool enable
= true );
1115 void DisableDragRowSize() { EnableDragRowSize( false ); }
1117 void EnableDragColSize( bool enable
= true );
1118 void DisableDragColSize() { EnableDragColSize( false ); }
1120 // if interactive resizing is enabled, some rows/columns can still have
1122 void DisableRowResize(int row
) { DoDisableLineResize(row
, m_setFixedRows
); }
1123 void DisableColResize(int col
) { DoDisableLineResize(col
, m_setFixedCols
); }
1125 // these functions return whether the given row/column can be
1126 // effectively resized: for this interactive resizing must be enabled
1127 // and this index must not have been passed to DisableRow/ColResize()
1128 bool CanDragRowSize(int row
) const
1129 { return m_canDragRowSize
&& DoCanResizeLine(row
, m_setFixedRows
); }
1130 bool CanDragColSize(int col
) const
1131 { return m_canDragColSize
&& DoCanResizeLine(col
, m_setFixedCols
); }
1133 // interactive column reordering (disabled by default)
1134 void EnableDragColMove( bool enable
= true );
1135 void DisableDragColMove() { EnableDragColMove( false ); }
1136 bool CanDragColMove() const { return m_canDragColMove
; }
1138 // interactive resizing of grid cells (enabled by default)
1139 void EnableDragGridSize(bool enable
= true);
1140 void DisableDragGridSize() { EnableDragGridSize(false); }
1141 bool CanDragGridSize() const { return m_canDragGridSize
; }
1143 // interactive dragging of cells (disabled by default)
1144 void EnableDragCell( bool enable
= true );
1145 void DisableDragCell() { EnableDragCell( false ); }
1146 bool CanDragCell() const { return m_canDragCell
; }
1152 // enable or disable drawing of the lines
1153 void EnableGridLines(bool enable
= true);
1154 bool GridLinesEnabled() const { return m_gridLinesEnabled
; }
1156 // by default grid lines stop at last column/row, but this may be changed
1157 void ClipHorzGridLines(bool clip
)
1158 { DoClipGridLines(m_gridLinesClipHorz
, clip
); }
1159 void ClipVertGridLines(bool clip
)
1160 { DoClipGridLines(m_gridLinesClipVert
, clip
); }
1161 bool AreHorzGridLinesClipped() const { return m_gridLinesClipHorz
; }
1162 bool AreVertGridLinesClipped() const { return m_gridLinesClipVert
; }
1164 // this can be used to change the global grid lines colour
1165 void SetGridLineColour(const wxColour
& col
);
1166 wxColour
GetGridLineColour() const { return m_gridLineColour
; }
1168 // these methods may be overridden to customize individual grid lines
1170 virtual wxPen
GetDefaultGridLinePen();
1171 virtual wxPen
GetRowGridLinePen(int row
);
1172 virtual wxPen
GetColGridLinePen(int col
);
1178 // this sets the specified attribute for this cell or in this row/col
1179 void SetAttr(int row
, int col
, wxGridCellAttr
*attr
);
1180 void SetRowAttr(int row
, wxGridCellAttr
*attr
);
1181 void SetColAttr(int col
, wxGridCellAttr
*attr
);
1183 // returns the attribute we may modify in place: a new one if this cell
1184 // doesn't have any yet or the existing one if it does
1186 // DecRef() must be called on the returned pointer, as usual
1187 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
1190 // shortcuts for setting the column parameters
1192 // set the format for the data in the column: default is string
1193 void SetColFormatBool(int col
);
1194 void SetColFormatNumber(int col
);
1195 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
1196 void SetColFormatCustom(int col
, const wxString
& typeName
);
1198 // ------ row and col formatting
1200 int GetDefaultRowSize() const;
1201 int GetRowSize( int row
) const;
1202 bool IsRowShown(int row
) const { return GetRowSize(row
) != 0; }
1203 int GetDefaultColSize() const;
1204 int GetColSize( int col
) const;
1205 bool IsColShown(int col
) const { return GetColSize(col
) != 0; }
1206 wxColour
GetDefaultCellBackgroundColour() const;
1207 wxColour
GetCellBackgroundColour( int row
, int col
) const;
1208 wxColour
GetDefaultCellTextColour() const;
1209 wxColour
GetCellTextColour( int row
, int col
) const;
1210 wxFont
GetDefaultCellFont() const;
1211 wxFont
GetCellFont( int row
, int col
) const;
1212 void GetDefaultCellAlignment( int *horiz
, int *vert
) const;
1213 void GetCellAlignment( int row
, int col
, int *horiz
, int *vert
) const;
1214 bool GetDefaultCellOverflow() const;
1215 bool GetCellOverflow( int row
, int col
) const;
1216 void GetCellSize( int row
, int col
, int *num_rows
, int *num_cols
) const;
1217 wxSize
GetCellSize(const wxGridCellCoords
& coords
)
1220 GetCellSize(coords
.GetRow(), coords
.GetCol(), &s
.x
, &s
.y
);
1224 // ------ row and col sizes
1225 void SetDefaultRowSize( int height
, bool resizeExistingRows
= false );
1226 void SetRowSize( int row
, int height
);
1227 void HideRow(int row
) { SetRowSize(row
, 0); }
1228 void ShowRow(int row
) { SetRowSize(row
, -1); }
1230 void SetDefaultColSize( int width
, bool resizeExistingCols
= false );
1231 void SetColSize( int col
, int width
);
1232 void HideCol(int col
) { SetColSize(col
, 0); }
1233 void ShowCol(int col
) { SetColSize(col
, -1); }
1235 // the row and column sizes can be also set all at once using
1236 // wxGridSizesInfo which holds all of them at once
1238 wxGridSizesInfo
GetColSizes() const
1239 { return wxGridSizesInfo(GetDefaultColSize(), m_colWidths
); }
1240 wxGridSizesInfo
GetRowSizes() const
1241 { return wxGridSizesInfo(GetDefaultRowSize(), m_rowHeights
); }
1243 void SetColSizes(const wxGridSizesInfo
& sizeInfo
);
1244 void SetRowSizes(const wxGridSizesInfo
& sizeInfo
);
1247 // ------- columns (only, for now) reordering
1249 // columns index <-> positions mapping: by default, the position of the
1250 // column is the same as its index, but the columns can also be reordered
1251 // (either by calling SetColPos() explicitly or by the user dragging the
1252 // columns around) in which case their indices don't correspond to their
1253 // positions on display any longer
1255 // internally we always work with indices except for the functions which
1256 // have "Pos" in their names (and which work with columns, not pixels) and
1257 // only the display and hit testing code really cares about display
1260 // set the positions of all columns at once (this method uses the same
1261 // conventions as wxHeaderCtrl::SetColumnsOrder() for the order array)
1262 void SetColumnsOrder(const wxArrayInt
& order
);
1264 // return the column index corresponding to the given (valid) position
1265 int GetColAt(int pos
) const
1267 return m_colAt
.empty() ? pos
: m_colAt
[pos
];
1270 // reorder the columns so that the column with the given index is now shown
1271 // as the position pos
1272 void SetColPos(int idx
, int pos
);
1274 // return the position at which the column with the given index is
1275 // displayed: notice that this is a slow operation as we don't maintain the
1276 // reverse mapping currently
1277 int GetColPos(int idx
) const
1279 if ( m_colAt
.IsEmpty() )
1282 for ( int i
= 0; i
< m_numCols
; i
++ )
1284 if ( m_colAt
[i
] == idx
)
1288 wxFAIL_MSG( "invalid column index" );
1293 // reset the columns positions to the default order
1297 // automatically size the column or row to fit to its contents, if
1298 // setAsMin is true, this optimal width will also be set as minimal width
1300 void AutoSizeColumn( int col
, bool setAsMin
= true )
1301 { AutoSizeColOrRow(col
, setAsMin
, wxGRID_COLUMN
); }
1302 void AutoSizeRow( int row
, bool setAsMin
= true )
1303 { AutoSizeColOrRow(row
, setAsMin
, wxGRID_ROW
); }
1305 // auto size all columns (very ineffective for big grids!)
1306 void AutoSizeColumns( bool setAsMin
= true )
1307 { (void)SetOrCalcColumnSizes(false, setAsMin
); }
1309 void AutoSizeRows( bool setAsMin
= true )
1310 { (void)SetOrCalcRowSizes(false, setAsMin
); }
1312 // auto size the grid, that is make the columns/rows of the "right" size
1313 // and also set the grid size to just fit its contents
1316 // Note for both AutoSizeRowLabelSize and AutoSizeColLabelSize:
1317 // If col equals to wxGRID_AUTOSIZE value then function autosizes labels column
1318 // instead of data column. Note that this operation may be slow for large
1320 // autosize row height depending on label text
1321 void AutoSizeRowLabelSize( int row
);
1323 // autosize column width depending on label text
1324 void AutoSizeColLabelSize( int col
);
1326 // column won't be resized to be lesser width - this must be called during
1327 // the grid creation because it won't resize the column if it's already
1328 // narrower than the minimal width
1329 void SetColMinimalWidth( int col
, int width
);
1330 void SetRowMinimalHeight( int row
, int width
);
1332 /* These members can be used to query and modify the minimal
1333 * acceptable size of grid rows and columns. Call this function in
1334 * your code which creates the grid if you want to display cells
1335 * with a size smaller than the default acceptable minimum size.
1336 * Like the members SetColMinimalWidth and SetRowMinimalWidth,
1337 * the existing rows or columns will not be checked/resized.
1339 void SetColMinimalAcceptableWidth( int width
);
1340 void SetRowMinimalAcceptableHeight( int width
);
1341 int GetColMinimalAcceptableWidth() const;
1342 int GetRowMinimalAcceptableHeight() const;
1344 void SetDefaultCellBackgroundColour( const wxColour
& );
1345 void SetCellBackgroundColour( int row
, int col
, const wxColour
& );
1346 void SetDefaultCellTextColour( const wxColour
& );
1348 void SetCellTextColour( int row
, int col
, const wxColour
& );
1349 void SetDefaultCellFont( const wxFont
& );
1350 void SetCellFont( int row
, int col
, const wxFont
& );
1351 void SetDefaultCellAlignment( int horiz
, int vert
);
1352 void SetCellAlignment( int row
, int col
, int horiz
, int vert
);
1353 void SetDefaultCellOverflow( bool allow
);
1354 void SetCellOverflow( int row
, int col
, bool allow
);
1355 void SetCellSize( int row
, int col
, int num_rows
, int num_cols
);
1357 // takes ownership of the pointer
1358 void SetDefaultRenderer(wxGridCellRenderer
*renderer
);
1359 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
*renderer
);
1360 wxGridCellRenderer
*GetDefaultRenderer() const;
1361 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
1363 // takes ownership of the pointer
1364 void SetDefaultEditor(wxGridCellEditor
*editor
);
1365 void SetCellEditor(int row
, int col
, wxGridCellEditor
*editor
);
1366 wxGridCellEditor
*GetDefaultEditor() const;
1367 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
1371 // ------ cell value accessors
1373 wxString
GetCellValue( int row
, int col
) const
1377 return m_table
->GetValue( row
, col
);
1381 return wxEmptyString
;
1385 wxString
GetCellValue( const wxGridCellCoords
& coords
) const
1386 { return GetCellValue( coords
.GetRow(), coords
.GetCol() ); }
1388 void SetCellValue( int row
, int col
, const wxString
& s
);
1389 void SetCellValue( const wxGridCellCoords
& coords
, const wxString
& s
)
1390 { SetCellValue( coords
.GetRow(), coords
.GetCol(), s
); }
1392 // returns true if the cell can't be edited
1393 bool IsReadOnly(int row
, int col
) const;
1395 // make the cell editable/readonly
1396 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
1398 // ------ select blocks of cells
1400 void SelectRow( int row
, bool addToSelected
= false );
1401 void SelectCol( int col
, bool addToSelected
= false );
1403 void SelectBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
,
1404 bool addToSelected
= false );
1406 void SelectBlock( const wxGridCellCoords
& topLeft
,
1407 const wxGridCellCoords
& bottomRight
,
1408 bool addToSelected
= false )
1409 { SelectBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1410 bottomRight
.GetRow(), bottomRight
.GetCol(),
1415 bool IsSelection() const;
1417 // ------ deselect blocks or cells
1419 void DeselectRow( int row
);
1420 void DeselectCol( int col
);
1421 void DeselectCell( int row
, int col
);
1423 void ClearSelection();
1425 bool IsInSelection( int row
, int col
) const;
1427 bool IsInSelection( const wxGridCellCoords
& coords
) const
1428 { return IsInSelection( coords
.GetRow(), coords
.GetCol() ); }
1430 wxGridCellCoordsArray
GetSelectedCells() const;
1431 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
1432 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
1433 wxArrayInt
GetSelectedRows() const;
1434 wxArrayInt
GetSelectedCols() const;
1436 // This function returns the rectangle that encloses the block of cells
1437 // limited by TopLeft and BottomRight cell in device coords and clipped
1438 // to the client size of the grid window.
1440 wxRect
BlockToDeviceRect( const wxGridCellCoords
& topLeft
,
1441 const wxGridCellCoords
& bottomRight
) const;
1443 // Access or update the selection fore/back colours
1444 wxColour
GetSelectionBackground() const
1445 { return m_selectionBackground
; }
1446 wxColour
GetSelectionForeground() const
1447 { return m_selectionForeground
; }
1449 void SetSelectionBackground(const wxColour
& c
) { m_selectionBackground
= c
; }
1450 void SetSelectionForeground(const wxColour
& c
) { m_selectionForeground
= c
; }
1453 // Methods for a registry for mapping data types to Renderers/Editors
1454 void RegisterDataType(const wxString
& typeName
,
1455 wxGridCellRenderer
* renderer
,
1456 wxGridCellEditor
* editor
);
1458 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1459 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const
1460 { return GetDefaultEditorForCell(c
.GetRow(), c
.GetCol()); }
1461 virtual wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1462 virtual wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1463 virtual wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1465 // grid may occupy more space than needed for its rows/columns, this
1466 // function allows to set how big this extra space is
1467 void SetMargins(int extraWidth
, int extraHeight
)
1469 m_extraWidth
= extraWidth
;
1470 m_extraHeight
= extraHeight
;
1475 // Accessors for component windows
1476 wxWindow
* GetGridWindow() const { return (wxWindow
*)m_gridWin
; }
1477 wxWindow
* GetGridRowLabelWindow() const { return (wxWindow
*)m_rowLabelWin
; }
1478 wxWindow
* GetGridColLabelWindow() const { return m_colWindow
; }
1479 wxWindow
* GetGridCornerLabelWindow() const { return (wxWindow
*)m_cornerLabelWin
; }
1481 // This one can only be called if we are using the native header window
1482 wxHeaderCtrl
*GetGridColHeader() const
1484 wxASSERT_MSG( m_useNativeHeader
, "no column header window" );
1486 // static_cast<> doesn't work without the full class declaration in
1487 // view and we prefer to avoid adding more compile-time dependencies
1488 // even at the cost of using reinterpret_cast<>
1489 return reinterpret_cast<wxHeaderCtrl
*>(m_colWindow
);
1492 // Allow adjustment of scroll increment. The default is (15, 15).
1493 void SetScrollLineX(int x
) { m_scrollLineX
= x
; }
1494 void SetScrollLineY(int y
) { m_scrollLineY
= y
; }
1495 int GetScrollLineX() const { return m_scrollLineX
; }
1496 int GetScrollLineY() const { return m_scrollLineY
; }
1498 // ------- drag and drop
1499 #if wxUSE_DRAG_AND_DROP
1500 virtual void SetDropTarget(wxDropTarget
*dropTarget
);
1501 #endif // wxUSE_DRAG_AND_DROP
1504 // ------- sorting support
1506 // wxGrid doesn't support sorting on its own but it can indicate the sort
1507 // order in the column header (currently only if native header control is
1510 // return the column currently displaying the sort indicator or wxNOT_FOUND
1512 int GetSortingColumn() const { return m_sortCol
; }
1514 // return true if this column is currently used for sorting
1515 bool IsSortingBy(int col
) const { return GetSortingColumn() == col
; }
1517 // return the current sorting order (on GetSortingColumn()): true for
1518 // ascending sort and false for descending; it doesn't make sense to call
1519 // it if GetSortingColumn() returns wxNOT_FOUND
1520 bool IsSortOrderAscending() const { return m_sortIsAscending
; }
1522 // set the sorting column (or unsets any existing one if wxNOT_FOUND) and
1523 // the order in which to sort
1524 void SetSortingColumn(int col
, bool ascending
= true);
1526 // unset any existing sorting column
1527 void UnsetSortingColumn() { SetSortingColumn(wxNOT_FOUND
); }
1529 #ifdef WXWIN_COMPATIBILITY_2_8
1530 // ------ For compatibility with previous wxGrid only...
1532 // ************************************************
1533 // ** Don't use these in new code because they **
1534 // ** are liable to disappear in a future **
1536 // ************************************************
1539 wxGrid( wxWindow
*parent
,
1540 int x
, int y
, int w
= wxDefaultCoord
, int h
= wxDefaultCoord
,
1541 long style
= wxWANTS_CHARS
,
1542 const wxString
& name
= wxPanelNameStr
)
1545 Create(parent
, wxID_ANY
, wxPoint(x
, y
), wxSize(w
, h
), style
, name
);
1548 void SetCellValue( const wxString
& val
, int row
, int col
)
1549 { SetCellValue( row
, col
, val
); }
1551 void UpdateDimensions()
1552 { CalcDimensions(); }
1554 int GetRows() const { return GetNumberRows(); }
1555 int GetCols() const { return GetNumberCols(); }
1556 int GetCursorRow() const { return GetGridCursorRow(); }
1557 int GetCursorColumn() const { return GetGridCursorCol(); }
1559 int GetScrollPosX() const { return 0; }
1560 int GetScrollPosY() const { return 0; }
1562 void SetScrollX( int WXUNUSED(x
) ) { }
1563 void SetScrollY( int WXUNUSED(y
) ) { }
1565 void SetColumnWidth( int col
, int width
)
1566 { SetColSize( col
, width
); }
1568 int GetColumnWidth( int col
) const
1569 { return GetColSize( col
); }
1571 void SetRowHeight( int row
, int height
)
1572 { SetRowSize( row
, height
); }
1574 // GetRowHeight() is below
1576 int GetViewHeight() const // returned num whole rows visible
1579 int GetViewWidth() const // returned num whole cols visible
1582 void SetLabelSize( int orientation
, int sz
)
1584 if ( orientation
== wxHORIZONTAL
)
1585 SetColLabelSize( sz
);
1587 SetRowLabelSize( sz
);
1590 int GetLabelSize( int orientation
) const
1592 if ( orientation
== wxHORIZONTAL
)
1593 return GetColLabelSize();
1595 return GetRowLabelSize();
1598 void SetLabelAlignment( int orientation
, int align
)
1600 if ( orientation
== wxHORIZONTAL
)
1601 SetColLabelAlignment( align
, -1 );
1603 SetRowLabelAlignment( align
, -1 );
1606 int GetLabelAlignment( int orientation
, int WXUNUSED(align
) ) const
1609 if ( orientation
== wxHORIZONTAL
)
1611 GetColLabelAlignment( &h
, &v
);
1616 GetRowLabelAlignment( &h
, &v
);
1621 void SetLabelValue( int orientation
, const wxString
& val
, int pos
)
1623 if ( orientation
== wxHORIZONTAL
)
1624 SetColLabelValue( pos
, val
);
1626 SetRowLabelValue( pos
, val
);
1629 wxString
GetLabelValue( int orientation
, int pos
) const
1631 if ( orientation
== wxHORIZONTAL
)
1632 return GetColLabelValue( pos
);
1634 return GetRowLabelValue( pos
);
1637 wxFont
GetCellTextFont() const
1638 { return m_defaultCellAttr
->GetFont(); }
1640 wxFont
GetCellTextFont(int WXUNUSED(row
), int WXUNUSED(col
)) const
1641 { return m_defaultCellAttr
->GetFont(); }
1643 void SetCellTextFont(const wxFont
& fnt
)
1644 { SetDefaultCellFont( fnt
); }
1646 void SetCellTextFont(const wxFont
& fnt
, int row
, int col
)
1647 { SetCellFont( row
, col
, fnt
); }
1649 void SetCellTextColour(const wxColour
& val
, int row
, int col
)
1650 { SetCellTextColour( row
, col
, val
); }
1652 void SetCellTextColour(const wxColour
& col
)
1653 { SetDefaultCellTextColour( col
); }
1655 void SetCellBackgroundColour(const wxColour
& col
)
1656 { SetDefaultCellBackgroundColour( col
); }
1658 void SetCellBackgroundColour(const wxColour
& colour
, int row
, int col
)
1659 { SetCellBackgroundColour( row
, col
, colour
); }
1661 bool GetEditable() const { return IsEditable(); }
1662 void SetEditable( bool edit
= true ) { EnableEditing( edit
); }
1663 bool GetEditInPlace() const { return IsCellEditControlEnabled(); }
1665 void SetEditInPlace(bool WXUNUSED(edit
) = true) { }
1667 void SetCellAlignment( int align
, int row
, int col
)
1668 { SetCellAlignment(row
, col
, align
, wxALIGN_CENTER
); }
1669 void SetCellAlignment( int WXUNUSED(align
) ) {}
1670 void SetCellBitmap(wxBitmap
*WXUNUSED(bitmap
), int WXUNUSED(row
), int WXUNUSED(col
))
1672 void SetDividerPen(const wxPen
& WXUNUSED(pen
)) { }
1673 wxPen
& GetDividerPen() const;
1674 void OnActivate(bool WXUNUSED(active
)) {}
1676 // ******** End of compatibility functions **********
1680 // ------ control IDs
1681 enum { wxGRID_CELLCTRL
= 2000,
1684 // ------ control types
1685 enum { wxGRID_TEXTCTRL
= 2100,
1690 wxDEPRECATED_INLINE(bool CanDragRowSize() const, return m_canDragRowSize
; )
1691 wxDEPRECATED_INLINE(bool CanDragColSize() const, return m_canDragColSize
; )
1692 #endif // WXWIN_COMPATIBILITY_2_8
1695 // override some base class functions
1696 virtual bool Enable(bool enable
= true);
1697 virtual wxWindow
*GetMainWindowOfCompositeControl()
1698 { return (wxWindow
*)m_gridWin
; }
1701 // implementation only
1702 void CancelMouseCapture();
1705 virtual wxSize
DoGetBestSize() const;
1709 wxGridWindow
*m_gridWin
;
1710 wxGridCornerLabelWindow
*m_cornerLabelWin
;
1711 wxGridRowLabelWindow
*m_rowLabelWin
;
1713 // the real type of the column window depends on m_useNativeHeader value:
1714 // if it is true, its dynamic type is wxHeaderCtrl, otherwise it is
1715 // wxGridColLabelWindow, use accessors below when the real type matters
1716 wxWindow
*m_colWindow
;
1718 wxGridColLabelWindow
*GetColLabelWindow() const
1720 wxASSERT_MSG( !m_useNativeHeader
, "no column label window" );
1722 return reinterpret_cast<wxGridColLabelWindow
*>(m_colWindow
);
1725 wxGridTableBase
*m_table
;
1731 wxGridCellCoords m_currentCellCoords
;
1733 // the corners of the block being currently selected or wxGridNoCellCoords
1734 wxGridCellCoords m_selectedBlockTopLeft
;
1735 wxGridCellCoords m_selectedBlockBottomRight
;
1737 // when selecting blocks of cells (either from the keyboard using Shift
1738 // with cursor keys, or by dragging the mouse), the selection is anchored
1739 // at m_currentCellCoords which defines one of the corners of the rectangle
1740 // being selected -- and this variable defines the other corner, i.e. it's
1741 // either m_selectedBlockTopLeft or m_selectedBlockBottomRight depending on
1742 // which of them is not m_currentCellCoords
1744 // if no block selection is in process, it is set to wxGridNoCellCoords
1745 wxGridCellCoords m_selectedBlockCorner
;
1747 wxGridSelection
*m_selection
;
1749 wxColour m_selectionBackground
;
1750 wxColour m_selectionForeground
;
1752 // NB: *never* access m_row/col arrays directly because they are created
1753 // on demand, *always* use accessor functions instead!
1755 // init the m_rowHeights/Bottoms arrays with default values
1756 void InitRowHeights();
1758 int m_defaultRowHeight
;
1759 int m_minAcceptableRowHeight
;
1760 wxArrayInt m_rowHeights
;
1761 wxArrayInt m_rowBottoms
;
1763 // init the m_colWidths/Rights arrays
1764 void InitColWidths();
1766 int m_defaultColWidth
;
1767 int m_minAcceptableColWidth
;
1768 wxArrayInt m_colWidths
;
1769 wxArrayInt m_colRights
;
1772 bool m_sortIsAscending
;
1774 bool m_useNativeHeader
,
1775 m_nativeColumnLabels
;
1777 // get the col/row coords
1778 int GetColWidth(int col
) const;
1779 int GetColLeft(int col
) const;
1780 int GetColRight(int col
) const;
1782 // this function must be public for compatibility...
1784 int GetRowHeight(int row
) const;
1787 int GetRowTop(int row
) const;
1788 int GetRowBottom(int row
) const;
1790 int m_rowLabelWidth
;
1791 int m_colLabelHeight
;
1793 // the size of the margin left to the right and bottom of the cell area
1797 wxColour m_labelBackgroundColour
;
1798 wxColour m_labelTextColour
;
1801 int m_rowLabelHorizAlign
;
1802 int m_rowLabelVertAlign
;
1803 int m_colLabelHorizAlign
;
1804 int m_colLabelVertAlign
;
1805 int m_colLabelTextOrientation
;
1807 bool m_defaultRowLabelValues
;
1808 bool m_defaultColLabelValues
;
1810 wxColour m_gridLineColour
;
1811 bool m_gridLinesEnabled
;
1812 bool m_gridLinesClipHorz
,
1813 m_gridLinesClipVert
;
1814 wxColour m_cellHighlightColour
;
1815 int m_cellHighlightPenWidth
;
1816 int m_cellHighlightROPenWidth
;
1819 // common part of AutoSizeColumn/Row() and GetBestSize()
1820 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= true);
1821 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= true);
1823 // common part of AutoSizeColumn/Row()
1824 void AutoSizeColOrRow(int n
, bool setAsMin
, wxGridDirection direction
);
1826 // Calculate the minimum acceptable size for labels area
1827 wxCoord
CalcColOrRowLabelAreaMinSize(wxGridDirection direction
);
1829 // if a column has a minimal width, it will be the value for it in this
1831 wxLongToLongHashMap m_colMinWidths
,
1834 // get the minimal width of the given column/row
1835 int GetColMinimalWidth(int col
) const;
1836 int GetRowMinimalHeight(int col
) const;
1838 // do we have some place to store attributes in?
1839 bool CanHaveAttributes() const;
1841 // cell attribute cache (currently we only cache 1, may be will do
1842 // more/better later)
1846 wxGridCellAttr
*attr
;
1849 // invalidates the attribute cache
1850 void ClearAttrCache();
1852 // adds an attribute to cache
1853 void CacheAttr(int row
, int col
, wxGridCellAttr
*attr
) const;
1855 // looks for an attr in cache, returns true if found
1856 bool LookupAttr(int row
, int col
, wxGridCellAttr
**attr
) const;
1858 // looks for the attr in cache, if not found asks the table and caches the
1860 wxGridCellAttr
*GetCellAttr(int row
, int col
) const;
1861 wxGridCellAttr
*GetCellAttr(const wxGridCellCoords
& coords
) const
1862 { return GetCellAttr( coords
.GetRow(), coords
.GetCol() ); }
1864 // the default cell attr object for cells that don't have their own
1865 wxGridCellAttr
* m_defaultCellAttr
;
1872 wxGridTypeRegistry
* m_typeRegistry
;
1876 WXGRID_CURSOR_SELECT_CELL
,
1877 WXGRID_CURSOR_RESIZE_ROW
,
1878 WXGRID_CURSOR_RESIZE_COL
,
1879 WXGRID_CURSOR_SELECT_ROW
,
1880 WXGRID_CURSOR_SELECT_COL
,
1881 WXGRID_CURSOR_MOVE_COL
1884 // this method not only sets m_cursorMode but also sets the correct cursor
1885 // for the given mode and, if captureMouse is not false releases the mouse
1886 // if it was captured and captures it if it must be captured
1888 // for this to work, you should always use it and not set m_cursorMode
1890 void ChangeCursorMode(CursorMode mode
,
1891 wxWindow
*win
= NULL
,
1892 bool captureMouse
= true);
1894 wxWindow
*m_winCapture
; // the window which captured the mouse
1896 // this variable is used not for finding the correct current cursor but
1897 // mainly for finding out what is going to happen if the mouse starts being
1898 // dragged right now
1900 // by default it is WXGRID_CURSOR_SELECT_CELL meaning that nothing else is
1901 // going on, and it is set to one of RESIZE/SELECT/MOVE values while the
1902 // corresponding operation will be started if the user starts dragging the
1903 // mouse from the current position
1904 CursorMode m_cursorMode
;
1910 bool m_canDragRowSize
;
1911 bool m_canDragColSize
;
1912 bool m_canDragColMove
;
1913 bool m_canDragGridSize
;
1916 // the last position (horizontal or vertical depending on whether the user
1917 // is resizing a column or a row) where a row or column separator line was
1918 // dragged by the user or -1 of there is no drag operation in progress
1922 // true if a drag operation is in progress; when this is true,
1923 // m_startDragPos is valid, i.e. not wxDefaultPosition
1926 // the position (in physical coordinates) where the user started dragging
1927 // the mouse or wxDefaultPosition if mouse isn't being dragged
1929 // notice that this can be != wxDefaultPosition while m_isDragging is still
1930 // false because we wait until the mouse is moved some distance away before
1931 // setting m_isDragging to true
1932 wxPoint m_startDragPos
;
1934 bool m_waitForSlowClick
;
1936 wxGridCellCoords m_selectionStart
;
1938 wxCursor m_rowResizeCursor
;
1939 wxCursor m_colResizeCursor
;
1941 bool m_editable
; // applies to whole grid
1942 bool m_cellEditCtrlEnabled
; // is in-place edit currently shown?
1944 int m_scrollLineX
; // X scroll increment
1945 int m_scrollLineY
; // Y scroll increment
1947 void Init(); // common part of all ctors
1949 void CreateColumnWindow();
1950 void CalcDimensions();
1951 void CalcWindowSizes();
1952 bool Redimension( wxGridTableMessage
& );
1955 // generate the appropriate grid event and return -1 if it was vetoed, 1 if
1956 // it was processed (but not vetoed) and 0 if it wasn't processed
1957 int SendEvent(const wxEventType evtType
,
1959 const wxMouseEvent
& e
);
1960 int SendEvent(const wxEventType evtType
,
1961 const wxGridCellCoords
& coords
,
1962 const wxMouseEvent
& e
)
1963 { return SendEvent(evtType
, coords
.GetRow(), coords
.GetCol(), e
); }
1964 int SendEvent(const wxEventType evtType
,
1966 const wxString
& s
= wxString());
1967 int SendEvent(const wxEventType evtType
,
1968 const wxGridCellCoords
& coords
,
1969 const wxString
& s
= wxString())
1970 { return SendEvent(evtType
, coords
.GetRow(), coords
.GetCol(), s
); }
1971 int SendEvent(const wxEventType evtType
, const wxString
& s
= wxString())
1972 { return SendEvent(evtType
, m_currentCellCoords
, s
); }
1974 // send wxEVT_GRID_{ROW,COL}_SIZE
1975 void SendGridSizeEvent(wxEventType type
,
1977 const wxMouseEvent
& mouseEv
);
1979 void OnPaint( wxPaintEvent
& );
1980 void OnSize( wxSizeEvent
& );
1981 void OnKeyDown( wxKeyEvent
& );
1982 void OnKeyUp( wxKeyEvent
& );
1983 void OnChar( wxKeyEvent
& );
1984 void OnEraseBackground( wxEraseEvent
& );
1987 bool SetCurrentCell( const wxGridCellCoords
& coords
);
1988 bool SetCurrentCell( int row
, int col
)
1989 { return SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1992 // this function is called to extend the block being currently selected
1993 // from mouse and keyboard event handlers
1994 void UpdateBlockBeingSelected(int topRow
, int leftCol
,
1995 int bottomRow
, int rightCol
);
1997 void UpdateBlockBeingSelected(const wxGridCellCoords
& topLeft
,
1998 const wxGridCellCoords
& bottomRight
)
1999 { UpdateBlockBeingSelected(topLeft
.GetRow(), topLeft
.GetCol(),
2000 bottomRight
.GetRow(), bottomRight
.GetCol()); }
2002 // ------ functions to get/send data (see also public functions)
2004 bool GetModelValues();
2005 bool SetModelValues();
2007 friend class WXDLLIMPEXP_FWD_ADV wxGridSelection
;
2008 friend class wxGridRowOperations
;
2009 friend class wxGridColumnOperations
;
2011 // they call our private Process{{Corner,Col,Row}Label,GridCell}MouseEvent()
2012 friend class wxGridCornerLabelWindow
;
2013 friend class wxGridColLabelWindow
;
2014 friend class wxGridRowLabelWindow
;
2015 friend class wxGridWindow
;
2017 friend class wxGridHeaderCtrl
;
2020 // implement wxScrolledWindow method to return m_gridWin size
2021 virtual wxSize
GetSizeAvailableForScrollTarget(const wxSize
& size
);
2023 // redraw the grid lines, should be called after changing their attributes
2024 void RedrawGridLines();
2026 // common part of Clip{Horz,Vert}GridLines
2027 void DoClipGridLines(bool& var
, bool clip
);
2029 // update the sorting indicator shown in the specified column (whose index
2032 // this will use GetSortingColumn() and IsSortOrderAscending() to determine
2033 // the sorting indicator to effectively show
2034 void UpdateColumnSortingIndicator(int col
);
2036 // update the grid after changing the columns order (common part of
2037 // SetColPos() and ResetColPos())
2038 void RefreshAfterColPosChange();
2041 // return the position (not index) of the column at the given logical pixel
2044 // this always returns a valid position, even if the coordinate is out of
2045 // bounds (in which case first/last column is returned)
2046 int XToPos(int x
) const;
2049 // event handlers and their helpers
2050 // --------------------------------
2052 // process mouse drag event in WXGRID_CURSOR_SELECT_CELL mode
2053 void DoGridCellDrag(wxMouseEvent
& event
,
2054 const wxGridCellCoords
& coords
,
2057 // process row/column resizing drag event
2058 void DoGridLineDrag(wxMouseEvent
& event
, const wxGridOperations
& oper
);
2060 // process mouse drag event in the grid window
2061 void DoGridDragEvent(wxMouseEvent
& event
, const wxGridCellCoords
& coords
);
2063 // process different clicks on grid cells
2064 void DoGridCellLeftDown(wxMouseEvent
& event
,
2065 const wxGridCellCoords
& coords
,
2066 const wxPoint
& pos
);
2067 void DoGridCellLeftDClick(wxMouseEvent
& event
,
2068 const wxGridCellCoords
& coords
,
2069 const wxPoint
& pos
);
2070 void DoGridCellLeftUp(wxMouseEvent
& event
, const wxGridCellCoords
& coords
);
2072 // process movement (but not dragging) event in the grid cell area
2073 void DoGridMouseMoveEvent(wxMouseEvent
& event
,
2074 const wxGridCellCoords
& coords
,
2075 const wxPoint
& pos
);
2077 // process mouse events in the grid window
2078 void ProcessGridCellMouseEvent(wxMouseEvent
& event
);
2080 // process mouse events in the row/column labels/corner windows
2081 void ProcessRowLabelMouseEvent(wxMouseEvent
& event
);
2082 void ProcessColLabelMouseEvent(wxMouseEvent
& event
);
2083 void ProcessCornerLabelMouseEvent(wxMouseEvent
& event
);
2085 void DoColHeaderClick(int col
);
2087 void DoStartResizeCol(int col
);
2088 void DoUpdateResizeCol(int x
);
2089 void DoUpdateResizeColWidth(int w
);
2090 void DoStartMoveCol(int col
);
2092 void DoEndDragResizeRow(const wxMouseEvent
& event
);
2093 void DoEndDragResizeCol(const wxMouseEvent
& event
);
2094 void DoEndMoveCol(int pos
);
2097 // common implementations of methods defined for both rows and columns
2098 void DeselectLine(int line
, const wxGridOperations
& oper
);
2099 bool DoEndDragResizeLine(const wxGridOperations
& oper
);
2100 int PosToLinePos(int pos
, bool clipToMinMax
,
2101 const wxGridOperations
& oper
) const;
2102 int PosToLine(int pos
, bool clipToMinMax
,
2103 const wxGridOperations
& oper
) const;
2104 int PosToEdgeOfLine(int pos
, const wxGridOperations
& oper
) const;
2106 bool DoMoveCursor(bool expandSelection
,
2107 const wxGridDirectionOperations
& diroper
);
2108 bool DoMoveCursorByPage(const wxGridDirectionOperations
& diroper
);
2109 bool DoMoveCursorByBlock(bool expandSelection
,
2110 const wxGridDirectionOperations
& diroper
);
2111 void AdvanceToNextNonEmpty(wxGridCellCoords
& coords
,
2112 const wxGridDirectionOperations
& diroper
);
2114 // common part of {Insert,Delete}{Rows,Cols}
2115 bool DoModifyLines(bool (wxGridTableBase::*funcModify
)(size_t, size_t),
2116 int pos
, int num
, bool updateLabels
);
2117 // Append{Rows,Cols} is a bit different because of one less parameter
2118 bool DoAppendLines(bool (wxGridTableBase::*funcAppend
)(size_t),
2119 int num
, bool updateLabels
);
2121 // common part of Set{Col,Row}Sizes
2122 void DoSetSizes(const wxGridSizesInfo
& sizeInfo
,
2123 const wxGridOperations
& oper
);
2125 // common part of Disable{Row,Col}Resize and CanDrag{Row,Col}Size
2126 void DoDisableLineResize(int line
, wxGridFixedIndicesSet
*& setFixed
);
2127 bool DoCanResizeLine(int line
, const wxGridFixedIndicesSet
*setFixed
) const;
2131 // these sets contain the indices of fixed, i.e. non-resizable
2132 // interactively, grid rows or columns and are NULL if there are no fixed
2133 // elements (which is the default)
2134 wxGridFixedIndicesSet
*m_setFixedRows
,
2137 DECLARE_DYNAMIC_CLASS( wxGrid
)
2138 DECLARE_EVENT_TABLE()
2139 wxDECLARE_NO_COPY_CLASS(wxGrid
);
2142 // ----------------------------------------------------------------------------
2143 // wxGridUpdateLocker prevents updates to a grid during its lifetime
2144 // ----------------------------------------------------------------------------
2146 class WXDLLIMPEXP_ADV wxGridUpdateLocker
2149 // if the pointer is NULL, Create() can be called later
2150 wxGridUpdateLocker(wxGrid
*grid
= NULL
)
2155 // can be called if ctor was used with a NULL pointer, must not be called
2157 void Create(wxGrid
*grid
)
2159 wxASSERT_MSG( !m_grid
, _T("shouldn't be called more than once") );
2164 ~wxGridUpdateLocker()
2171 void Init(wxGrid
*grid
)
2175 m_grid
->BeginBatch();
2180 wxDECLARE_NO_COPY_CLASS(wxGridUpdateLocker
);
2183 // ----------------------------------------------------------------------------
2184 // Grid event class and event types
2185 // ----------------------------------------------------------------------------
2187 class WXDLLIMPEXP_ADV wxGridEvent
: public wxNotifyEvent
,
2188 public wxKeyboardState
2194 Init(-1, -1, -1, -1, false);
2200 int row
= -1, int col
= -1,
2201 int x
= -1, int y
= -1,
2203 const wxKeyboardState
& kbd
= wxKeyboardState())
2204 : wxNotifyEvent(type
, id
),
2205 wxKeyboardState(kbd
)
2207 Init(row
, col
, x
, y
, sel
);
2208 SetEventObject(obj
);
2211 // explicitly specifying inline allows gcc < 3.4 to
2212 // handle the deprecation attribute even in the constructor.
2213 wxDEPRECATED_CONSTRUCTOR(
2221 bool shift
= false, bool alt
= false, bool meta
= false));
2223 virtual int GetRow() { return m_row
; }
2224 virtual int GetCol() { return m_col
; }
2225 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
2226 bool Selecting() { return m_selecting
; }
2228 virtual wxEvent
*Clone() const { return new wxGridEvent(*this); }
2238 void Init(int row
, int col
, int x
, int y
, bool sel
)
2247 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEvent
)
2250 class WXDLLIMPEXP_ADV wxGridSizeEvent
: public wxNotifyEvent
,
2251 public wxKeyboardState
2260 wxGridSizeEvent(int id
,
2264 int x
= -1, int y
= -1,
2265 const wxKeyboardState
& kbd
= wxKeyboardState())
2266 : wxNotifyEvent(type
, id
),
2267 wxKeyboardState(kbd
)
2269 Init(rowOrCol
, x
, y
);
2271 SetEventObject(obj
);
2274 wxDEPRECATED_CONSTRUCTOR(
2275 wxGridSizeEvent(int id
,
2283 bool meta
= false) );
2285 int GetRowOrCol() { return m_rowOrCol
; }
2286 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
2288 virtual wxEvent
*Clone() const { return new wxGridSizeEvent(*this); }
2296 void Init(int rowOrCol
, int x
, int y
)
2298 m_rowOrCol
= rowOrCol
;
2303 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridSizeEvent
)
2307 class WXDLLIMPEXP_ADV wxGridRangeSelectEvent
: public wxNotifyEvent
,
2308 public wxKeyboardState
2311 wxGridRangeSelectEvent()
2314 Init(wxGridNoCellCoords
, wxGridNoCellCoords
, false);
2317 wxGridRangeSelectEvent(int id
,
2320 const wxGridCellCoords
& topLeft
,
2321 const wxGridCellCoords
& bottomRight
,
2323 const wxKeyboardState
& kbd
= wxKeyboardState())
2324 : wxNotifyEvent(type
, id
),
2325 wxKeyboardState(kbd
)
2327 Init(topLeft
, bottomRight
, sel
);
2329 SetEventObject(obj
);
2332 wxDEPRECATED_CONSTRUCTOR(
2333 wxGridRangeSelectEvent(int id
,
2336 const wxGridCellCoords
& topLeft
,
2337 const wxGridCellCoords
& bottomRight
,
2342 bool meta
= false) );
2344 wxGridCellCoords
GetTopLeftCoords() { return m_topLeft
; }
2345 wxGridCellCoords
GetBottomRightCoords() { return m_bottomRight
; }
2346 int GetTopRow() { return m_topLeft
.GetRow(); }
2347 int GetBottomRow() { return m_bottomRight
.GetRow(); }
2348 int GetLeftCol() { return m_topLeft
.GetCol(); }
2349 int GetRightCol() { return m_bottomRight
.GetCol(); }
2350 bool Selecting() { return m_selecting
; }
2352 virtual wxEvent
*Clone() const { return new wxGridRangeSelectEvent(*this); }
2355 void Init(const wxGridCellCoords
& topLeft
,
2356 const wxGridCellCoords
& bottomRight
,
2359 m_topLeft
= topLeft
;
2360 m_bottomRight
= bottomRight
;
2361 m_selecting
= selecting
;
2364 wxGridCellCoords m_topLeft
;
2365 wxGridCellCoords m_bottomRight
;
2368 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridRangeSelectEvent
)
2372 class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent
: public wxCommandEvent
2375 wxGridEditorCreatedEvent()
2383 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
2384 int row
, int col
, wxControl
* ctrl
);
2386 int GetRow() { return m_row
; }
2387 int GetCol() { return m_col
; }
2388 wxControl
* GetControl() { return m_ctrl
; }
2389 void SetRow(int row
) { m_row
= row
; }
2390 void SetCol(int col
) { m_col
= col
; }
2391 void SetControl(wxControl
* ctrl
) { m_ctrl
= ctrl
; }
2393 virtual wxEvent
*Clone() const { return new wxGridEditorCreatedEvent(*this); }
2400 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEditorCreatedEvent
)
2404 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_LEFT_CLICK
, wxGridEvent
);
2405 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_RIGHT_CLICK
, wxGridEvent
);
2406 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_LEFT_DCLICK
, wxGridEvent
);
2407 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_RIGHT_DCLICK
, wxGridEvent
);
2408 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_LEFT_CLICK
, wxGridEvent
);
2409 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_RIGHT_CLICK
, wxGridEvent
);
2410 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_LEFT_DCLICK
, wxGridEvent
);
2411 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_RIGHT_DCLICK
, wxGridEvent
);
2412 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_ROW_SIZE
, wxGridSizeEvent
);
2413 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_COL_SIZE
, wxGridSizeEvent
);
2414 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_RANGE_SELECT
, wxGridRangeSelectEvent
);
2415 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_CHANGING
, wxGridEvent
);
2416 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_CHANGED
, wxGridEvent
);
2417 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_SELECT_CELL
, wxGridEvent
);
2418 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_EDITOR_SHOWN
, wxGridEvent
);
2419 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_EDITOR_HIDDEN
, wxGridEvent
);
2420 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_EDITOR_CREATED
, wxGridEditorCreatedEvent
);
2421 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_BEGIN_DRAG
, wxGridEvent
);
2422 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_COL_MOVE
, wxGridEvent
);
2423 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_COL_SORT
, wxGridEvent
);
2425 typedef void (wxEvtHandler::*wxGridEventFunction
)(wxGridEvent
&);
2426 typedef void (wxEvtHandler::*wxGridSizeEventFunction
)(wxGridSizeEvent
&);
2427 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction
)(wxGridRangeSelectEvent
&);
2428 typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction
)(wxGridEditorCreatedEvent
&);
2430 #define wxGridEventHandler(func) \
2431 wxEVENT_HANDLER_CAST(wxGridEventFunction, func)
2433 #define wxGridSizeEventHandler(func) \
2434 wxEVENT_HANDLER_CAST(wxGridSizeEventFunction, func)
2436 #define wxGridRangeSelectEventHandler(func) \
2437 wxEVENT_HANDLER_CAST(wxGridRangeSelectEventFunction, func)
2439 #define wxGridEditorCreatedEventHandler(func) \
2440 wxEVENT_HANDLER_CAST(wxGridEditorCreatedEventFunction, func)
2442 #define wx__DECLARE_GRIDEVT(evt, id, fn) \
2443 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEventHandler(fn))
2445 #define wx__DECLARE_GRIDSIZEEVT(evt, id, fn) \
2446 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridSizeEventHandler(fn))
2448 #define wx__DECLARE_GRIDRANGESELEVT(evt, id, fn) \
2449 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridRangeSelectEventHandler(fn))
2451 #define wx__DECLARE_GRIDEDITOREVT(evt, id, fn) \
2452 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEditorCreatedEventHandler(fn))
2454 #define EVT_GRID_CMD_CELL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_CLICK, id, fn)
2455 #define EVT_GRID_CMD_CELL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_CLICK, id, fn)
2456 #define EVT_GRID_CMD_CELL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_DCLICK, id, fn)
2457 #define EVT_GRID_CMD_CELL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_DCLICK, id, fn)
2458 #define EVT_GRID_CMD_LABEL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_CLICK, id, fn)
2459 #define EVT_GRID_CMD_LABEL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_CLICK, id, fn)
2460 #define EVT_GRID_CMD_LABEL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_DCLICK, id, fn)
2461 #define EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_DCLICK, id, fn)
2462 #define EVT_GRID_CMD_ROW_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(ROW_SIZE, id, fn)
2463 #define EVT_GRID_CMD_COL_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_SIZE, id, fn)
2464 #define EVT_GRID_CMD_COL_MOVE(id, fn) wx__DECLARE_GRIDEVT(COL_MOVE, id, fn)
2465 #define EVT_GRID_CMD_COL_SORT(id, fn) wx__DECLARE_GRIDEVT(COL_SORT, id, fn)
2466 #define EVT_GRID_CMD_RANGE_SELECT(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECT, id, fn)
2467 #define EVT_GRID_CMD_CELL_CHANGING(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGING, id, fn)
2468 #define EVT_GRID_CMD_CELL_CHANGED(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGED, id, fn)
2469 #define EVT_GRID_CMD_SELECT_CELL(id, fn) wx__DECLARE_GRIDEVT(SELECT_CELL, id, fn)
2470 #define EVT_GRID_CMD_EDITOR_SHOWN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_SHOWN, id, fn)
2471 #define EVT_GRID_CMD_EDITOR_HIDDEN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_HIDDEN, id, fn)
2472 #define EVT_GRID_CMD_EDITOR_CREATED(id, fn) wx__DECLARE_GRIDEDITOREVT(EDITOR_CREATED, id, fn)
2473 #define EVT_GRID_CMD_CELL_BEGIN_DRAG(id, fn) wx__DECLARE_GRIDEVT(CELL_BEGIN_DRAG, id, fn)
2475 // same as above but for any id (exists mainly for backwards compatibility but
2476 // then it's also true that you rarely have multiple grid in the same window)
2477 #define EVT_GRID_CELL_LEFT_CLICK(fn) EVT_GRID_CMD_CELL_LEFT_CLICK(wxID_ANY, fn)
2478 #define EVT_GRID_CELL_RIGHT_CLICK(fn) EVT_GRID_CMD_CELL_RIGHT_CLICK(wxID_ANY, fn)
2479 #define EVT_GRID_CELL_LEFT_DCLICK(fn) EVT_GRID_CMD_CELL_LEFT_DCLICK(wxID_ANY, fn)
2480 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) EVT_GRID_CMD_CELL_RIGHT_DCLICK(wxID_ANY, fn)
2481 #define EVT_GRID_LABEL_LEFT_CLICK(fn) EVT_GRID_CMD_LABEL_LEFT_CLICK(wxID_ANY, fn)
2482 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_CLICK(wxID_ANY, fn)
2483 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) EVT_GRID_CMD_LABEL_LEFT_DCLICK(wxID_ANY, fn)
2484 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_DCLICK(wxID_ANY, fn)
2485 #define EVT_GRID_ROW_SIZE(fn) EVT_GRID_CMD_ROW_SIZE(wxID_ANY, fn)
2486 #define EVT_GRID_COL_SIZE(fn) EVT_GRID_CMD_COL_SIZE(wxID_ANY, fn)
2487 #define EVT_GRID_COL_MOVE(fn) EVT_GRID_CMD_COL_MOVE(wxID_ANY, fn)
2488 #define EVT_GRID_COL_SORT(fn) EVT_GRID_CMD_COL_SORT(wxID_ANY, fn)
2489 #define EVT_GRID_RANGE_SELECT(fn) EVT_GRID_CMD_RANGE_SELECT(wxID_ANY, fn)
2490 #define EVT_GRID_CELL_CHANGING(fn) EVT_GRID_CMD_CELL_CHANGING(wxID_ANY, fn)
2491 #define EVT_GRID_CELL_CHANGED(fn) EVT_GRID_CMD_CELL_CHANGED(wxID_ANY, fn)
2492 #define EVT_GRID_SELECT_CELL(fn) EVT_GRID_CMD_SELECT_CELL(wxID_ANY, fn)
2493 #define EVT_GRID_EDITOR_SHOWN(fn) EVT_GRID_CMD_EDITOR_SHOWN(wxID_ANY, fn)
2494 #define EVT_GRID_EDITOR_HIDDEN(fn) EVT_GRID_CMD_EDITOR_HIDDEN(wxID_ANY, fn)
2495 #define EVT_GRID_EDITOR_CREATED(fn) EVT_GRID_CMD_EDITOR_CREATED(wxID_ANY, fn)
2496 #define EVT_GRID_CELL_BEGIN_DRAG(fn) EVT_GRID_CMD_CELL_BEGIN_DRAG(wxID_ANY, fn)
2498 // we used to have a single wxEVT_GRID_CELL_CHANGE event but it was split into
2499 // wxEVT_GRID_CELL_CHANGING and CHANGED ones in wx 2.9.0, however the CHANGED
2500 // is basically the same as the old CHANGE event so we keep the name for
2502 #if WXWIN_COMPATIBILITY_2_8
2503 #define wxEVT_GRID_CELL_CHANGE wxEVT_GRID_CELL_CHANGED
2505 #define EVT_GRID_CMD_CELL_CHANGE EVT_GRID_CMD_CELL_CHANGED
2506 #define EVT_GRID_CELL_CHANGE EVT_GRID_CELL_CHANGED
2507 #endif // WXWIN_COMPATIBILITY_2_8
2509 #if 0 // TODO: implement these ? others ?
2511 extern const int wxEVT_GRID_CREATE_CELL
;
2512 extern const int wxEVT_GRID_CHANGE_LABELS
;
2513 extern const int wxEVT_GRID_CHANGE_SEL_LABEL
;
2515 #define EVT_GRID_CREATE_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2516 #define EVT_GRID_CHANGE_LABELS(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2517 #define EVT_GRID_CHANGE_SEL_LABEL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_SEL_LABEL, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2521 #endif // wxUSE_GRID
2522 #endif // _WX_GENERIC_GRID_H_