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 wxT("string")
48 #define wxGRID_VALUE_BOOL wxT("bool")
49 #define wxGRID_VALUE_NUMBER wxT("long")
50 #define wxGRID_VALUE_FLOAT wxT("double")
51 #define wxGRID_VALUE_CHOICE wxT("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
, public wxRefCounter
116 wxGridCellWorker() { }
118 // interpret renderer parameters: arbitrary string whose interpretatin is
119 // left to the derived classes
120 virtual void SetParameters(const wxString
& params
);
123 // virtual dtor for any base class - private because only DecRef() can
125 virtual ~wxGridCellWorker();
128 // suppress the stupid gcc warning about the class having private dtor and
130 friend class wxGridCellWorkerDummyFriend
;
133 // ----------------------------------------------------------------------------
134 // wxGridCellRenderer: this class is responsible for actually drawing the cell
135 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
136 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
137 // view of all cells. This is an ABC, you will normally use one of the
138 // predefined derived classes or derive your own class from it.
139 // ----------------------------------------------------------------------------
141 class WXDLLIMPEXP_ADV wxGridCellRenderer
: public wxGridCellWorker
144 // draw the given cell on the provided DC inside the given rectangle
145 // using the style specified by the attribute and the default or selected
146 // state corresponding to the isSelected value.
148 // this pure virtual function has a default implementation which will
149 // prepare the DC using the given attribute: it will draw the rectangle
150 // with the bg colour from attr and set the text colour and font
151 virtual void Draw(wxGrid
& grid
,
152 wxGridCellAttr
& attr
,
156 bool isSelected
) = 0;
158 // get the preferred size of the cell for its contents
159 virtual wxSize
GetBestSize(wxGrid
& grid
,
160 wxGridCellAttr
& attr
,
162 int row
, int col
) = 0;
164 // create a new object which is the copy of this one
165 virtual wxGridCellRenderer
*Clone() const = 0;
168 // ----------------------------------------------------------------------------
169 // wxGridCellEditor: This class is responsible for providing and manipulating
170 // the in-place edit controls for the grid. Instances of wxGridCellEditor
171 // (actually, instances of derived classes since it is an ABC) can be
172 // associated with the cell attributes for individual cells, rows, columns, or
173 // even for the entire grid.
174 // ----------------------------------------------------------------------------
176 class WXDLLIMPEXP_ADV wxGridCellEditor
: public wxGridCellWorker
181 bool IsCreated() { return m_control
!= NULL
; }
182 wxControl
* GetControl() { return m_control
; }
183 void SetControl(wxControl
* control
) { m_control
= control
; }
185 wxGridCellAttr
* GetCellAttr() { return m_attr
; }
186 void SetCellAttr(wxGridCellAttr
* attr
) { m_attr
= attr
; }
188 // Creates the actual edit control
189 virtual void Create(wxWindow
* parent
,
191 wxEvtHandler
* evtHandler
) = 0;
193 // Size and position the edit control
194 virtual void SetSize(const wxRect
& rect
);
196 // Show or hide the edit control, use the specified attributes to set
197 // colours/fonts for it
198 virtual void Show(bool show
, wxGridCellAttr
*attr
= NULL
);
200 // Draws the part of the cell not occupied by the control: the base class
201 // version just fills it with background colour from the attribute
202 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
205 // The methods called by wxGrid when a cell is edited: first BeginEdit() is
206 // called, then EndEdit() is and if it returns true and if the change is
207 // not vetoed by a user-defined event handler, finally ApplyEdit() is called
209 // Fetch the value from the table and prepare the edit control
210 // to begin editing. Set the focus to the edit control.
211 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
213 // Returns false if nothing changed, otherwise returns true and return the
214 // new value in its string form in the newval output parameter.
216 // This should also store the new value in its real type internally so that
217 // it could be used by ApplyEdit() but it must not modify the grid as the
218 // change could still be vetoed.
219 virtual bool EndEdit(int row
, int col
, const wxGrid
*grid
,
220 const wxString
& oldval
, wxString
*newval
) = 0;
222 // Complete the editing of the current cell by storing the value saved by
223 // the previous call to EndEdit() in the grid
224 virtual void ApplyEdit(int row
, int col
, wxGrid
* grid
) = 0;
227 // Reset the value in the control back to its starting value
228 virtual void Reset() = 0;
230 // return true to allow the given key to start editing: the base class
231 // version only checks that the event has no modifiers. The derived
232 // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in
233 // their IsAcceptedKey() implementation, although, of course, it is not a
234 // mandatory requirment.
236 // NB: if the key is F2 (special), editing will always start and this
237 // method will not be called at all (but StartingKey() will)
238 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
240 // If the editor is enabled by pressing keys on the grid, this will be
241 // called to let the editor do something about that first key if desired
242 virtual void StartingKey(wxKeyEvent
& event
);
244 // if the editor is enabled by clicking on the cell, this method will be
246 virtual void StartingClick();
248 // Some types of controls on some platforms may need some help
249 // with the Return key.
250 virtual void HandleReturn(wxKeyEvent
& event
);
253 virtual void Destroy();
255 // create a new object which is the copy of this one
256 virtual wxGridCellEditor
*Clone() const = 0;
258 // added GetValue so we can get the value which is in the control
259 virtual wxString
GetValue() const = 0;
262 // the dtor is private because only DecRef() can delete us
263 virtual ~wxGridCellEditor();
265 // the control we show on screen
266 wxControl
* m_control
;
268 // a temporary pointer to the attribute being edited
269 wxGridCellAttr
* m_attr
;
271 // if we change the colours/font of the control from the default ones, we
272 // must restore the default later and we save them here between calls to
273 // Show(true) and Show(false)
278 // suppress the stupid gcc warning about the class having private dtor and
280 friend class wxGridCellEditorDummyFriend
;
282 wxDECLARE_NO_COPY_CLASS(wxGridCellEditor
);
285 // ----------------------------------------------------------------------------
286 // wxGridHeaderRenderer and company: like wxGridCellRenderer but for headers
287 // ----------------------------------------------------------------------------
289 // Base class for corner window renderer: it is the simplest of all renderers
290 // and only has a single function
291 class WXDLLIMPEXP_ADV wxGridCornerHeaderRenderer
294 // Draw the border around the corner window.
295 virtual void DrawBorder(const wxGrid
& grid
,
297 wxRect
& rect
) const = 0;
301 // Base class for the row/column header cells renderers
302 class WXDLLIMPEXP_ADV wxGridHeaderLabelsRenderer
303 : public wxGridCornerHeaderRenderer
306 // Draw header cell label
307 virtual void DrawLabel(const wxGrid
& grid
,
309 const wxString
& value
,
313 int textOrientation
) const;
316 // Currently the row/column/corner renders don't need any methods other than
317 // those already in wxGridHeaderLabelsRenderer but still define separate classes
318 // for them for future extensions and also for better type safety (i.e. to
319 // avoid inadvertently using a column header renderer for the row headers)
320 class WXDLLIMPEXP_ADV wxGridRowHeaderRenderer
321 : public wxGridHeaderLabelsRenderer
325 class WXDLLIMPEXP_ADV wxGridColumnHeaderRenderer
326 : public wxGridHeaderLabelsRenderer
330 // Also define the default renderers which are used by wxGridCellAttrProvider
332 class WXDLLIMPEXP_ADV wxGridRowHeaderRendererDefault
333 : public wxGridRowHeaderRenderer
336 virtual void DrawBorder(const wxGrid
& grid
,
341 // Column header cells renderers
342 class WXDLLIMPEXP_ADV wxGridColumnHeaderRendererDefault
343 : public wxGridColumnHeaderRenderer
346 virtual void DrawBorder(const wxGrid
& grid
,
351 // Header corner renderer
352 class WXDLLIMPEXP_ADV wxGridCornerHeaderRendererDefault
353 : public wxGridCornerHeaderRenderer
356 virtual void DrawBorder(const wxGrid
& grid
,
362 // ----------------------------------------------------------------------------
363 // wxGridCellAttr: this class can be used to alter the cells appearance in
364 // the grid by changing their colour/font/... from default. An object of this
365 // class may be returned by wxGridTable::GetAttr().
366 // ----------------------------------------------------------------------------
368 class WXDLLIMPEXP_ADV wxGridCellAttr
: public wxClientDataContainer
, public wxRefCounter
382 wxGridCellAttr(wxGridCellAttr
*attrDefault
= NULL
)
386 // MB: args used to be 0,0 here but wxALIGN_LEFT is 0
387 SetAlignment(-1, -1);
390 // VZ: considering the number of members wxGridCellAttr has now, this ctor
391 // seems to be pretty useless... may be we should just remove it?
392 wxGridCellAttr(const wxColour
& colText
,
393 const wxColour
& colBack
,
397 : m_colText(colText
), m_colBack(colBack
), m_font(font
)
400 SetAlignment(hAlign
, vAlign
);
403 // creates a new copy of this object
404 wxGridCellAttr
*Clone() const;
405 void MergeWith(wxGridCellAttr
*mergefrom
);
408 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
409 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
410 void SetFont(const wxFont
& font
) { m_font
= font
; }
411 void SetAlignment(int hAlign
, int vAlign
)
416 void SetSize(int num_rows
, int num_cols
);
417 void SetOverflow(bool allow
= true)
418 { m_overflow
= allow
? Overflow
: SingleCell
; }
419 void SetReadOnly(bool isReadOnly
= true)
420 { m_isReadOnly
= isReadOnly
? ReadOnly
: ReadWrite
; }
422 // takes ownership of the pointer
423 void SetRenderer(wxGridCellRenderer
*renderer
)
424 { wxSafeDecRef(m_renderer
); m_renderer
= renderer
; }
425 void SetEditor(wxGridCellEditor
* editor
)
426 { wxSafeDecRef(m_editor
); m_editor
= editor
; }
428 void SetKind(wxAttrKind kind
) { m_attrkind
= kind
; }
431 bool HasTextColour() const { return m_colText
.Ok(); }
432 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
433 bool HasFont() const { return m_font
.Ok(); }
434 bool HasAlignment() const { return (m_hAlign
!= -1 || m_vAlign
!= -1); }
435 bool HasRenderer() const { return m_renderer
!= NULL
; }
436 bool HasEditor() const { return m_editor
!= NULL
; }
437 bool HasReadWriteMode() const { return m_isReadOnly
!= Unset
; }
438 bool HasOverflowMode() const { return m_overflow
!= UnsetOverflow
; }
439 bool HasSize() const { return m_sizeRows
!= 1 || m_sizeCols
!= 1; }
441 const wxColour
& GetTextColour() const;
442 const wxColour
& GetBackgroundColour() const;
443 const wxFont
& GetFont() const;
444 void GetAlignment(int *hAlign
, int *vAlign
) const;
445 void GetSize(int *num_rows
, int *num_cols
) const;
446 bool GetOverflow() const
447 { return m_overflow
!= SingleCell
; }
448 wxGridCellRenderer
*GetRenderer(const wxGrid
* grid
, int row
, int col
) const;
449 wxGridCellEditor
*GetEditor(const wxGrid
* grid
, int row
, int col
) const;
451 bool IsReadOnly() const { return m_isReadOnly
== wxGridCellAttr::ReadOnly
; }
453 wxAttrKind
GetKind() { return m_attrkind
; }
455 void SetDefAttr(wxGridCellAttr
* defAttr
) { m_defGridAttr
= defAttr
; }
458 // the dtor is private because only DecRef() can delete us
459 virtual ~wxGridCellAttr()
461 wxSafeDecRef(m_renderer
);
462 wxSafeDecRef(m_editor
);
473 enum wxAttrOverflowMode
480 // the common part of all ctors
481 void Init(wxGridCellAttr
*attrDefault
= NULL
);
492 wxAttrOverflowMode m_overflow
;
494 wxGridCellRenderer
* m_renderer
;
495 wxGridCellEditor
* m_editor
;
496 wxGridCellAttr
* m_defGridAttr
;
498 wxAttrReadMode m_isReadOnly
;
500 wxAttrKind m_attrkind
;
502 // use Clone() instead
503 wxDECLARE_NO_COPY_CLASS(wxGridCellAttr
);
505 // suppress the stupid gcc warning about the class having private dtor and
507 friend class wxGridCellAttrDummyFriend
;
510 // ----------------------------------------------------------------------------
511 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
513 // ----------------------------------------------------------------------------
515 // implementation note: we separate it from wxGridTableBase because we wish to
516 // avoid deriving a new table class if possible, and sometimes it will be
517 // enough to just derive another wxGridCellAttrProvider instead
519 // the default implementation is reasonably efficient for the generic case,
520 // but you might still wish to implement your own for some specific situations
521 // if you have performance problems with the stock one
522 class WXDLLIMPEXP_ADV wxGridCellAttrProvider
: public wxClientDataContainer
525 wxGridCellAttrProvider();
526 virtual ~wxGridCellAttrProvider();
528 // DecRef() must be called on the returned pointer
529 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
530 wxGridCellAttr::wxAttrKind kind
) const;
532 // all these functions take ownership of the pointer, don't call DecRef()
534 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
535 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
536 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
538 // these functions must be called whenever some rows/cols are deleted
539 // because the internal data must be updated then
540 void UpdateAttrRows( size_t pos
, int numRows
);
541 void UpdateAttrCols( size_t pos
, int numCols
);
544 // get renderers for the given row/column header label and the corner
545 // window: unlike cell renderers, these objects are not reference counted
546 // and are never NULL so they are returned by reference
547 virtual const wxGridColumnHeaderRenderer
&
548 GetColumnHeaderRenderer(int WXUNUSED(col
))
550 return m_defaultHeaderRenderers
.colRenderer
;
553 virtual const wxGridRowHeaderRenderer
&
554 GetRowHeaderRenderer(int WXUNUSED(row
))
556 return m_defaultHeaderRenderers
.rowRenderer
;
559 virtual const wxGridCornerHeaderRenderer
& GetCornerRenderer()
561 return m_defaultHeaderRenderers
.cornerRenderer
;
567 wxGridCellAttrProviderData
*m_data
;
569 // this struct simply combines together the default header renderers
572 wxGridColumnHeaderRendererDefault colRenderer
;
573 wxGridRowHeaderRendererDefault rowRenderer
;
574 wxGridCornerHeaderRendererDefault cornerRenderer
;
575 } m_defaultHeaderRenderers
;
577 wxDECLARE_NO_COPY_CLASS(wxGridCellAttrProvider
);
580 // ----------------------------------------------------------------------------
581 // wxGridCellCoords: location of a cell in the grid
582 // ----------------------------------------------------------------------------
584 class WXDLLIMPEXP_ADV wxGridCellCoords
587 wxGridCellCoords() { m_row
= m_col
= -1; }
588 wxGridCellCoords( int r
, int c
) { m_row
= r
; m_col
= c
; }
590 // default copy ctor is ok
592 int GetRow() const { return m_row
; }
593 void SetRow( int n
) { m_row
= n
; }
594 int GetCol() const { return m_col
; }
595 void SetCol( int n
) { m_col
= n
; }
596 void Set( int row
, int col
) { m_row
= row
; m_col
= col
; }
598 wxGridCellCoords
& operator=( const wxGridCellCoords
& other
)
600 if ( &other
!= this )
608 bool operator==( const wxGridCellCoords
& other
) const
610 return (m_row
== other
.m_row
&& m_col
== other
.m_col
);
613 bool operator!=( const wxGridCellCoords
& other
) const
615 return (m_row
!= other
.m_row
|| m_col
!= other
.m_col
);
618 bool operator!() const
620 return (m_row
== -1 && m_col
== -1 );
629 // For comparisons...
631 extern WXDLLIMPEXP_ADV wxGridCellCoords wxGridNoCellCoords
;
632 extern WXDLLIMPEXP_ADV wxRect wxGridNoCellRect
;
634 // An array of cell coords...
636 WX_DECLARE_OBJARRAY_WITH_DECL(wxGridCellCoords
, wxGridCellCoordsArray
,
637 class WXDLLIMPEXP_ADV
);
639 // ----------------------------------------------------------------------------
640 // Grid table classes
641 // ----------------------------------------------------------------------------
643 // the abstract base class
644 class WXDLLIMPEXP_ADV wxGridTableBase
: public wxObject
,
645 public wxClientDataContainer
649 virtual ~wxGridTableBase();
651 // You must override these functions in a derived table class
654 // return the number of rows and columns in this table
655 virtual int GetNumberRows() = 0;
656 virtual int GetNumberCols() = 0;
658 // the methods above are unfortunately non-const even though they should
659 // have been const -- but changing it now is not possible any longer as it
660 // would break the existing code overriding them, so instead we provide
661 // these const synonyms which can be used from const-correct code
662 int GetRowsCount() const
663 { return const_cast<wxGridTableBase
*>(this)->GetNumberRows(); }
664 int GetColsCount() const
665 { return const_cast<wxGridTableBase
*>(this)->GetNumberCols(); }
668 virtual bool IsEmptyCell( int row
, int col
)
670 return GetValue(row
, col
).empty();
673 bool IsEmpty(const wxGridCellCoords
& coord
)
675 return IsEmptyCell(coord
.GetRow(), coord
.GetCol());
678 virtual wxString
GetValue( int row
, int col
) = 0;
679 virtual void SetValue( int row
, int col
, const wxString
& value
) = 0;
681 // Data type determination and value access
682 virtual wxString
GetTypeName( int row
, int col
);
683 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
684 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
686 virtual long GetValueAsLong( int row
, int col
);
687 virtual double GetValueAsDouble( int row
, int col
);
688 virtual bool GetValueAsBool( int row
, int col
);
690 virtual void SetValueAsLong( int row
, int col
, long value
);
691 virtual void SetValueAsDouble( int row
, int col
, double value
);
692 virtual void SetValueAsBool( int row
, int col
, bool value
);
694 // For user defined types
695 virtual void* GetValueAsCustom( int row
, int col
, const wxString
& typeName
);
696 virtual void SetValueAsCustom( int row
, int col
, const wxString
& typeName
, void* value
);
699 // Overriding these is optional
701 virtual void SetView( wxGrid
*grid
) { m_view
= grid
; }
702 virtual wxGrid
* GetView() const { return m_view
; }
704 virtual void Clear() {}
705 virtual bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
706 virtual bool AppendRows( size_t numRows
= 1 );
707 virtual bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
708 virtual bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
709 virtual bool AppendCols( size_t numCols
= 1 );
710 virtual bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
712 virtual wxString
GetRowLabelValue( int row
);
713 virtual wxString
GetColLabelValue( int col
);
714 virtual void SetRowLabelValue( int WXUNUSED(row
), const wxString
& ) {}
715 virtual void SetColLabelValue( int WXUNUSED(col
), const wxString
& ) {}
717 // Attribute handling
720 // give us the attr provider to use - we take ownership of the pointer
721 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
723 // get the currently used attr provider (may be NULL)
724 wxGridCellAttrProvider
*GetAttrProvider() const { return m_attrProvider
; }
726 // Does this table allow attributes? Default implementation creates
727 // a wxGridCellAttrProvider if necessary.
728 virtual bool CanHaveAttributes();
730 // by default forwarded to wxGridCellAttrProvider if any. May be
731 // overridden to handle attributes directly in the table.
732 virtual wxGridCellAttr
*GetAttr( int row
, int col
,
733 wxGridCellAttr::wxAttrKind kind
);
736 // these functions take ownership of the pointer
737 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
738 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
739 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
743 wxGridCellAttrProvider
*m_attrProvider
;
745 DECLARE_ABSTRACT_CLASS(wxGridTableBase
)
746 wxDECLARE_NO_COPY_CLASS(wxGridTableBase
);
750 // ----------------------------------------------------------------------------
751 // wxGridTableMessage
752 // ----------------------------------------------------------------------------
754 // IDs for messages sent from grid table to view
756 enum wxGridTableRequest
758 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
759 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
760 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
761 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
762 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
763 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
764 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
765 wxGRIDTABLE_NOTIFY_COLS_DELETED
768 class WXDLLIMPEXP_ADV wxGridTableMessage
771 wxGridTableMessage();
772 wxGridTableMessage( wxGridTableBase
*table
, int id
,
776 void SetTableObject( wxGridTableBase
*table
) { m_table
= table
; }
777 wxGridTableBase
* GetTableObject() const { return m_table
; }
778 void SetId( int id
) { m_id
= id
; }
779 int GetId() { return m_id
; }
780 void SetCommandInt( int comInt1
) { m_comInt1
= comInt1
; }
781 int GetCommandInt() { return m_comInt1
; }
782 void SetCommandInt2( int comInt2
) { m_comInt2
= comInt2
; }
783 int GetCommandInt2() { return m_comInt2
; }
786 wxGridTableBase
*m_table
;
791 wxDECLARE_NO_COPY_CLASS(wxGridTableMessage
);
796 // ------ wxGridStringArray
797 // A 2-dimensional array of strings for data values
800 WX_DECLARE_OBJARRAY_WITH_DECL(wxArrayString
, wxGridStringArray
,
801 class WXDLLIMPEXP_ADV
);
805 // ------ wxGridStringTable
807 // Simplest type of data table for a grid for small tables of strings
808 // that are stored in memory
811 class WXDLLIMPEXP_ADV wxGridStringTable
: public wxGridTableBase
815 wxGridStringTable( int numRows
, int numCols
);
817 // these are pure virtual in wxGridTableBase
819 virtual int GetNumberRows() { return m_data
.size(); }
820 virtual int GetNumberCols() { return m_numCols
; }
821 virtual wxString
GetValue( int row
, int col
);
822 virtual void SetValue( int row
, int col
, const wxString
& s
);
824 // overridden functions from wxGridTableBase
827 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
828 bool AppendRows( size_t numRows
= 1 );
829 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
830 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
831 bool AppendCols( size_t numCols
= 1 );
832 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
834 void SetRowLabelValue( int row
, const wxString
& );
835 void SetColLabelValue( int col
, const wxString
& );
836 wxString
GetRowLabelValue( int row
);
837 wxString
GetColLabelValue( int col
);
840 wxGridStringArray m_data
;
842 // notice that while we don't need to store the number of our rows as it's
843 // always equal to the size of m_data array, we do need to store the number
844 // of our columns as we can't retrieve it from m_data when the number of
845 // rows is 0 (see #10818)
848 // These only get used if you set your own labels, otherwise the
849 // GetRow/ColLabelValue functions return wxGridTableBase defaults
851 wxArrayString m_rowLabels
;
852 wxArrayString m_colLabels
;
854 DECLARE_DYNAMIC_CLASS_NO_COPY( wxGridStringTable
)
859 // ============================================================================
861 // ============================================================================
863 // ----------------------------------------------------------------------------
864 // wxGridSizesInfo stores information about sizes of the rows or columns.
866 // It assumes that most of the columns or rows have default size and so stores
867 // the default size separately and uses a hash to map column or row numbers to
868 // their non default size for those which don't have the default size.
869 // ----------------------------------------------------------------------------
871 // hash map to store positions as the keys and sizes as the values
872 WX_DECLARE_HASH_MAP_WITH_DECL( unsigned, int, wxIntegerHash
, wxIntegerEqual
,
873 wxUnsignedToIntHashMap
, class WXDLLIMPEXP_ADV
);
875 struct WXDLLIMPEXP_ADV wxGridSizesInfo
877 // default ctor, initialize m_sizeDefault and m_customSizes later
878 wxGridSizesInfo() { }
880 // ctor used by wxGrid::Get{Col,Row}Sizes()
881 wxGridSizesInfo(int defSize
, const wxArrayInt
& allSizes
);
883 // default copy ctor, assignment operator and dtor are ok
885 // Get the size of the element with the given index
886 int GetSize(unsigned pos
) const;
892 // position -> size map containing all elements with non-default size
893 wxUnsignedToIntHashMap m_customSizes
;
896 // ----------------------------------------------------------------------------
898 // ----------------------------------------------------------------------------
900 class WXDLLIMPEXP_ADV wxGrid
: public wxScrolledWindow
903 // possible selection modes
904 enum wxGridSelectionModes
906 wxGridSelectCells
= 0, // allow selecting anything
907 wxGridSelectRows
= 1, // allow selecting only entire rows
908 wxGridSelectColumns
= 2, // allow selecting only entire columns
909 wxGridSelectRowsOrColumns
= wxGridSelectRows
| wxGridSelectColumns
912 // creation and destruction
913 // ------------------------
915 // ctor and Create() create the grid window, as with the other controls
918 wxGrid(wxWindow
*parent
,
920 const wxPoint
& pos
= wxDefaultPosition
,
921 const wxSize
& size
= wxDefaultSize
,
922 long style
= wxWANTS_CHARS
,
923 const wxString
& name
= wxGridNameStr
)
927 Create(parent
, id
, pos
, size
, style
, name
);
930 bool Create(wxWindow
*parent
,
932 const wxPoint
& pos
= wxDefaultPosition
,
933 const wxSize
& size
= wxDefaultSize
,
934 long style
= wxWANTS_CHARS
,
935 const wxString
& name
= wxGridNameStr
);
939 // however to initialize grid data either CreateGrid() or SetTable() must
942 // this is basically equivalent to
944 // SetTable(new wxGridStringTable(numRows, numCols), true, selmode)
946 bool CreateGrid( int numRows
, int numCols
,
947 wxGridSelectionModes selmode
= wxGridSelectCells
);
949 bool SetTable( wxGridTableBase
*table
,
950 bool takeOwnership
= false,
951 wxGridSelectionModes selmode
= wxGridSelectCells
);
953 bool ProcessTableMessage(wxGridTableMessage
&);
955 wxGridTableBase
*GetTable() const { return m_table
; }
958 void SetSelectionMode(wxGridSelectionModes selmode
);
959 wxGridSelectionModes
GetSelectionMode() const;
961 // ------ grid dimensions
963 int GetNumberRows() const { return m_numRows
; }
964 int GetNumberCols() const { return m_numCols
; }
967 // ------ display update functions
969 wxArrayInt
CalcRowLabelsExposed( const wxRegion
& reg
) const;
971 wxArrayInt
CalcColLabelsExposed( const wxRegion
& reg
) const;
972 wxGridCellCoordsArray
CalcCellsExposed( const wxRegion
& reg
) const;
976 bool InsertRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true)
978 return DoModifyLines(&wxGridTableBase::InsertRows
,
979 pos
, numRows
, updateLabels
);
981 bool InsertCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true)
983 return DoModifyLines(&wxGridTableBase::InsertCols
,
984 pos
, numCols
, updateLabels
);
987 bool AppendRows(int numRows
= 1, bool updateLabels
= true)
989 return DoAppendLines(&wxGridTableBase::AppendRows
, numRows
, updateLabels
);
991 bool AppendCols(int numCols
= 1, bool updateLabels
= true)
993 return DoAppendLines(&wxGridTableBase::AppendCols
, numCols
, updateLabels
);
996 bool DeleteRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true)
998 return DoModifyLines(&wxGridTableBase::DeleteRows
,
999 pos
, numRows
, updateLabels
);
1001 bool DeleteCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true)
1003 return DoModifyLines(&wxGridTableBase::DeleteCols
,
1004 pos
, numCols
, updateLabels
);
1007 void DrawGridCellArea( wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1008 void DrawGridSpace( wxDC
& dc
);
1009 void DrawCellBorder( wxDC
& dc
, const wxGridCellCoords
& );
1010 void DrawAllGridLines( wxDC
& dc
, const wxRegion
& reg
);
1011 void DrawCell( wxDC
& dc
, const wxGridCellCoords
& );
1012 void DrawHighlight(wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1014 // this function is called when the current cell highlight must be redrawn
1015 // and may be overridden by the user
1016 virtual void DrawCellHighlight( wxDC
& dc
, const wxGridCellAttr
*attr
);
1018 virtual void DrawRowLabels( wxDC
& dc
, const wxArrayInt
& rows
);
1019 virtual void DrawRowLabel( wxDC
& dc
, int row
);
1021 virtual void DrawColLabels( wxDC
& dc
, const wxArrayInt
& cols
);
1022 virtual void DrawColLabel( wxDC
& dc
, int col
);
1024 virtual void DrawCornerLabel(wxDC
& dc
);
1026 // ------ Cell text drawing functions
1028 void DrawTextRectangle( wxDC
& dc
, const wxString
&, const wxRect
&,
1029 int horizontalAlignment
= wxALIGN_LEFT
,
1030 int verticalAlignment
= wxALIGN_TOP
,
1031 int textOrientation
= wxHORIZONTAL
) const;
1033 void DrawTextRectangle( wxDC
& dc
, const wxArrayString
& lines
, const wxRect
&,
1034 int horizontalAlignment
= wxALIGN_LEFT
,
1035 int verticalAlignment
= wxALIGN_TOP
,
1036 int textOrientation
= wxHORIZONTAL
) const;
1039 // Split a string containing newline characters into an array of
1040 // strings and return the number of lines
1042 void StringToLines( const wxString
& value
, wxArrayString
& lines
) const;
1044 void GetTextBoxSize( const wxDC
& dc
,
1045 const wxArrayString
& lines
,
1046 long *width
, long *height
) const;
1050 // Code that does a lot of grid modification can be enclosed
1051 // between BeginBatch() and EndBatch() calls to avoid screen
1054 void BeginBatch() { m_batchCount
++; }
1057 int GetBatchCount() { return m_batchCount
; }
1059 virtual void Refresh(bool eraseb
= true, const wxRect
* rect
= NULL
);
1061 // Use this, rather than wxWindow::Refresh(), to force an
1062 // immediate repainting of the grid. Has no effect if you are
1063 // already inside a BeginBatch / EndBatch block.
1065 // This function is necessary because wxGrid has a minimal OnPaint()
1066 // handler to reduce screen flicker.
1068 void ForceRefresh();
1071 // ------ edit control functions
1073 bool IsEditable() const { return m_editable
; }
1074 void EnableEditing( bool edit
);
1076 void EnableCellEditControl( bool enable
= true );
1077 void DisableCellEditControl() { EnableCellEditControl(false); }
1078 bool CanEnableCellControl() const;
1079 bool IsCellEditControlEnabled() const;
1080 bool IsCellEditControlShown() const;
1082 bool IsCurrentCellReadOnly() const;
1084 void ShowCellEditControl();
1085 void HideCellEditControl();
1086 void SaveEditControlValue();
1089 // ------ grid location functions
1090 // Note that all of these functions work with the logical coordinates of
1091 // grid cells and labels so you will need to convert from device
1092 // coordinates for mouse events etc.
1094 wxGridCellCoords
XYToCell(int x
, int y
) const;
1095 void XYToCell(int x
, int y
, wxGridCellCoords
& coords
) const
1096 { coords
= XYToCell(x
, y
); }
1097 wxGridCellCoords
XYToCell(const wxPoint
& pos
) const
1098 { return XYToCell(pos
.x
, pos
.y
); }
1100 // these functions return the index of the row/columns corresponding to the
1101 // given logical position in pixels
1103 // if clipToMinMax is false (default, wxNOT_FOUND is returned if the
1104 // position is outside any row/column, otherwise the first/last element is
1105 // returned in this case
1106 int YToRow( int y
, bool clipToMinMax
= false ) const;
1107 int XToCol( int x
, bool clipToMinMax
= false ) const;
1109 int YToEdgeOfRow( int y
) const;
1110 int XToEdgeOfCol( int x
) const;
1112 wxRect
CellToRect( int row
, int col
) const;
1113 wxRect
CellToRect( const wxGridCellCoords
& coords
) const
1114 { return CellToRect( coords
.GetRow(), coords
.GetCol() ); }
1116 int GetGridCursorRow() const { return m_currentCellCoords
.GetRow(); }
1117 int GetGridCursorCol() const { return m_currentCellCoords
.GetCol(); }
1119 // check to see if a cell is either wholly visible (the default arg) or
1120 // at least partially visible in the grid window
1122 bool IsVisible( int row
, int col
, bool wholeCellVisible
= true ) const;
1123 bool IsVisible( const wxGridCellCoords
& coords
, bool wholeCellVisible
= true ) const
1124 { return IsVisible( coords
.GetRow(), coords
.GetCol(), wholeCellVisible
); }
1125 void MakeCellVisible( int row
, int col
);
1126 void MakeCellVisible( const wxGridCellCoords
& coords
)
1127 { MakeCellVisible( coords
.GetRow(), coords
.GetCol() ); }
1130 // ------ grid cursor movement functions
1132 void SetGridCursor(int row
, int col
) { SetCurrentCell(row
, col
); }
1133 void SetGridCursor(const wxGridCellCoords
& c
) { SetCurrentCell(c
); }
1135 void GoToCell(int row
, int col
)
1137 if ( SetCurrentCell(row
, col
) )
1138 MakeCellVisible(row
, col
);
1141 void GoToCell(const wxGridCellCoords
& coords
)
1143 if ( SetCurrentCell(coords
) )
1144 MakeCellVisible(coords
);
1147 bool MoveCursorUp( bool expandSelection
);
1148 bool MoveCursorDown( bool expandSelection
);
1149 bool MoveCursorLeft( bool expandSelection
);
1150 bool MoveCursorRight( bool expandSelection
);
1151 bool MovePageDown();
1153 bool MoveCursorUpBlock( bool expandSelection
);
1154 bool MoveCursorDownBlock( bool expandSelection
);
1155 bool MoveCursorLeftBlock( bool expandSelection
);
1156 bool MoveCursorRightBlock( bool expandSelection
);
1159 // ------ label and gridline formatting
1161 int GetDefaultRowLabelSize() const { return WXGRID_DEFAULT_ROW_LABEL_WIDTH
; }
1162 int GetRowLabelSize() const { return m_rowLabelWidth
; }
1163 int GetDefaultColLabelSize() const { return WXGRID_DEFAULT_COL_LABEL_HEIGHT
; }
1164 int GetColLabelSize() const { return m_colLabelHeight
; }
1165 wxColour
GetLabelBackgroundColour() const { return m_labelBackgroundColour
; }
1166 wxColour
GetLabelTextColour() const { return m_labelTextColour
; }
1167 wxFont
GetLabelFont() const { return m_labelFont
; }
1168 void GetRowLabelAlignment( int *horiz
, int *vert
) const;
1169 void GetColLabelAlignment( int *horiz
, int *vert
) const;
1170 int GetColLabelTextOrientation() const;
1171 wxString
GetRowLabelValue( int row
) const;
1172 wxString
GetColLabelValue( int col
) const;
1174 wxColour
GetCellHighlightColour() const { return m_cellHighlightColour
; }
1175 int GetCellHighlightPenWidth() const { return m_cellHighlightPenWidth
; }
1176 int GetCellHighlightROPenWidth() const { return m_cellHighlightROPenWidth
; }
1178 // this one will use wxHeaderCtrl for the column labels
1179 void UseNativeColHeader(bool native
= true);
1181 // this one will still draw them manually but using the native renderer
1182 // instead of using the same appearance as for the row labels
1183 void SetUseNativeColLabels( bool native
= true );
1185 void SetRowLabelSize( int width
);
1186 void SetColLabelSize( int height
);
1187 void HideRowLabels() { SetRowLabelSize( 0 ); }
1188 void HideColLabels() { SetColLabelSize( 0 ); }
1189 void SetLabelBackgroundColour( const wxColour
& );
1190 void SetLabelTextColour( const wxColour
& );
1191 void SetLabelFont( const wxFont
& );
1192 void SetRowLabelAlignment( int horiz
, int vert
);
1193 void SetColLabelAlignment( int horiz
, int vert
);
1194 void SetColLabelTextOrientation( int textOrientation
);
1195 void SetRowLabelValue( int row
, const wxString
& );
1196 void SetColLabelValue( int col
, const wxString
& );
1197 void SetCellHighlightColour( const wxColour
& );
1198 void SetCellHighlightPenWidth(int width
);
1199 void SetCellHighlightROPenWidth(int width
);
1202 // interactive grid mouse operations control
1203 // -----------------------------------------
1205 // functions globally enabling row/column interactive resizing (enabled by
1207 void EnableDragRowSize( bool enable
= true );
1208 void DisableDragRowSize() { EnableDragRowSize( false ); }
1210 void EnableDragColSize( bool enable
= true );
1211 void DisableDragColSize() { EnableDragColSize( false ); }
1213 // if interactive resizing is enabled, some rows/columns can still have
1215 void DisableRowResize(int row
) { DoDisableLineResize(row
, m_setFixedRows
); }
1216 void DisableColResize(int col
) { DoDisableLineResize(col
, m_setFixedCols
); }
1218 // these functions return whether the given row/column can be
1219 // effectively resized: for this interactive resizing must be enabled
1220 // and this index must not have been passed to DisableRow/ColResize()
1221 bool CanDragRowSize(int row
) const
1222 { return m_canDragRowSize
&& DoCanResizeLine(row
, m_setFixedRows
); }
1223 bool CanDragColSize(int col
) const
1224 { return m_canDragColSize
&& DoCanResizeLine(col
, m_setFixedCols
); }
1226 // interactive column reordering (disabled by default)
1227 void EnableDragColMove( bool enable
= true );
1228 void DisableDragColMove() { EnableDragColMove( false ); }
1229 bool CanDragColMove() const { return m_canDragColMove
; }
1231 // interactive resizing of grid cells (enabled by default)
1232 void EnableDragGridSize(bool enable
= true);
1233 void DisableDragGridSize() { EnableDragGridSize(false); }
1234 bool CanDragGridSize() const { return m_canDragGridSize
; }
1236 // interactive dragging of cells (disabled by default)
1237 void EnableDragCell( bool enable
= true );
1238 void DisableDragCell() { EnableDragCell( false ); }
1239 bool CanDragCell() const { return m_canDragCell
; }
1245 // enable or disable drawing of the lines
1246 void EnableGridLines(bool enable
= true);
1247 bool GridLinesEnabled() const { return m_gridLinesEnabled
; }
1249 // by default grid lines stop at last column/row, but this may be changed
1250 void ClipHorzGridLines(bool clip
)
1251 { DoClipGridLines(m_gridLinesClipHorz
, clip
); }
1252 void ClipVertGridLines(bool clip
)
1253 { DoClipGridLines(m_gridLinesClipVert
, clip
); }
1254 bool AreHorzGridLinesClipped() const { return m_gridLinesClipHorz
; }
1255 bool AreVertGridLinesClipped() const { return m_gridLinesClipVert
; }
1257 // this can be used to change the global grid lines colour
1258 void SetGridLineColour(const wxColour
& col
);
1259 wxColour
GetGridLineColour() const { return m_gridLineColour
; }
1261 // these methods may be overridden to customize individual grid lines
1263 virtual wxPen
GetDefaultGridLinePen();
1264 virtual wxPen
GetRowGridLinePen(int row
);
1265 virtual wxPen
GetColGridLinePen(int col
);
1271 // this sets the specified attribute for this cell or in this row/col
1272 void SetAttr(int row
, int col
, wxGridCellAttr
*attr
);
1273 void SetRowAttr(int row
, wxGridCellAttr
*attr
);
1274 void SetColAttr(int col
, wxGridCellAttr
*attr
);
1276 // returns the attribute we may modify in place: a new one if this cell
1277 // doesn't have any yet or the existing one if it does
1279 // DecRef() must be called on the returned pointer, as usual
1280 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
1283 // shortcuts for setting the column parameters
1285 // set the format for the data in the column: default is string
1286 void SetColFormatBool(int col
);
1287 void SetColFormatNumber(int col
);
1288 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
1289 void SetColFormatCustom(int col
, const wxString
& typeName
);
1291 // ------ row and col formatting
1293 int GetDefaultRowSize() const;
1294 int GetRowSize( int row
) const;
1295 bool IsRowShown(int row
) const { return GetRowSize(row
) != 0; }
1296 int GetDefaultColSize() const;
1297 int GetColSize( int col
) const;
1298 bool IsColShown(int col
) const { return GetColSize(col
) != 0; }
1299 wxColour
GetDefaultCellBackgroundColour() const;
1300 wxColour
GetCellBackgroundColour( int row
, int col
) const;
1301 wxColour
GetDefaultCellTextColour() const;
1302 wxColour
GetCellTextColour( int row
, int col
) const;
1303 wxFont
GetDefaultCellFont() const;
1304 wxFont
GetCellFont( int row
, int col
) const;
1305 void GetDefaultCellAlignment( int *horiz
, int *vert
) const;
1306 void GetCellAlignment( int row
, int col
, int *horiz
, int *vert
) const;
1307 bool GetDefaultCellOverflow() const;
1308 bool GetCellOverflow( int row
, int col
) const;
1309 void GetCellSize( int row
, int col
, int *num_rows
, int *num_cols
) const;
1310 wxSize
GetCellSize(const wxGridCellCoords
& coords
)
1313 GetCellSize(coords
.GetRow(), coords
.GetCol(), &s
.x
, &s
.y
);
1317 // ------ row and col sizes
1318 void SetDefaultRowSize( int height
, bool resizeExistingRows
= false );
1319 void SetRowSize( int row
, int height
);
1320 void HideRow(int row
) { SetRowSize(row
, 0); }
1321 void ShowRow(int row
) { SetRowSize(row
, -1); }
1323 void SetDefaultColSize( int width
, bool resizeExistingCols
= false );
1324 void SetColSize( int col
, int width
);
1325 void HideCol(int col
) { SetColSize(col
, 0); }
1326 void ShowCol(int col
) { SetColSize(col
, -1); }
1328 // the row and column sizes can be also set all at once using
1329 // wxGridSizesInfo which holds all of them at once
1331 wxGridSizesInfo
GetColSizes() const
1332 { return wxGridSizesInfo(GetDefaultColSize(), m_colWidths
); }
1333 wxGridSizesInfo
GetRowSizes() const
1334 { return wxGridSizesInfo(GetDefaultRowSize(), m_rowHeights
); }
1336 void SetColSizes(const wxGridSizesInfo
& sizeInfo
);
1337 void SetRowSizes(const wxGridSizesInfo
& sizeInfo
);
1340 // ------- columns (only, for now) reordering
1342 // columns index <-> positions mapping: by default, the position of the
1343 // column is the same as its index, but the columns can also be reordered
1344 // (either by calling SetColPos() explicitly or by the user dragging the
1345 // columns around) in which case their indices don't correspond to their
1346 // positions on display any longer
1348 // internally we always work with indices except for the functions which
1349 // have "Pos" in their names (and which work with columns, not pixels) and
1350 // only the display and hit testing code really cares about display
1353 // set the positions of all columns at once (this method uses the same
1354 // conventions as wxHeaderCtrl::SetColumnsOrder() for the order array)
1355 void SetColumnsOrder(const wxArrayInt
& order
);
1357 // return the column index corresponding to the given (valid) position
1358 int GetColAt(int pos
) const
1360 return m_colAt
.empty() ? pos
: m_colAt
[pos
];
1363 // reorder the columns so that the column with the given index is now shown
1364 // as the position pos
1365 void SetColPos(int idx
, int pos
);
1367 // return the position at which the column with the given index is
1368 // displayed: notice that this is a slow operation as we don't maintain the
1369 // reverse mapping currently
1370 int GetColPos(int idx
) const
1372 if ( m_colAt
.IsEmpty() )
1375 for ( int i
= 0; i
< m_numCols
; i
++ )
1377 if ( m_colAt
[i
] == idx
)
1381 wxFAIL_MSG( "invalid column index" );
1386 // reset the columns positions to the default order
1390 // automatically size the column or row to fit to its contents, if
1391 // setAsMin is true, this optimal width will also be set as minimal width
1393 void AutoSizeColumn( int col
, bool setAsMin
= true )
1394 { AutoSizeColOrRow(col
, setAsMin
, wxGRID_COLUMN
); }
1395 void AutoSizeRow( int row
, bool setAsMin
= true )
1396 { AutoSizeColOrRow(row
, setAsMin
, wxGRID_ROW
); }
1398 // auto size all columns (very ineffective for big grids!)
1399 void AutoSizeColumns( bool setAsMin
= true )
1400 { (void)SetOrCalcColumnSizes(false, setAsMin
); }
1402 void AutoSizeRows( bool setAsMin
= true )
1403 { (void)SetOrCalcRowSizes(false, setAsMin
); }
1405 // auto size the grid, that is make the columns/rows of the "right" size
1406 // and also set the grid size to just fit its contents
1409 // Note for both AutoSizeRowLabelSize and AutoSizeColLabelSize:
1410 // If col equals to wxGRID_AUTOSIZE value then function autosizes labels column
1411 // instead of data column. Note that this operation may be slow for large
1413 // autosize row height depending on label text
1414 void AutoSizeRowLabelSize( int row
);
1416 // autosize column width depending on label text
1417 void AutoSizeColLabelSize( int col
);
1419 // column won't be resized to be lesser width - this must be called during
1420 // the grid creation because it won't resize the column if it's already
1421 // narrower than the minimal width
1422 void SetColMinimalWidth( int col
, int width
);
1423 void SetRowMinimalHeight( int row
, int width
);
1425 /* These members can be used to query and modify the minimal
1426 * acceptable size of grid rows and columns. Call this function in
1427 * your code which creates the grid if you want to display cells
1428 * with a size smaller than the default acceptable minimum size.
1429 * Like the members SetColMinimalWidth and SetRowMinimalWidth,
1430 * the existing rows or columns will not be checked/resized.
1432 void SetColMinimalAcceptableWidth( int width
);
1433 void SetRowMinimalAcceptableHeight( int width
);
1434 int GetColMinimalAcceptableWidth() const;
1435 int GetRowMinimalAcceptableHeight() const;
1437 void SetDefaultCellBackgroundColour( const wxColour
& );
1438 void SetCellBackgroundColour( int row
, int col
, const wxColour
& );
1439 void SetDefaultCellTextColour( const wxColour
& );
1441 void SetCellTextColour( int row
, int col
, const wxColour
& );
1442 void SetDefaultCellFont( const wxFont
& );
1443 void SetCellFont( int row
, int col
, const wxFont
& );
1444 void SetDefaultCellAlignment( int horiz
, int vert
);
1445 void SetCellAlignment( int row
, int col
, int horiz
, int vert
);
1446 void SetDefaultCellOverflow( bool allow
);
1447 void SetCellOverflow( int row
, int col
, bool allow
);
1448 void SetCellSize( int row
, int col
, int num_rows
, int num_cols
);
1450 // takes ownership of the pointer
1451 void SetDefaultRenderer(wxGridCellRenderer
*renderer
);
1452 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
*renderer
);
1453 wxGridCellRenderer
*GetDefaultRenderer() const;
1454 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
1456 // takes ownership of the pointer
1457 void SetDefaultEditor(wxGridCellEditor
*editor
);
1458 void SetCellEditor(int row
, int col
, wxGridCellEditor
*editor
);
1459 wxGridCellEditor
*GetDefaultEditor() const;
1460 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
1464 // ------ cell value accessors
1466 wxString
GetCellValue( int row
, int col
) const
1470 return m_table
->GetValue( row
, col
);
1474 return wxEmptyString
;
1478 wxString
GetCellValue( const wxGridCellCoords
& coords
) const
1479 { return GetCellValue( coords
.GetRow(), coords
.GetCol() ); }
1481 void SetCellValue( int row
, int col
, const wxString
& s
);
1482 void SetCellValue( const wxGridCellCoords
& coords
, const wxString
& s
)
1483 { SetCellValue( coords
.GetRow(), coords
.GetCol(), s
); }
1485 // returns true if the cell can't be edited
1486 bool IsReadOnly(int row
, int col
) const;
1488 // make the cell editable/readonly
1489 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
1491 // ------ select blocks of cells
1493 void SelectRow( int row
, bool addToSelected
= false );
1494 void SelectCol( int col
, bool addToSelected
= false );
1496 void SelectBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
,
1497 bool addToSelected
= false );
1499 void SelectBlock( const wxGridCellCoords
& topLeft
,
1500 const wxGridCellCoords
& bottomRight
,
1501 bool addToSelected
= false )
1502 { SelectBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1503 bottomRight
.GetRow(), bottomRight
.GetCol(),
1508 bool IsSelection() const;
1510 // ------ deselect blocks or cells
1512 void DeselectRow( int row
);
1513 void DeselectCol( int col
);
1514 void DeselectCell( int row
, int col
);
1516 void ClearSelection();
1518 bool IsInSelection( int row
, int col
) const;
1520 bool IsInSelection( const wxGridCellCoords
& coords
) const
1521 { return IsInSelection( coords
.GetRow(), coords
.GetCol() ); }
1523 wxGridCellCoordsArray
GetSelectedCells() const;
1524 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
1525 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
1526 wxArrayInt
GetSelectedRows() const;
1527 wxArrayInt
GetSelectedCols() const;
1529 // This function returns the rectangle that encloses the block of cells
1530 // limited by TopLeft and BottomRight cell in device coords and clipped
1531 // to the client size of the grid window.
1533 wxRect
BlockToDeviceRect( const wxGridCellCoords
& topLeft
,
1534 const wxGridCellCoords
& bottomRight
) const;
1536 // Access or update the selection fore/back colours
1537 wxColour
GetSelectionBackground() const
1538 { return m_selectionBackground
; }
1539 wxColour
GetSelectionForeground() const
1540 { return m_selectionForeground
; }
1542 void SetSelectionBackground(const wxColour
& c
) { m_selectionBackground
= c
; }
1543 void SetSelectionForeground(const wxColour
& c
) { m_selectionForeground
= c
; }
1546 // Methods for a registry for mapping data types to Renderers/Editors
1547 void RegisterDataType(const wxString
& typeName
,
1548 wxGridCellRenderer
* renderer
,
1549 wxGridCellEditor
* editor
);
1551 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1552 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const
1553 { return GetDefaultEditorForCell(c
.GetRow(), c
.GetCol()); }
1554 virtual wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1555 virtual wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1556 virtual wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1558 // grid may occupy more space than needed for its rows/columns, this
1559 // function allows to set how big this extra space is
1560 void SetMargins(int extraWidth
, int extraHeight
)
1562 m_extraWidth
= extraWidth
;
1563 m_extraHeight
= extraHeight
;
1568 // Accessors for component windows
1569 wxWindow
* GetGridWindow() const { return (wxWindow
*)m_gridWin
; }
1570 wxWindow
* GetGridRowLabelWindow() const { return (wxWindow
*)m_rowLabelWin
; }
1571 wxWindow
* GetGridColLabelWindow() const { return m_colWindow
; }
1572 wxWindow
* GetGridCornerLabelWindow() const { return (wxWindow
*)m_cornerLabelWin
; }
1574 // This one can only be called if we are using the native header window
1575 wxHeaderCtrl
*GetGridColHeader() const
1577 wxASSERT_MSG( m_useNativeHeader
, "no column header window" );
1579 // static_cast<> doesn't work without the full class declaration in
1580 // view and we prefer to avoid adding more compile-time dependencies
1581 // even at the cost of using reinterpret_cast<>
1582 return reinterpret_cast<wxHeaderCtrl
*>(m_colWindow
);
1585 // Allow adjustment of scroll increment. The default is (15, 15).
1586 void SetScrollLineX(int x
) { m_scrollLineX
= x
; }
1587 void SetScrollLineY(int y
) { m_scrollLineY
= y
; }
1588 int GetScrollLineX() const { return m_scrollLineX
; }
1589 int GetScrollLineY() const { return m_scrollLineY
; }
1591 // ------- drag and drop
1592 #if wxUSE_DRAG_AND_DROP
1593 virtual void SetDropTarget(wxDropTarget
*dropTarget
);
1594 #endif // wxUSE_DRAG_AND_DROP
1597 // ------- sorting support
1599 // wxGrid doesn't support sorting on its own but it can indicate the sort
1600 // order in the column header (currently only if native header control is
1603 // return the column currently displaying the sort indicator or wxNOT_FOUND
1605 int GetSortingColumn() const { return m_sortCol
; }
1607 // return true if this column is currently used for sorting
1608 bool IsSortingBy(int col
) const { return GetSortingColumn() == col
; }
1610 // return the current sorting order (on GetSortingColumn()): true for
1611 // ascending sort and false for descending; it doesn't make sense to call
1612 // it if GetSortingColumn() returns wxNOT_FOUND
1613 bool IsSortOrderAscending() const { return m_sortIsAscending
; }
1615 // set the sorting column (or unsets any existing one if wxNOT_FOUND) and
1616 // the order in which to sort
1617 void SetSortingColumn(int col
, bool ascending
= true);
1619 // unset any existing sorting column
1620 void UnsetSortingColumn() { SetSortingColumn(wxNOT_FOUND
); }
1622 #ifdef WXWIN_COMPATIBILITY_2_8
1623 // ------ For compatibility with previous wxGrid only...
1625 // ************************************************
1626 // ** Don't use these in new code because they **
1627 // ** are liable to disappear in a future **
1629 // ************************************************
1632 wxGrid( wxWindow
*parent
,
1633 int x
, int y
, int w
= wxDefaultCoord
, int h
= wxDefaultCoord
,
1634 long style
= wxWANTS_CHARS
,
1635 const wxString
& name
= wxPanelNameStr
)
1638 Create(parent
, wxID_ANY
, wxPoint(x
, y
), wxSize(w
, h
), style
, name
);
1641 void SetCellValue( const wxString
& val
, int row
, int col
)
1642 { SetCellValue( row
, col
, val
); }
1644 void UpdateDimensions()
1645 { CalcDimensions(); }
1647 int GetRows() const { return GetNumberRows(); }
1648 int GetCols() const { return GetNumberCols(); }
1649 int GetCursorRow() const { return GetGridCursorRow(); }
1650 int GetCursorColumn() const { return GetGridCursorCol(); }
1652 int GetScrollPosX() const { return 0; }
1653 int GetScrollPosY() const { return 0; }
1655 void SetScrollX( int WXUNUSED(x
) ) { }
1656 void SetScrollY( int WXUNUSED(y
) ) { }
1658 void SetColumnWidth( int col
, int width
)
1659 { SetColSize( col
, width
); }
1661 int GetColumnWidth( int col
) const
1662 { return GetColSize( col
); }
1664 void SetRowHeight( int row
, int height
)
1665 { SetRowSize( row
, height
); }
1667 // GetRowHeight() is below
1669 int GetViewHeight() const // returned num whole rows visible
1672 int GetViewWidth() const // returned num whole cols visible
1675 void SetLabelSize( int orientation
, int sz
)
1677 if ( orientation
== wxHORIZONTAL
)
1678 SetColLabelSize( sz
);
1680 SetRowLabelSize( sz
);
1683 int GetLabelSize( int orientation
) const
1685 if ( orientation
== wxHORIZONTAL
)
1686 return GetColLabelSize();
1688 return GetRowLabelSize();
1691 void SetLabelAlignment( int orientation
, int align
)
1693 if ( orientation
== wxHORIZONTAL
)
1694 SetColLabelAlignment( align
, -1 );
1696 SetRowLabelAlignment( align
, -1 );
1699 int GetLabelAlignment( int orientation
, int WXUNUSED(align
) ) const
1702 if ( orientation
== wxHORIZONTAL
)
1704 GetColLabelAlignment( &h
, &v
);
1709 GetRowLabelAlignment( &h
, &v
);
1714 void SetLabelValue( int orientation
, const wxString
& val
, int pos
)
1716 if ( orientation
== wxHORIZONTAL
)
1717 SetColLabelValue( pos
, val
);
1719 SetRowLabelValue( pos
, val
);
1722 wxString
GetLabelValue( int orientation
, int pos
) const
1724 if ( orientation
== wxHORIZONTAL
)
1725 return GetColLabelValue( pos
);
1727 return GetRowLabelValue( pos
);
1730 wxFont
GetCellTextFont() const
1731 { return m_defaultCellAttr
->GetFont(); }
1733 wxFont
GetCellTextFont(int WXUNUSED(row
), int WXUNUSED(col
)) const
1734 { return m_defaultCellAttr
->GetFont(); }
1736 void SetCellTextFont(const wxFont
& fnt
)
1737 { SetDefaultCellFont( fnt
); }
1739 void SetCellTextFont(const wxFont
& fnt
, int row
, int col
)
1740 { SetCellFont( row
, col
, fnt
); }
1742 void SetCellTextColour(const wxColour
& val
, int row
, int col
)
1743 { SetCellTextColour( row
, col
, val
); }
1745 void SetCellTextColour(const wxColour
& col
)
1746 { SetDefaultCellTextColour( col
); }
1748 void SetCellBackgroundColour(const wxColour
& col
)
1749 { SetDefaultCellBackgroundColour( col
); }
1751 void SetCellBackgroundColour(const wxColour
& colour
, int row
, int col
)
1752 { SetCellBackgroundColour( row
, col
, colour
); }
1754 bool GetEditable() const { return IsEditable(); }
1755 void SetEditable( bool edit
= true ) { EnableEditing( edit
); }
1756 bool GetEditInPlace() const { return IsCellEditControlEnabled(); }
1758 void SetEditInPlace(bool WXUNUSED(edit
) = true) { }
1760 void SetCellAlignment( int align
, int row
, int col
)
1761 { SetCellAlignment(row
, col
, align
, wxALIGN_CENTER
); }
1762 void SetCellAlignment( int WXUNUSED(align
) ) {}
1763 void SetCellBitmap(wxBitmap
*WXUNUSED(bitmap
), int WXUNUSED(row
), int WXUNUSED(col
))
1765 void SetDividerPen(const wxPen
& WXUNUSED(pen
)) { }
1766 wxPen
& GetDividerPen() const;
1767 void OnActivate(bool WXUNUSED(active
)) {}
1769 // ******** End of compatibility functions **********
1773 // ------ control IDs
1774 enum { wxGRID_CELLCTRL
= 2000,
1777 // ------ control types
1778 enum { wxGRID_TEXTCTRL
= 2100,
1783 wxDEPRECATED_INLINE(bool CanDragRowSize() const, return m_canDragRowSize
; )
1784 wxDEPRECATED_INLINE(bool CanDragColSize() const, return m_canDragColSize
; )
1785 #endif // WXWIN_COMPATIBILITY_2_8
1788 // override some base class functions
1789 virtual bool Enable(bool enable
= true);
1790 virtual wxWindow
*GetMainWindowOfCompositeControl()
1791 { return (wxWindow
*)m_gridWin
; }
1794 // implementation only
1795 void CancelMouseCapture();
1798 virtual wxSize
DoGetBestSize() const;
1802 wxGridWindow
*m_gridWin
;
1803 wxGridCornerLabelWindow
*m_cornerLabelWin
;
1804 wxGridRowLabelWindow
*m_rowLabelWin
;
1806 // the real type of the column window depends on m_useNativeHeader value:
1807 // if it is true, its dynamic type is wxHeaderCtrl, otherwise it is
1808 // wxGridColLabelWindow, use accessors below when the real type matters
1809 wxWindow
*m_colWindow
;
1811 wxGridColLabelWindow
*GetColLabelWindow() const
1813 wxASSERT_MSG( !m_useNativeHeader
, "no column label window" );
1815 return reinterpret_cast<wxGridColLabelWindow
*>(m_colWindow
);
1818 wxGridTableBase
*m_table
;
1824 wxGridCellCoords m_currentCellCoords
;
1826 // the corners of the block being currently selected or wxGridNoCellCoords
1827 wxGridCellCoords m_selectedBlockTopLeft
;
1828 wxGridCellCoords m_selectedBlockBottomRight
;
1830 // when selecting blocks of cells (either from the keyboard using Shift
1831 // with cursor keys, or by dragging the mouse), the selection is anchored
1832 // at m_currentCellCoords which defines one of the corners of the rectangle
1833 // being selected -- and this variable defines the other corner, i.e. it's
1834 // either m_selectedBlockTopLeft or m_selectedBlockBottomRight depending on
1835 // which of them is not m_currentCellCoords
1837 // if no block selection is in process, it is set to wxGridNoCellCoords
1838 wxGridCellCoords m_selectedBlockCorner
;
1840 wxGridSelection
*m_selection
;
1842 wxColour m_selectionBackground
;
1843 wxColour m_selectionForeground
;
1845 // NB: *never* access m_row/col arrays directly because they are created
1846 // on demand, *always* use accessor functions instead!
1848 // init the m_rowHeights/Bottoms arrays with default values
1849 void InitRowHeights();
1851 int m_defaultRowHeight
;
1852 int m_minAcceptableRowHeight
;
1853 wxArrayInt m_rowHeights
;
1854 wxArrayInt m_rowBottoms
;
1856 // init the m_colWidths/Rights arrays
1857 void InitColWidths();
1859 int m_defaultColWidth
;
1860 int m_minAcceptableColWidth
;
1861 wxArrayInt m_colWidths
;
1862 wxArrayInt m_colRights
;
1865 bool m_sortIsAscending
;
1867 bool m_useNativeHeader
,
1868 m_nativeColumnLabels
;
1870 // get the col/row coords
1871 int GetColWidth(int col
) const;
1872 int GetColLeft(int col
) const;
1873 int GetColRight(int col
) const;
1875 // this function must be public for compatibility...
1877 int GetRowHeight(int row
) const;
1880 int GetRowTop(int row
) const;
1881 int GetRowBottom(int row
) const;
1883 int m_rowLabelWidth
;
1884 int m_colLabelHeight
;
1886 // the size of the margin left to the right and bottom of the cell area
1890 wxColour m_labelBackgroundColour
;
1891 wxColour m_labelTextColour
;
1894 int m_rowLabelHorizAlign
;
1895 int m_rowLabelVertAlign
;
1896 int m_colLabelHorizAlign
;
1897 int m_colLabelVertAlign
;
1898 int m_colLabelTextOrientation
;
1900 bool m_defaultRowLabelValues
;
1901 bool m_defaultColLabelValues
;
1903 wxColour m_gridLineColour
;
1904 bool m_gridLinesEnabled
;
1905 bool m_gridLinesClipHorz
,
1906 m_gridLinesClipVert
;
1907 wxColour m_cellHighlightColour
;
1908 int m_cellHighlightPenWidth
;
1909 int m_cellHighlightROPenWidth
;
1912 // common part of AutoSizeColumn/Row() and GetBestSize()
1913 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= true);
1914 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= true);
1916 // common part of AutoSizeColumn/Row()
1917 void AutoSizeColOrRow(int n
, bool setAsMin
, wxGridDirection direction
);
1919 // Calculate the minimum acceptable size for labels area
1920 wxCoord
CalcColOrRowLabelAreaMinSize(wxGridDirection direction
);
1922 // if a column has a minimal width, it will be the value for it in this
1924 wxLongToLongHashMap m_colMinWidths
,
1927 // get the minimal width of the given column/row
1928 int GetColMinimalWidth(int col
) const;
1929 int GetRowMinimalHeight(int col
) const;
1931 // do we have some place to store attributes in?
1932 bool CanHaveAttributes() const;
1934 // cell attribute cache (currently we only cache 1, may be will do
1935 // more/better later)
1939 wxGridCellAttr
*attr
;
1942 // invalidates the attribute cache
1943 void ClearAttrCache();
1945 // adds an attribute to cache
1946 void CacheAttr(int row
, int col
, wxGridCellAttr
*attr
) const;
1948 // looks for an attr in cache, returns true if found
1949 bool LookupAttr(int row
, int col
, wxGridCellAttr
**attr
) const;
1951 // looks for the attr in cache, if not found asks the table and caches the
1953 wxGridCellAttr
*GetCellAttr(int row
, int col
) const;
1954 wxGridCellAttr
*GetCellAttr(const wxGridCellCoords
& coords
) const
1955 { return GetCellAttr( coords
.GetRow(), coords
.GetCol() ); }
1957 // the default cell attr object for cells that don't have their own
1958 wxGridCellAttr
* m_defaultCellAttr
;
1965 wxGridTypeRegistry
* m_typeRegistry
;
1969 WXGRID_CURSOR_SELECT_CELL
,
1970 WXGRID_CURSOR_RESIZE_ROW
,
1971 WXGRID_CURSOR_RESIZE_COL
,
1972 WXGRID_CURSOR_SELECT_ROW
,
1973 WXGRID_CURSOR_SELECT_COL
,
1974 WXGRID_CURSOR_MOVE_COL
1977 // this method not only sets m_cursorMode but also sets the correct cursor
1978 // for the given mode and, if captureMouse is not false releases the mouse
1979 // if it was captured and captures it if it must be captured
1981 // for this to work, you should always use it and not set m_cursorMode
1983 void ChangeCursorMode(CursorMode mode
,
1984 wxWindow
*win
= NULL
,
1985 bool captureMouse
= true);
1987 wxWindow
*m_winCapture
; // the window which captured the mouse
1989 // this variable is used not for finding the correct current cursor but
1990 // mainly for finding out what is going to happen if the mouse starts being
1991 // dragged right now
1993 // by default it is WXGRID_CURSOR_SELECT_CELL meaning that nothing else is
1994 // going on, and it is set to one of RESIZE/SELECT/MOVE values while the
1995 // corresponding operation will be started if the user starts dragging the
1996 // mouse from the current position
1997 CursorMode m_cursorMode
;
2003 bool m_canDragRowSize
;
2004 bool m_canDragColSize
;
2005 bool m_canDragColMove
;
2006 bool m_canDragGridSize
;
2009 // the last position (horizontal or vertical depending on whether the user
2010 // is resizing a column or a row) where a row or column separator line was
2011 // dragged by the user or -1 of there is no drag operation in progress
2015 // true if a drag operation is in progress; when this is true,
2016 // m_startDragPos is valid, i.e. not wxDefaultPosition
2019 // the position (in physical coordinates) where the user started dragging
2020 // the mouse or wxDefaultPosition if mouse isn't being dragged
2022 // notice that this can be != wxDefaultPosition while m_isDragging is still
2023 // false because we wait until the mouse is moved some distance away before
2024 // setting m_isDragging to true
2025 wxPoint m_startDragPos
;
2027 bool m_waitForSlowClick
;
2029 wxGridCellCoords m_selectionStart
;
2031 wxCursor m_rowResizeCursor
;
2032 wxCursor m_colResizeCursor
;
2034 bool m_editable
; // applies to whole grid
2035 bool m_cellEditCtrlEnabled
; // is in-place edit currently shown?
2037 int m_scrollLineX
; // X scroll increment
2038 int m_scrollLineY
; // Y scroll increment
2040 void Init(); // common part of all ctors
2042 void CreateColumnWindow();
2043 void CalcDimensions();
2044 void CalcWindowSizes();
2045 bool Redimension( wxGridTableMessage
& );
2048 // generate the appropriate grid event and return -1 if it was vetoed, 1 if
2049 // it was processed (but not vetoed) and 0 if it wasn't processed
2050 int SendEvent(const wxEventType evtType
,
2052 const wxMouseEvent
& e
);
2053 int SendEvent(const wxEventType evtType
,
2054 const wxGridCellCoords
& coords
,
2055 const wxMouseEvent
& e
)
2056 { return SendEvent(evtType
, coords
.GetRow(), coords
.GetCol(), e
); }
2057 int SendEvent(const wxEventType evtType
,
2059 const wxString
& s
= wxString());
2060 int SendEvent(const wxEventType evtType
,
2061 const wxGridCellCoords
& coords
,
2062 const wxString
& s
= wxString())
2063 { return SendEvent(evtType
, coords
.GetRow(), coords
.GetCol(), s
); }
2064 int SendEvent(const wxEventType evtType
, const wxString
& s
= wxString())
2065 { return SendEvent(evtType
, m_currentCellCoords
, s
); }
2067 // send wxEVT_GRID_{ROW,COL}_SIZE
2068 void SendGridSizeEvent(wxEventType type
,
2070 const wxMouseEvent
& mouseEv
);
2072 void OnPaint( wxPaintEvent
& );
2073 void OnSize( wxSizeEvent
& );
2074 void OnKeyDown( wxKeyEvent
& );
2075 void OnKeyUp( wxKeyEvent
& );
2076 void OnChar( wxKeyEvent
& );
2077 void OnEraseBackground( wxEraseEvent
& );
2080 bool SetCurrentCell( const wxGridCellCoords
& coords
);
2081 bool SetCurrentCell( int row
, int col
)
2082 { return SetCurrentCell( wxGridCellCoords(row
, col
) ); }
2085 // this function is called to extend the block being currently selected
2086 // from mouse and keyboard event handlers
2087 void UpdateBlockBeingSelected(int topRow
, int leftCol
,
2088 int bottomRow
, int rightCol
);
2090 void UpdateBlockBeingSelected(const wxGridCellCoords
& topLeft
,
2091 const wxGridCellCoords
& bottomRight
)
2092 { UpdateBlockBeingSelected(topLeft
.GetRow(), topLeft
.GetCol(),
2093 bottomRight
.GetRow(), bottomRight
.GetCol()); }
2095 // ------ functions to get/send data (see also public functions)
2097 bool GetModelValues();
2098 bool SetModelValues();
2100 friend class WXDLLIMPEXP_FWD_ADV wxGridSelection
;
2101 friend class wxGridRowOperations
;
2102 friend class wxGridColumnOperations
;
2104 // they call our private Process{{Corner,Col,Row}Label,GridCell}MouseEvent()
2105 friend class wxGridCornerLabelWindow
;
2106 friend class wxGridColLabelWindow
;
2107 friend class wxGridRowLabelWindow
;
2108 friend class wxGridWindow
;
2109 friend class wxGridHeaderRenderer
;
2111 friend class wxGridHeaderCtrl
;
2115 // implement wxScrolledWindow method to return m_gridWin size
2116 virtual wxSize
GetSizeAvailableForScrollTarget(const wxSize
& size
);
2118 // redraw the grid lines, should be called after changing their attributes
2119 void RedrawGridLines();
2121 // common part of Clip{Horz,Vert}GridLines
2122 void DoClipGridLines(bool& var
, bool clip
);
2124 // update the sorting indicator shown in the specified column (whose index
2127 // this will use GetSortingColumn() and IsSortOrderAscending() to determine
2128 // the sorting indicator to effectively show
2129 void UpdateColumnSortingIndicator(int col
);
2131 // update the grid after changing the columns order (common part of
2132 // SetColPos() and ResetColPos())
2133 void RefreshAfterColPosChange();
2136 // return the position (not index) of the column at the given logical pixel
2139 // this always returns a valid position, even if the coordinate is out of
2140 // bounds (in which case first/last column is returned)
2141 int XToPos(int x
) const;
2144 // event handlers and their helpers
2145 // --------------------------------
2147 // process mouse drag event in WXGRID_CURSOR_SELECT_CELL mode
2148 void DoGridCellDrag(wxMouseEvent
& event
,
2149 const wxGridCellCoords
& coords
,
2152 // process row/column resizing drag event
2153 void DoGridLineDrag(wxMouseEvent
& event
, const wxGridOperations
& oper
);
2155 // process mouse drag event in the grid window
2156 void DoGridDragEvent(wxMouseEvent
& event
, const wxGridCellCoords
& coords
);
2158 // process different clicks on grid cells
2159 void DoGridCellLeftDown(wxMouseEvent
& event
,
2160 const wxGridCellCoords
& coords
,
2161 const wxPoint
& pos
);
2162 void DoGridCellLeftDClick(wxMouseEvent
& event
,
2163 const wxGridCellCoords
& coords
,
2164 const wxPoint
& pos
);
2165 void DoGridCellLeftUp(wxMouseEvent
& event
, const wxGridCellCoords
& coords
);
2167 // process movement (but not dragging) event in the grid cell area
2168 void DoGridMouseMoveEvent(wxMouseEvent
& event
,
2169 const wxGridCellCoords
& coords
,
2170 const wxPoint
& pos
);
2172 // process mouse events in the grid window
2173 void ProcessGridCellMouseEvent(wxMouseEvent
& event
);
2175 // process mouse events in the row/column labels/corner windows
2176 void ProcessRowLabelMouseEvent(wxMouseEvent
& event
);
2177 void ProcessColLabelMouseEvent(wxMouseEvent
& event
);
2178 void ProcessCornerLabelMouseEvent(wxMouseEvent
& event
);
2180 void DoColHeaderClick(int col
);
2182 void DoStartResizeCol(int col
);
2183 void DoUpdateResizeCol(int x
);
2184 void DoUpdateResizeColWidth(int w
);
2185 void DoStartMoveCol(int col
);
2187 void DoEndDragResizeRow(const wxMouseEvent
& event
);
2188 void DoEndDragResizeCol(const wxMouseEvent
& event
);
2189 void DoEndMoveCol(int pos
);
2192 // common implementations of methods defined for both rows and columns
2193 void DeselectLine(int line
, const wxGridOperations
& oper
);
2194 bool DoEndDragResizeLine(const wxGridOperations
& oper
);
2195 int PosToLinePos(int pos
, bool clipToMinMax
,
2196 const wxGridOperations
& oper
) const;
2197 int PosToLine(int pos
, bool clipToMinMax
,
2198 const wxGridOperations
& oper
) const;
2199 int PosToEdgeOfLine(int pos
, const wxGridOperations
& oper
) const;
2201 bool DoMoveCursor(bool expandSelection
,
2202 const wxGridDirectionOperations
& diroper
);
2203 bool DoMoveCursorByPage(const wxGridDirectionOperations
& diroper
);
2204 bool DoMoveCursorByBlock(bool expandSelection
,
2205 const wxGridDirectionOperations
& diroper
);
2206 void AdvanceToNextNonEmpty(wxGridCellCoords
& coords
,
2207 const wxGridDirectionOperations
& diroper
);
2209 // common part of {Insert,Delete}{Rows,Cols}
2210 bool DoModifyLines(bool (wxGridTableBase::*funcModify
)(size_t, size_t),
2211 int pos
, int num
, bool updateLabels
);
2212 // Append{Rows,Cols} is a bit different because of one less parameter
2213 bool DoAppendLines(bool (wxGridTableBase::*funcAppend
)(size_t),
2214 int num
, bool updateLabels
);
2216 // common part of Set{Col,Row}Sizes
2217 void DoSetSizes(const wxGridSizesInfo
& sizeInfo
,
2218 const wxGridOperations
& oper
);
2220 // common part of Disable{Row,Col}Resize and CanDrag{Row,Col}Size
2221 void DoDisableLineResize(int line
, wxGridFixedIndicesSet
*& setFixed
);
2222 bool DoCanResizeLine(int line
, const wxGridFixedIndicesSet
*setFixed
) const;
2226 // these sets contain the indices of fixed, i.e. non-resizable
2227 // interactively, grid rows or columns and are NULL if there are no fixed
2228 // elements (which is the default)
2229 wxGridFixedIndicesSet
*m_setFixedRows
,
2232 DECLARE_DYNAMIC_CLASS( wxGrid
)
2233 DECLARE_EVENT_TABLE()
2234 wxDECLARE_NO_COPY_CLASS(wxGrid
);
2237 // ----------------------------------------------------------------------------
2238 // wxGridUpdateLocker prevents updates to a grid during its lifetime
2239 // ----------------------------------------------------------------------------
2241 class WXDLLIMPEXP_ADV wxGridUpdateLocker
2244 // if the pointer is NULL, Create() can be called later
2245 wxGridUpdateLocker(wxGrid
*grid
= NULL
)
2250 // can be called if ctor was used with a NULL pointer, must not be called
2252 void Create(wxGrid
*grid
)
2254 wxASSERT_MSG( !m_grid
, wxT("shouldn't be called more than once") );
2259 ~wxGridUpdateLocker()
2266 void Init(wxGrid
*grid
)
2270 m_grid
->BeginBatch();
2275 wxDECLARE_NO_COPY_CLASS(wxGridUpdateLocker
);
2278 // ----------------------------------------------------------------------------
2279 // Grid event class and event types
2280 // ----------------------------------------------------------------------------
2282 class WXDLLIMPEXP_ADV wxGridEvent
: public wxNotifyEvent
,
2283 public wxKeyboardState
2289 Init(-1, -1, -1, -1, false);
2295 int row
= -1, int col
= -1,
2296 int x
= -1, int y
= -1,
2298 const wxKeyboardState
& kbd
= wxKeyboardState())
2299 : wxNotifyEvent(type
, id
),
2300 wxKeyboardState(kbd
)
2302 Init(row
, col
, x
, y
, sel
);
2303 SetEventObject(obj
);
2306 // explicitly specifying inline allows gcc < 3.4 to
2307 // handle the deprecation attribute even in the constructor.
2308 wxDEPRECATED_CONSTRUCTOR(
2316 bool shift
= false, bool alt
= false, bool meta
= false));
2318 virtual int GetRow() { return m_row
; }
2319 virtual int GetCol() { return m_col
; }
2320 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
2321 bool Selecting() { return m_selecting
; }
2323 virtual wxEvent
*Clone() const { return new wxGridEvent(*this); }
2333 void Init(int row
, int col
, int x
, int y
, bool sel
)
2342 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEvent
)
2345 class WXDLLIMPEXP_ADV wxGridSizeEvent
: public wxNotifyEvent
,
2346 public wxKeyboardState
2355 wxGridSizeEvent(int id
,
2359 int x
= -1, int y
= -1,
2360 const wxKeyboardState
& kbd
= wxKeyboardState())
2361 : wxNotifyEvent(type
, id
),
2362 wxKeyboardState(kbd
)
2364 Init(rowOrCol
, x
, y
);
2366 SetEventObject(obj
);
2369 wxDEPRECATED_CONSTRUCTOR(
2370 wxGridSizeEvent(int id
,
2378 bool meta
= false) );
2380 int GetRowOrCol() { return m_rowOrCol
; }
2381 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
2383 virtual wxEvent
*Clone() const { return new wxGridSizeEvent(*this); }
2391 void Init(int rowOrCol
, int x
, int y
)
2393 m_rowOrCol
= rowOrCol
;
2398 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridSizeEvent
)
2402 class WXDLLIMPEXP_ADV wxGridRangeSelectEvent
: public wxNotifyEvent
,
2403 public wxKeyboardState
2406 wxGridRangeSelectEvent()
2409 Init(wxGridNoCellCoords
, wxGridNoCellCoords
, false);
2412 wxGridRangeSelectEvent(int id
,
2415 const wxGridCellCoords
& topLeft
,
2416 const wxGridCellCoords
& bottomRight
,
2418 const wxKeyboardState
& kbd
= wxKeyboardState())
2419 : wxNotifyEvent(type
, id
),
2420 wxKeyboardState(kbd
)
2422 Init(topLeft
, bottomRight
, sel
);
2424 SetEventObject(obj
);
2427 wxDEPRECATED_CONSTRUCTOR(
2428 wxGridRangeSelectEvent(int id
,
2431 const wxGridCellCoords
& topLeft
,
2432 const wxGridCellCoords
& bottomRight
,
2437 bool meta
= false) );
2439 wxGridCellCoords
GetTopLeftCoords() { return m_topLeft
; }
2440 wxGridCellCoords
GetBottomRightCoords() { return m_bottomRight
; }
2441 int GetTopRow() { return m_topLeft
.GetRow(); }
2442 int GetBottomRow() { return m_bottomRight
.GetRow(); }
2443 int GetLeftCol() { return m_topLeft
.GetCol(); }
2444 int GetRightCol() { return m_bottomRight
.GetCol(); }
2445 bool Selecting() { return m_selecting
; }
2447 virtual wxEvent
*Clone() const { return new wxGridRangeSelectEvent(*this); }
2450 void Init(const wxGridCellCoords
& topLeft
,
2451 const wxGridCellCoords
& bottomRight
,
2454 m_topLeft
= topLeft
;
2455 m_bottomRight
= bottomRight
;
2456 m_selecting
= selecting
;
2459 wxGridCellCoords m_topLeft
;
2460 wxGridCellCoords m_bottomRight
;
2463 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridRangeSelectEvent
)
2467 class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent
: public wxCommandEvent
2470 wxGridEditorCreatedEvent()
2478 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
2479 int row
, int col
, wxControl
* ctrl
);
2481 int GetRow() { return m_row
; }
2482 int GetCol() { return m_col
; }
2483 wxControl
* GetControl() { return m_ctrl
; }
2484 void SetRow(int row
) { m_row
= row
; }
2485 void SetCol(int col
) { m_col
= col
; }
2486 void SetControl(wxControl
* ctrl
) { m_ctrl
= ctrl
; }
2488 virtual wxEvent
*Clone() const { return new wxGridEditorCreatedEvent(*this); }
2495 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEditorCreatedEvent
)
2499 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_LEFT_CLICK
, wxGridEvent
);
2500 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_RIGHT_CLICK
, wxGridEvent
);
2501 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_LEFT_DCLICK
, wxGridEvent
);
2502 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_RIGHT_DCLICK
, wxGridEvent
);
2503 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_LEFT_CLICK
, wxGridEvent
);
2504 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_RIGHT_CLICK
, wxGridEvent
);
2505 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_LEFT_DCLICK
, wxGridEvent
);
2506 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_RIGHT_DCLICK
, wxGridEvent
);
2507 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_ROW_SIZE
, wxGridSizeEvent
);
2508 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_COL_SIZE
, wxGridSizeEvent
);
2509 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_RANGE_SELECT
, wxGridRangeSelectEvent
);
2510 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_CHANGING
, wxGridEvent
);
2511 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_CHANGED
, wxGridEvent
);
2512 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_SELECT_CELL
, wxGridEvent
);
2513 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_EDITOR_SHOWN
, wxGridEvent
);
2514 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_EDITOR_HIDDEN
, wxGridEvent
);
2515 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_EDITOR_CREATED
, wxGridEditorCreatedEvent
);
2516 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_BEGIN_DRAG
, wxGridEvent
);
2517 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_COL_MOVE
, wxGridEvent
);
2518 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_GRID_COL_SORT
, wxGridEvent
);
2520 typedef void (wxEvtHandler::*wxGridEventFunction
)(wxGridEvent
&);
2521 typedef void (wxEvtHandler::*wxGridSizeEventFunction
)(wxGridSizeEvent
&);
2522 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction
)(wxGridRangeSelectEvent
&);
2523 typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction
)(wxGridEditorCreatedEvent
&);
2525 #define wxGridEventHandler(func) \
2526 wxEVENT_HANDLER_CAST(wxGridEventFunction, func)
2528 #define wxGridSizeEventHandler(func) \
2529 wxEVENT_HANDLER_CAST(wxGridSizeEventFunction, func)
2531 #define wxGridRangeSelectEventHandler(func) \
2532 wxEVENT_HANDLER_CAST(wxGridRangeSelectEventFunction, func)
2534 #define wxGridEditorCreatedEventHandler(func) \
2535 wxEVENT_HANDLER_CAST(wxGridEditorCreatedEventFunction, func)
2537 #define wx__DECLARE_GRIDEVT(evt, id, fn) \
2538 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEventHandler(fn))
2540 #define wx__DECLARE_GRIDSIZEEVT(evt, id, fn) \
2541 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridSizeEventHandler(fn))
2543 #define wx__DECLARE_GRIDRANGESELEVT(evt, id, fn) \
2544 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridRangeSelectEventHandler(fn))
2546 #define wx__DECLARE_GRIDEDITOREVT(evt, id, fn) \
2547 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEditorCreatedEventHandler(fn))
2549 #define EVT_GRID_CMD_CELL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_CLICK, id, fn)
2550 #define EVT_GRID_CMD_CELL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_CLICK, id, fn)
2551 #define EVT_GRID_CMD_CELL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_DCLICK, id, fn)
2552 #define EVT_GRID_CMD_CELL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_DCLICK, id, fn)
2553 #define EVT_GRID_CMD_LABEL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_CLICK, id, fn)
2554 #define EVT_GRID_CMD_LABEL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_CLICK, id, fn)
2555 #define EVT_GRID_CMD_LABEL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_DCLICK, id, fn)
2556 #define EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_DCLICK, id, fn)
2557 #define EVT_GRID_CMD_ROW_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(ROW_SIZE, id, fn)
2558 #define EVT_GRID_CMD_COL_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_SIZE, id, fn)
2559 #define EVT_GRID_CMD_COL_MOVE(id, fn) wx__DECLARE_GRIDEVT(COL_MOVE, id, fn)
2560 #define EVT_GRID_CMD_COL_SORT(id, fn) wx__DECLARE_GRIDEVT(COL_SORT, id, fn)
2561 #define EVT_GRID_CMD_RANGE_SELECT(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECT, id, fn)
2562 #define EVT_GRID_CMD_CELL_CHANGING(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGING, id, fn)
2563 #define EVT_GRID_CMD_CELL_CHANGED(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGED, id, fn)
2564 #define EVT_GRID_CMD_SELECT_CELL(id, fn) wx__DECLARE_GRIDEVT(SELECT_CELL, id, fn)
2565 #define EVT_GRID_CMD_EDITOR_SHOWN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_SHOWN, id, fn)
2566 #define EVT_GRID_CMD_EDITOR_HIDDEN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_HIDDEN, id, fn)
2567 #define EVT_GRID_CMD_EDITOR_CREATED(id, fn) wx__DECLARE_GRIDEDITOREVT(EDITOR_CREATED, id, fn)
2568 #define EVT_GRID_CMD_CELL_BEGIN_DRAG(id, fn) wx__DECLARE_GRIDEVT(CELL_BEGIN_DRAG, id, fn)
2570 // same as above but for any id (exists mainly for backwards compatibility but
2571 // then it's also true that you rarely have multiple grid in the same window)
2572 #define EVT_GRID_CELL_LEFT_CLICK(fn) EVT_GRID_CMD_CELL_LEFT_CLICK(wxID_ANY, fn)
2573 #define EVT_GRID_CELL_RIGHT_CLICK(fn) EVT_GRID_CMD_CELL_RIGHT_CLICK(wxID_ANY, fn)
2574 #define EVT_GRID_CELL_LEFT_DCLICK(fn) EVT_GRID_CMD_CELL_LEFT_DCLICK(wxID_ANY, fn)
2575 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) EVT_GRID_CMD_CELL_RIGHT_DCLICK(wxID_ANY, fn)
2576 #define EVT_GRID_LABEL_LEFT_CLICK(fn) EVT_GRID_CMD_LABEL_LEFT_CLICK(wxID_ANY, fn)
2577 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_CLICK(wxID_ANY, fn)
2578 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) EVT_GRID_CMD_LABEL_LEFT_DCLICK(wxID_ANY, fn)
2579 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_DCLICK(wxID_ANY, fn)
2580 #define EVT_GRID_ROW_SIZE(fn) EVT_GRID_CMD_ROW_SIZE(wxID_ANY, fn)
2581 #define EVT_GRID_COL_SIZE(fn) EVT_GRID_CMD_COL_SIZE(wxID_ANY, fn)
2582 #define EVT_GRID_COL_MOVE(fn) EVT_GRID_CMD_COL_MOVE(wxID_ANY, fn)
2583 #define EVT_GRID_COL_SORT(fn) EVT_GRID_CMD_COL_SORT(wxID_ANY, fn)
2584 #define EVT_GRID_RANGE_SELECT(fn) EVT_GRID_CMD_RANGE_SELECT(wxID_ANY, fn)
2585 #define EVT_GRID_CELL_CHANGING(fn) EVT_GRID_CMD_CELL_CHANGING(wxID_ANY, fn)
2586 #define EVT_GRID_CELL_CHANGED(fn) EVT_GRID_CMD_CELL_CHANGED(wxID_ANY, fn)
2587 #define EVT_GRID_SELECT_CELL(fn) EVT_GRID_CMD_SELECT_CELL(wxID_ANY, fn)
2588 #define EVT_GRID_EDITOR_SHOWN(fn) EVT_GRID_CMD_EDITOR_SHOWN(wxID_ANY, fn)
2589 #define EVT_GRID_EDITOR_HIDDEN(fn) EVT_GRID_CMD_EDITOR_HIDDEN(wxID_ANY, fn)
2590 #define EVT_GRID_EDITOR_CREATED(fn) EVT_GRID_CMD_EDITOR_CREATED(wxID_ANY, fn)
2591 #define EVT_GRID_CELL_BEGIN_DRAG(fn) EVT_GRID_CMD_CELL_BEGIN_DRAG(wxID_ANY, fn)
2593 // we used to have a single wxEVT_GRID_CELL_CHANGE event but it was split into
2594 // wxEVT_GRID_CELL_CHANGING and CHANGED ones in wx 2.9.0, however the CHANGED
2595 // is basically the same as the old CHANGE event so we keep the name for
2597 #if WXWIN_COMPATIBILITY_2_8
2598 #define wxEVT_GRID_CELL_CHANGE wxEVT_GRID_CELL_CHANGED
2600 #define EVT_GRID_CMD_CELL_CHANGE EVT_GRID_CMD_CELL_CHANGED
2601 #define EVT_GRID_CELL_CHANGE EVT_GRID_CELL_CHANGED
2602 #endif // WXWIN_COMPATIBILITY_2_8
2604 #if 0 // TODO: implement these ? others ?
2606 extern const int wxEVT_GRID_CREATE_CELL
;
2607 extern const int wxEVT_GRID_CHANGE_LABELS
;
2608 extern const int wxEVT_GRID_CHANGE_SEL_LABEL
;
2610 #define EVT_GRID_CREATE_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2611 #define EVT_GRID_CHANGE_LABELS(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2612 #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 ),
2616 #endif // wxUSE_GRID
2617 #endif // _WX_GENERIC_GRID_H_