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