]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/grid.h
added wxTempFile::Flush() (dedicated to Theodore Ts'o and Ext4)
[wxWidgets.git] / include / wx / generic / grid.h
CommitLineData
f85afd4e 1/////////////////////////////////////////////////////////////////////////////
43947979 2// Name: wx/generic/grid.h
f85afd4e
MB
3// Purpose: wxGrid and related classes
4// Author: Michael Bedward (based on code by Julian Smart, Robin Dunn)
d4175745 5// Modified by: Santiago Palacios
f85afd4e
MB
6// Created: 1/08/1999
7// RCS-ID: $Id$
8// Copyright: (c) Michael Bedward
65571936 9// Licence: wxWindows licence
f85afd4e
MB
10/////////////////////////////////////////////////////////////////////////////
11
df9fac6d
PC
12#ifndef _WX_GENERIC_GRID_H_
13#define _WX_GENERIC_GRID_H_
14
15#include "wx/defs.h"
16
17#if wxUSE_GRID
f85afd4e 18
82edfbe7
VZ
19#include "wx/hashmap.h"
20
2d66e025 21#include "wx/scrolwin.h"
f85afd4e 22
816be743
VZ
23// ----------------------------------------------------------------------------
24// constants
25// ----------------------------------------------------------------------------
26
23318a53 27extern WXDLLIMPEXP_DATA_ADV(const char) wxGridNameStr[];
61961a3c 28
f85afd4e
MB
29// Default parameters for wxGrid
30//
31#define WXGRID_DEFAULT_NUMBER_ROWS 10
32#define WXGRID_DEFAULT_NUMBER_COLS 10
e6002250 33#if defined(__WXMSW__) || defined(__WXGTK20__)
f85afd4e
MB
34#define WXGRID_DEFAULT_ROW_HEIGHT 25
35#else
36#define WXGRID_DEFAULT_ROW_HEIGHT 30
37#endif // __WXMSW__
38#define WXGRID_DEFAULT_COL_WIDTH 80
39#define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
40#define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
f1567cdd 41#define WXGRID_LABEL_EDGE_ZONE 2
f85afd4e
MB
42#define WXGRID_MIN_ROW_HEIGHT 15
43#define WXGRID_MIN_COL_WIDTH 15
44#define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
f85afd4e 45
816be743
VZ
46// type names for grid table values
47#define wxGRID_VALUE_STRING _T("string")
48#define wxGRID_VALUE_BOOL _T("bool")
49#define wxGRID_VALUE_NUMBER _T("long")
50#define wxGRID_VALUE_FLOAT _T("double")
c4608a8a 51#define wxGRID_VALUE_CHOICE _T("choice")
816be743
VZ
52
53#define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
54#define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
55
733f486a
VZ
56// magic constant which tells (to some functions) to automatically calculate
57// the appropriate size
58#define wxGRID_AUTOSIZE (-1)
59
60// many wxGrid methods work either with columns or rows, this enum is used for
61// the parameter indicating which one should it be
62enum wxGridDirection
63{
64 wxGRID_COLUMN,
05cc594a 65 wxGRID_ROW
733f486a
VZ
66};
67
b99be8fb
VZ
68// ----------------------------------------------------------------------------
69// forward declarations
70// ----------------------------------------------------------------------------
71
b5dbe15d
VS
72class WXDLLIMPEXP_FWD_ADV wxGrid;
73class WXDLLIMPEXP_FWD_ADV wxGridCellAttr;
74class WXDLLIMPEXP_FWD_ADV wxGridCellAttrProviderData;
75class WXDLLIMPEXP_FWD_ADV wxGridColLabelWindow;
76class WXDLLIMPEXP_FWD_ADV wxGridCornerLabelWindow;
77class WXDLLIMPEXP_FWD_ADV wxGridRowLabelWindow;
78class WXDLLIMPEXP_FWD_ADV wxGridWindow;
79class WXDLLIMPEXP_FWD_ADV wxGridTypeRegistry;
80class WXDLLIMPEXP_FWD_ADV wxGridSelection;
81
ad805b9e 82class WXDLLIMPEXP_FWD_CORE wxHeaderCtrl;
b5dbe15d
VS
83class WXDLLIMPEXP_FWD_CORE wxCheckBox;
84class WXDLLIMPEXP_FWD_CORE wxComboBox;
85class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
0e871ad0 86#if wxUSE_SPINCTRL
b5dbe15d 87class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
0e871ad0 88#endif
508011ce 89
82edfbe7
VZ
90class wxGridFixedIndicesSet;
91
bec70262
VZ
92class wxGridOperations;
93class wxGridRowOperations;
94class wxGridColumnOperations;
10a4531d 95class wxGridDirectionOperations;
bec70262 96
29efc6e4 97
39bcce60
VZ
98// ----------------------------------------------------------------------------
99// macros
100// ----------------------------------------------------------------------------
101
102#define wxSafeIncRef(p) if ( p ) (p)->IncRef()
103#define wxSafeDecRef(p) if ( p ) (p)->DecRef()
104
ab79958a 105// ----------------------------------------------------------------------------
c4608a8a
VZ
106// wxGridCellWorker: common base class for wxGridCellRenderer and
107// wxGridCellEditor
108//
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
ab79958a
VZ
111// ----------------------------------------------------------------------------
112
12f190b0 113class WXDLLIMPEXP_ADV wxGridCellWorker : public wxClientDataContainer
ab79958a
VZ
114{
115public:
c4608a8a 116 wxGridCellWorker() { m_nRef = 1; }
39bcce60
VZ
117
118 // this class is ref counted: it is created with ref count of 1, so
119 // calling DecRef() once will delete it. Calling IncRef() allows to lock
120 // it until the matching DecRef() is called
121 void IncRef() { m_nRef++; }
8d7eaf91 122 void DecRef() { if ( --m_nRef == 0 ) delete this; }
39bcce60 123
c4608a8a
VZ
124 // interpret renderer parameters: arbitrary string whose interpretatin is
125 // left to the derived classes
126 virtual void SetParameters(const wxString& params);
127
128protected:
129 // virtual dtor for any base class - private because only DecRef() can
130 // delete us
131 virtual ~wxGridCellWorker();
132
133private:
134 size_t m_nRef;
135
136 // suppress the stupid gcc warning about the class having private dtor and
137 // no friends
138 friend class wxGridCellWorkerDummyFriend;
139};
140
141// ----------------------------------------------------------------------------
142// wxGridCellRenderer: this class is responsible for actually drawing the cell
143// in the grid. You may pass it to the wxGridCellAttr (below) to change the
144// format of one given cell or to wxGrid::SetDefaultRenderer() to change the
145// view of all cells. This is an ABC, you will normally use one of the
146// predefined derived classes or derive your own class from it.
147// ----------------------------------------------------------------------------
148
12f190b0 149class WXDLLIMPEXP_ADV wxGridCellRenderer : public wxGridCellWorker
c4608a8a
VZ
150{
151public:
ab79958a
VZ
152 // draw the given cell on the provided DC inside the given rectangle
153 // using the style specified by the attribute and the default or selected
154 // state corresponding to the isSelected value.
155 //
156 // this pure virtual function has a default implementation which will
157 // prepare the DC using the given attribute: it will draw the rectangle
158 // with the bg colour from attr and set the text colour and font
159 virtual void Draw(wxGrid& grid,
2796cce3 160 wxGridCellAttr& attr,
ab79958a
VZ
161 wxDC& dc,
162 const wxRect& rect,
163 int row, int col,
164 bool isSelected) = 0;
816be743 165
65e4e78e
VZ
166 // get the preferred size of the cell for its contents
167 virtual wxSize GetBestSize(wxGrid& grid,
168 wxGridCellAttr& attr,
169 wxDC& dc,
170 int row, int col) = 0;
171
e72b4213
VZ
172 // create a new object which is the copy of this one
173 virtual wxGridCellRenderer *Clone() const = 0;
ab79958a
VZ
174};
175
2796cce3
RD
176// ----------------------------------------------------------------------------
177// wxGridCellEditor: This class is responsible for providing and manipulating
178// the in-place edit controls for the grid. Instances of wxGridCellEditor
179// (actually, instances of derived classes since it is an ABC) can be
180// associated with the cell attributes for individual cells, rows, columns, or
181// even for the entire grid.
182// ----------------------------------------------------------------------------
183
12f190b0 184class WXDLLIMPEXP_ADV wxGridCellEditor : public wxGridCellWorker
2796cce3
RD
185{
186public:
187 wxGridCellEditor();
39bcce60 188
2796cce3 189 bool IsCreated() { return m_control != NULL; }
f6bcfd97
BP
190 wxControl* GetControl() { return m_control; }
191 void SetControl(wxControl* control) { m_control = control; }
2796cce3 192
1bd71df9
JS
193 wxGridCellAttr* GetCellAttr() { return m_attr; }
194 void SetCellAttr(wxGridCellAttr* attr) { m_attr = attr; }
195
2796cce3
RD
196 // Creates the actual edit control
197 virtual void Create(wxWindow* parent,
198 wxWindowID id,
2796cce3
RD
199 wxEvtHandler* evtHandler) = 0;
200
201 // Size and position the edit control
202 virtual void SetSize(const wxRect& rect);
203
3da93aae
VZ
204 // Show or hide the edit control, use the specified attributes to set
205 // colours/fonts for it
8a3e536c 206 virtual void Show(bool show, wxGridCellAttr *attr = NULL);
2796cce3 207
189d0213
VZ
208 // Draws the part of the cell not occupied by the control: the base class
209 // version just fills it with background colour from the attribute
210 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
211
763163a8
VZ
212
213 // The methods called by wxGrid when a cell is edited: first BeginEdit() is
214 // called, then EndEdit() is and if it returns true and if the change is
215 // not vetoed by a user-defined event handler, finally ApplyEdit() is called
216
2796cce3
RD
217 // Fetch the value from the table and prepare the edit control
218 // to begin editing. Set the focus to the edit control.
3da93aae 219 virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
2796cce3 220
763163a8
VZ
221 // Returns false if nothing changed, otherwise returns true and return the
222 // new value in its string form in the newval output parameter.
223 //
224 // This should also store the new value in its real type internally so that
78e78812
VZ
225 // it could be used by ApplyEdit() but it must not modify the grid as the
226 // change could still be vetoed.
227 virtual bool EndEdit(int row, int col, const wxGrid *grid,
228 const wxString& oldval, wxString *newval) = 0;
763163a8
VZ
229
230 // Complete the editing of the current cell by storing the value saved by
231 // the previous call to EndEdit() in the grid
232 virtual void ApplyEdit(int row, int col, wxGrid* grid) = 0;
233
2796cce3
RD
234
235 // Reset the value in the control back to its starting value
236 virtual void Reset() = 0;
237
ca65c044 238 // return true to allow the given key to start editing: the base class
f6bcfd97
BP
239 // version only checks that the event has no modifiers. The derived
240 // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in
241 // their IsAcceptedKey() implementation, although, of course, it is not a
242 // mandatory requirment.
243 //
244 // NB: if the key is F2 (special), editing will always start and this
245 // method will not be called at all (but StartingKey() will)
246 virtual bool IsAcceptedKey(wxKeyEvent& event);
247
248 // If the editor is enabled by pressing keys on the grid, this will be
249 // called to let the editor do something about that first key if desired
2c9a89e0
RD
250 virtual void StartingKey(wxKeyEvent& event);
251
e195a54c
VZ
252 // if the editor is enabled by clicking on the cell, this method will be
253 // called
254 virtual void StartingClick();
255
2796cce3
RD
256 // Some types of controls on some platforms may need some help
257 // with the Return key.
258 virtual void HandleReturn(wxKeyEvent& event);
259
260 // Final cleanup
261 virtual void Destroy();
262
c4608a8a
VZ
263 // create a new object which is the copy of this one
264 virtual wxGridCellEditor *Clone() const = 0;
265
73145b0e
JS
266 // added GetValue so we can get the value which is in the control
267 virtual wxString GetValue() const = 0;
268
2796cce3 269protected:
39bcce60
VZ
270 // the dtor is private because only DecRef() can delete us
271 virtual ~wxGridCellEditor();
272
3da93aae 273 // the control we show on screen
2796cce3 274 wxControl* m_control;
3da93aae 275
1bd71df9
JS
276 // a temporary pointer to the attribute being edited
277 wxGridCellAttr* m_attr;
278
3da93aae
VZ
279 // if we change the colours/font of the control from the default ones, we
280 // must restore the default later and we save them here between calls to
ca65c044 281 // Show(true) and Show(false)
3da93aae
VZ
282 wxColour m_colFgOld,
283 m_colBgOld;
284 wxFont m_fontOld;
39bcce60
VZ
285
286 // suppress the stupid gcc warning about the class having private dtor and
287 // no friends
288 friend class wxGridCellEditorDummyFriend;
22f3361e 289
c0c133e1 290 wxDECLARE_NO_COPY_CLASS(wxGridCellEditor);
2796cce3
RD
291};
292
3379ed37 293
b99be8fb
VZ
294// ----------------------------------------------------------------------------
295// wxGridCellAttr: this class can be used to alter the cells appearance in
296// the grid by changing their colour/font/... from default. An object of this
297// class may be returned by wxGridTable::GetAttr().
298// ----------------------------------------------------------------------------
299
12f190b0 300class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer
b99be8fb
VZ
301{
302public:
19d7140e
VZ
303 enum wxAttrKind
304 {
305 Any,
306 Default,
307 Cell,
308 Row,
309 Col,
310 Merged
311 };
312
b99be8fb 313 // ctors
1df4050d 314 wxGridCellAttr(wxGridCellAttr *attrDefault = NULL)
b99be8fb 315 {
1df4050d
VZ
316 Init(attrDefault);
317
0767cb6f
MB
318 // MB: args used to be 0,0 here but wxALIGN_LEFT is 0
319 SetAlignment(-1, -1);
b99be8fb
VZ
320 }
321
283b7808
VZ
322 // VZ: considering the number of members wxGridCellAttr has now, this ctor
323 // seems to be pretty useless... may be we should just remove it?
b99be8fb
VZ
324 wxGridCellAttr(const wxColour& colText,
325 const wxColour& colBack,
326 const wxFont& font,
327 int hAlign,
328 int vAlign)
329 : m_colText(colText), m_colBack(colBack), m_font(font)
330 {
2e9a6788 331 Init();
b99be8fb
VZ
332 SetAlignment(hAlign, vAlign);
333 }
334
39bcce60
VZ
335 // creates a new copy of this object
336 wxGridCellAttr *Clone() const;
19d7140e 337 void MergeWith(wxGridCellAttr *mergefrom);
b99be8fb 338
2e9a6788
VZ
339 // this class is ref counted: it is created with ref count of 1, so
340 // calling DecRef() once will delete it. Calling IncRef() allows to lock
341 // it until the matching DecRef() is called
342 void IncRef() { m_nRef++; }
8d7eaf91 343 void DecRef() { if ( --m_nRef == 0 ) delete this; }
2e9a6788 344
b99be8fb
VZ
345 // setters
346 void SetTextColour(const wxColour& colText) { m_colText = colText; }
347 void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
348 void SetFont(const wxFont& font) { m_font = font; }
349 void SetAlignment(int hAlign, int vAlign)
350 {
351 m_hAlign = hAlign;
352 m_vAlign = vAlign;
353 }
27f35b66 354 void SetSize(int num_rows, int num_cols);
ca65c044 355 void SetOverflow(bool allow = true)
ef5df12b 356 { m_overflow = allow ? Overflow : SingleCell; }
ca65c044 357 void SetReadOnly(bool isReadOnly = true)
19d7140e 358 { m_isReadOnly = isReadOnly ? ReadOnly : ReadWrite; }
b99be8fb 359
ab79958a
VZ
360 // takes ownership of the pointer
361 void SetRenderer(wxGridCellRenderer *renderer)
39bcce60 362 { wxSafeDecRef(m_renderer); m_renderer = renderer; }
07296f0b 363 void SetEditor(wxGridCellEditor* editor)
39bcce60 364 { wxSafeDecRef(m_editor); m_editor = editor; }
ab79958a 365
19d7140e
VZ
366 void SetKind(wxAttrKind kind) { m_attrkind = kind; }
367
b99be8fb
VZ
368 // accessors
369 bool HasTextColour() const { return m_colText.Ok(); }
370 bool HasBackgroundColour() const { return m_colBack.Ok(); }
371 bool HasFont() const { return m_font.Ok(); }
0767cb6f 372 bool HasAlignment() const { return (m_hAlign != -1 || m_vAlign != -1); }
2796cce3 373 bool HasRenderer() const { return m_renderer != NULL; }
07296f0b 374 bool HasEditor() const { return m_editor != NULL; }
19d7140e 375 bool HasReadWriteMode() const { return m_isReadOnly != Unset; }
b63fce94 376 bool HasOverflowMode() const { return m_overflow != UnsetOverflow; }
3100c3db 377 bool HasSize() const { return m_sizeRows != 1 || m_sizeCols != 1; }
b99be8fb 378
2796cce3
RD
379 const wxColour& GetTextColour() const;
380 const wxColour& GetBackgroundColour() const;
381 const wxFont& GetFont() const;
382 void GetAlignment(int *hAlign, int *vAlign) const;
27f35b66 383 void GetSize(int *num_rows, int *num_cols) const;
ef5df12b 384 bool GetOverflow() const
b63fce94 385 { return m_overflow != SingleCell; }
ef316e23
VZ
386 wxGridCellRenderer *GetRenderer(const wxGrid* grid, int row, int col) const;
387 wxGridCellEditor *GetEditor(const wxGrid* grid, int row, int col) const;
b99be8fb 388
19d7140e
VZ
389 bool IsReadOnly() const { return m_isReadOnly == wxGridCellAttr::ReadOnly; }
390
391 wxAttrKind GetKind() { return m_attrkind; }
283b7808 392
2796cce3 393 void SetDefAttr(wxGridCellAttr* defAttr) { m_defGridAttr = defAttr; }
ab79958a 394
338d1deb
VZ
395protected:
396 // the dtor is private because only DecRef() can delete us
397 virtual ~wxGridCellAttr()
398 {
399 wxSafeDecRef(m_renderer);
400 wxSafeDecRef(m_editor);
401 }
402
b99be8fb 403private:
19d7140e
VZ
404 enum wxAttrReadMode
405 {
406 Unset = -1,
407 ReadWrite,
408 ReadOnly
30bc4a8f 409 };
19d7140e 410
b63fce94
RD
411 enum wxAttrOverflowMode
412 {
413 UnsetOverflow = -1,
414 Overflow,
415 SingleCell
416 };
417
2e9a6788 418 // the common part of all ctors
1df4050d 419 void Init(wxGridCellAttr *attrDefault = NULL);
2e9a6788 420
2e9a6788
VZ
421
422 // the ref count - when it goes to 0, we die
423 size_t m_nRef;
424
b99be8fb
VZ
425 wxColour m_colText,
426 m_colBack;
427 wxFont m_font;
428 int m_hAlign,
429 m_vAlign;
27f35b66
SN
430 int m_sizeRows,
431 m_sizeCols;
ef5df12b
RD
432
433 wxAttrOverflowMode m_overflow;
2e9a6788 434
07296f0b
RD
435 wxGridCellRenderer* m_renderer;
436 wxGridCellEditor* m_editor;
437 wxGridCellAttr* m_defGridAttr;
ab79958a 438
19d7140e
VZ
439 wxAttrReadMode m_isReadOnly;
440
441 wxAttrKind m_attrkind;
283b7808 442
a68c1246 443 // use Clone() instead
c0c133e1 444 wxDECLARE_NO_COPY_CLASS(wxGridCellAttr);
a68c1246 445
2e9a6788
VZ
446 // suppress the stupid gcc warning about the class having private dtor and
447 // no friends
448 friend class wxGridCellAttrDummyFriend;
b99be8fb
VZ
449};
450
451// ----------------------------------------------------------------------------
452// wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
453// cell attributes.
454// ----------------------------------------------------------------------------
455
456// implementation note: we separate it from wxGridTableBase because we wish to
457// avoid deriving a new table class if possible, and sometimes it will be
458// enough to just derive another wxGridCellAttrProvider instead
758cbedf
VZ
459//
460// the default implementation is reasonably efficient for the generic case,
461// but you might still wish to implement your own for some specific situations
462// if you have performance problems with the stock one
12f190b0 463class WXDLLIMPEXP_ADV wxGridCellAttrProvider : public wxClientDataContainer
b99be8fb
VZ
464{
465public:
466 wxGridCellAttrProvider();
467 virtual ~wxGridCellAttrProvider();
468
2e9a6788 469 // DecRef() must be called on the returned pointer
19d7140e
VZ
470 virtual wxGridCellAttr *GetAttr(int row, int col,
471 wxGridCellAttr::wxAttrKind kind ) const;
2e9a6788 472
758cbedf
VZ
473 // all these functions take ownership of the pointer, don't call DecRef()
474 // on it
2e9a6788 475 virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
758cbedf
VZ
476 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
477 virtual void SetColAttr(wxGridCellAttr *attr, int col);
d1c0b4f9
VZ
478
479 // these functions must be called whenever some rows/cols are deleted
480 // because the internal data must be updated then
4d60017a
SN
481 void UpdateAttrRows( size_t pos, int numRows );
482 void UpdateAttrCols( size_t pos, int numCols );
b99be8fb
VZ
483
484private:
485 void InitData();
486
487 wxGridCellAttrProviderData *m_data;
22f3361e 488
c0c133e1 489 wxDECLARE_NO_COPY_CLASS(wxGridCellAttrProvider);
b99be8fb 490};
f85afd4e 491
10a4531d
VZ
492// ----------------------------------------------------------------------------
493// wxGridCellCoords: location of a cell in the grid
494// ----------------------------------------------------------------------------
495
496class WXDLLIMPEXP_ADV wxGridCellCoords
497{
498public:
499 wxGridCellCoords() { m_row = m_col = -1; }
500 wxGridCellCoords( int r, int c ) { m_row = r; m_col = c; }
501
502 // default copy ctor is ok
503
504 int GetRow() const { return m_row; }
505 void SetRow( int n ) { m_row = n; }
506 int GetCol() const { return m_col; }
507 void SetCol( int n ) { m_col = n; }
508 void Set( int row, int col ) { m_row = row; m_col = col; }
509
510 wxGridCellCoords& operator=( const wxGridCellCoords& other )
511 {
512 if ( &other != this )
513 {
514 m_row=other.m_row;
515 m_col=other.m_col;
516 }
517 return *this;
518 }
519
520 bool operator==( const wxGridCellCoords& other ) const
521 {
522 return (m_row == other.m_row && m_col == other.m_col);
523 }
524
525 bool operator!=( const wxGridCellCoords& other ) const
526 {
527 return (m_row != other.m_row || m_col != other.m_col);
528 }
529
530 bool operator!() const
531 {
532 return (m_row == -1 && m_col == -1 );
533 }
534
535private:
536 int m_row;
537 int m_col;
538};
539
540
541// For comparisons...
f85afd4e 542//
10a4531d
VZ
543extern WXDLLIMPEXP_ADV wxGridCellCoords wxGridNoCellCoords;
544extern WXDLLIMPEXP_ADV wxRect wxGridNoCellRect;
545
546// An array of cell coords...
f85afd4e 547//
10a4531d
VZ
548WX_DECLARE_OBJARRAY_WITH_DECL(wxGridCellCoords, wxGridCellCoordsArray,
549 class WXDLLIMPEXP_ADV);
f85afd4e 550
10a4531d
VZ
551// ----------------------------------------------------------------------------
552// Grid table classes
553// ----------------------------------------------------------------------------
f85afd4e 554
10a4531d
VZ
555// the abstract base class
556class WXDLLIMPEXP_ADV wxGridTableBase : public wxObject,
557 public wxClientDataContainer
f85afd4e 558{
60ff3b99 559public:
f85afd4e
MB
560 wxGridTableBase();
561 virtual ~wxGridTableBase();
562
563 // You must override these functions in a derived table class
564 //
77d2c45c
VZ
565
566 // return the number of rows and columns in this table
e32352cf
SN
567 virtual int GetNumberRows() = 0;
568 virtual int GetNumberCols() = 0;
77d2c45c
VZ
569
570 // the methods above are unfortunately non-const even though they should
571 // have been const -- but changing it now is not possible any longer as it
572 // would break the existing code overriding them, so instead we provide
573 // these const synonyms which can be used from const-correct code
574 int GetRowsCount() const
5c33522f 575 { return const_cast<wxGridTableBase *>(this)->GetNumberRows(); }
77d2c45c 576 int GetColsCount() const
5c33522f 577 { return const_cast<wxGridTableBase *>(this)->GetNumberCols(); }
77d2c45c
VZ
578
579
8acad210
VZ
580 virtual bool IsEmptyCell( int row, int col )
581 {
582 return GetValue(row, col).empty();
583 }
10a4531d
VZ
584
585 bool IsEmpty(const wxGridCellCoords& coord)
586 {
587 return IsEmptyCell(coord.GetRow(), coord.GetCol());
588 }
589
f2d76237
RD
590 virtual wxString GetValue( int row, int col ) = 0;
591 virtual void SetValue( int row, int col, const wxString& value ) = 0;
592
593 // Data type determination and value access
594 virtual wxString GetTypeName( int row, int col );
595 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
596 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
597
598 virtual long GetValueAsLong( int row, int col );
599 virtual double GetValueAsDouble( int row, int col );
600 virtual bool GetValueAsBool( int row, int col );
601
602 virtual void SetValueAsLong( int row, int col, long value );
603 virtual void SetValueAsDouble( int row, int col, double value );
604 virtual void SetValueAsBool( int row, int col, bool value );
605
606 // For user defined types
607 virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
608 virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
609
60ff3b99 610
f85afd4e
MB
611 // Overriding these is optional
612 //
613 virtual void SetView( wxGrid *grid ) { m_view = grid; }
614 virtual wxGrid * GetView() const { return m_view; }
615
616 virtual void Clear() {}
617 virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
618 virtual bool AppendRows( size_t numRows = 1 );
619 virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
620 virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
621 virtual bool AppendCols( size_t numCols = 1 );
622 virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
623
624 virtual wxString GetRowLabelValue( int row );
625 virtual wxString GetColLabelValue( int col );
af111fc3
JS
626 virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {}
627 virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {}
60ff3b99 628
b99be8fb
VZ
629 // Attribute handling
630 //
631
632 // give us the attr provider to use - we take ownership of the pointer
633 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
634
635 // get the currently used attr provider (may be NULL)
636 wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; }
637
f2d76237
RD
638 // Does this table allow attributes? Default implementation creates
639 // a wxGridCellAttrProvider if necessary.
640 virtual bool CanHaveAttributes();
641
b99be8fb 642 // by default forwarded to wxGridCellAttrProvider if any. May be
f2d76237 643 // overridden to handle attributes directly in the table.
19d7140e
VZ
644 virtual wxGridCellAttr *GetAttr( int row, int col,
645 wxGridCellAttr::wxAttrKind kind );
646
b99be8fb 647
758cbedf
VZ
648 // these functions take ownership of the pointer
649 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
650 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
651 virtual void SetColAttr(wxGridCellAttr *attr, int col);
b99be8fb 652
60ff3b99
VZ
653private:
654 wxGrid * m_view;
b99be8fb 655 wxGridCellAttrProvider *m_attrProvider;
60ff3b99 656
3839f37e 657 DECLARE_ABSTRACT_CLASS(wxGridTableBase)
c0c133e1 658 wxDECLARE_NO_COPY_CLASS(wxGridTableBase);
f85afd4e
MB
659};
660
661
b99be8fb
VZ
662// ----------------------------------------------------------------------------
663// wxGridTableMessage
664// ----------------------------------------------------------------------------
f85afd4e
MB
665
666// IDs for messages sent from grid table to view
667//
60ff3b99
VZ
668enum wxGridTableRequest
669{
f85afd4e
MB
670 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
671 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
672 wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
673 wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
674 wxGRIDTABLE_NOTIFY_ROWS_DELETED,
675 wxGRIDTABLE_NOTIFY_COLS_INSERTED,
676 wxGRIDTABLE_NOTIFY_COLS_APPENDED,
677 wxGRIDTABLE_NOTIFY_COLS_DELETED
678};
679
12f190b0 680class WXDLLIMPEXP_ADV wxGridTableMessage
f85afd4e 681{
60ff3b99 682public:
f85afd4e
MB
683 wxGridTableMessage();
684 wxGridTableMessage( wxGridTableBase *table, int id,
685 int comInt1 = -1,
686 int comInt2 = -1 );
687
688 void SetTableObject( wxGridTableBase *table ) { m_table = table; }
689 wxGridTableBase * GetTableObject() const { return m_table; }
690 void SetId( int id ) { m_id = id; }
691 int GetId() { return m_id; }
692 void SetCommandInt( int comInt1 ) { m_comInt1 = comInt1; }
693 int GetCommandInt() { return m_comInt1; }
694 void SetCommandInt2( int comInt2 ) { m_comInt2 = comInt2; }
60ff3b99
VZ
695 int GetCommandInt2() { return m_comInt2; }
696
697private:
698 wxGridTableBase *m_table;
699 int m_id;
700 int m_comInt1;
701 int m_comInt2;
22f3361e 702
c0c133e1 703 wxDECLARE_NO_COPY_CLASS(wxGridTableMessage);
f85afd4e
MB
704};
705
706
707
708// ------ wxGridStringArray
709// A 2-dimensional array of strings for data values
710//
711
160ba750
VS
712WX_DECLARE_OBJARRAY_WITH_DECL(wxArrayString, wxGridStringArray,
713 class WXDLLIMPEXP_ADV);
2d66e025 714
f85afd4e
MB
715
716
717// ------ wxGridStringTable
718//
719// Simplest type of data table for a grid for small tables of strings
720// that are stored in memory
721//
722
12f190b0 723class WXDLLIMPEXP_ADV wxGridStringTable : public wxGridTableBase
f85afd4e 724{
60ff3b99 725public:
f85afd4e
MB
726 wxGridStringTable();
727 wxGridStringTable( int numRows, int numCols );
f85afd4e
MB
728
729 // these are pure virtual in wxGridTableBase
730 //
5c3313a9
VZ
731 virtual int GetNumberRows() { return m_data.size(); }
732 virtual int GetNumberCols() { return m_numCols; }
733 virtual wxString GetValue( int row, int col );
734 virtual void SetValue( int row, int col, const wxString& s );
60ff3b99 735
f85afd4e
MB
736 // overridden functions from wxGridTableBase
737 //
738 void Clear();
739 bool InsertRows( size_t pos = 0, size_t numRows = 1 );
740 bool AppendRows( size_t numRows = 1 );
741 bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
742 bool InsertCols( size_t pos = 0, size_t numCols = 1 );
743 bool AppendCols( size_t numCols = 1 );
744 bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
745
746 void SetRowLabelValue( int row, const wxString& );
747 void SetColLabelValue( int col, const wxString& );
748 wxString GetRowLabelValue( int row );
749 wxString GetColLabelValue( int col );
60ff3b99
VZ
750
751private:
752 wxGridStringArray m_data;
753
5c3313a9
VZ
754 // notice that while we don't need to store the number of our rows as it's
755 // always equal to the size of m_data array, we do need to store the number
756 // of our columns as we can't retrieve it from m_data when the number of
757 // rows is 0 (see #10818)
758 int m_numCols;
759
60ff3b99
VZ
760 // These only get used if you set your own labels, otherwise the
761 // GetRow/ColLabelValue functions return wxGridTableBase defaults
762 //
763 wxArrayString m_rowLabels;
764 wxArrayString m_colLabels;
765
fc7a2a60 766 DECLARE_DYNAMIC_CLASS_NO_COPY( wxGridStringTable )
f85afd4e
MB
767};
768
769
770
43947979 771// ============================================================================
f85afd4e 772// Grid view classes
43947979
VZ
773// ============================================================================
774
574e1c5a
VZ
775// ----------------------------------------------------------------------------
776// wxGridSizesInfo stores information about sizes of the rows or columns.
777//
778// It assumes that most of the columns or rows have default size and so stores
779// the default size separately and uses a hash to map column or row numbers to
780// their non default size for those which don't have the default size.
781// ----------------------------------------------------------------------------
782
82edfbe7 783// hash map to store positions as the keys and sizes as the values
574e1c5a
VZ
784WX_DECLARE_HASH_MAP_WITH_DECL( unsigned, int, wxIntegerHash, wxIntegerEqual,
785 wxUnsignedToIntHashMap, class WXDLLIMPEXP_ADV );
786
787struct WXDLLIMPEXP_ADV wxGridSizesInfo
788{
789 // default ctor, initialize m_sizeDefault and m_customSizes later
790 wxGridSizesInfo() { }
791
792 // ctor used by wxGrid::Get{Col,Row}Sizes()
793 wxGridSizesInfo(int defSize, const wxArrayInt& allSizes);
794
795 // default copy ctor, assignment operator and dtor are ok
796
797 // Get the size of the element with the given index
798 int GetSize(unsigned pos) const;
799
800
801 // default size
802 int m_sizeDefault;
803
804 // position -> size map containing all elements with non-default size
805 wxUnsignedToIntHashMap m_customSizes;
806};
807
b99be8fb
VZ
808// ----------------------------------------------------------------------------
809// wxGrid
810// ----------------------------------------------------------------------------
f85afd4e 811
12f190b0 812class WXDLLIMPEXP_ADV wxGrid : public wxScrolledWindow
60ff3b99
VZ
813{
814public:
bf2c8b31
VZ
815 // possible selection modes
816 enum wxGridSelectionModes
817 {
818 wxGridSelectCells = 0, // allow selecting anything
819 wxGridSelectRows = 1, // allow selecting only entire rows
820 wxGridSelectColumns = 2, // allow selecting only entire columns
821 wxGridSelectRowsOrColumns = wxGridSelectRows | wxGridSelectColumns
822 };
823
824 // creation and destruction
825 // ------------------------
826
827 // ctor and Create() create the grid window, as with the other controls
ad805b9e 828 wxGrid() { Init(); }
986a98c6 829
bf2c8b31 830 wxGrid(wxWindow *parent,
986a98c6
SC
831 wxWindowID id,
832 const wxPoint& pos = wxDefaultPosition,
833 const wxSize& size = wxDefaultSize,
834 long style = wxWANTS_CHARS,
ad805b9e
VZ
835 const wxString& name = wxGridNameStr)
836 {
837 Init();
838
839 Create(parent, id, pos, size, style, name);
840 }
60ff3b99 841
bf2c8b31
VZ
842 bool Create(wxWindow *parent,
843 wxWindowID id,
844 const wxPoint& pos = wxDefaultPosition,
845 const wxSize& size = wxDefaultSize,
846 long style = wxWANTS_CHARS,
847 const wxString& name = wxGridNameStr);
2d66e025 848
e669d97a 849 virtual ~wxGrid();
f85afd4e 850
bf2c8b31
VZ
851 // however to initialize grid data either CreateGrid() or SetTable() must
852 // be also called
b5808881 853
bf2c8b31
VZ
854 // this is basically equivalent to
855 //
856 // SetTable(new wxGridStringTable(numRows, numCols), true, selmode)
857 //
b5808881 858 bool CreateGrid( int numRows, int numCols,
801a9641 859 wxGridSelectionModes selmode = wxGridSelectCells );
2d66e025 860
bf2c8b31
VZ
861 bool SetTable( wxGridTableBase *table,
862 bool takeOwnership = false,
863 wxGridSelectionModes selmode = wxGridSelectCells );
864
8a3e536c
VZ
865 bool ProcessTableMessage(wxGridTableMessage&);
866
867 wxGridTableBase *GetTable() const { return m_table; }
868
bf2c8b31 869
801a9641
VZ
870 void SetSelectionMode(wxGridSelectionModes selmode);
871 wxGridSelectionModes GetSelectionMode() const;
60ff3b99 872
2d66e025
MB
873 // ------ grid dimensions
874 //
ef316e23
VZ
875 int GetNumberRows() const { return m_numRows; }
876 int GetNumberCols() const { return m_numCols; }
2d66e025 877
60ff3b99 878
2d66e025
MB
879 // ------ display update functions
880 //
ef316e23 881 wxArrayInt CalcRowLabelsExposed( const wxRegion& reg ) const;
8fb66724 882
ef316e23
VZ
883 wxArrayInt CalcColLabelsExposed( const wxRegion& reg ) const;
884 wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg ) const;
60ff3b99 885
2d66e025 886
f85afd4e 887 void ClearGrid();
10a4531d
VZ
888 bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true)
889 {
890 return DoModifyLines(&wxGridTableBase::InsertRows,
891 pos, numRows, updateLabels);
892 }
893 bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true)
894 {
895 return DoModifyLines(&wxGridTableBase::InsertCols,
896 pos, numCols, updateLabels);
897 }
898
899 bool AppendRows(int numRows = 1, bool updateLabels = true)
900 {
901 return DoAppendLines(&wxGridTableBase::AppendRows, numRows, updateLabels);
902 }
903 bool AppendCols(int numCols = 1, bool updateLabels = true)
904 {
905 return DoAppendLines(&wxGridTableBase::AppendCols, numCols, updateLabels);
906 }
907
908 bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true)
909 {
910 return DoModifyLines(&wxGridTableBase::DeleteRows,
911 pos, numRows, updateLabels);
912 }
913 bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true)
914 {
915 return DoModifyLines(&wxGridTableBase::DeleteCols,
916 pos, numCols, updateLabels);
917 }
f85afd4e 918
d10f4bf9 919 void DrawGridCellArea( wxDC& dc , const wxGridCellCoordsArray& cells );
7c8a8ad5 920 void DrawGridSpace( wxDC& dc );
2d66e025 921 void DrawCellBorder( wxDC& dc, const wxGridCellCoords& );
4634a5d6 922 void DrawAllGridLines( wxDC& dc, const wxRegion & reg );
2d66e025 923 void DrawCell( wxDC& dc, const wxGridCellCoords& );
d10f4bf9 924 void DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells);
d16c04bb
VZ
925
926 // this function is called when the current cell highlight must be redrawn
927 // and may be overridden by the user
928 virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
1f1ce288 929
6914b57a
JS
930 virtual void DrawRowLabels( wxDC& dc, const wxArrayInt& rows );
931 virtual void DrawRowLabel( wxDC& dc, int row );
8fb66724 932
6914b57a
JS
933 virtual void DrawColLabels( wxDC& dc, const wxArrayInt& cols );
934 virtual void DrawColLabel( wxDC& dc, int col );
60ff3b99 935
ff72f628 936 virtual void DrawCornerLabel(wxDC& dc);
f85afd4e 937
2d66e025 938 // ------ Cell text drawing functions
f85afd4e 939 //
2d66e025 940 void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
4c7277db 941 int horizontalAlignment = wxALIGN_LEFT,
d43851f7
JS
942 int verticalAlignment = wxALIGN_TOP,
943 int textOrientation = wxHORIZONTAL );
30bc4a8f 944
d10f4bf9
VZ
945 void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect&,
946 int horizontalAlignment = wxALIGN_LEFT,
d43851f7
JS
947 int verticalAlignment = wxALIGN_TOP,
948 int textOrientation = wxHORIZONTAL );
d10f4bf9 949
f85afd4e 950
ef316e23 951 // Split a string containing newline characters into an array of
2d66e025
MB
952 // strings and return the number of lines
953 //
ef316e23 954 void StringToLines( const wxString& value, wxArrayString& lines ) const;
60ff3b99 955
fbfb8bcc 956 void GetTextBoxSize( const wxDC& dc,
d10f4bf9 957 const wxArrayString& lines,
ef316e23 958 long *width, long *height ) const;
60ff3b99 959
2d66e025 960
f85afd4e
MB
961 // ------
962 // Code that does a lot of grid modification can be enclosed
963 // between BeginBatch() and EndBatch() calls to avoid screen
964 // flicker
965 //
966 void BeginBatch() { m_batchCount++; }
f6bcfd97
BP
967 void EndBatch();
968
f85afd4e
MB
969 int GetBatchCount() { return m_batchCount; }
970
8a3e536c 971 virtual void Refresh(bool eraseb = true, const wxRect* rect = NULL);
27f35b66 972
d8232393
MB
973 // Use this, rather than wxWindow::Refresh(), to force an
974 // immediate repainting of the grid. Has no effect if you are
975 // already inside a BeginBatch / EndBatch block.
976 //
977 // This function is necessary because wxGrid has a minimal OnPaint()
978 // handler to reduce screen flicker.
979 //
980 void ForceRefresh();
d2520c85 981
2d66e025
MB
982
983 // ------ edit control functions
984 //
84035150 985 bool IsEditable() const { return m_editable; }
2d66e025
MB
986 void EnableEditing( bool edit );
987
ca65c044
WS
988 void EnableCellEditControl( bool enable = true );
989 void DisableCellEditControl() { EnableCellEditControl(false); }
b54ba671
VZ
990 bool CanEnableCellControl() const;
991 bool IsCellEditControlEnabled() const;
f6bcfd97 992 bool IsCellEditControlShown() const;
2d66e025 993
b54ba671 994 bool IsCurrentCellReadOnly() const;
2d66e025 995
2d66e025
MB
996 void ShowCellEditControl();
997 void HideCellEditControl();
2d66e025
MB
998 void SaveEditControlValue();
999
60ff3b99 1000
2d66e025 1001 // ------ grid location functions
60ff3b99 1002 // Note that all of these functions work with the logical coordinates of
2d66e025
MB
1003 // grid cells and labels so you will need to convert from device
1004 // coordinates for mouse events etc.
1005 //
8a3e536c
VZ
1006 wxGridCellCoords XYToCell(int x, int y) const;
1007 void XYToCell(int x, int y, wxGridCellCoords& coords) const
1008 { coords = XYToCell(x, y); }
1009 wxGridCellCoords XYToCell(const wxPoint& pos) const
1010 { return XYToCell(pos.x, pos.y); }
1011
cd4f6f5f
VZ
1012 // these functions return the index of the row/columns corresponding to the
1013 // given logical position in pixels
1014 //
1015 // if clipToMinMax is false (default, wxNOT_FOUND is returned if the
1016 // position is outside any row/column, otherwise the first/last element is
1017 // returned in this case
bec70262 1018 int YToRow( int y, bool clipToMinMax = false ) const;
ef316e23 1019 int XToCol( int x, bool clipToMinMax = false ) const;
2d66e025 1020
ef316e23
VZ
1021 int YToEdgeOfRow( int y ) const;
1022 int XToEdgeOfCol( int x ) const;
2d66e025 1023
ef316e23
VZ
1024 wxRect CellToRect( int row, int col ) const;
1025 wxRect CellToRect( const wxGridCellCoords& coords ) const
2d66e025
MB
1026 { return CellToRect( coords.GetRow(), coords.GetCol() ); }
1027
ef316e23
VZ
1028 int GetGridCursorRow() const { return m_currentCellCoords.GetRow(); }
1029 int GetGridCursorCol() const { return m_currentCellCoords.GetCol(); }
60ff3b99 1030
2d66e025
MB
1031 // check to see if a cell is either wholly visible (the default arg) or
1032 // at least partially visible in the grid window
1033 //
ef316e23
VZ
1034 bool IsVisible( int row, int col, bool wholeCellVisible = true ) const;
1035 bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = true ) const
2d66e025
MB
1036 { return IsVisible( coords.GetRow(), coords.GetCol(), wholeCellVisible ); }
1037 void MakeCellVisible( int row, int col );
1038 void MakeCellVisible( const wxGridCellCoords& coords )
1039 { MakeCellVisible( coords.GetRow(), coords.GetCol() ); }
1040
60ff3b99 1041
2d66e025
MB
1042 // ------ grid cursor movement functions
1043 //
8a3e536c
VZ
1044 void SetGridCursor(int row, int col) { SetCurrentCell(row, col); }
1045 void SetGridCursor(const wxGridCellCoords& c) { SetCurrentCell(c); }
1046
1047 void GoToCell(int row, int col)
1048 {
1049 if ( SetCurrentCell(row, col) )
1050 MakeCellVisible(row, col);
1051 }
1052
1053 void GoToCell(const wxGridCellCoords& coords)
1054 {
1055 if ( SetCurrentCell(coords) )
1056 MakeCellVisible(coords);
1057 }
dfaf42d2 1058
5c8fc7c1
SN
1059 bool MoveCursorUp( bool expandSelection );
1060 bool MoveCursorDown( bool expandSelection );
1061 bool MoveCursorLeft( bool expandSelection );
1062 bool MoveCursorRight( bool expandSelection );
2d66e025
MB
1063 bool MovePageDown();
1064 bool MovePageUp();
5c8fc7c1
SN
1065 bool MoveCursorUpBlock( bool expandSelection );
1066 bool MoveCursorDownBlock( bool expandSelection );
1067 bool MoveCursorLeftBlock( bool expandSelection );
1068 bool MoveCursorRightBlock( bool expandSelection );
2d66e025 1069
60ff3b99 1070
f85afd4e
MB
1071 // ------ label and gridline formatting
1072 //
ef316e23
VZ
1073 int GetDefaultRowLabelSize() const { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; }
1074 int GetRowLabelSize() const { return m_rowLabelWidth; }
1075 int GetDefaultColLabelSize() const { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; }
1076 int GetColLabelSize() const { return m_colLabelHeight; }
1077 wxColour GetLabelBackgroundColour() const { return m_labelBackgroundColour; }
1078 wxColour GetLabelTextColour() const { return m_labelTextColour; }
1079 wxFont GetLabelFont() const { return m_labelFont; }
1080 void GetRowLabelAlignment( int *horiz, int *vert ) const;
1081 void GetColLabelAlignment( int *horiz, int *vert ) const;
1082 int GetColLabelTextOrientation() const;
1083 wxString GetRowLabelValue( int row ) const;
1084 wxString GetColLabelValue( int col ) const;
3d3f3e37 1085
ef316e23
VZ
1086 wxColour GetCellHighlightColour() const { return m_cellHighlightColour; }
1087 int GetCellHighlightPenWidth() const { return m_cellHighlightPenWidth; }
1088 int GetCellHighlightROPenWidth() const { return m_cellHighlightROPenWidth; }
f85afd4e 1089
ad805b9e
VZ
1090 // this one will use wxHeaderCtrl for the column labels
1091 void UseNativeColHeader(bool native = true);
1092
1093 // this one will still draw them manually but using the native renderer
1094 // instead of using the same appearance as for the row labels
1095 void SetUseNativeColLabels( bool native = true );
1096
ab79958a 1097 void SetRowLabelSize( int width );
f85afd4e 1098 void SetColLabelSize( int height );
0a9ca9c4
RR
1099 void HideRowLabels() { SetRowLabelSize( 0 ); }
1100 void HideColLabels() { SetColLabelSize( 0 ); }
f85afd4e
MB
1101 void SetLabelBackgroundColour( const wxColour& );
1102 void SetLabelTextColour( const wxColour& );
1103 void SetLabelFont( const wxFont& );
1104 void SetRowLabelAlignment( int horiz, int vert );
1105 void SetColLabelAlignment( int horiz, int vert );
d43851f7 1106 void SetColLabelTextOrientation( int textOrientation );
f85afd4e
MB
1107 void SetRowLabelValue( int row, const wxString& );
1108 void SetColLabelValue( int col, const wxString& );
f6bcfd97 1109 void SetCellHighlightColour( const wxColour& );
d2520c85
RD
1110 void SetCellHighlightPenWidth(int width);
1111 void SetCellHighlightROPenWidth(int width);
28a77bc4 1112
82edfbe7
VZ
1113
1114 // interactive grid mouse operations control
1115 // -----------------------------------------
1116
1117 // functions globally enabling row/column interactive resizing (enabled by
1118 // default)
ca65c044
WS
1119 void EnableDragRowSize( bool enable = true );
1120 void DisableDragRowSize() { EnableDragRowSize( false ); }
82edfbe7 1121
ca65c044
WS
1122 void EnableDragColSize( bool enable = true );
1123 void DisableDragColSize() { EnableDragColSize( false ); }
82edfbe7
VZ
1124
1125 // if interactive resizing is enabled, some rows/columns can still have
1126 // fixed size
1127 void DisableRowResize(int row) { DoDisableLineResize(row, m_setFixedRows); }
1128 void DisableColResize(int col) { DoDisableLineResize(col, m_setFixedCols); }
1129
1130 // these functions return whether the given row/column can be
1131 // effectively resized: for this interactive resizing must be enabled
1132 // and this index must not have been passed to DisableRow/ColResize()
1133 bool CanDragRowSize(int row) const
1134 { return m_canDragRowSize && DoCanResizeLine(row, m_setFixedRows); }
1135 bool CanDragColSize(int col) const
1136 { return m_canDragColSize && DoCanResizeLine(col, m_setFixedCols); }
1137
1138 // interactive column reordering (disabled by default)
d4175745
VZ
1139 void EnableDragColMove( bool enable = true );
1140 void DisableDragColMove() { EnableDragColMove( false ); }
ef316e23 1141 bool CanDragColMove() const { return m_canDragColMove; }
82edfbe7
VZ
1142
1143 // interactive resizing of grid cells (enabled by default)
ca65c044
WS
1144 void EnableDragGridSize(bool enable = true);
1145 void DisableDragGridSize() { EnableDragGridSize(false); }
ef316e23 1146 bool CanDragGridSize() const { return m_canDragGridSize; }
4cfa5de6 1147
82edfbe7 1148 // interactive dragging of cells (disabled by default)
79dbea21
RD
1149 void EnableDragCell( bool enable = true );
1150 void DisableDragCell() { EnableDragCell( false ); }
ef316e23 1151 bool CanDragCell() const { return m_canDragCell; }
79dbea21 1152
9f7aee01
VZ
1153
1154 // grid lines
1155 // ----------
1156
1157 // enable or disable drawing of the lines
1158 void EnableGridLines(bool enable = true);
1159 bool GridLinesEnabled() const { return m_gridLinesEnabled; }
1160
1161 // by default grid lines stop at last column/row, but this may be changed
1162 void ClipHorzGridLines(bool clip)
1163 { DoClipGridLines(m_gridLinesClipHorz, clip); }
1164 void ClipVertGridLines(bool clip)
1165 { DoClipGridLines(m_gridLinesClipVert, clip); }
1166 bool AreHorzGridLinesClipped() const { return m_gridLinesClipHorz; }
1167 bool AreVertGridLinesClipped() const { return m_gridLinesClipVert; }
1168
1169 // this can be used to change the global grid lines colour
1170 void SetGridLineColour(const wxColour& col);
1171 wxColour GetGridLineColour() const { return m_gridLineColour; }
1172
1173 // these methods may be overridden to customize individual grid lines
1174 // appearance
1175 virtual wxPen GetDefaultGridLinePen();
1176 virtual wxPen GetRowGridLinePen(int row);
1177 virtual wxPen GetColGridLinePen(int col);
1178
1179
1180 // attributes
1181 // ----------
1182
27f35b66
SN
1183 // this sets the specified attribute for this cell or in this row/col
1184 void SetAttr(int row, int col, wxGridCellAttr *attr);
758cbedf
VZ
1185 void SetRowAttr(int row, wxGridCellAttr *attr);
1186 void SetColAttr(int col, wxGridCellAttr *attr);
1187
71e60f70
RD
1188 // returns the attribute we may modify in place: a new one if this cell
1189 // doesn't have any yet or the existing one if it does
1190 //
1191 // DecRef() must be called on the returned pointer, as usual
1192 wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
1193
d94c09cd 1194
0b190b0f
VZ
1195 // shortcuts for setting the column parameters
1196
1197 // set the format for the data in the column: default is string
1198 void SetColFormatBool(int col);
1199 void SetColFormatNumber(int col);
1200 void SetColFormatFloat(int col, int width = -1, int precision = -1);
1201 void SetColFormatCustom(int col, const wxString& typeName);
1202
f85afd4e
MB
1203 // ------ row and col formatting
1204 //
ef316e23
VZ
1205 int GetDefaultRowSize() const;
1206 int GetRowSize( int row ) const;
fe79f76b 1207 bool IsRowShown(int row) const { return GetRowSize(row) != 0; }
ef316e23
VZ
1208 int GetDefaultColSize() const;
1209 int GetColSize( int col ) const;
fe79f76b 1210 bool IsColShown(int col) const { return GetColSize(col) != 0; }
ef316e23
VZ
1211 wxColour GetDefaultCellBackgroundColour() const;
1212 wxColour GetCellBackgroundColour( int row, int col ) const;
1213 wxColour GetDefaultCellTextColour() const;
1214 wxColour GetCellTextColour( int row, int col ) const;
1215 wxFont GetDefaultCellFont() const;
1216 wxFont GetCellFont( int row, int col ) const;
1217 void GetDefaultCellAlignment( int *horiz, int *vert ) const;
1218 void GetCellAlignment( int row, int col, int *horiz, int *vert ) const;
1219 bool GetDefaultCellOverflow() const;
1220 bool GetCellOverflow( int row, int col ) const;
1221 void GetCellSize( int row, int col, int *num_rows, int *num_cols ) const;
bec70262
VZ
1222 wxSize GetCellSize(const wxGridCellCoords& coords)
1223 {
1224 wxSize s;
1225 GetCellSize(coords.GetRow(), coords.GetCol(), &s.x, &s.y);
1226 return s;
1227 }
60ff3b99 1228
009c7216 1229 // ------ row and col sizes
ca65c044 1230 void SetDefaultRowSize( int height, bool resizeExistingRows = false );
f85afd4e 1231 void SetRowSize( int row, int height );
009c7216
VZ
1232 void HideRow(int row) { SetRowSize(row, 0); }
1233 void ShowRow(int row) { SetRowSize(row, -1); }
8fb66724 1234
009c7216 1235 void SetDefaultColSize( int width, bool resizeExistingCols = false );
f85afd4e 1236 void SetColSize( int col, int width );
009c7216
VZ
1237 void HideCol(int col) { SetColSize(col, 0); }
1238 void ShowCol(int col) { SetColSize(col, -1); }
1239
574e1c5a
VZ
1240 // the row and column sizes can be also set all at once using
1241 // wxGridSizesInfo which holds all of them at once
1242
1243 wxGridSizesInfo GetColSizes() const
1244 { return wxGridSizesInfo(GetDefaultColSize(), m_colWidths); }
1245 wxGridSizesInfo GetRowSizes() const
1246 { return wxGridSizesInfo(GetDefaultRowSize(), m_rowHeights); }
1247
1248 void SetColSizes(const wxGridSizesInfo& sizeInfo);
1249 void SetRowSizes(const wxGridSizesInfo& sizeInfo);
1250
009c7216
VZ
1251
1252 // ------- columns (only, for now) reordering
43947979 1253
cd4f6f5f
VZ
1254 // columns index <-> positions mapping: by default, the position of the
1255 // column is the same as its index, but the columns can also be reordered
1256 // (either by calling SetColPos() explicitly or by the user dragging the
1257 // columns around) in which case their indices don't correspond to their
1258 // positions on display any longer
1259 //
1260 // internally we always work with indices except for the functions which
1261 // have "Pos" in their names (and which work with columns, not pixels) and
1262 // only the display and hit testing code really cares about display
1263 // positions at all
1264
31ec8b4e
VZ
1265 // set the positions of all columns at once (this method uses the same
1266 // conventions as wxHeaderCtrl::SetColumnsOrder() for the order array)
1267 void SetColumnsOrder(const wxArrayInt& order);
1268
cd4f6f5f
VZ
1269 // return the column index corresponding to the given (valid) position
1270 int GetColAt(int pos) const
d4175745 1271 {
cd4f6f5f 1272 return m_colAt.empty() ? pos : m_colAt[pos];
d4175745
VZ
1273 }
1274
cd4f6f5f
VZ
1275 // reorder the columns so that the column with the given index is now shown
1276 // as the position pos
1277 void SetColPos(int idx, int pos);
d4175745 1278
cd4f6f5f
VZ
1279 // return the position at which the column with the given index is
1280 // displayed: notice that this is a slow operation as we don't maintain the
1281 // reverse mapping currently
1282 int GetColPos(int idx) const
d4175745
VZ
1283 {
1284 if ( m_colAt.IsEmpty() )
cd4f6f5f
VZ
1285 return idx;
1286
1287 for ( int i = 0; i < m_numCols; i++ )
d4175745 1288 {
cd4f6f5f
VZ
1289 if ( m_colAt[i] == idx )
1290 return i;
d4175745
VZ
1291 }
1292
cd4f6f5f
VZ
1293 wxFAIL_MSG( "invalid column index" );
1294
1295 return wxNOT_FOUND;
d4175745
VZ
1296 }
1297
009c7216
VZ
1298 // reset the columns positions to the default order
1299 void ResetColPos();
cd4f6f5f
VZ
1300
1301
af547d51 1302 // automatically size the column or row to fit to its contents, if
ca65c044 1303 // setAsMin is true, this optimal width will also be set as minimal width
af547d51 1304 // for this column
ca65c044 1305 void AutoSizeColumn( int col, bool setAsMin = true )
733f486a 1306 { AutoSizeColOrRow(col, setAsMin, wxGRID_COLUMN); }
ca65c044 1307 void AutoSizeRow( int row, bool setAsMin = true )
733f486a 1308 { AutoSizeColOrRow(row, setAsMin, wxGRID_ROW); }
65e4e78e
VZ
1309
1310 // auto size all columns (very ineffective for big grids!)
ca65c044
WS
1311 void AutoSizeColumns( bool setAsMin = true )
1312 { (void)SetOrCalcColumnSizes(false, setAsMin); }
65e4e78e 1313
ca65c044
WS
1314 void AutoSizeRows( bool setAsMin = true )
1315 { (void)SetOrCalcRowSizes(false, setAsMin); }
57c086ef
VZ
1316
1317 // auto size the grid, that is make the columns/rows of the "right" size
1318 // and also set the grid size to just fit its contents
1319 void AutoSize();
1320
733f486a
VZ
1321 // Note for both AutoSizeRowLabelSize and AutoSizeColLabelSize:
1322 // If col equals to wxGRID_AUTOSIZE value then function autosizes labels column
1323 // instead of data column. Note that this operation may be slow for large
1324 // tables.
d43851f7
JS
1325 // autosize row height depending on label text
1326 void AutoSizeRowLabelSize( int row );
1327
1328 // autosize column width depending on label text
1329 void AutoSizeColLabelSize( int col );
1330
43947979
VZ
1331 // column won't be resized to be lesser width - this must be called during
1332 // the grid creation because it won't resize the column if it's already
1333 // narrower than the minimal width
1334 void SetColMinimalWidth( int col, int width );
af547d51 1335 void SetRowMinimalHeight( int row, int width );
43947979 1336
b8d24d4e
RG
1337 /* These members can be used to query and modify the minimal
1338 * acceptable size of grid rows and columns. Call this function in
1339 * your code which creates the grid if you want to display cells
1340 * with a size smaller than the default acceptable minimum size.
1341 * Like the members SetColMinimalWidth and SetRowMinimalWidth,
1342 * the existing rows or columns will not be checked/resized.
1343 */
1344 void SetColMinimalAcceptableWidth( int width );
1345 void SetRowMinimalAcceptableHeight( int width );
1346 int GetColMinimalAcceptableWidth() const;
1347 int GetRowMinimalAcceptableHeight() const;
1348
f85afd4e
MB
1349 void SetDefaultCellBackgroundColour( const wxColour& );
1350 void SetCellBackgroundColour( int row, int col, const wxColour& );
1351 void SetDefaultCellTextColour( const wxColour& );
8fb66724 1352
f85afd4e 1353 void SetCellTextColour( int row, int col, const wxColour& );
f85afd4e
MB
1354 void SetDefaultCellFont( const wxFont& );
1355 void SetCellFont( int row, int col, const wxFont& );
1356 void SetDefaultCellAlignment( int horiz, int vert );
1357 void SetCellAlignment( int row, int col, int horiz, int vert );
27f35b66
SN
1358 void SetDefaultCellOverflow( bool allow );
1359 void SetCellOverflow( int row, int col, bool allow );
1360 void SetCellSize( int row, int col, int num_rows, int num_cols );
f85afd4e 1361
ab79958a 1362 // takes ownership of the pointer
2796cce3 1363 void SetDefaultRenderer(wxGridCellRenderer *renderer);
ab79958a 1364 void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
2796cce3 1365 wxGridCellRenderer *GetDefaultRenderer() const;
ef316e23 1366 wxGridCellRenderer* GetCellRenderer(int row, int col) const;
2796cce3 1367
283b7808 1368 // takes ownership of the pointer
0ba143c9 1369 void SetDefaultEditor(wxGridCellEditor *editor);
9b4aede2 1370 void SetCellEditor(int row, int col, wxGridCellEditor *editor);
0ba143c9 1371 wxGridCellEditor *GetDefaultEditor() const;
ef316e23 1372 wxGridCellEditor* GetCellEditor(int row, int col) const;
9b4aede2 1373
60a67569 1374
f2d76237 1375
f85afd4e
MB
1376 // ------ cell value accessors
1377 //
ef316e23 1378 wxString GetCellValue( int row, int col ) const
f85afd4e
MB
1379 {
1380 if ( m_table )
1381 {
1382 return m_table->GetValue( row, col );
1383 }
1384 else
1385 {
1386 return wxEmptyString;
1387 }
1388 }
1389
ef316e23 1390 wxString GetCellValue( const wxGridCellCoords& coords ) const
f85afd4e 1391 { return GetCellValue( coords.GetRow(), coords.GetCol() ); }
60ff3b99 1392
f85afd4e
MB
1393 void SetCellValue( int row, int col, const wxString& s );
1394 void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
1395 { SetCellValue( coords.GetRow(), coords.GetCol(), s ); }
f85afd4e 1396
ca65c044 1397 // returns true if the cell can't be edited
283b7808 1398 bool IsReadOnly(int row, int col) const;
60ff3b99 1399
283b7808 1400 // make the cell editable/readonly
ca65c044 1401 void SetReadOnly(int row, int col, bool isReadOnly = true);
f85afd4e 1402
aa5b8857 1403 // ------ select blocks of cells
f85afd4e 1404 //
ca65c044
WS
1405 void SelectRow( int row, bool addToSelected = false );
1406 void SelectCol( int col, bool addToSelected = false );
60ff3b99 1407
c9097836 1408 void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
ca65c044 1409 bool addToSelected = false );
f85afd4e
MB
1410
1411 void SelectBlock( const wxGridCellCoords& topLeft,
c9097836 1412 const wxGridCellCoords& bottomRight,
ca65c044 1413 bool addToSelected = false )
f85afd4e 1414 { SelectBlock( topLeft.GetRow(), topLeft.GetCol(),
c9097836
MB
1415 bottomRight.GetRow(), bottomRight.GetCol(),
1416 addToSelected ); }
f85afd4e
MB
1417
1418 void SelectAll();
60ff3b99 1419
ef316e23 1420 bool IsSelection() const;
f85afd4e 1421
aa5b8857 1422 // ------ deselect blocks or cells
f7b4b343
VZ
1423 //
1424 void DeselectRow( int row );
1425 void DeselectCol( int col );
1426 void DeselectCell( int row, int col );
1427
f85afd4e
MB
1428 void ClearSelection();
1429
84035150 1430 bool IsInSelection( int row, int col ) const;
f85afd4e 1431
84035150 1432 bool IsInSelection( const wxGridCellCoords& coords ) const
f85afd4e
MB
1433 { return IsInSelection( coords.GetRow(), coords.GetCol() ); }
1434
aa5b8857
SN
1435 wxGridCellCoordsArray GetSelectedCells() const;
1436 wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
1437 wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
1438 wxArrayInt GetSelectedRows() const;
1439 wxArrayInt GetSelectedCols() const;
c3baf426
SN
1440
1441 // This function returns the rectangle that encloses the block of cells
1442 // limited by TopLeft and BottomRight cell in device coords and clipped
1443 // to the client size of the grid window.
1444 //
58dd5b3b 1445 wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
ef316e23 1446 const wxGridCellCoords & bottomRight ) const;
c3baf426 1447
2796cce3
RD
1448 // Access or update the selection fore/back colours
1449 wxColour GetSelectionBackground() const
1450 { return m_selectionBackground; }
1451 wxColour GetSelectionForeground() const
1452 { return m_selectionForeground; }
1453
1454 void SetSelectionBackground(const wxColour& c) { m_selectionBackground = c; }
1455 void SetSelectionForeground(const wxColour& c) { m_selectionForeground = c; }
1456
1457
f2d76237
RD
1458 // Methods for a registry for mapping data types to Renderers/Editors
1459 void RegisterDataType(const wxString& typeName,
1460 wxGridCellRenderer* renderer,
1461 wxGridCellEditor* editor);
73145b0e
JS
1462 // DJC MAPTEK
1463 virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
99306db2
VZ
1464 wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
1465 { return GetDefaultEditorForCell(c.GetRow(), c.GetCol()); }
73145b0e
JS
1466 virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
1467 virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
1468 virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
f2d76237 1469
266e8367
VZ
1470 // grid may occupy more space than needed for its rows/columns, this
1471 // function allows to set how big this extra space is
1472 void SetMargins(int extraWidth, int extraHeight)
1473 {
1474 m_extraWidth = extraWidth;
1475 m_extraHeight = extraHeight;
b8125adf
VZ
1476
1477 CalcDimensions();
266e8367 1478 }
f85afd4e 1479
d2520c85 1480 // Accessors for component windows
ef316e23
VZ
1481 wxWindow* GetGridWindow() const { return (wxWindow*)m_gridWin; }
1482 wxWindow* GetGridRowLabelWindow() const { return (wxWindow*)m_rowLabelWin; }
ad805b9e 1483 wxWindow* GetGridColLabelWindow() const { return m_colWindow; }
ef316e23 1484 wxWindow* GetGridCornerLabelWindow() const { return (wxWindow*)m_cornerLabelWin; }
d2520c85 1485
3039ade9
VZ
1486 // This one can only be called if we are using the native header window
1487 wxHeaderCtrl *GetGridColHeader() const
1488 {
1489 wxASSERT_MSG( m_useNativeHeader, "no column header window" );
1490
1491 // static_cast<> doesn't work without the full class declaration in
1492 // view and we prefer to avoid adding more compile-time dependencies
1493 // even at the cost of using reinterpret_cast<>
1494 return reinterpret_cast<wxHeaderCtrl *>(m_colWindow);
1495 }
1496
608754c4
JS
1497 // Allow adjustment of scroll increment. The default is (15, 15).
1498 void SetScrollLineX(int x) { m_scrollLineX = x; }
1499 void SetScrollLineY(int y) { m_scrollLineY = y; }
1500 int GetScrollLineX() const { return m_scrollLineX; }
1501 int GetScrollLineY() const { return m_scrollLineY; }
1502
1edce33f
VZ
1503 // ------- drag and drop
1504#if wxUSE_DRAG_AND_DROP
1505 virtual void SetDropTarget(wxDropTarget *dropTarget);
1506#endif // wxUSE_DRAG_AND_DROP
bf646121 1507
bf2c8b31 1508
11393d29
VZ
1509 // ------- sorting support
1510
1511 // wxGrid doesn't support sorting on its own but it can indicate the sort
1512 // order in the column header (currently only if native header control is
1513 // used though)
1514
1515 // return the column currently displaying the sort indicator or wxNOT_FOUND
1516 // if none
1517 int GetSortingColumn() const { return m_sortCol; }
1518
1519 // return true if this column is currently used for sorting
1520 bool IsSortingBy(int col) const { return GetSortingColumn() == col; }
1521
1522 // return the current sorting order (on GetSortingColumn()): true for
1523 // ascending sort and false for descending; it doesn't make sense to call
1524 // it if GetSortingColumn() returns wxNOT_FOUND
1525 bool IsSortOrderAscending() const { return m_sortIsAscending; }
1526
1527 // set the sorting column (or unsets any existing one if wxNOT_FOUND) and
1528 // the order in which to sort
1529 void SetSortingColumn(int col, bool ascending = true);
1530
1531 // unset any existing sorting column
1532 void UnsetSortingColumn() { SetSortingColumn(wxNOT_FOUND); }
1533
bf2c8b31 1534#ifdef WXWIN_COMPATIBILITY_2_8
f85afd4e
MB
1535 // ------ For compatibility with previous wxGrid only...
1536 //
1537 // ************************************************
1538 // ** Don't use these in new code because they **
1539 // ** are liable to disappear in a future **
1540 // ** revision **
1541 // ************************************************
1542 //
1543
1544 wxGrid( wxWindow *parent,
422d0ff0 1545 int x, int y, int w = wxDefaultCoord, int h = wxDefaultCoord,
ebd773c6 1546 long style = wxWANTS_CHARS,
f85afd4e 1547 const wxString& name = wxPanelNameStr )
ad805b9e
VZ
1548 {
1549 Init();
1550 Create(parent, wxID_ANY, wxPoint(x, y), wxSize(w, h), style, name);
1551 }
f85afd4e
MB
1552
1553 void SetCellValue( const wxString& val, int row, int col )
1554 { SetCellValue( row, col, val ); }
60ff3b99 1555
f85afd4e
MB
1556 void UpdateDimensions()
1557 { CalcDimensions(); }
1558
ef316e23
VZ
1559 int GetRows() const { return GetNumberRows(); }
1560 int GetCols() const { return GetNumberCols(); }
1561 int GetCursorRow() const { return GetGridCursorRow(); }
1562 int GetCursorColumn() const { return GetGridCursorCol(); }
60ff3b99 1563
ef316e23
VZ
1564 int GetScrollPosX() const { return 0; }
1565 int GetScrollPosY() const { return 0; }
60ff3b99 1566
aa5e1f75
SN
1567 void SetScrollX( int WXUNUSED(x) ) { }
1568 void SetScrollY( int WXUNUSED(y) ) { }
f85afd4e
MB
1569
1570 void SetColumnWidth( int col, int width )
1571 { SetColSize( col, width ); }
60ff3b99 1572
ef316e23 1573 int GetColumnWidth( int col ) const
f85afd4e 1574 { return GetColSize( col ); }
60ff3b99 1575
f85afd4e
MB
1576 void SetRowHeight( int row, int height )
1577 { SetRowSize( row, height ); }
60ff3b99 1578
7c1cb261 1579 // GetRowHeight() is below
60ff3b99 1580
ef316e23 1581 int GetViewHeight() const // returned num whole rows visible
2d66e025 1582 { return 0; }
60ff3b99 1583
ef316e23 1584 int GetViewWidth() const // returned num whole cols visible
2d66e025 1585 { return 0; }
f85afd4e
MB
1586
1587 void SetLabelSize( int orientation, int sz )
1588 {
1589 if ( orientation == wxHORIZONTAL )
1590 SetColLabelSize( sz );
1591 else
1592 SetRowLabelSize( sz );
1593 }
1594
ef316e23 1595 int GetLabelSize( int orientation ) const
f85afd4e
MB
1596 {
1597 if ( orientation == wxHORIZONTAL )
1598 return GetColLabelSize();
1599 else
1600 return GetRowLabelSize();
1601 }
1602
1603 void SetLabelAlignment( int orientation, int align )
1604 {
1605 if ( orientation == wxHORIZONTAL )
1606 SetColLabelAlignment( align, -1 );
1607 else
1608 SetRowLabelAlignment( align, -1 );
1609 }
1610
ef316e23 1611 int GetLabelAlignment( int orientation, int WXUNUSED(align) ) const
f85afd4e
MB
1612 {
1613 int h, v;
1614 if ( orientation == wxHORIZONTAL )
1615 {
1616 GetColLabelAlignment( &h, &v );
1617 return h;
1618 }
1619 else
1620 {
1621 GetRowLabelAlignment( &h, &v );
1622 return h;
1623 }
1624 }
1625
1626 void SetLabelValue( int orientation, const wxString& val, int pos )
1627 {
1628 if ( orientation == wxHORIZONTAL )
1629 SetColLabelValue( pos, val );
1630 else
1631 SetRowLabelValue( pos, val );
1632 }
60ff3b99 1633
ef316e23 1634 wxString GetLabelValue( int orientation, int pos) const
f85afd4e
MB
1635 {
1636 if ( orientation == wxHORIZONTAL )
1637 return GetColLabelValue( pos );
1638 else
1639 return GetRowLabelValue( pos );
1640 }
1641
60ff3b99 1642 wxFont GetCellTextFont() const
2796cce3 1643 { return m_defaultCellAttr->GetFont(); }
60ff3b99 1644
af111fc3 1645 wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const
2796cce3 1646 { return m_defaultCellAttr->GetFont(); }
60ff3b99 1647
f85afd4e
MB
1648 void SetCellTextFont(const wxFont& fnt)
1649 { SetDefaultCellFont( fnt ); }
60ff3b99 1650
f85afd4e
MB
1651 void SetCellTextFont(const wxFont& fnt, int row, int col)
1652 { SetCellFont( row, col, fnt ); }
60ff3b99 1653
f85afd4e
MB
1654 void SetCellTextColour(const wxColour& val, int row, int col)
1655 { SetCellTextColour( row, col, val ); }
60ff3b99 1656
f85afd4e
MB
1657 void SetCellTextColour(const wxColour& col)
1658 { SetDefaultCellTextColour( col ); }
60ff3b99 1659
f85afd4e
MB
1660 void SetCellBackgroundColour(const wxColour& col)
1661 { SetDefaultCellBackgroundColour( col ); }
60ff3b99 1662
f85afd4e
MB
1663 void SetCellBackgroundColour(const wxColour& colour, int row, int col)
1664 { SetCellBackgroundColour( row, col, colour ); }
60ff3b99 1665
ef316e23 1666 bool GetEditable() const { return IsEditable(); }
ca65c044 1667 void SetEditable( bool edit = true ) { EnableEditing( edit ); }
ef316e23 1668 bool GetEditInPlace() const { return IsCellEditControlEnabled(); }
8fb66724 1669
ca65c044 1670 void SetEditInPlace(bool WXUNUSED(edit) = true) { }
f85afd4e 1671
60a67569 1672 void SetCellAlignment( int align, int row, int col)
4c7277db 1673 { SetCellAlignment(row, col, align, wxALIGN_CENTER); }
60a67569
JS
1674 void SetCellAlignment( int WXUNUSED(align) ) {}
1675 void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col))
1676 { }
1677 void SetDividerPen(const wxPen& WXUNUSED(pen)) { }
6fc0f38f 1678 wxPen& GetDividerPen() const;
60a67569 1679 void OnActivate(bool WXUNUSED(active)) {}
60ff3b99 1680
f85afd4e
MB
1681 // ******** End of compatibility functions **********
1682
2d66e025
MB
1683
1684
f85afd4e 1685 // ------ control IDs
2d66e025 1686 enum { wxGRID_CELLCTRL = 2000,
f85afd4e
MB
1687 wxGRID_TOPCTRL };
1688
1689 // ------ control types
2d66e025 1690 enum { wxGRID_TEXTCTRL = 2100,
f85afd4e
MB
1691 wxGRID_CHECKBOX,
1692 wxGRID_CHOICE,
1693 wxGRID_COMBOBOX };
82edfbe7
VZ
1694
1695 wxDEPRECATED_INLINE(bool CanDragRowSize() const, return m_canDragRowSize; )
1696 wxDEPRECATED_INLINE(bool CanDragColSize() const, return m_canDragColSize; )
bf2c8b31
VZ
1697#endif // WXWIN_COMPATIBILITY_2_8
1698
f85afd4e 1699
bf2c8b31
VZ
1700 // override some base class functions
1701 virtual bool Enable(bool enable = true);
1702 virtual wxWindow *GetMainWindowOfCompositeControl()
1703 { return (wxWindow*)m_gridWin; }
266e8367
VZ
1704 virtual void Fit();
1705
86033c4b
VZ
1706 // implementation only
1707 void CancelMouseCapture();
1708
60ff3b99 1709protected:
266e8367
VZ
1710 virtual wxSize DoGetBestSize() const;
1711
60ff3b99
VZ
1712 bool m_created;
1713
1714 wxGridWindow *m_gridWin;
60ff3b99 1715 wxGridCornerLabelWindow *m_cornerLabelWin;
ad805b9e
VZ
1716 wxGridRowLabelWindow *m_rowLabelWin;
1717
1718 // the real type of the column window depends on m_useNativeHeader value:
1719 // if it is true, its dynamic type is wxHeaderCtrl, otherwise it is
1720 // wxGridColLabelWindow, use accessors below when the real type matters
1721 wxWindow *m_colWindow;
1722
ad805b9e
VZ
1723 wxGridColLabelWindow *GetColLabelWindow() const
1724 {
1725 wxASSERT_MSG( !m_useNativeHeader, "no column label window" );
1726
1727 return reinterpret_cast<wxGridColLabelWindow *>(m_colWindow);
1728 }
60ff3b99 1729
60ff3b99 1730 wxGridTableBase *m_table;
2796cce3 1731 bool m_ownTable;
60ff3b99 1732
60ff3b99
VZ
1733 int m_numRows;
1734 int m_numCols;
1735
1736 wxGridCellCoords m_currentCellCoords;
1737
8a3e536c
VZ
1738 // the corners of the block being currently selected or wxGridNoCellCoords
1739 wxGridCellCoords m_selectedBlockTopLeft;
1740 wxGridCellCoords m_selectedBlockBottomRight;
1741
1742 // when selecting blocks of cells (either from the keyboard using Shift
1743 // with cursor keys, or by dragging the mouse), the selection is anchored
1744 // at m_currentCellCoords which defines one of the corners of the rectangle
1745 // being selected -- and this variable defines the other corner, i.e. it's
1746 // either m_selectedBlockTopLeft or m_selectedBlockBottomRight depending on
1747 // which of them is not m_currentCellCoords
1748 //
1749 // if no block selection is in process, it is set to wxGridNoCellCoords
1750 wxGridCellCoords m_selectedBlockCorner;
1751
b5808881 1752 wxGridSelection *m_selection;
8a3e536c 1753
2796cce3
RD
1754 wxColour m_selectionBackground;
1755 wxColour m_selectionForeground;
60ff3b99 1756
7c1cb261
VZ
1757 // NB: *never* access m_row/col arrays directly because they are created
1758 // on demand, *always* use accessor functions instead!
1759
1760 // init the m_rowHeights/Bottoms arrays with default values
1761 void InitRowHeights();
1762
60ff3b99 1763 int m_defaultRowHeight;
b8d24d4e 1764 int m_minAcceptableRowHeight;
60ff3b99
VZ
1765 wxArrayInt m_rowHeights;
1766 wxArrayInt m_rowBottoms;
1767
7c1cb261
VZ
1768 // init the m_colWidths/Rights arrays
1769 void InitColWidths();
1770
60ff3b99 1771 int m_defaultColWidth;
b8d24d4e 1772 int m_minAcceptableColWidth;
60ff3b99
VZ
1773 wxArrayInt m_colWidths;
1774 wxArrayInt m_colRights;
bf2c8b31 1775
11393d29
VZ
1776 int m_sortCol;
1777 bool m_sortIsAscending;
1778
ad805b9e
VZ
1779 bool m_useNativeHeader,
1780 m_nativeColumnLabels;
7c1cb261
VZ
1781
1782 // get the col/row coords
1783 int GetColWidth(int col) const;
1784 int GetColLeft(int col) const;
1785 int GetColRight(int col) const;
1786
1787 // this function must be public for compatibility...
1788public:
1789 int GetRowHeight(int row) const;
1790protected:
1791
1792 int GetRowTop(int row) const;
1793 int GetRowBottom(int row) const;
1794
60ff3b99
VZ
1795 int m_rowLabelWidth;
1796 int m_colLabelHeight;
1797
266e8367
VZ
1798 // the size of the margin left to the right and bottom of the cell area
1799 int m_extraWidth,
1800 m_extraHeight;
1801
60ff3b99
VZ
1802 wxColour m_labelBackgroundColour;
1803 wxColour m_labelTextColour;
1804 wxFont m_labelFont;
1805
1806 int m_rowLabelHorizAlign;
1807 int m_rowLabelVertAlign;
1808 int m_colLabelHorizAlign;
1809 int m_colLabelVertAlign;
d43851f7 1810 int m_colLabelTextOrientation;
60ff3b99
VZ
1811
1812 bool m_defaultRowLabelValues;
1813 bool m_defaultColLabelValues;
1814
1815 wxColour m_gridLineColour;
1816 bool m_gridLinesEnabled;
9f7aee01
VZ
1817 bool m_gridLinesClipHorz,
1818 m_gridLinesClipVert;
f6bcfd97 1819 wxColour m_cellHighlightColour;
d2520c85
RD
1820 int m_cellHighlightPenWidth;
1821 int m_cellHighlightROPenWidth;
1822
60ff3b99 1823
266e8367 1824 // common part of AutoSizeColumn/Row() and GetBestSize()
ca65c044
WS
1825 int SetOrCalcColumnSizes(bool calcOnly, bool setAsMin = true);
1826 int SetOrCalcRowSizes(bool calcOnly, bool setAsMin = true);
266e8367 1827
af547d51 1828 // common part of AutoSizeColumn/Row()
733f486a
VZ
1829 void AutoSizeColOrRow(int n, bool setAsMin, wxGridDirection direction);
1830
1831 // Calculate the minimum acceptable size for labels area
1832 wxCoord CalcColOrRowLabelAreaMinSize(wxGridDirection direction);
af547d51 1833
43947979
VZ
1834 // if a column has a minimal width, it will be the value for it in this
1835 // hash table
ba8c1601
MB
1836 wxLongToLongHashMap m_colMinWidths,
1837 m_rowMinHeights;
43947979 1838
af547d51
VZ
1839 // get the minimal width of the given column/row
1840 int GetColMinimalWidth(int col) const;
1841 int GetRowMinimalHeight(int col) const;
b99be8fb
VZ
1842
1843 // do we have some place to store attributes in?
ef316e23 1844 bool CanHaveAttributes() const;
60ff3b99 1845
0a976765
VZ
1846 // cell attribute cache (currently we only cache 1, may be will do
1847 // more/better later)
1848 struct CachedAttr
1849 {
1850 int row, col;
1851 wxGridCellAttr *attr;
1852 } m_attrCache;
1853
1854 // invalidates the attribute cache
1855 void ClearAttrCache();
1856
1857 // adds an attribute to cache
1858 void CacheAttr(int row, int col, wxGridCellAttr *attr) const;
1859
ca65c044 1860 // looks for an attr in cache, returns true if found
0a976765
VZ
1861 bool LookupAttr(int row, int col, wxGridCellAttr **attr) const;
1862
1863 // looks for the attr in cache, if not found asks the table and caches the
1864 // result
2e9a6788 1865 wxGridCellAttr *GetCellAttr(int row, int col) const;
ef316e23 1866 wxGridCellAttr *GetCellAttr(const wxGridCellCoords& coords ) const
2c9a89e0 1867 { return GetCellAttr( coords.GetRow(), coords.GetCol() ); }
2e9a6788 1868
2796cce3
RD
1869 // the default cell attr object for cells that don't have their own
1870 wxGridCellAttr* m_defaultCellAttr;
1871
1872
60ff3b99
VZ
1873 bool m_inOnKeyDown;
1874 int m_batchCount;
1875
f2d76237
RD
1876
1877 wxGridTypeRegistry* m_typeRegistry;
1878
e2b42eeb
VZ
1879 enum CursorMode
1880 {
1881 WXGRID_CURSOR_SELECT_CELL,
1882 WXGRID_CURSOR_RESIZE_ROW,
1883 WXGRID_CURSOR_RESIZE_COL,
1884 WXGRID_CURSOR_SELECT_ROW,
d4175745
VZ
1885 WXGRID_CURSOR_SELECT_COL,
1886 WXGRID_CURSOR_MOVE_COL
60ff3b99
VZ
1887 };
1888
e2b42eeb 1889 // this method not only sets m_cursorMode but also sets the correct cursor
ca65c044 1890 // for the given mode and, if captureMouse is not false releases the mouse
e2b42eeb
VZ
1891 // if it was captured and captures it if it must be captured
1892 //
1893 // for this to work, you should always use it and not set m_cursorMode
1894 // directly!
1895 void ChangeCursorMode(CursorMode mode,
8a3e536c 1896 wxWindow *win = NULL,
ca65c044 1897 bool captureMouse = true);
e2b42eeb
VZ
1898
1899 wxWindow *m_winCapture; // the window which captured the mouse
8a3e536c
VZ
1900
1901 // this variable is used not for finding the correct current cursor but
1902 // mainly for finding out what is going to happen if the mouse starts being
1903 // dragged right now
1904 //
1905 // by default it is WXGRID_CURSOR_SELECT_CELL meaning that nothing else is
1906 // going on, and it is set to one of RESIZE/SELECT/MOVE values while the
1907 // corresponding operation will be started if the user starts dragging the
1908 // mouse from the current position
e2b42eeb
VZ
1909 CursorMode m_cursorMode;
1910
8a3e536c 1911
d4175745
VZ
1912 //Column positions
1913 wxArrayInt m_colAt;
d4175745 1914
6e8524b1
MB
1915 bool m_canDragRowSize;
1916 bool m_canDragColSize;
d4175745 1917 bool m_canDragColMove;
4cfa5de6 1918 bool m_canDragGridSize;
79dbea21 1919 bool m_canDragCell;
bec70262
VZ
1920
1921 // the last position (horizontal or vertical depending on whether the user
1922 // is resizing a column or a row) where a row or column separator line was
1923 // dragged by the user or -1 of there is no drag operation in progress
07296f0b
RD
1924 int m_dragLastPos;
1925 int m_dragRowOrCol;
bec70262 1926
8a3e536c
VZ
1927 // true if a drag operation is in progress; when this is true,
1928 // m_startDragPos is valid, i.e. not wxDefaultPosition
07296f0b 1929 bool m_isDragging;
8a3e536c
VZ
1930
1931 // the position (in physical coordinates) where the user started dragging
1932 // the mouse or wxDefaultPosition if mouse isn't being dragged
1933 //
1934 // notice that this can be != wxDefaultPosition while m_isDragging is still
1935 // false because we wait until the mouse is moved some distance away before
1936 // setting m_isDragging to true
07296f0b 1937 wxPoint m_startDragPos;
60ff3b99 1938
75ecbe45 1939 bool m_waitForSlowClick;
025562fe 1940
60ff3b99
VZ
1941 wxGridCellCoords m_selectionStart;
1942
1943 wxCursor m_rowResizeCursor;
1944 wxCursor m_colResizeCursor;
1945
b54ba671
VZ
1946 bool m_editable; // applies to whole grid
1947 bool m_cellEditCtrlEnabled; // is in-place edit currently shown?
60ff3b99 1948
608754c4
JS
1949 int m_scrollLineX; // X scroll increment
1950 int m_scrollLineY; // Y scroll increment
60ff3b99 1951
ad805b9e 1952 void Init(); // common part of all ctors
60ff3b99 1953 void Create();
ad805b9e 1954 void CreateColumnWindow();
60ff3b99 1955 void CalcDimensions();
7807d81c 1956 void CalcWindowSizes();
60ff3b99
VZ
1957 bool Redimension( wxGridTableMessage& );
1958
1959
8a3e536c
VZ
1960 // generate the appropriate grid event and return -1 if it was vetoed, 1 if
1961 // it was processed (but not vetoed) and 0 if it wasn't processed
1962 int SendEvent(const wxEventType evtType,
1963 int row, int col,
27bb2c8c 1964 const wxMouseEvent& e);
8a3e536c
VZ
1965 int SendEvent(const wxEventType evtType,
1966 const wxGridCellCoords& coords,
27bb2c8c 1967 const wxMouseEvent& e)
8a3e536c 1968 { return SendEvent(evtType, coords.GetRow(), coords.GetCol(), e); }
763163a8
VZ
1969 int SendEvent(const wxEventType evtType,
1970 int row, int col,
1971 const wxString& s = wxString());
1972 int SendEvent(const wxEventType evtType,
1973 const wxGridCellCoords& coords,
1974 const wxString& s = wxString())
1975 { return SendEvent(evtType, coords.GetRow(), coords.GetCol(), s); }
1976 int SendEvent(const wxEventType evtType, const wxString& s = wxString())
1977 { return SendEvent(evtType, m_currentCellCoords, s); }
60ff3b99 1978
27bb2c8c 1979 // send wxEVT_GRID_{ROW,COL}_SIZE
c5c1ea96
VZ
1980 void SendGridSizeEvent(wxEventType type,
1981 int row, int col,
1982 const wxMouseEvent& mouseEv);
27bb2c8c 1983
60ff3b99
VZ
1984 void OnPaint( wxPaintEvent& );
1985 void OnSize( wxSizeEvent& );
1986 void OnKeyDown( wxKeyEvent& );
f6bcfd97 1987 void OnKeyUp( wxKeyEvent& );
63e2147c 1988 void OnChar( wxKeyEvent& );
2796cce3 1989 void OnEraseBackground( wxEraseEvent& );
60ff3b99
VZ
1990
1991
8a3e536c
VZ
1992 bool SetCurrentCell( const wxGridCellCoords& coords );
1993 bool SetCurrentCell( int row, int col )
1994 { return SetCurrentCell( wxGridCellCoords(row, col) ); }
1995
60ff3b99 1996
8a3e536c
VZ
1997 // this function is called to extend the block being currently selected
1998 // from mouse and keyboard event handlers
1999 void UpdateBlockBeingSelected(int topRow, int leftCol,
2000 int bottomRow, int rightCol);
c9097836 2001
8a3e536c
VZ
2002 void UpdateBlockBeingSelected(const wxGridCellCoords& topLeft,
2003 const wxGridCellCoords& bottomRight)
2004 { UpdateBlockBeingSelected(topLeft.GetRow(), topLeft.GetCol(),
2005 bottomRight.GetRow(), bottomRight.GetCol()); }
60ff3b99
VZ
2006
2007 // ------ functions to get/send data (see also public functions)
2008 //
2009 bool GetModelValues();
2010 bool SetModelValues();
2011
b5dbe15d 2012 friend class WXDLLIMPEXP_FWD_ADV wxGridSelection;
bec70262
VZ
2013 friend class wxGridRowOperations;
2014 friend class wxGridColumnOperations;
60ff3b99 2015
8a3e536c
VZ
2016 // they call our private Process{{Corner,Col,Row}Label,GridCell}MouseEvent()
2017 friend class wxGridCornerLabelWindow;
2018 friend class wxGridColLabelWindow;
2019 friend class wxGridRowLabelWindow;
2020 friend class wxGridWindow;
2021
ad805b9e
VZ
2022 friend class wxGridHeaderCtrl;
2023
69367c56
VZ
2024private:
2025 // implement wxScrolledWindow method to return m_gridWin size
2026 virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size);
2027
9f7aee01
VZ
2028 // redraw the grid lines, should be called after changing their attributes
2029 void RedrawGridLines();
2030
2031 // common part of Clip{Horz,Vert}GridLines
2032 void DoClipGridLines(bool& var, bool clip);
2033
11393d29
VZ
2034 // update the sorting indicator shown in the specified column (whose index
2035 // must be valid)
2036 //
2037 // this will use GetSortingColumn() and IsSortOrderAscending() to determine
2038 // the sorting indicator to effectively show
2039 void UpdateColumnSortingIndicator(int col);
2040
4797b014
VZ
2041 // update the grid after changing the columns order (common part of
2042 // SetColPos() and ResetColPos())
2043 void RefreshAfterColPosChange();
009c7216 2044
9f7aee01 2045
cd4f6f5f
VZ
2046 // return the position (not index) of the column at the given logical pixel
2047 // position
2048 //
2049 // this always returns a valid position, even if the coordinate is out of
2050 // bounds (in which case first/last column is returned)
2051 int XToPos(int x) const;
2052
2053
8a3e536c
VZ
2054 // event handlers and their helpers
2055 // --------------------------------
2056
2057 // process mouse drag event in WXGRID_CURSOR_SELECT_CELL mode
2058 void DoGridCellDrag(wxMouseEvent& event,
2059 const wxGridCellCoords& coords,
2060 bool isFirstDrag);
2061
2062 // process row/column resizing drag event
2063 void DoGridLineDrag(wxMouseEvent& event, const wxGridOperations& oper);
2064
2065 // process mouse drag event in the grid window
2066 void DoGridDragEvent(wxMouseEvent& event, const wxGridCellCoords& coords);
2067
2068 // process different clicks on grid cells
2069 void DoGridCellLeftDown(wxMouseEvent& event,
2070 const wxGridCellCoords& coords,
2071 const wxPoint& pos);
2072 void DoGridCellLeftDClick(wxMouseEvent& event,
2073 const wxGridCellCoords& coords,
2074 const wxPoint& pos);
2075 void DoGridCellLeftUp(wxMouseEvent& event, const wxGridCellCoords& coords);
2076
2077 // process movement (but not dragging) event in the grid cell area
2078 void DoGridMouseMoveEvent(wxMouseEvent& event,
2079 const wxGridCellCoords& coords,
2080 const wxPoint& pos);
2081
2082 // process mouse events in the grid window
2083 void ProcessGridCellMouseEvent(wxMouseEvent& event);
2084
2085 // process mouse events in the row/column labels/corner windows
2086 void ProcessRowLabelMouseEvent(wxMouseEvent& event);
2087 void ProcessColLabelMouseEvent(wxMouseEvent& event);
2088 void ProcessCornerLabelMouseEvent(wxMouseEvent& event);
2089
11393d29
VZ
2090 void DoColHeaderClick(int col);
2091
ad805b9e
VZ
2092 void DoStartResizeCol(int col);
2093 void DoUpdateResizeCol(int x);
2094 void DoUpdateResizeColWidth(int w);
cd68daf5 2095 void DoStartMoveCol(int col);
ad805b9e 2096
27bb2c8c
VZ
2097 void DoEndDragResizeRow(const wxMouseEvent& event);
2098 void DoEndDragResizeCol(const wxMouseEvent& event);
cd68daf5 2099 void DoEndMoveCol(int pos);
8a3e536c 2100
bec70262
VZ
2101
2102 // common implementations of methods defined for both rows and columns
2103 void DeselectLine(int line, const wxGridOperations& oper);
27bb2c8c 2104 bool DoEndDragResizeLine(const wxGridOperations& oper);
cd4f6f5f
VZ
2105 int PosToLinePos(int pos, bool clipToMinMax,
2106 const wxGridOperations& oper) const;
2107 int PosToLine(int pos, bool clipToMinMax,
2108 const wxGridOperations& oper) const;
10a4531d
VZ
2109 int PosToEdgeOfLine(int pos, const wxGridOperations& oper) const;
2110
2111 bool DoMoveCursor(bool expandSelection,
2112 const wxGridDirectionOperations& diroper);
2113 bool DoMoveCursorByPage(const wxGridDirectionOperations& diroper);
2114 bool DoMoveCursorByBlock(bool expandSelection,
2115 const wxGridDirectionOperations& diroper);
2116 void AdvanceToNextNonEmpty(wxGridCellCoords& coords,
2117 const wxGridDirectionOperations& diroper);
2118
2119 // common part of {Insert,Delete}{Rows,Cols}
2120 bool DoModifyLines(bool (wxGridTableBase::*funcModify)(size_t, size_t),
2121 int pos, int num, bool updateLabels);
2122 // Append{Rows,Cols} is a bit different because of one less parameter
2123 bool DoAppendLines(bool (wxGridTableBase::*funcAppend)(size_t),
2124 int num, bool updateLabels);
bec70262 2125
82edfbe7 2126 // common part of Set{Col,Row}Sizes
574e1c5a
VZ
2127 void DoSetSizes(const wxGridSizesInfo& sizeInfo,
2128 const wxGridOperations& oper);
2129
82edfbe7
VZ
2130 // common part of Disable{Row,Col}Resize and CanDrag{Row,Col}Size
2131 void DoDisableLineResize(int line, wxGridFixedIndicesSet *& setFixed);
2132 bool DoCanResizeLine(int line, const wxGridFixedIndicesSet *setFixed) const;
2133
2134
2135
2136 // these sets contain the indices of fixed, i.e. non-resizable
2137 // interactively, grid rows or columns and are NULL if there are no fixed
2138 // elements (which is the default)
2139 wxGridFixedIndicesSet *m_setFixedRows,
2140 *m_setFixedCols;
2141
2d66e025 2142 DECLARE_DYNAMIC_CLASS( wxGrid )
f85afd4e 2143 DECLARE_EVENT_TABLE()
c0c133e1 2144 wxDECLARE_NO_COPY_CLASS(wxGrid);
f85afd4e
MB
2145};
2146
b62f94ff
VZ
2147// ----------------------------------------------------------------------------
2148// wxGridUpdateLocker prevents updates to a grid during its lifetime
2149// ----------------------------------------------------------------------------
2150
2151class WXDLLIMPEXP_ADV wxGridUpdateLocker
2152{
2153public:
2154 // if the pointer is NULL, Create() can be called later
2155 wxGridUpdateLocker(wxGrid *grid = NULL)
2156 {
2157 Init(grid);
2158 }
2159
2160 // can be called if ctor was used with a NULL pointer, must not be called
2161 // more than once
2162 void Create(wxGrid *grid)
2163 {
2164 wxASSERT_MSG( !m_grid, _T("shouldn't be called more than once") );
2165
2166 Init(grid);
2167 }
2168
2169 ~wxGridUpdateLocker()
2170 {
2171 if ( m_grid )
2172 m_grid->EndBatch();
2173 }
2174
2175private:
2176 void Init(wxGrid *grid)
2177 {
2178 m_grid = grid;
2179 if ( m_grid )
2180 m_grid->BeginBatch();
2181 }
2182
2183 wxGrid *m_grid;
2184
c0c133e1 2185 wxDECLARE_NO_COPY_CLASS(wxGridUpdateLocker);
b62f94ff
VZ
2186};
2187
43947979
VZ
2188// ----------------------------------------------------------------------------
2189// Grid event class and event types
2190// ----------------------------------------------------------------------------
f85afd4e 2191
8b5f6d9d
VZ
2192class WXDLLIMPEXP_ADV wxGridEvent : public wxNotifyEvent,
2193 public wxKeyboardState
f85afd4e 2194{
60ff3b99 2195public:
f85afd4e 2196 wxGridEvent()
8b5f6d9d
VZ
2197 : wxNotifyEvent()
2198 {
2199 Init(-1, -1, -1, -1, false);
2200 }
f85afd4e 2201
8b5f6d9d
VZ
2202 wxGridEvent(int id,
2203 wxEventType type,
2204 wxObject* obj,
2205 int row = -1, int col = -1,
2206 int x = -1, int y = -1,
2207 bool sel = true,
2208 const wxKeyboardState& kbd = wxKeyboardState())
2209 : wxNotifyEvent(type, id),
2210 wxKeyboardState(kbd)
2211 {
2212 Init(row, col, x, y, sel);
2213 SetEventObject(obj);
2214 }
2215
23318a53
FM
2216 // explicitly specifying inline allows gcc < 3.4 to
2217 // handle the deprecation attribute even in the constructor.
a05e6efe 2218 wxDEPRECATED_CONSTRUCTOR(
8b5f6d9d
VZ
2219 wxGridEvent(int id,
2220 wxEventType type,
2221 wxObject* obj,
2222 int row, int col,
2223 int x, int y,
2224 bool sel,
2225 bool control,
2226 bool shift = false, bool alt = false, bool meta = false));
f85afd4e
MB
2227
2228 virtual int GetRow() { return m_row; }
2229 virtual int GetCol() { return m_col; }
2230 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
5c8fc7c1 2231 bool Selecting() { return m_selecting; }
2d66e025 2232
e1f8ec29
RD
2233 virtual wxEvent *Clone() const { return new wxGridEvent(*this); }
2234
60ff3b99
VZ
2235protected:
2236 int m_row;
2237 int m_col;
f85afd4e
MB
2238 int m_x;
2239 int m_y;
5c8fc7c1 2240 bool m_selecting;
8b5f6d9d
VZ
2241
2242private:
2243 void Init(int row, int col, int x, int y, bool sel)
2244 {
2245 m_row = row;
2246 m_col = col;
2247 m_x = x;
2248 m_y = y;
2249 m_selecting = sel;
2250 }
60ff3b99 2251
e1f8ec29 2252 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEvent)
60ff3b99
VZ
2253};
2254
8b5f6d9d
VZ
2255class WXDLLIMPEXP_ADV wxGridSizeEvent : public wxNotifyEvent,
2256 public wxKeyboardState
60ff3b99
VZ
2257{
2258public:
f85afd4e 2259 wxGridSizeEvent()
8b5f6d9d
VZ
2260 : wxNotifyEvent()
2261 {
2262 Init(-1, -1, -1);
2263 }
2264
2265 wxGridSizeEvent(int id,
2266 wxEventType type,
2267 wxObject* obj,
2268 int rowOrCol = -1,
2269 int x = -1, int y = -1,
2270 const wxKeyboardState& kbd = wxKeyboardState())
2271 : wxNotifyEvent(type, id),
2272 wxKeyboardState(kbd)
2273 {
2274 Init(rowOrCol, x, y);
f85afd4e 2275
8b5f6d9d
VZ
2276 SetEventObject(obj);
2277 }
2278
a05e6efe 2279 wxDEPRECATED_CONSTRUCTOR(
8b5f6d9d
VZ
2280 wxGridSizeEvent(int id,
2281 wxEventType type,
2282 wxObject* obj,
2283 int rowOrCol,
2284 int x, int y,
2285 bool control,
2286 bool shift = false,
2287 bool alt = false,
2288 bool meta = false) );
f85afd4e
MB
2289
2290 int GetRowOrCol() { return m_rowOrCol; }
2291 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
733f486a 2292
e1f8ec29 2293 virtual wxEvent *Clone() const { return new wxGridSizeEvent(*this); }
2d66e025 2294
60ff3b99
VZ
2295protected:
2296 int m_rowOrCol;
2297 int m_x;
2298 int m_y;
8b5f6d9d
VZ
2299
2300private:
2301 void Init(int rowOrCol, int x, int y)
2302 {
2303 m_rowOrCol = rowOrCol;
2304 m_x = x;
2305 m_y = y;
2306 }
60ff3b99 2307
e1f8ec29 2308 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridSizeEvent)
f85afd4e
MB
2309};
2310
2311
8b5f6d9d
VZ
2312class WXDLLIMPEXP_ADV wxGridRangeSelectEvent : public wxNotifyEvent,
2313 public wxKeyboardState
f85afd4e 2314{
60ff3b99 2315public:
f85afd4e 2316 wxGridRangeSelectEvent()
60ff3b99 2317 : wxNotifyEvent()
8b5f6d9d
VZ
2318 {
2319 Init(wxGridNoCellCoords, wxGridNoCellCoords, false);
2320 }
f85afd4e 2321
8b5f6d9d
VZ
2322 wxGridRangeSelectEvent(int id,
2323 wxEventType type,
2324 wxObject* obj,
60ff3b99
VZ
2325 const wxGridCellCoords& topLeft,
2326 const wxGridCellCoords& bottomRight,
ca65c044 2327 bool sel = true,
8b5f6d9d
VZ
2328 const wxKeyboardState& kbd = wxKeyboardState())
2329 : wxNotifyEvent(type, id),
2330 wxKeyboardState(kbd)
2331 {
2332 Init(topLeft, bottomRight, sel);
2333
2334 SetEventObject(obj);
2335 }
2336
a05e6efe 2337 wxDEPRECATED_CONSTRUCTOR(
8b5f6d9d
VZ
2338 wxGridRangeSelectEvent(int id,
2339 wxEventType type,
2340 wxObject* obj,
2341 const wxGridCellCoords& topLeft,
2342 const wxGridCellCoords& bottomRight,
2343 bool sel,
2344 bool control,
2345 bool shift = false,
2346 bool alt = false,
2347 bool meta = false) );
f85afd4e
MB
2348
2349 wxGridCellCoords GetTopLeftCoords() { return m_topLeft; }
2350 wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; }
2351 int GetTopRow() { return m_topLeft.GetRow(); }
2352 int GetBottomRow() { return m_bottomRight.GetRow(); }
2353 int GetLeftCol() { return m_topLeft.GetCol(); }
2354 int GetRightCol() { return m_bottomRight.GetCol(); }
5c8fc7c1 2355 bool Selecting() { return m_selecting; }
733f486a 2356
e1f8ec29 2357 virtual wxEvent *Clone() const { return new wxGridRangeSelectEvent(*this); }
2d66e025 2358
60ff3b99 2359protected:
8b5f6d9d
VZ
2360 void Init(const wxGridCellCoords& topLeft,
2361 const wxGridCellCoords& bottomRight,
2362 bool selecting)
2363 {
2364 m_topLeft = topLeft;
2365 m_bottomRight = bottomRight;
2366 m_selecting = selecting;
2367 }
2368
60ff3b99
VZ
2369 wxGridCellCoords m_topLeft;
2370 wxGridCellCoords m_bottomRight;
5c8fc7c1 2371 bool m_selecting;
60ff3b99 2372
e1f8ec29 2373 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridRangeSelectEvent)
f85afd4e
MB
2374};
2375
bf7945ce 2376
8b5f6d9d
VZ
2377class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent : public wxCommandEvent
2378{
bf7945ce
RD
2379public:
2380 wxGridEditorCreatedEvent()
2381 : wxCommandEvent()
2382 {
2383 m_row = 0;
2384 m_col = 0;
2385 m_ctrl = NULL;
2386 }
2387
2388 wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
2389 int row, int col, wxControl* ctrl);
2390
2391 int GetRow() { return m_row; }
2392 int GetCol() { return m_col; }
2393 wxControl* GetControl() { return m_ctrl; }
2394 void SetRow(int row) { m_row = row; }
2395 void SetCol(int col) { m_col = col; }
2396 void SetControl(wxControl* ctrl) { m_ctrl = ctrl; }
733f486a 2397
e1f8ec29 2398 virtual wxEvent *Clone() const { return new wxGridEditorCreatedEvent(*this); }
bf7945ce
RD
2399
2400private:
2401 int m_row;
2402 int m_col;
2403 wxControl* m_ctrl;
2404
e1f8ec29 2405 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEditorCreatedEvent)
bf7945ce
RD
2406};
2407
2408
9b11752c
VZ
2409wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_LEFT_CLICK, wxGridEvent );
2410wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEvent );
2411wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEvent );
2412wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_RIGHT_DCLICK, wxGridEvent );
2413wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEvent );
2414wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_RIGHT_CLICK, wxGridEvent );
2415wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEvent );
2416wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent );
2417wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_ROW_SIZE, wxGridSizeEvent );
2418wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_SIZE, wxGridSizeEvent );
2419wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent );
2420wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGING, wxGridEvent );
2421wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGED, wxGridEvent );
2422wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_SELECT_CELL, wxGridEvent );
2423wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_SHOWN, wxGridEvent );
2424wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_HIDDEN, wxGridEvent );
2425wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_CREATED, wxGridEditorCreatedEvent );
2426wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_BEGIN_DRAG, wxGridEvent );
2427wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_MOVE, wxGridEvent );
2428wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_SORT, wxGridEvent );
749692cc 2429
f85afd4e
MB
2430typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&);
2431typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&);
2432typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&);
bf7945ce 2433typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction)(wxGridEditorCreatedEvent&);
f85afd4e 2434
7fa03f04 2435#define wxGridEventHandler(func) \
3c778901 2436 wxEVENT_HANDLER_CAST(wxGridEventFunction, func)
7fa03f04
VZ
2437
2438#define wxGridSizeEventHandler(func) \
3c778901 2439 wxEVENT_HANDLER_CAST(wxGridSizeEventFunction, func)
7fa03f04
VZ
2440
2441#define wxGridRangeSelectEventHandler(func) \
3c778901 2442 wxEVENT_HANDLER_CAST(wxGridRangeSelectEventFunction, func)
7fa03f04
VZ
2443
2444#define wxGridEditorCreatedEventHandler(func) \
3c778901 2445 wxEVENT_HANDLER_CAST(wxGridEditorCreatedEventFunction, func)
7fa03f04
VZ
2446
2447#define wx__DECLARE_GRIDEVT(evt, id, fn) \
2448 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEventHandler(fn))
2449
2450#define wx__DECLARE_GRIDSIZEEVT(evt, id, fn) \
2451 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridSizeEventHandler(fn))
2452
2453#define wx__DECLARE_GRIDRANGESELEVT(evt, id, fn) \
2454 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridRangeSelectEventHandler(fn))
2455
2456#define wx__DECLARE_GRIDEDITOREVT(evt, id, fn) \
2457 wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEditorCreatedEventHandler(fn))
2458
2459#define EVT_GRID_CMD_CELL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_CLICK, id, fn)
2460#define EVT_GRID_CMD_CELL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_CLICK, id, fn)
2461#define EVT_GRID_CMD_CELL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_DCLICK, id, fn)
2462#define EVT_GRID_CMD_CELL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_DCLICK, id, fn)
2463#define EVT_GRID_CMD_LABEL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_CLICK, id, fn)
2464#define EVT_GRID_CMD_LABEL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_CLICK, id, fn)
2465#define EVT_GRID_CMD_LABEL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_DCLICK, id, fn)
2466#define EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_DCLICK, id, fn)
2467#define EVT_GRID_CMD_ROW_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(ROW_SIZE, id, fn)
2468#define EVT_GRID_CMD_COL_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_SIZE, id, fn)
5d984f5d 2469#define EVT_GRID_CMD_COL_MOVE(id, fn) wx__DECLARE_GRIDEVT(COL_MOVE, id, fn)
11393d29 2470#define EVT_GRID_CMD_COL_SORT(id, fn) wx__DECLARE_GRIDEVT(COL_SORT, id, fn)
7fa03f04 2471#define EVT_GRID_CMD_RANGE_SELECT(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECT, id, fn)
763163a8
VZ
2472#define EVT_GRID_CMD_CELL_CHANGING(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGING, id, fn)
2473#define EVT_GRID_CMD_CELL_CHANGED(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGED, id, fn)
7fa03f04
VZ
2474#define EVT_GRID_CMD_SELECT_CELL(id, fn) wx__DECLARE_GRIDEVT(SELECT_CELL, id, fn)
2475#define EVT_GRID_CMD_EDITOR_SHOWN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_SHOWN, id, fn)
2476#define EVT_GRID_CMD_EDITOR_HIDDEN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_HIDDEN, id, fn)
2477#define EVT_GRID_CMD_EDITOR_CREATED(id, fn) wx__DECLARE_GRIDEDITOREVT(EDITOR_CREATED, id, fn)
2478#define EVT_GRID_CMD_CELL_BEGIN_DRAG(id, fn) wx__DECLARE_GRIDEVT(CELL_BEGIN_DRAG, id, fn)
2479
2480// same as above but for any id (exists mainly for backwards compatibility but
2481// then it's also true that you rarely have multiple grid in the same window)
2482#define EVT_GRID_CELL_LEFT_CLICK(fn) EVT_GRID_CMD_CELL_LEFT_CLICK(wxID_ANY, fn)
2483#define EVT_GRID_CELL_RIGHT_CLICK(fn) EVT_GRID_CMD_CELL_RIGHT_CLICK(wxID_ANY, fn)
2484#define EVT_GRID_CELL_LEFT_DCLICK(fn) EVT_GRID_CMD_CELL_LEFT_DCLICK(wxID_ANY, fn)
2485#define EVT_GRID_CELL_RIGHT_DCLICK(fn) EVT_GRID_CMD_CELL_RIGHT_DCLICK(wxID_ANY, fn)
2486#define EVT_GRID_LABEL_LEFT_CLICK(fn) EVT_GRID_CMD_LABEL_LEFT_CLICK(wxID_ANY, fn)
2487#define EVT_GRID_LABEL_RIGHT_CLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_CLICK(wxID_ANY, fn)
2488#define EVT_GRID_LABEL_LEFT_DCLICK(fn) EVT_GRID_CMD_LABEL_LEFT_DCLICK(wxID_ANY, fn)
2489#define EVT_GRID_LABEL_RIGHT_DCLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_DCLICK(wxID_ANY, fn)
2490#define EVT_GRID_ROW_SIZE(fn) EVT_GRID_CMD_ROW_SIZE(wxID_ANY, fn)
2491#define EVT_GRID_COL_SIZE(fn) EVT_GRID_CMD_COL_SIZE(wxID_ANY, fn)
4d5a1b0a 2492#define EVT_GRID_COL_MOVE(fn) EVT_GRID_CMD_COL_MOVE(wxID_ANY, fn)
11393d29 2493#define EVT_GRID_COL_SORT(fn) EVT_GRID_CMD_COL_SORT(wxID_ANY, fn)
7fa03f04 2494#define EVT_GRID_RANGE_SELECT(fn) EVT_GRID_CMD_RANGE_SELECT(wxID_ANY, fn)
763163a8
VZ
2495#define EVT_GRID_CELL_CHANGING(fn) EVT_GRID_CMD_CELL_CHANGING(wxID_ANY, fn)
2496#define EVT_GRID_CELL_CHANGED(fn) EVT_GRID_CMD_CELL_CHANGED(wxID_ANY, fn)
7fa03f04
VZ
2497#define EVT_GRID_SELECT_CELL(fn) EVT_GRID_CMD_SELECT_CELL(wxID_ANY, fn)
2498#define EVT_GRID_EDITOR_SHOWN(fn) EVT_GRID_CMD_EDITOR_SHOWN(wxID_ANY, fn)
2499#define EVT_GRID_EDITOR_HIDDEN(fn) EVT_GRID_CMD_EDITOR_HIDDEN(wxID_ANY, fn)
2500#define EVT_GRID_EDITOR_CREATED(fn) EVT_GRID_CMD_EDITOR_CREATED(wxID_ANY, fn)
2501#define EVT_GRID_CELL_BEGIN_DRAG(fn) EVT_GRID_CMD_CELL_BEGIN_DRAG(wxID_ANY, fn)
f85afd4e 2502
763163a8
VZ
2503// we used to have a single wxEVT_GRID_CELL_CHANGE event but it was split into
2504// wxEVT_GRID_CELL_CHANGING and CHANGED ones in wx 2.9.0, however the CHANGED
2505// is basically the same as the old CHANGE event so we keep the name for
2506// compatibility
2507#if WXWIN_COMPATIBILITY_2_8
2508 #define wxEVT_GRID_CELL_CHANGE wxEVT_GRID_CELL_CHANGED
2509
2510 #define EVT_GRID_CMD_CELL_CHANGE EVT_GRID_CMD_CELL_CHANGED
2511 #define EVT_GRID_CELL_CHANGE EVT_GRID_CELL_CHANGED
2512#endif // WXWIN_COMPATIBILITY_2_8
2513
f85afd4e
MB
2514#if 0 // TODO: implement these ? others ?
2515
77d4384e
RR
2516extern const int wxEVT_GRID_CREATE_CELL;
2517extern const int wxEVT_GRID_CHANGE_LABELS;
2518extern const int wxEVT_GRID_CHANGE_SEL_LABEL;
f85afd4e 2519
ca65c044
WS
2520#define EVT_GRID_CREATE_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2521#define EVT_GRID_CHANGE_LABELS(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2522#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 ),
f85afd4e
MB
2523
2524#endif
2525
df9fac6d
PC
2526#endif // wxUSE_GRID
2527#endif // _WX_GENERIC_GRID_H_