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)
8 // Copyright: (c) Michael Bedward
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID)
22 #pragma interface "grid.h"
27 #include "wx/scrolwin.h"
28 #include "wx/string.h"
29 #include "wx/scrolbar.h"
31 #include "wx/combobox.h"
32 #include "wx/dynarray.h"
35 // Default parameters for wxGrid
37 #define WXGRID_DEFAULT_NUMBER_ROWS 10
38 #define WXGRID_DEFAULT_NUMBER_COLS 10
40 #define WXGRID_DEFAULT_ROW_HEIGHT 25
42 #define WXGRID_DEFAULT_ROW_HEIGHT 30
44 #define WXGRID_DEFAULT_COL_WIDTH 80
45 #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
46 #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
47 #define WXGRID_LABEL_EDGE_ZONE 5
48 #define WXGRID_MIN_ROW_HEIGHT 15
49 #define WXGRID_MIN_COL_WIDTH 15
50 #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
52 // ----------------------------------------------------------------------------
53 // forward declarations
54 // ----------------------------------------------------------------------------
56 class WXDLLEXPORT wxGrid
;
57 class WXDLLEXPORT wxGridCellAttr
;
58 class WXDLLEXPORT wxGridCellAttrProviderData
;
59 class WXDLLEXPORT wxGridColLabelWindow
;
60 class WXDLLEXPORT wxGridCornerLabelWindow
;
61 class WXDLLEXPORT wxGridRowLabelWindow
;
62 class WXDLLEXPORT wxGridTableBase
;
63 class WXDLLEXPORT wxGridWindow
;
64 class WXDLLEXPORT wxGridTypeRegistry
;
66 class WXDLLEXPORT wxCheckBox
;
67 class WXDLLEXPORT wxTextCtrl
;
69 // ----------------------------------------------------------------------------
70 // wxGridCellRenderer: this class is responsible for actually drawing the cell
71 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
72 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
73 // view of all cells. This is an ABC, you will normally use one of the
74 // predefined derived classes or derive oyur own class from it.
75 // ----------------------------------------------------------------------------
77 class WXDLLEXPORT wxGridCellRenderer
80 // draw the given cell on the provided DC inside the given rectangle
81 // using the style specified by the attribute and the default or selected
82 // state corresponding to the isSelected value.
84 // this pure virtual function has a default implementation which will
85 // prepare the DC using the given attribute: it will draw the rectangle
86 // with the bg colour from attr and set the text colour and font
87 virtual void Draw(wxGrid
& grid
,
95 // the default renderer for the cells containing string data
96 class WXDLLEXPORT wxGridCellStringRenderer
: public wxGridCellRenderer
100 virtual void Draw(wxGrid
& grid
,
101 wxGridCellAttr
& attr
,
108 // renderer for boolean fields
109 class WXDLLEXPORT wxGridCellBoolRenderer
: public wxGridCellRenderer
113 // draw a check mark or nothing
114 virtual void Draw(wxGrid
& grid
,
115 wxGridCellAttr
& attr
,
122 // ----------------------------------------------------------------------------
123 // wxGridCellEditor: This class is responsible for providing and manipulating
124 // the in-place edit controls for the grid. Instances of wxGridCellEditor
125 // (actually, instances of derived classes since it is an ABC) can be
126 // associated with the cell attributes for individual cells, rows, columns, or
127 // even for the entire grid.
128 // ----------------------------------------------------------------------------
130 class WXDLLEXPORT wxGridCellEditor
134 virtual ~wxGridCellEditor();
136 bool IsCreated() { return m_control
!= NULL
; }
138 // Creates the actual edit control
139 virtual void Create(wxWindow
* parent
,
141 wxEvtHandler
* evtHandler
) = 0;
143 // Size and position the edit control
144 virtual void SetSize(const wxRect
& rect
);
146 // Show or hide the edit control, use the specified attributes to set
147 // colours/fonts for it
148 virtual void Show(bool show
, wxGridCellAttr
*attr
= (wxGridCellAttr
*)NULL
);
150 // Draws the part of the cell not occupied by the control: the base class
151 // version just fills it with background colour from the attribute
152 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
154 // Fetch the value from the table and prepare the edit control
155 // to begin editing. Set the focus to the edit control.
156 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
158 // Complete the editing of the current cell. If saveValue is
159 // true then send the new value back to the table. Returns true
160 // if the value has changed. If necessary, the control may be
162 virtual bool EndEdit(int row
, int col
, bool saveValue
, wxGrid
* grid
) = 0;
164 // Reset the value in the control back to its starting value
165 virtual void Reset() = 0;
167 // If the editor is enabled by pressing keys on the grid,
168 // this will be called to let the editor do something about
169 // that first key if desired.
170 virtual void StartingKey(wxKeyEvent
& event
);
172 // if the editor is enabled by clicking on the cell, this method will be
174 virtual void StartingClick();
176 // Some types of controls on some platforms may need some help
177 // with the Return key.
178 virtual void HandleReturn(wxKeyEvent
& event
);
181 virtual void Destroy();
184 // the control we show on screen
185 wxControl
* m_control
;
187 // if we change the colours/font of the control from the default ones, we
188 // must restore the default later and we save them here between calls to
189 // Show(TRUE) and Show(FALSE)
195 // the editor for string/text data
196 class WXDLLEXPORT wxGridCellTextEditor
: public wxGridCellEditor
199 wxGridCellTextEditor();
201 virtual void Create(wxWindow
* parent
,
203 wxEvtHandler
* evtHandler
);
205 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
207 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
208 virtual bool EndEdit(int row
, int col
, bool saveValue
, wxGrid
* grid
);
210 virtual void Reset();
211 virtual void StartingKey(wxKeyEvent
& event
);
212 virtual void HandleReturn(wxKeyEvent
& event
);
215 wxTextCtrl
*Text() const { return (wxTextCtrl
*)m_control
; }
218 wxString m_startValue
;
221 // the editor for boolean data
222 class WXDLLEXPORT wxGridCellBoolEditor
: public wxGridCellEditor
225 virtual void Create(wxWindow
* parent
,
227 wxEvtHandler
* evtHandler
);
229 virtual void SetSize(const wxRect
& rect
);
230 virtual void Show(bool show
, wxGridCellAttr
*attr
= (wxGridCellAttr
*)NULL
);
232 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
233 virtual bool EndEdit(int row
, int col
, bool saveValue
, wxGrid
* grid
);
235 virtual void Reset();
236 virtual void StartingClick();
239 wxCheckBox
*CBox() const { return (wxCheckBox
*)m_control
; }
245 // ----------------------------------------------------------------------------
246 // wxGridCellAttr: this class can be used to alter the cells appearance in
247 // the grid by changing their colour/font/... from default. An object of this
248 // class may be returned by wxGridTable::GetAttr().
249 // ----------------------------------------------------------------------------
251 class WXDLLEXPORT wxGridCellAttr
261 // VZ: considering the number of members wxGridCellAttr has now, this ctor
262 // seems to be pretty useless... may be we should just remove it?
263 wxGridCellAttr(const wxColour
& colText
,
264 const wxColour
& colBack
,
268 : m_colText(colText
), m_colBack(colBack
), m_font(font
)
271 SetAlignment(hAlign
, vAlign
);
274 // default copy ctor ok
276 // this class is ref counted: it is created with ref count of 1, so
277 // calling DecRef() once will delete it. Calling IncRef() allows to lock
278 // it until the matching DecRef() is called
279 void IncRef() { m_nRef
++; }
280 void DecRef() { if ( !--m_nRef
) delete this; }
281 void SafeIncRef() { if ( this ) IncRef(); }
282 void SafeDecRef() { if ( this ) DecRef(); }
285 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
286 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
287 void SetFont(const wxFont
& font
) { m_font
= font
; }
288 void SetAlignment(int hAlign
, int vAlign
)
293 void SetReadOnly(bool isReadOnly
= TRUE
) { m_isReadOnly
= isReadOnly
; }
295 // takes ownership of the pointer
296 void SetRenderer(wxGridCellRenderer
*renderer
)
297 { delete m_renderer
; m_renderer
= renderer
; }
298 void SetEditor(wxGridCellEditor
* editor
)
299 { delete m_editor
; m_editor
= editor
; }
302 bool HasTextColour() const { return m_colText
.Ok(); }
303 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
304 bool HasFont() const { return m_font
.Ok(); }
305 bool HasAlignment() const { return m_hAlign
|| m_vAlign
; }
306 bool HasRenderer() const { return m_renderer
!= NULL
; }
307 bool HasEditor() const { return m_editor
!= NULL
; }
309 const wxColour
& GetTextColour() const;
310 const wxColour
& GetBackgroundColour() const;
311 const wxFont
& GetFont() const;
312 void GetAlignment(int *hAlign
, int *vAlign
) const;
313 wxGridCellRenderer
*GetRenderer(wxGridCellRenderer
* def
) const;
314 wxGridCellEditor
*GetEditor(wxGridCellEditor
* def
) const;
316 bool IsReadOnly() const { return m_isReadOnly
; }
318 void SetDefAttr(wxGridCellAttr
* defAttr
) { m_defGridAttr
= defAttr
; }
321 // the common part of all ctors
326 m_isReadOnly
= FALSE
;
332 // the dtor is private because only DecRef() can delete us
333 ~wxGridCellAttr() { delete m_renderer
; delete m_editor
; }
335 // the ref count - when it goes to 0, we die
344 wxGridCellRenderer
* m_renderer
;
345 wxGridCellEditor
* m_editor
;
346 wxGridCellAttr
* m_defGridAttr
;
350 // suppress the stupid gcc warning about the class having private dtor and
352 friend class wxGridCellAttrDummyFriend
;
355 // ----------------------------------------------------------------------------
356 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
358 // ----------------------------------------------------------------------------
360 // implementation note: we separate it from wxGridTableBase because we wish to
361 // avoid deriving a new table class if possible, and sometimes it will be
362 // enough to just derive another wxGridCellAttrProvider instead
364 // the default implementation is reasonably efficient for the generic case,
365 // but you might still wish to implement your own for some specific situations
366 // if you have performance problems with the stock one
367 class WXDLLEXPORT wxGridCellAttrProvider
370 wxGridCellAttrProvider();
371 virtual ~wxGridCellAttrProvider();
373 // DecRef() must be called on the returned pointer
374 virtual wxGridCellAttr
*GetAttr(int row
, int col
) const;
376 // all these functions take ownership of the pointer, don't call DecRef()
378 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
379 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
380 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
382 // these functions must be called whenever some rows/cols are deleted
383 // because the internal data must be updated then
384 void UpdateAttrRows( size_t pos
, int numRows
);
385 void UpdateAttrCols( size_t pos
, int numCols
);
390 wxGridCellAttrProviderData
*m_data
;
393 //////////////////////////////////////////////////////////////////////
395 // Grid table classes
397 //////////////////////////////////////////////////////////////////////
400 class WXDLLEXPORT wxGridTableBase
: public wxObject
404 virtual ~wxGridTableBase();
406 // You must override these functions in a derived table class
408 virtual long GetNumberRows() = 0;
409 virtual long GetNumberCols() = 0;
410 virtual bool IsEmptyCell( int row
, int col
) = 0;
411 virtual wxString
GetValue( int row
, int col
) = 0;
412 virtual void SetValue( int row
, int col
, const wxString
& value
) = 0;
414 // Data type determination and value access
415 virtual wxString
GetTypeName( int row
, int col
);
416 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
417 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
419 virtual long GetValueAsLong( int row
, int col
);
420 virtual double GetValueAsDouble( int row
, int col
);
421 virtual bool GetValueAsBool( int row
, int col
);
423 virtual void SetValueAsLong( int row
, int col
, long value
);
424 virtual void SetValueAsDouble( int row
, int col
, double value
);
425 virtual void SetValueAsBool( int row
, int col
, bool value
);
427 // For user defined types
428 virtual void* GetValueAsCustom( int row
, int col
, const wxString
& typeName
);
429 virtual void SetValueAsCustom( int row
, int col
, const wxString
& typeName
, void* value
);
432 // Overriding these is optional
434 virtual void SetView( wxGrid
*grid
) { m_view
= grid
; }
435 virtual wxGrid
* GetView() const { return m_view
; }
437 virtual void Clear() {}
438 virtual bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
439 virtual bool AppendRows( size_t numRows
= 1 );
440 virtual bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
441 virtual bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
442 virtual bool AppendCols( size_t numCols
= 1 );
443 virtual bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
445 virtual wxString
GetRowLabelValue( int row
);
446 virtual wxString
GetColLabelValue( int col
);
447 virtual void SetRowLabelValue( int WXUNUSED(row
), const wxString
& ) {}
448 virtual void SetColLabelValue( int WXUNUSED(col
), const wxString
& ) {}
450 // Attribute handling
453 // give us the attr provider to use - we take ownership of the pointer
454 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
456 // get the currently used attr provider (may be NULL)
457 wxGridCellAttrProvider
*GetAttrProvider() const { return m_attrProvider
; }
459 // Does this table allow attributes? Default implementation creates
460 // a wxGridCellAttrProvider if necessary.
461 virtual bool CanHaveAttributes();
464 // change row/col number in attribute if needed
465 virtual void UpdateAttrRows( size_t pos
, int numRows
);
466 virtual void UpdateAttrCols( size_t pos
, int numCols
);
468 // by default forwarded to wxGridCellAttrProvider if any. May be
469 // overridden to handle attributes directly in the table.
470 virtual wxGridCellAttr
*GetAttr( int row
, int col
);
472 // these functions take ownership of the pointer
473 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
474 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
475 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
479 wxGridCellAttrProvider
*m_attrProvider
;
481 DECLARE_ABSTRACT_CLASS( wxGridTableBase
);
485 // ----------------------------------------------------------------------------
486 // wxGridTableMessage
487 // ----------------------------------------------------------------------------
489 // IDs for messages sent from grid table to view
491 enum wxGridTableRequest
493 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
494 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
495 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
496 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
497 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
498 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
499 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
500 wxGRIDTABLE_NOTIFY_COLS_DELETED
503 class WXDLLEXPORT wxGridTableMessage
506 wxGridTableMessage();
507 wxGridTableMessage( wxGridTableBase
*table
, int id
,
511 void SetTableObject( wxGridTableBase
*table
) { m_table
= table
; }
512 wxGridTableBase
* GetTableObject() const { return m_table
; }
513 void SetId( int id
) { m_id
= id
; }
514 int GetId() { return m_id
; }
515 void SetCommandInt( int comInt1
) { m_comInt1
= comInt1
; }
516 int GetCommandInt() { return m_comInt1
; }
517 void SetCommandInt2( int comInt2
) { m_comInt2
= comInt2
; }
518 int GetCommandInt2() { return m_comInt2
; }
521 wxGridTableBase
*m_table
;
529 // ------ wxGridStringArray
530 // A 2-dimensional array of strings for data values
533 WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString
, wxGridStringArray
);
537 // ------ wxGridStringTable
539 // Simplest type of data table for a grid for small tables of strings
540 // that are stored in memory
543 class WXDLLEXPORT wxGridStringTable
: public wxGridTableBase
547 wxGridStringTable( int numRows
, int numCols
);
548 ~wxGridStringTable();
550 // these are pure virtual in wxGridTableBase
552 long GetNumberRows();
553 long GetNumberCols();
554 wxString
GetValue( int row
, int col
);
555 void SetValue( int row
, int col
, const wxString
& s
);
556 bool IsEmptyCell( int row
, int col
);
558 // overridden functions from wxGridTableBase
561 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
562 bool AppendRows( size_t numRows
= 1 );
563 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
564 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
565 bool AppendCols( size_t numCols
= 1 );
566 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
568 void SetRowLabelValue( int row
, const wxString
& );
569 void SetColLabelValue( int col
, const wxString
& );
570 wxString
GetRowLabelValue( int row
);
571 wxString
GetColLabelValue( int col
);
574 wxGridStringArray m_data
;
576 // These only get used if you set your own labels, otherwise the
577 // GetRow/ColLabelValue functions return wxGridTableBase defaults
579 wxArrayString m_rowLabels
;
580 wxArrayString m_colLabels
;
582 DECLARE_DYNAMIC_CLASS( wxGridStringTable
)
587 // ============================================================================
589 // ============================================================================
591 // ----------------------------------------------------------------------------
592 // wxGridCellCoords: location of a cell in the grid
593 // ----------------------------------------------------------------------------
595 class WXDLLEXPORT wxGridCellCoords
598 wxGridCellCoords() { m_row
= m_col
= -1; }
599 wxGridCellCoords( int r
, int c
) { m_row
= r
; m_col
= c
; }
601 // default copy ctor is ok
603 long GetRow() const { return m_row
; }
604 void SetRow( long n
) { m_row
= n
; }
605 long GetCol() const { return m_col
; }
606 void SetCol( long n
) { m_col
= n
; }
607 void Set( long row
, long col
) { m_row
= row
; m_col
= col
; }
609 wxGridCellCoords
& operator=( const wxGridCellCoords
& other
)
611 if ( &other
!= this )
619 bool operator==( const wxGridCellCoords
& other
) const
621 return (m_row
== other
.m_row
&& m_col
== other
.m_col
);
624 bool operator!=( const wxGridCellCoords
& other
) const
626 return (m_row
!= other
.m_row
|| m_col
!= other
.m_col
);
629 bool operator!() const
631 return (m_row
== -1 && m_col
== -1 );
640 // For comparisons...
642 extern wxGridCellCoords wxGridNoCellCoords
;
643 extern wxRect wxGridNoCellRect
;
645 // An array of cell coords...
647 WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords
, wxGridCellCoordsArray
);
649 // ----------------------------------------------------------------------------
651 // ----------------------------------------------------------------------------
653 class WXDLLEXPORT wxGrid
: public wxScrolledWindow
661 wxGrid( wxWindow
*parent
,
663 const wxPoint
& pos
= wxDefaultPosition
,
664 const wxSize
& size
= wxDefaultSize
,
666 const wxString
& name
= wxPanelNameStr
);
670 bool CreateGrid( int numRows
, int numCols
);
673 // ------ grid dimensions
675 int GetNumberRows() { return m_numRows
; }
676 int GetNumberCols() { return m_numCols
; }
679 // ------ display update functions
681 void CalcRowLabelsExposed( wxRegion
& reg
);
683 void CalcColLabelsExposed( wxRegion
& reg
);
684 void CalcCellsExposed( wxRegion
& reg
);
687 // ------ event handlers
689 void ProcessRowLabelMouseEvent( wxMouseEvent
& event
);
690 void ProcessColLabelMouseEvent( wxMouseEvent
& event
);
691 void ProcessCornerLabelMouseEvent( wxMouseEvent
& event
);
692 void ProcessGridCellMouseEvent( wxMouseEvent
& event
);
693 bool ProcessTableMessage( wxGridTableMessage
& );
695 void DoEndDragResizeRow();
696 void DoEndDragResizeCol();
698 wxGridTableBase
* GetTable() const { return m_table
; }
699 bool SetTable( wxGridTableBase
*table
, bool takeOwnership
=FALSE
);
702 bool InsertRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
703 bool AppendRows( int numRows
= 1, bool updateLabels
=TRUE
);
704 bool DeleteRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
705 bool InsertCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
706 bool AppendCols( int numCols
= 1, bool updateLabels
=TRUE
);
707 bool DeleteCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
709 void DrawGridCellArea( wxDC
& dc
);
710 void DrawCellBorder( wxDC
& dc
, const wxGridCellCoords
& );
711 void DrawAllGridLines( wxDC
& dc
, const wxRegion
& reg
);
712 void DrawCell( wxDC
& dc
, const wxGridCellCoords
& );
713 void DrawHighlight(wxDC
& dc
);
715 // this function is called when the current cell highlight must be redrawn
716 // and may be overridden by the user
717 virtual void DrawCellHighlight( wxDC
& dc
, const wxGridCellAttr
*attr
);
719 void DrawRowLabels( wxDC
& dc
);
720 void DrawRowLabel( wxDC
& dc
, int row
);
722 void DrawColLabels( wxDC
& dc
);
723 void DrawColLabel( wxDC
& dc
, int col
);
726 // ------ Cell text drawing functions
728 void DrawTextRectangle( wxDC
& dc
, const wxString
&, const wxRect
&,
729 int horizontalAlignment
= wxLEFT
,
730 int verticalAlignment
= wxTOP
);
732 // Split a string containing newline chararcters into an array of
733 // strings and return the number of lines
735 void StringToLines( const wxString
& value
, wxArrayString
& lines
);
737 void GetTextBoxSize( wxDC
& dc
,
738 wxArrayString
& lines
,
739 long *width
, long *height
);
743 // Code that does a lot of grid modification can be enclosed
744 // between BeginBatch() and EndBatch() calls to avoid screen
747 void BeginBatch() { m_batchCount
++; }
748 void EndBatch() { if ( m_batchCount
> 0 ) m_batchCount
--; }
749 int GetBatchCount() { return m_batchCount
; }
752 // ------ edit control functions
754 bool IsEditable() { return m_editable
; }
755 void EnableEditing( bool edit
);
757 void EnableCellEditControl( bool enable
= TRUE
);
758 void DisableCellEditControl() { EnableCellEditControl(FALSE
); }
759 bool CanEnableCellControl() const;
760 bool IsCellEditControlEnabled() const;
762 bool IsCurrentCellReadOnly() const;
764 void ShowCellEditControl();
765 void HideCellEditControl();
766 void SetEditControlValue( const wxString
& s
= wxEmptyString
);
767 void SaveEditControlValue();
770 // ------ grid location functions
771 // Note that all of these functions work with the logical coordinates of
772 // grid cells and labels so you will need to convert from device
773 // coordinates for mouse events etc.
775 void XYToCell( int x
, int y
, wxGridCellCoords
& );
779 int YToEdgeOfRow( int y
);
780 int XToEdgeOfCol( int x
);
782 wxRect
CellToRect( int row
, int col
);
783 wxRect
CellToRect( const wxGridCellCoords
& coords
)
784 { return CellToRect( coords
.GetRow(), coords
.GetCol() ); }
786 int GetGridCursorRow() { return m_currentCellCoords
.GetRow(); }
787 int GetGridCursorCol() { return m_currentCellCoords
.GetCol(); }
789 // check to see if a cell is either wholly visible (the default arg) or
790 // at least partially visible in the grid window
792 bool IsVisible( int row
, int col
, bool wholeCellVisible
= TRUE
);
793 bool IsVisible( const wxGridCellCoords
& coords
, bool wholeCellVisible
= TRUE
)
794 { return IsVisible( coords
.GetRow(), coords
.GetCol(), wholeCellVisible
); }
795 void MakeCellVisible( int row
, int col
);
796 void MakeCellVisible( const wxGridCellCoords
& coords
)
797 { MakeCellVisible( coords
.GetRow(), coords
.GetCol() ); }
800 // ------ grid cursor movement functions
802 void SetGridCursor( int row
, int col
)
803 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
806 bool MoveCursorDown();
807 bool MoveCursorLeft();
808 bool MoveCursorRight();
811 bool MoveCursorUpBlock();
812 bool MoveCursorDownBlock();
813 bool MoveCursorLeftBlock();
814 bool MoveCursorRightBlock();
817 // ------ label and gridline formatting
819 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH
; }
820 int GetRowLabelSize() { return m_rowLabelWidth
; }
821 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT
; }
822 int GetColLabelSize() { return m_colLabelHeight
; }
823 wxColour
GetLabelBackgroundColour() { return m_labelBackgroundColour
; }
824 wxColour
GetLabelTextColour() { return m_labelTextColour
; }
825 wxFont
GetLabelFont() { return m_labelFont
; }
826 void GetRowLabelAlignment( int *horiz
, int *vert
);
827 void GetColLabelAlignment( int *horiz
, int *vert
);
828 wxString
GetRowLabelValue( int row
);
829 wxString
GetColLabelValue( int col
);
830 wxColour
GetGridLineColour() { return m_gridLineColour
; }
832 void SetRowLabelSize( int width
);
833 void SetColLabelSize( int height
);
834 void SetLabelBackgroundColour( const wxColour
& );
835 void SetLabelTextColour( const wxColour
& );
836 void SetLabelFont( const wxFont
& );
837 void SetRowLabelAlignment( int horiz
, int vert
);
838 void SetColLabelAlignment( int horiz
, int vert
);
839 void SetRowLabelValue( int row
, const wxString
& );
840 void SetColLabelValue( int col
, const wxString
& );
841 void SetGridLineColour( const wxColour
& );
843 // this sets the specified attribute for all cells in this row/col
844 void SetRowAttr(int row
, wxGridCellAttr
*attr
);
845 void SetColAttr(int col
, wxGridCellAttr
*attr
);
847 void EnableGridLines( bool enable
= TRUE
);
848 bool GridLinesEnabled() { return m_gridLinesEnabled
; }
850 // ------ row and col formatting
852 int GetDefaultRowSize();
853 int GetRowSize( int row
);
854 int GetDefaultColSize();
855 int GetColSize( int col
);
856 wxColour
GetDefaultCellBackgroundColour();
857 wxColour
GetCellBackgroundColour( int row
, int col
);
858 wxColour
GetDefaultCellTextColour();
859 wxColour
GetCellTextColour( int row
, int col
);
860 wxFont
GetDefaultCellFont();
861 wxFont
GetCellFont( int row
, int col
);
862 void GetDefaultCellAlignment( int *horiz
, int *vert
);
863 void GetCellAlignment( int row
, int col
, int *horiz
, int *vert
);
865 void SetDefaultRowSize( int height
, bool resizeExistingRows
= FALSE
);
866 void SetRowSize( int row
, int height
);
867 void SetDefaultColSize( int width
, bool resizeExistingCols
= FALSE
);
869 void SetColSize( int col
, int width
);
871 // column won't be resized to be lesser width - this must be called during
872 // the grid creation because it won't resize the column if it's already
873 // narrower than the minimal width
874 void SetColMinimalWidth( int col
, int width
);
876 void SetDefaultCellBackgroundColour( const wxColour
& );
877 void SetCellBackgroundColour( int row
, int col
, const wxColour
& );
878 void SetDefaultCellTextColour( const wxColour
& );
880 void SetCellTextColour( int row
, int col
, const wxColour
& );
881 void SetDefaultCellFont( const wxFont
& );
882 void SetCellFont( int row
, int col
, const wxFont
& );
883 void SetDefaultCellAlignment( int horiz
, int vert
);
884 void SetCellAlignment( int row
, int col
, int horiz
, int vert
);
886 // takes ownership of the pointer
887 void SetDefaultRenderer(wxGridCellRenderer
*renderer
);
888 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
*renderer
);
889 wxGridCellRenderer
*GetDefaultRenderer() const;
890 wxGridCellRenderer
* GetCellRenderer(int row
, int col
);
892 // takes ownership of the pointer
893 void SetDefaultEditor(wxGridCellEditor
*editor
);
894 void SetCellEditor(int row
, int col
, wxGridCellEditor
*editor
);
895 wxGridCellEditor
*GetDefaultEditor() const;
896 wxGridCellEditor
* GetCellEditor(int row
, int col
);
900 // ------ cell value accessors
902 wxString
GetCellValue( int row
, int col
)
906 return m_table
->GetValue( row
, col
);
910 return wxEmptyString
;
914 wxString
GetCellValue( const wxGridCellCoords
& coords
)
915 { return GetCellValue( coords
.GetRow(), coords
.GetCol() ); }
917 void SetCellValue( int row
, int col
, const wxString
& s
);
918 void SetCellValue( const wxGridCellCoords
& coords
, const wxString
& s
)
919 { SetCellValue( coords
.GetRow(), coords
.GetCol(), s
); }
921 // returns TRUE if the cell can't be edited
922 bool IsReadOnly(int row
, int col
) const;
924 // make the cell editable/readonly
925 void SetReadOnly(int row
, int col
, bool isReadOnly
= TRUE
);
927 // ------ selections of blocks of cells
929 void SelectRow( int row
, bool addToSelected
= FALSE
);
930 void SelectCol( int col
, bool addToSelected
= FALSE
);
932 void SelectBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
);
934 void SelectBlock( const wxGridCellCoords
& topLeft
,
935 const wxGridCellCoords
& bottomRight
)
936 { SelectBlock( topLeft
.GetRow(), topLeft
.GetCol(),
937 bottomRight
.GetRow(), bottomRight
.GetCol() ); }
942 { return ( m_selectedTopLeft
!= wxGridNoCellCoords
&&
943 m_selectedBottomRight
!= wxGridNoCellCoords
);
946 void ClearSelection();
948 bool IsInSelection( int row
, int col
)
949 { return ( IsSelection() &&
950 row
>= m_selectedTopLeft
.GetRow() &&
951 col
>= m_selectedTopLeft
.GetCol() &&
952 row
<= m_selectedBottomRight
.GetRow() &&
953 col
<= m_selectedBottomRight
.GetCol() );
956 bool IsInSelection( const wxGridCellCoords
& coords
)
957 { return IsInSelection( coords
.GetRow(), coords
.GetCol() ); }
959 void GetSelection( int* topRow
, int* leftCol
, int* bottomRow
, int* rightCol
)
961 // these will all be -1 if there is no selected block
963 *topRow
= m_selectedTopLeft
.GetRow();
964 *leftCol
= m_selectedTopLeft
.GetCol();
965 *bottomRow
= m_selectedBottomRight
.GetRow();
966 *rightCol
= m_selectedBottomRight
.GetCol();
970 // This function returns the rectangle that encloses the block of cells
971 // limited by TopLeft and BottomRight cell in device coords and clipped
972 // to the client size of the grid window.
974 wxRect
BlockToDeviceRect( const wxGridCellCoords
& topLeft
,
975 const wxGridCellCoords
& bottomRight
);
977 // This function returns the rectangle that encloses the selected cells
978 // in device coords and clipped to the client size of the grid window.
980 wxRect
SelectionToDeviceRect()
982 return BlockToDeviceRect( m_selectedTopLeft
,
983 m_selectedBottomRight
);
986 // Access or update the selection fore/back colours
987 wxColour
GetSelectionBackground() const
988 { return m_selectionBackground
; }
989 wxColour
GetSelectionForeground() const
990 { return m_selectionForeground
; }
992 void SetSelectionBackground(const wxColour
& c
) { m_selectionBackground
= c
; }
993 void SetSelectionForeground(const wxColour
& c
) { m_selectionForeground
= c
; }
996 // Methods for a registry for mapping data types to Renderers/Editors
997 void RegisterDataType(const wxString
& typeName
,
998 wxGridCellRenderer
* renderer
,
999 wxGridCellEditor
* editor
);
1000 wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
);
1001 wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
);
1002 wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
);
1003 wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
);
1007 // ------ For compatibility with previous wxGrid only...
1009 // ************************************************
1010 // ** Don't use these in new code because they **
1011 // ** are liable to disappear in a future **
1013 // ************************************************
1016 wxGrid( wxWindow
*parent
,
1017 int x
= -1, int y
= -1, int w
= -1, int h
= -1,
1019 const wxString
& name
= wxPanelNameStr
)
1020 : wxScrolledWindow( parent
, -1, wxPoint(x
,y
), wxSize(w
,h
), style
, name
)
1025 void SetCellValue( const wxString
& val
, int row
, int col
)
1026 { SetCellValue( row
, col
, val
); }
1028 void UpdateDimensions()
1029 { CalcDimensions(); }
1031 int GetRows() { return GetNumberRows(); }
1032 int GetCols() { return GetNumberCols(); }
1033 int GetCursorRow() { return GetGridCursorRow(); }
1034 int GetCursorColumn() { return GetGridCursorCol(); }
1036 int GetScrollPosX() { return 0; }
1037 int GetScrollPosY() { return 0; }
1039 void SetScrollX( int x
) { }
1040 void SetScrollY( int y
) { }
1042 void SetColumnWidth( int col
, int width
)
1043 { SetColSize( col
, width
); }
1045 int GetColumnWidth( int col
)
1046 { return GetColSize( col
); }
1048 void SetRowHeight( int row
, int height
)
1049 { SetRowSize( row
, height
); }
1051 // GetRowHeight() is below
1053 int GetViewHeight() // returned num whole rows visible
1056 int GetViewWidth() // returned num whole cols visible
1059 void SetLabelSize( int orientation
, int sz
)
1061 if ( orientation
== wxHORIZONTAL
)
1062 SetColLabelSize( sz
);
1064 SetRowLabelSize( sz
);
1067 int GetLabelSize( int orientation
)
1069 if ( orientation
== wxHORIZONTAL
)
1070 return GetColLabelSize();
1072 return GetRowLabelSize();
1075 void SetLabelAlignment( int orientation
, int align
)
1077 if ( orientation
== wxHORIZONTAL
)
1078 SetColLabelAlignment( align
, -1 );
1080 SetRowLabelAlignment( align
, -1 );
1083 int GetLabelAlignment( int orientation
, int WXUNUSED(align
) )
1086 if ( orientation
== wxHORIZONTAL
)
1088 GetColLabelAlignment( &h
, &v
);
1093 GetRowLabelAlignment( &h
, &v
);
1098 void SetLabelValue( int orientation
, const wxString
& val
, int pos
)
1100 if ( orientation
== wxHORIZONTAL
)
1101 SetColLabelValue( pos
, val
);
1103 SetRowLabelValue( pos
, val
);
1106 wxString
GetLabelValue( int orientation
, int pos
)
1108 if ( orientation
== wxHORIZONTAL
)
1109 return GetColLabelValue( pos
);
1111 return GetRowLabelValue( pos
);
1114 wxFont
GetCellTextFont() const
1115 { return m_defaultCellAttr
->GetFont(); }
1117 wxFont
GetCellTextFont(int WXUNUSED(row
), int WXUNUSED(col
)) const
1118 { return m_defaultCellAttr
->GetFont(); }
1120 void SetCellTextFont(const wxFont
& fnt
)
1121 { SetDefaultCellFont( fnt
); }
1123 void SetCellTextFont(const wxFont
& fnt
, int row
, int col
)
1124 { SetCellFont( row
, col
, fnt
); }
1126 void SetCellTextColour(const wxColour
& val
, int row
, int col
)
1127 { SetCellTextColour( row
, col
, val
); }
1129 void SetCellTextColour(const wxColour
& col
)
1130 { SetDefaultCellTextColour( col
); }
1132 void SetCellBackgroundColour(const wxColour
& col
)
1133 { SetDefaultCellBackgroundColour( col
); }
1135 void SetCellBackgroundColour(const wxColour
& colour
, int row
, int col
)
1136 { SetCellBackgroundColour( row
, col
, colour
); }
1138 bool GetEditable() { return IsEditable(); }
1139 void SetEditable( bool edit
= TRUE
) { EnableEditing( edit
); }
1140 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
1142 void SetEditInPlace(bool edit
= TRUE
) { }
1144 void SetCellAlignment( int align
, int row
, int col
)
1145 { SetCellAlignment(row
, col
, align
, wxCENTER
); }
1146 void SetCellAlignment( int WXUNUSED(align
) ) {}
1147 void SetCellBitmap(wxBitmap
*WXUNUSED(bitmap
), int WXUNUSED(row
), int WXUNUSED(col
))
1149 void SetDividerPen(const wxPen
& WXUNUSED(pen
)) { }
1150 wxPen
& GetDividerPen() const { return wxNullPen
; }
1151 void OnActivate(bool WXUNUSED(active
)) {}
1153 // ******** End of compatibility functions **********
1157 // ------ control IDs
1158 enum { wxGRID_CELLCTRL
= 2000,
1161 // ------ control types
1162 enum { wxGRID_TEXTCTRL
= 2100,
1167 // for wxGridCellBoolEditor
1168 wxWindow
*GetGridWindow() const;
1174 wxGridWindow
*m_gridWin
;
1175 wxGridRowLabelWindow
*m_rowLabelWin
;
1176 wxGridColLabelWindow
*m_colLabelWin
;
1177 wxGridCornerLabelWindow
*m_cornerLabelWin
;
1179 wxGridTableBase
*m_table
;
1190 wxGridCellCoords m_currentCellCoords
;
1192 wxGridCellCoords m_selectedTopLeft
;
1193 wxGridCellCoords m_selectedBottomRight
;
1194 wxColour m_selectionBackground
;
1195 wxColour m_selectionForeground
;
1197 // NB: *never* access m_row/col arrays directly because they are created
1198 // on demand, *always* use accessor functions instead!
1200 // init the m_rowHeights/Bottoms arrays with default values
1201 void InitRowHeights();
1203 int m_defaultRowHeight
;
1204 wxArrayInt m_rowHeights
;
1205 wxArrayInt m_rowBottoms
;
1207 // init the m_colWidths/Rights arrays
1208 void InitColWidths();
1210 int m_defaultColWidth
;
1211 wxArrayInt m_colWidths
;
1212 wxArrayInt m_colRights
;
1214 // get the col/row coords
1215 int GetColWidth(int col
) const;
1216 int GetColLeft(int col
) const;
1217 int GetColRight(int col
) const;
1219 // this function must be public for compatibility...
1221 int GetRowHeight(int row
) const;
1224 int GetRowTop(int row
) const;
1225 int GetRowBottom(int row
) const;
1227 int m_rowLabelWidth
;
1228 int m_colLabelHeight
;
1230 wxColour m_labelBackgroundColour
;
1231 wxColour m_labelTextColour
;
1234 int m_rowLabelHorizAlign
;
1235 int m_rowLabelVertAlign
;
1236 int m_colLabelHorizAlign
;
1237 int m_colLabelVertAlign
;
1239 bool m_defaultRowLabelValues
;
1240 bool m_defaultColLabelValues
;
1242 wxColour m_gridLineColour
;
1243 bool m_gridLinesEnabled
;
1245 // if a column has a minimal width, it will be the value for it in this
1247 wxHashTable m_colMinWidths
;
1249 // get the minimal width of the given column
1250 int GetColMinimalWidth(int col
) const;
1252 // do we have some place to store attributes in?
1253 bool CanHaveAttributes();
1255 // returns the attribute we may modify in place: a new one if this cell
1256 // doesn't have any yet or the existing one if it does
1258 // DecRef() must be called on the returned pointer, as usual
1259 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
1261 // cell attribute cache (currently we only cache 1, may be will do
1262 // more/better later)
1266 wxGridCellAttr
*attr
;
1269 // invalidates the attribute cache
1270 void ClearAttrCache();
1272 // adds an attribute to cache
1273 void CacheAttr(int row
, int col
, wxGridCellAttr
*attr
) const;
1275 // looks for an attr in cache, returns TRUE if found
1276 bool LookupAttr(int row
, int col
, wxGridCellAttr
**attr
) const;
1278 // looks for the attr in cache, if not found asks the table and caches the
1280 wxGridCellAttr
*GetCellAttr(int row
, int col
) const;
1281 wxGridCellAttr
*GetCellAttr(const wxGridCellCoords
& coords
)
1282 { return GetCellAttr( coords
.GetRow(), coords
.GetCol() ); }
1284 // the default cell attr object for cells that don't have their own
1285 wxGridCellAttr
* m_defaultCellAttr
;
1288 wxGridCellCoordsArray m_cellsExposed
;
1289 wxArrayInt m_rowsExposed
;
1290 wxArrayInt m_colsExposed
;
1291 wxArrayInt m_rowLabelsExposed
;
1292 wxArrayInt m_colLabelsExposed
;
1298 wxGridTypeRegistry
* m_typeRegistry
;
1302 WXGRID_CURSOR_SELECT_CELL
,
1303 WXGRID_CURSOR_RESIZE_ROW
,
1304 WXGRID_CURSOR_RESIZE_COL
,
1305 WXGRID_CURSOR_SELECT_ROW
,
1306 WXGRID_CURSOR_SELECT_COL
1309 // this method not only sets m_cursorMode but also sets the correct cursor
1310 // for the given mode and, if captureMouse is not FALSE releases the mouse
1311 // if it was captured and captures it if it must be captured
1313 // for this to work, you should always use it and not set m_cursorMode
1315 void ChangeCursorMode(CursorMode mode
,
1316 wxWindow
*win
= (wxWindow
*)NULL
,
1317 bool captureMouse
= TRUE
);
1319 wxWindow
*m_winCapture
; // the window which captured the mouse
1320 CursorMode m_cursorMode
;
1325 wxPoint m_startDragPos
;
1327 bool m_waitForSlowClick
;
1329 wxGridCellCoords m_selectionStart
;
1331 wxCursor m_rowResizeCursor
;
1332 wxCursor m_colResizeCursor
;
1334 bool m_editable
; // applies to whole grid
1335 bool m_cellEditCtrlEnabled
; // is in-place edit currently shown?
1340 void CalcDimensions();
1341 void CalcWindowSizes();
1342 bool Redimension( wxGridTableMessage
& );
1345 bool SendEvent( const wxEventType
, int row
, int col
, wxMouseEvent
& );
1346 bool SendEvent( const wxEventType
, int row
, int col
);
1347 bool SendEvent( const wxEventType type
)
1349 return SendEvent(type
,
1350 m_currentCellCoords
.GetRow(),
1351 m_currentCellCoords
.GetCol());
1354 void OnPaint( wxPaintEvent
& );
1355 void OnSize( wxSizeEvent
& );
1356 void OnKeyDown( wxKeyEvent
& );
1357 void OnEraseBackground( wxEraseEvent
& );
1360 void SetCurrentCell( const wxGridCellCoords
& coords
);
1361 void SetCurrentCell( int row
, int col
)
1362 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1365 // ------ functions to get/send data (see also public functions)
1367 bool GetModelValues();
1368 bool SetModelValues();
1371 DECLARE_DYNAMIC_CLASS( wxGrid
)
1372 DECLARE_EVENT_TABLE()
1377 // ----------------------------------------------------------------------------
1378 // Grid event class and event types
1379 // ----------------------------------------------------------------------------
1381 class WXDLLEXPORT wxGridEvent
: public wxNotifyEvent
1385 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
1386 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1390 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
1391 int row
=-1, int col
=-1, int x
=-1, int y
=-1,
1392 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1394 virtual int GetRow() { return m_row
; }
1395 virtual int GetCol() { return m_col
; }
1396 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1397 bool ControlDown() { return m_control
; }
1398 bool MetaDown() { return m_meta
; }
1399 bool ShiftDown() { return m_shift
; }
1400 bool AltDown() { return m_alt
; }
1412 DECLARE_DYNAMIC_CLASS(wxGridEvent
)
1415 class WXDLLEXPORT wxGridSizeEvent
: public wxNotifyEvent
1419 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1420 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1424 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
1425 int rowOrCol
=-1, int x
=-1, int y
=-1,
1426 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1428 int GetRowOrCol() { return m_rowOrCol
; }
1429 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1430 bool ControlDown() { return m_control
; }
1431 bool MetaDown() { return m_meta
; }
1432 bool ShiftDown() { return m_shift
; }
1433 bool AltDown() { return m_alt
; }
1444 DECLARE_DYNAMIC_CLASS(wxGridSizeEvent
)
1448 class WXDLLEXPORT wxGridRangeSelectEvent
: public wxNotifyEvent
1451 wxGridRangeSelectEvent()
1454 m_topLeft
= wxGridNoCellCoords
;
1455 m_bottomRight
= wxGridNoCellCoords
;
1462 wxGridRangeSelectEvent(int id
, wxEventType type
, wxObject
* obj
,
1463 const wxGridCellCoords
& topLeft
,
1464 const wxGridCellCoords
& bottomRight
,
1465 bool control
=FALSE
, bool shift
=FALSE
,
1466 bool alt
=FALSE
, bool meta
=FALSE
);
1468 wxGridCellCoords
GetTopLeftCoords() { return m_topLeft
; }
1469 wxGridCellCoords
GetBottomRightCoords() { return m_bottomRight
; }
1470 int GetTopRow() { return m_topLeft
.GetRow(); }
1471 int GetBottomRow() { return m_bottomRight
.GetRow(); }
1472 int GetLeftCol() { return m_topLeft
.GetCol(); }
1473 int GetRightCol() { return m_bottomRight
.GetCol(); }
1474 bool ControlDown() { return m_control
; }
1475 bool MetaDown() { return m_meta
; }
1476 bool ShiftDown() { return m_shift
; }
1477 bool AltDown() { return m_alt
; }
1480 wxGridCellCoords m_topLeft
;
1481 wxGridCellCoords m_bottomRight
;
1487 DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent
)
1490 // TODO move to wx/event.h
1491 const wxEventType wxEVT_GRID_CELL_LEFT_CLICK
= wxEVT_FIRST
+ 1580;
1492 const wxEventType wxEVT_GRID_CELL_RIGHT_CLICK
= wxEVT_FIRST
+ 1581;
1493 const wxEventType wxEVT_GRID_CELL_LEFT_DCLICK
= wxEVT_FIRST
+ 1582;
1494 const wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK
= wxEVT_FIRST
+ 1583;
1495 const wxEventType wxEVT_GRID_LABEL_LEFT_CLICK
= wxEVT_FIRST
+ 1584;
1496 const wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK
= wxEVT_FIRST
+ 1585;
1497 const wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK
= wxEVT_FIRST
+ 1586;
1498 const wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK
= wxEVT_FIRST
+ 1587;
1499 const wxEventType wxEVT_GRID_ROW_SIZE
= wxEVT_FIRST
+ 1588;
1500 const wxEventType wxEVT_GRID_COL_SIZE
= wxEVT_FIRST
+ 1589;
1501 const wxEventType wxEVT_GRID_RANGE_SELECT
= wxEVT_FIRST
+ 1590;
1502 const wxEventType wxEVT_GRID_CELL_CHANGE
= wxEVT_FIRST
+ 1591;
1503 const wxEventType wxEVT_GRID_SELECT_CELL
= wxEVT_FIRST
+ 1592;
1504 const wxEventType wxEVT_GRID_EDITOR_SHOWN
= wxEVT_FIRST
+ 1593;
1505 const wxEventType wxEVT_GRID_EDITOR_HIDDEN
= wxEVT_FIRST
+ 1594;
1508 typedef void (wxEvtHandler::*wxGridEventFunction
)(wxGridEvent
&);
1509 typedef void (wxEvtHandler::*wxGridSizeEventFunction
)(wxGridSizeEvent
&);
1510 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction
)(wxGridRangeSelectEvent
&);
1512 #define EVT_GRID_CELL_LEFT_CLICK(fn) { wxEVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1513 #define EVT_GRID_CELL_RIGHT_CLICK(fn) { wxEVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1514 #define EVT_GRID_CELL_LEFT_DCLICK(fn) { wxEVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1515 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) { wxEVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1516 #define EVT_GRID_LABEL_LEFT_CLICK(fn) { wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1517 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) { wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1518 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) { wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1519 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) { wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1520 #define EVT_GRID_ROW_SIZE(fn) { wxEVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1521 #define EVT_GRID_COL_SIZE(fn) { wxEVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1522 #define EVT_GRID_RANGE_SELECT(fn) { wxEVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL },
1523 #define EVT_GRID_CELL_CHANGE(fn) { wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1524 #define EVT_GRID_SELECT_CELL(fn) { wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1525 #define EVT_GRID_EDITOR_SHOWN(fn) { wxEVT_GRID_EDITOR_SHOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1526 #define EVT_GRID_EDITOR_HIDDEN(fn) { wxEVT_GRID_EDITOR_HIDDEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1529 #if 0 // TODO: implement these ? others ?
1531 const wxEventType wxEVT_GRID_CREATE_CELL
= wxEVT_FIRST
+ 1576;
1532 const wxEventType wxEVT_GRID_CHANGE_LABELS
= wxEVT_FIRST
+ 1577;
1533 const wxEventType wxEVT_GRID_CHANGE_SEL_LABEL
= wxEVT_FIRST
+ 1578;
1535 #define EVT_GRID_CREATE_CELL(fn) { wxEVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1536 #define EVT_GRID_CHANGE_LABELS(fn) { wxEVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1537 #define EVT_GRID_CHANGE_SEL_LABEL(fn) { wxEVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1541 #endif // #ifndef __WXGRID_H__
1543 #endif // ifndef wxUSE_NEW_GRID