]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/grid.h
suppress warning about not being able to generate copy ctor/operator=()
[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)
5// Modified by:
6// Created: 1/08/1999
7// RCS-ID: $Id$
8// Copyright: (c) Michael Bedward
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
f85afd4e
MB
12#include "wx/defs.h"
13
f85afd4e
MB
14#ifndef __WXGRID_H__
15#define __WXGRID_H__
16
af49c4b8 17#if defined(__GNUG__) && !defined(__APPLE__)
f85afd4e
MB
18#pragma interface "grid.h"
19#endif
20
ba8c1601 21#include "wx/hashmap.h"
f85afd4e 22#include "wx/panel.h"
2d66e025 23#include "wx/scrolwin.h"
f85afd4e 24#include "wx/string.h"
2da2f941 25#include "wx/arrstr.h"
f85afd4e
MB
26#include "wx/scrolbar.h"
27#include "wx/event.h"
f85afd4e
MB
28#include "wx/combobox.h"
29#include "wx/dynarray.h"
025562fe 30#include "wx/timer.h"
afbd598c 31#include "wx/clntdata.h"
f85afd4e 32
816be743
VZ
33// ----------------------------------------------------------------------------
34// constants
35// ----------------------------------------------------------------------------
36
f85afd4e
MB
37// Default parameters for wxGrid
38//
39#define WXGRID_DEFAULT_NUMBER_ROWS 10
40#define WXGRID_DEFAULT_NUMBER_COLS 10
41#ifdef __WXMSW__
42#define WXGRID_DEFAULT_ROW_HEIGHT 25
43#else
44#define WXGRID_DEFAULT_ROW_HEIGHT 30
45#endif // __WXMSW__
46#define WXGRID_DEFAULT_COL_WIDTH 80
47#define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
48#define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
f1567cdd 49#define WXGRID_LABEL_EDGE_ZONE 2
f85afd4e
MB
50#define WXGRID_MIN_ROW_HEIGHT 15
51#define WXGRID_MIN_COL_WIDTH 15
52#define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
f85afd4e 53
816be743
VZ
54// type names for grid table values
55#define wxGRID_VALUE_STRING _T("string")
56#define wxGRID_VALUE_BOOL _T("bool")
57#define wxGRID_VALUE_NUMBER _T("long")
58#define wxGRID_VALUE_FLOAT _T("double")
c4608a8a 59#define wxGRID_VALUE_CHOICE _T("choice")
816be743
VZ
60
61#define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
62#define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
63
b99be8fb
VZ
64// ----------------------------------------------------------------------------
65// forward declarations
66// ----------------------------------------------------------------------------
67
ab79958a
VZ
68class WXDLLEXPORT wxGrid;
69class WXDLLEXPORT wxGridCellAttr;
b99be8fb 70class WXDLLEXPORT wxGridCellAttrProviderData;
b99be8fb
VZ
71class WXDLLEXPORT wxGridColLabelWindow;
72class WXDLLEXPORT wxGridCornerLabelWindow;
ab79958a
VZ
73class WXDLLEXPORT wxGridRowLabelWindow;
74class WXDLLEXPORT wxGridTableBase;
b99be8fb 75class WXDLLEXPORT wxGridWindow;
f2d76237 76class WXDLLEXPORT wxGridTypeRegistry;
b5808881 77class WXDLLEXPORT wxGridSelection;
ab79958a 78
508011ce 79class WXDLLEXPORT wxCheckBox;
4ee5fc9c 80class WXDLLEXPORT wxComboBox;
508011ce 81class WXDLLEXPORT wxTextCtrl;
816be743 82class WXDLLEXPORT wxSpinCtrl;
508011ce 83
ba8c1601
MB
84WX_DECLARE_EXPORTED_HASH_MAP( long, long, wxIntegerHash, wxIntegerEqual,
85 wxLongToLongHashMap );
86
39bcce60
VZ
87// ----------------------------------------------------------------------------
88// macros
89// ----------------------------------------------------------------------------
90
91#define wxSafeIncRef(p) if ( p ) (p)->IncRef()
92#define wxSafeDecRef(p) if ( p ) (p)->DecRef()
93
ab79958a 94// ----------------------------------------------------------------------------
c4608a8a
VZ
95// wxGridCellWorker: common base class for wxGridCellRenderer and
96// wxGridCellEditor
97//
98// NB: this is more an implementation convenience than a design issue, so this
99// class is not documented and is not public at all
ab79958a
VZ
100// ----------------------------------------------------------------------------
101
afbd598c 102class WXDLLEXPORT wxGridCellWorker : public wxClientDataContainer
ab79958a
VZ
103{
104public:
c4608a8a 105 wxGridCellWorker() { m_nRef = 1; }
39bcce60
VZ
106
107 // this class is ref counted: it is created with ref count of 1, so
108 // calling DecRef() once will delete it. Calling IncRef() allows to lock
109 // it until the matching DecRef() is called
110 void IncRef() { m_nRef++; }
111 void DecRef() { if ( !--m_nRef ) delete this; }
112
c4608a8a
VZ
113 // interpret renderer parameters: arbitrary string whose interpretatin is
114 // left to the derived classes
115 virtual void SetParameters(const wxString& params);
116
117protected:
118 // virtual dtor for any base class - private because only DecRef() can
119 // delete us
120 virtual ~wxGridCellWorker();
121
122private:
123 size_t m_nRef;
124
125 // suppress the stupid gcc warning about the class having private dtor and
126 // no friends
127 friend class wxGridCellWorkerDummyFriend;
128};
129
130// ----------------------------------------------------------------------------
131// wxGridCellRenderer: this class is responsible for actually drawing the cell
132// in the grid. You may pass it to the wxGridCellAttr (below) to change the
133// format of one given cell or to wxGrid::SetDefaultRenderer() to change the
134// view of all cells. This is an ABC, you will normally use one of the
135// predefined derived classes or derive your own class from it.
136// ----------------------------------------------------------------------------
137
138class WXDLLEXPORT wxGridCellRenderer : public wxGridCellWorker
139{
140public:
ab79958a
VZ
141 // draw the given cell on the provided DC inside the given rectangle
142 // using the style specified by the attribute and the default or selected
143 // state corresponding to the isSelected value.
144 //
145 // this pure virtual function has a default implementation which will
146 // prepare the DC using the given attribute: it will draw the rectangle
147 // with the bg colour from attr and set the text colour and font
148 virtual void Draw(wxGrid& grid,
2796cce3 149 wxGridCellAttr& attr,
ab79958a
VZ
150 wxDC& dc,
151 const wxRect& rect,
152 int row, int col,
153 bool isSelected) = 0;
816be743 154
65e4e78e
VZ
155 // get the preferred size of the cell for its contents
156 virtual wxSize GetBestSize(wxGrid& grid,
157 wxGridCellAttr& attr,
158 wxDC& dc,
159 int row, int col) = 0;
160
e72b4213
VZ
161 // create a new object which is the copy of this one
162 virtual wxGridCellRenderer *Clone() const = 0;
ab79958a
VZ
163};
164
165// the default renderer for the cells containing string data
166class WXDLLEXPORT wxGridCellStringRenderer : public wxGridCellRenderer
167{
168public:
169 // draw the string
170 virtual void Draw(wxGrid& grid,
2796cce3 171 wxGridCellAttr& attr,
ab79958a
VZ
172 wxDC& dc,
173 const wxRect& rect,
174 int row, int col,
175 bool isSelected);
816be743 176
65e4e78e
VZ
177 // return the string extent
178 virtual wxSize GetBestSize(wxGrid& grid,
179 wxGridCellAttr& attr,
180 wxDC& dc,
181 int row, int col);
182
e72b4213
VZ
183 virtual wxGridCellRenderer *Clone() const
184 { return new wxGridCellStringRenderer; }
185
816be743
VZ
186protected:
187 // set the text colours before drawing
188 void SetTextColoursAndFont(wxGrid& grid,
189 wxGridCellAttr& attr,
190 wxDC& dc,
191 bool isSelected);
65e4e78e
VZ
192
193 // calc the string extent for given string/font
194 wxSize DoGetBestSize(wxGridCellAttr& attr,
195 wxDC& dc,
196 const wxString& text);
816be743
VZ
197};
198
199// the default renderer for the cells containing numeric (long) data
200class WXDLLEXPORT wxGridCellNumberRenderer : public wxGridCellStringRenderer
201{
202public:
203 // draw the string right aligned
204 virtual void Draw(wxGrid& grid,
205 wxGridCellAttr& attr,
206 wxDC& dc,
207 const wxRect& rect,
208 int row, int col,
209 bool isSelected);
65e4e78e
VZ
210
211 virtual wxSize GetBestSize(wxGrid& grid,
212 wxGridCellAttr& attr,
213 wxDC& dc,
214 int row, int col);
215
e72b4213
VZ
216 virtual wxGridCellRenderer *Clone() const
217 { return new wxGridCellNumberRenderer; }
218
65e4e78e
VZ
219protected:
220 wxString GetString(wxGrid& grid, int row, int col);
816be743
VZ
221};
222
223class WXDLLEXPORT wxGridCellFloatRenderer : public wxGridCellStringRenderer
224{
225public:
0b190b0f 226 wxGridCellFloatRenderer(int width = -1, int precision = -1);
816be743
VZ
227
228 // get/change formatting parameters
229 int GetWidth() const { return m_width; }
0b190b0f 230 void SetWidth(int width) { m_width = width; m_format.clear(); }
816be743 231 int GetPrecision() const { return m_precision; }
0b190b0f 232 void SetPrecision(int precision) { m_precision = precision; m_format.clear(); }
816be743
VZ
233
234 // draw the string right aligned with given width/precision
235 virtual void Draw(wxGrid& grid,
236 wxGridCellAttr& attr,
237 wxDC& dc,
238 const wxRect& rect,
239 int row, int col,
240 bool isSelected);
241
65e4e78e
VZ
242 virtual wxSize GetBestSize(wxGrid& grid,
243 wxGridCellAttr& attr,
244 wxDC& dc,
245 int row, int col);
0b190b0f
VZ
246
247 // parameters string format is "width[,precision]"
248 virtual void SetParameters(const wxString& params);
249
e72b4213
VZ
250 virtual wxGridCellRenderer *Clone() const;
251
65e4e78e
VZ
252protected:
253 wxString GetString(wxGrid& grid, int row, int col);
254
816be743
VZ
255private:
256 // formatting parameters
257 int m_width,
0b190b0f 258 m_precision;
816be743
VZ
259
260 wxString m_format;
ab79958a 261};
f85afd4e 262
508011ce
VZ
263// renderer for boolean fields
264class WXDLLEXPORT wxGridCellBoolRenderer : public wxGridCellRenderer
265{
266public:
508011ce
VZ
267 // draw a check mark or nothing
268 virtual void Draw(wxGrid& grid,
269 wxGridCellAttr& attr,
270 wxDC& dc,
271 const wxRect& rect,
272 int row, int col,
273 bool isSelected);
65e4e78e
VZ
274
275 // return the checkmark size
276 virtual wxSize GetBestSize(wxGrid& grid,
277 wxGridCellAttr& attr,
278 wxDC& dc,
279 int row, int col);
280
e72b4213
VZ
281 virtual wxGridCellRenderer *Clone() const
282 { return new wxGridCellBoolRenderer; }
283
65e4e78e
VZ
284private:
285 static wxSize ms_sizeCheckMark;
508011ce 286};
2796cce3
RD
287
288// ----------------------------------------------------------------------------
289// wxGridCellEditor: This class is responsible for providing and manipulating
290// the in-place edit controls for the grid. Instances of wxGridCellEditor
291// (actually, instances of derived classes since it is an ABC) can be
292// associated with the cell attributes for individual cells, rows, columns, or
293// even for the entire grid.
294// ----------------------------------------------------------------------------
295
c4608a8a 296class WXDLLEXPORT wxGridCellEditor : public wxGridCellWorker
2796cce3
RD
297{
298public:
299 wxGridCellEditor();
39bcce60 300
2796cce3 301 bool IsCreated() { return m_control != NULL; }
f6bcfd97
BP
302 wxControl* GetControl() { return m_control; }
303 void SetControl(wxControl* control) { m_control = control; }
2796cce3 304
1bd71df9
JS
305 wxGridCellAttr* GetCellAttr() { return m_attr; }
306 void SetCellAttr(wxGridCellAttr* attr) { m_attr = attr; }
307
2796cce3
RD
308 // Creates the actual edit control
309 virtual void Create(wxWindow* parent,
310 wxWindowID id,
2796cce3
RD
311 wxEvtHandler* evtHandler) = 0;
312
313 // Size and position the edit control
314 virtual void SetSize(const wxRect& rect);
315
3da93aae
VZ
316 // Show or hide the edit control, use the specified attributes to set
317 // colours/fonts for it
318 virtual void Show(bool show, wxGridCellAttr *attr = (wxGridCellAttr *)NULL);
2796cce3 319
189d0213
VZ
320 // Draws the part of the cell not occupied by the control: the base class
321 // version just fills it with background colour from the attribute
322 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
323
2796cce3
RD
324 // Fetch the value from the table and prepare the edit control
325 // to begin editing. Set the focus to the edit control.
3da93aae 326 virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
2796cce3 327
3324d5f5
VZ
328 // Complete the editing of the current cell. Returns true if the value has
329 // changed. If necessary, the control may be destroyed.
330 virtual bool EndEdit(int row, int col, wxGrid* grid) = 0;
2796cce3
RD
331
332 // Reset the value in the control back to its starting value
333 virtual void Reset() = 0;
334
f6bcfd97
BP
335 // return TRUE to allow the given key to start editing: the base class
336 // version only checks that the event has no modifiers. The derived
337 // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in
338 // their IsAcceptedKey() implementation, although, of course, it is not a
339 // mandatory requirment.
340 //
341 // NB: if the key is F2 (special), editing will always start and this
342 // method will not be called at all (but StartingKey() will)
343 virtual bool IsAcceptedKey(wxKeyEvent& event);
344
345 // If the editor is enabled by pressing keys on the grid, this will be
346 // called to let the editor do something about that first key if desired
2c9a89e0
RD
347 virtual void StartingKey(wxKeyEvent& event);
348
e195a54c
VZ
349 // if the editor is enabled by clicking on the cell, this method will be
350 // called
351 virtual void StartingClick();
352
2796cce3
RD
353 // Some types of controls on some platforms may need some help
354 // with the Return key.
355 virtual void HandleReturn(wxKeyEvent& event);
356
357 // Final cleanup
358 virtual void Destroy();
359
c4608a8a
VZ
360 // create a new object which is the copy of this one
361 virtual wxGridCellEditor *Clone() const = 0;
362
73145b0e
JS
363 // DJC MAPTEK
364 // added GetValue so we can get the value which is in the control
365 virtual wxString GetValue() const = 0;
366
2796cce3 367protected:
39bcce60
VZ
368 // the dtor is private because only DecRef() can delete us
369 virtual ~wxGridCellEditor();
370
3da93aae 371 // the control we show on screen
2796cce3 372 wxControl* m_control;
3da93aae 373
1bd71df9
JS
374 // a temporary pointer to the attribute being edited
375 wxGridCellAttr* m_attr;
376
3da93aae
VZ
377 // if we change the colours/font of the control from the default ones, we
378 // must restore the default later and we save them here between calls to
379 // Show(TRUE) and Show(FALSE)
380 wxColour m_colFgOld,
381 m_colBgOld;
382 wxFont m_fontOld;
39bcce60
VZ
383
384 // suppress the stupid gcc warning about the class having private dtor and
385 // no friends
386 friend class wxGridCellEditorDummyFriend;
22f3361e
VZ
387
388 DECLARE_NO_COPY_CLASS(wxGridCellEditor)
2796cce3
RD
389};
390
3379ed37
VZ
391#if wxUSE_TEXTCTRL
392
508011ce 393// the editor for string/text data
2796cce3
RD
394class WXDLLEXPORT wxGridCellTextEditor : public wxGridCellEditor
395{
396public:
397 wxGridCellTextEditor();
398
399 virtual void Create(wxWindow* parent,
400 wxWindowID id,
2796cce3 401 wxEvtHandler* evtHandler);
99306db2 402 virtual void SetSize(const wxRect& rect);
2796cce3 403
189d0213
VZ
404 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
405
f6bcfd97 406 virtual bool IsAcceptedKey(wxKeyEvent& event);
3da93aae 407 virtual void BeginEdit(int row, int col, wxGrid* grid);
3324d5f5 408 virtual bool EndEdit(int row, int col, wxGrid* grid);
2796cce3
RD
409
410 virtual void Reset();
2c9a89e0 411 virtual void StartingKey(wxKeyEvent& event);
2796cce3
RD
412 virtual void HandleReturn(wxKeyEvent& event);
413
c4608a8a
VZ
414 // parameters string format is "max_width"
415 virtual void SetParameters(const wxString& params);
416
417 virtual wxGridCellEditor *Clone() const
418 { return new wxGridCellTextEditor; }
419
73145b0e
JS
420 // DJC MAPTEK
421 // added GetValue so we can get the value which is in the control
422 virtual wxString GetValue() const;
b54ba671
VZ
423protected:
424 wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }
2796cce3 425
816be743
VZ
426 // parts of our virtual functions reused by the derived classes
427 void DoBeginEdit(const wxString& startValue);
428 void DoReset(const wxString& startValue);
429
2796cce3 430private:
c4608a8a 431 size_t m_maxChars; // max number of chars allowed
2796cce3
RD
432 wxString m_startValue;
433};
434
816be743
VZ
435// the editor for numeric (long) data
436class WXDLLEXPORT wxGridCellNumberEditor : public wxGridCellTextEditor
437{
438public:
439 // allows to specify the range - if min == max == -1, no range checking is
440 // done
441 wxGridCellNumberEditor(int min = -1, int max = -1);
442
443 virtual void Create(wxWindow* parent,
444 wxWindowID id,
445 wxEvtHandler* evtHandler);
446
f6bcfd97 447 virtual bool IsAcceptedKey(wxKeyEvent& event);
816be743 448 virtual void BeginEdit(int row, int col, wxGrid* grid);
3324d5f5 449 virtual bool EndEdit(int row, int col, wxGrid* grid);
816be743
VZ
450
451 virtual void Reset();
452 virtual void StartingKey(wxKeyEvent& event);
453
c4608a8a
VZ
454 // parameters string format is "min,max"
455 virtual void SetParameters(const wxString& params);
456
457 virtual wxGridCellEditor *Clone() const
458 { return new wxGridCellNumberEditor(m_min, m_max); }
73145b0e
JS
459 // DJC MAPTEK
460 // added GetValue so we can get the value which is in the control
461 virtual wxString GetValue() const;
c4608a8a 462
816be743
VZ
463protected:
464 wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; }
465
466 // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl
467 bool HasRange() const { return m_min != m_max; }
468
469 // string representation of m_valueOld
470 wxString GetString() const
471 { return wxString::Format(_T("%ld"), m_valueOld); }
472
473private:
474 int m_min,
475 m_max;
476
477 long m_valueOld;
478};
479
480// the editor for floating point numbers (double) data
481class WXDLLEXPORT wxGridCellFloatEditor : public wxGridCellTextEditor
482{
483public:
f6bcfd97
BP
484 wxGridCellFloatEditor(int width = -1, int precision = -1);
485
816be743
VZ
486 virtual void Create(wxWindow* parent,
487 wxWindowID id,
488 wxEvtHandler* evtHandler);
489
f6bcfd97 490 virtual bool IsAcceptedKey(wxKeyEvent& event);
816be743 491 virtual void BeginEdit(int row, int col, wxGrid* grid);
3324d5f5 492 virtual bool EndEdit(int row, int col, wxGrid* grid);
816be743
VZ
493
494 virtual void Reset();
495 virtual void StartingKey(wxKeyEvent& event);
496
c4608a8a 497 virtual wxGridCellEditor *Clone() const
ec53826c 498 { return new wxGridCellFloatEditor(m_width, m_precision); }
c4608a8a 499
f6bcfd97
BP
500 // parameters string format is "width,precision"
501 virtual void SetParameters(const wxString& params);
502
816be743
VZ
503protected:
504 // string representation of m_valueOld
f6bcfd97 505 wxString GetString() const;
816be743
VZ
506
507private:
f6bcfd97
BP
508 int m_width,
509 m_precision;
816be743
VZ
510 double m_valueOld;
511};
512
3379ed37
VZ
513#endif // wxUSE_TEXTCTRL
514
515#if wxUSE_CHECKBOX
516
508011ce
VZ
517// the editor for boolean data
518class WXDLLEXPORT wxGridCellBoolEditor : public wxGridCellEditor
519{
520public:
521 virtual void Create(wxWindow* parent,
522 wxWindowID id,
523 wxEvtHandler* evtHandler);
524
525 virtual void SetSize(const wxRect& rect);
526 virtual void Show(bool show, wxGridCellAttr *attr = (wxGridCellAttr *)NULL);
527
f6bcfd97 528 virtual bool IsAcceptedKey(wxKeyEvent& event);
508011ce 529 virtual void BeginEdit(int row, int col, wxGrid* grid);
3324d5f5 530 virtual bool EndEdit(int row, int col, wxGrid* grid);
508011ce
VZ
531
532 virtual void Reset();
e195a54c 533 virtual void StartingClick();
508011ce 534
c4608a8a
VZ
535 virtual wxGridCellEditor *Clone() const
536 { return new wxGridCellBoolEditor; }
73145b0e
JS
537 // DJC MAPTEK
538 // added GetValue so we can get the value which is in the control
539 virtual wxString GetValue() const;
c4608a8a 540
508011ce
VZ
541protected:
542 wxCheckBox *CBox() const { return (wxCheckBox *)m_control; }
543
544private:
545 bool m_startValue;
508011ce
VZ
546};
547
3379ed37
VZ
548#endif // wxUSE_CHECKBOX
549
550#if wxUSE_COMBOBOX
551
4ee5fc9c
VZ
552// the editor for string data allowing to choose from the list of strings
553class WXDLLEXPORT wxGridCellChoiceEditor : public wxGridCellEditor
554{
555public:
556 // if !allowOthers, user can't type a string not in choices array
c4608a8a 557 wxGridCellChoiceEditor(size_t count = 0,
f6bcfd97 558 const wxString choices[] = NULL,
4ee5fc9c
VZ
559 bool allowOthers = FALSE);
560
561 virtual void Create(wxWindow* parent,
562 wxWindowID id,
563 wxEvtHandler* evtHandler);
564
565 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
566
567 virtual void BeginEdit(int row, int col, wxGrid* grid);
3324d5f5 568 virtual bool EndEdit(int row, int col, wxGrid* grid);
4ee5fc9c
VZ
569
570 virtual void Reset();
571
c4608a8a
VZ
572 // parameters string format is "item1[,item2[...,itemN]]"
573 virtual void SetParameters(const wxString& params);
574
575 virtual wxGridCellEditor *Clone() const;
73145b0e
JS
576 // DJC MAPTEK
577 // added GetValue so we can get the value which is in the control
578 virtual wxString GetValue() const;
c4608a8a 579
4ee5fc9c
VZ
580protected:
581 wxComboBox *Combo() const { return (wxComboBox *)m_control; }
582
73145b0e
JS
583// DJC - (MAPTEK) you at least need access to m_choices if you
584// wish to override this class
585protected:
4ee5fc9c
VZ
586 wxString m_startValue;
587 wxArrayString m_choices;
588 bool m_allowOthers;
589};
a68c1246 590
3379ed37
VZ
591#endif // wxUSE_COMBOBOX
592
b99be8fb
VZ
593// ----------------------------------------------------------------------------
594// wxGridCellAttr: this class can be used to alter the cells appearance in
595// the grid by changing their colour/font/... from default. An object of this
596// class may be returned by wxGridTable::GetAttr().
597// ----------------------------------------------------------------------------
598
afbd598c 599class WXDLLEXPORT wxGridCellAttr : public wxClientDataContainer
b99be8fb
VZ
600{
601public:
19d7140e
VZ
602 enum wxAttrKind
603 {
604 Any,
605 Default,
606 Cell,
607 Row,
608 Col,
609 Merged
610 };
611
b99be8fb 612 // ctors
1df4050d 613 wxGridCellAttr(wxGridCellAttr *attrDefault = NULL)
b99be8fb 614 {
1df4050d
VZ
615 Init(attrDefault);
616
0767cb6f
MB
617 // MB: args used to be 0,0 here but wxALIGN_LEFT is 0
618 SetAlignment(-1, -1);
b99be8fb
VZ
619 }
620
283b7808
VZ
621 // VZ: considering the number of members wxGridCellAttr has now, this ctor
622 // seems to be pretty useless... may be we should just remove it?
b99be8fb
VZ
623 wxGridCellAttr(const wxColour& colText,
624 const wxColour& colBack,
625 const wxFont& font,
626 int hAlign,
627 int vAlign)
628 : m_colText(colText), m_colBack(colBack), m_font(font)
629 {
2e9a6788 630 Init();
b99be8fb
VZ
631 SetAlignment(hAlign, vAlign);
632 }
633
39bcce60
VZ
634 // creates a new copy of this object
635 wxGridCellAttr *Clone() const;
19d7140e 636 void MergeWith(wxGridCellAttr *mergefrom);
b99be8fb 637
2e9a6788
VZ
638 // this class is ref counted: it is created with ref count of 1, so
639 // calling DecRef() once will delete it. Calling IncRef() allows to lock
640 // it until the matching DecRef() is called
641 void IncRef() { m_nRef++; }
642 void DecRef() { if ( !--m_nRef ) delete this; }
2e9a6788 643
b99be8fb
VZ
644 // setters
645 void SetTextColour(const wxColour& colText) { m_colText = colText; }
646 void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
647 void SetFont(const wxFont& font) { m_font = font; }
648 void SetAlignment(int hAlign, int vAlign)
649 {
650 m_hAlign = hAlign;
651 m_vAlign = vAlign;
652 }
27f35b66 653 void SetSize(int num_rows, int num_cols);
ef5df12b
RD
654 void SetOverflow(bool allow = TRUE)
655 { m_overflow = allow ? Overflow : SingleCell; }
19d7140e
VZ
656 void SetReadOnly(bool isReadOnly = TRUE)
657 { m_isReadOnly = isReadOnly ? ReadOnly : ReadWrite; }
b99be8fb 658
ab79958a
VZ
659 // takes ownership of the pointer
660 void SetRenderer(wxGridCellRenderer *renderer)
39bcce60 661 { wxSafeDecRef(m_renderer); m_renderer = renderer; }
07296f0b 662 void SetEditor(wxGridCellEditor* editor)
39bcce60 663 { wxSafeDecRef(m_editor); m_editor = editor; }
ab79958a 664
19d7140e
VZ
665 void SetKind(wxAttrKind kind) { m_attrkind = kind; }
666
b99be8fb
VZ
667 // accessors
668 bool HasTextColour() const { return m_colText.Ok(); }
669 bool HasBackgroundColour() const { return m_colBack.Ok(); }
670 bool HasFont() const { return m_font.Ok(); }
0767cb6f 671 bool HasAlignment() const { return (m_hAlign != -1 || m_vAlign != -1); }
2796cce3 672 bool HasRenderer() const { return m_renderer != NULL; }
07296f0b 673 bool HasEditor() const { return m_editor != NULL; }
19d7140e 674 bool HasReadWriteMode() const { return m_isReadOnly != Unset; }
b63fce94 675 bool HasOverflowMode() const { return m_overflow != UnsetOverflow; }
b99be8fb 676
2796cce3
RD
677 const wxColour& GetTextColour() const;
678 const wxColour& GetBackgroundColour() const;
679 const wxFont& GetFont() const;
680 void GetAlignment(int *hAlign, int *vAlign) const;
27f35b66 681 void GetSize(int *num_rows, int *num_cols) const;
ef5df12b 682 bool GetOverflow() const
b63fce94 683 { return m_overflow != SingleCell; }
28a77bc4
RD
684 wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
685 wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
b99be8fb 686
19d7140e
VZ
687 bool IsReadOnly() const { return m_isReadOnly == wxGridCellAttr::ReadOnly; }
688
689 wxAttrKind GetKind() { return m_attrkind; }
283b7808 690
2796cce3 691 void SetDefAttr(wxGridCellAttr* defAttr) { m_defGridAttr = defAttr; }
ab79958a 692
b99be8fb 693private:
19d7140e
VZ
694 enum wxAttrReadMode
695 {
696 Unset = -1,
697 ReadWrite,
698 ReadOnly
30bc4a8f 699 };
19d7140e 700
b63fce94
RD
701 enum wxAttrOverflowMode
702 {
703 UnsetOverflow = -1,
704 Overflow,
705 SingleCell
706 };
707
2e9a6788 708 // the common part of all ctors
1df4050d 709 void Init(wxGridCellAttr *attrDefault = NULL);
2e9a6788
VZ
710
711 // the dtor is private because only DecRef() can delete us
39bcce60
VZ
712 ~wxGridCellAttr()
713 {
714 wxSafeDecRef(m_renderer);
715 wxSafeDecRef(m_editor);
716 }
2e9a6788
VZ
717
718 // the ref count - when it goes to 0, we die
719 size_t m_nRef;
720
b99be8fb
VZ
721 wxColour m_colText,
722 m_colBack;
723 wxFont m_font;
724 int m_hAlign,
725 m_vAlign;
27f35b66
SN
726 int m_sizeRows,
727 m_sizeCols;
ef5df12b
RD
728
729 wxAttrOverflowMode m_overflow;
2e9a6788 730
07296f0b
RD
731 wxGridCellRenderer* m_renderer;
732 wxGridCellEditor* m_editor;
733 wxGridCellAttr* m_defGridAttr;
ab79958a 734
19d7140e
VZ
735 wxAttrReadMode m_isReadOnly;
736
737 wxAttrKind m_attrkind;
283b7808 738
a68c1246 739 // use Clone() instead
7ef4c90b 740 DECLARE_NO_COPY_CLASS(wxGridCellAttr)
a68c1246 741
2e9a6788
VZ
742 // suppress the stupid gcc warning about the class having private dtor and
743 // no friends
744 friend class wxGridCellAttrDummyFriend;
b99be8fb
VZ
745};
746
747// ----------------------------------------------------------------------------
748// wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
749// cell attributes.
750// ----------------------------------------------------------------------------
751
752// implementation note: we separate it from wxGridTableBase because we wish to
753// avoid deriving a new table class if possible, and sometimes it will be
754// enough to just derive another wxGridCellAttrProvider instead
758cbedf
VZ
755//
756// the default implementation is reasonably efficient for the generic case,
757// but you might still wish to implement your own for some specific situations
758// if you have performance problems with the stock one
afbd598c 759class WXDLLEXPORT wxGridCellAttrProvider : public wxClientDataContainer
b99be8fb
VZ
760{
761public:
762 wxGridCellAttrProvider();
763 virtual ~wxGridCellAttrProvider();
764
2e9a6788 765 // DecRef() must be called on the returned pointer
19d7140e
VZ
766 virtual wxGridCellAttr *GetAttr(int row, int col,
767 wxGridCellAttr::wxAttrKind kind ) const;
2e9a6788 768
758cbedf
VZ
769 // all these functions take ownership of the pointer, don't call DecRef()
770 // on it
2e9a6788 771 virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
758cbedf
VZ
772 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
773 virtual void SetColAttr(wxGridCellAttr *attr, int col);
d1c0b4f9
VZ
774
775 // these functions must be called whenever some rows/cols are deleted
776 // because the internal data must be updated then
4d60017a
SN
777 void UpdateAttrRows( size_t pos, int numRows );
778 void UpdateAttrCols( size_t pos, int numCols );
b99be8fb
VZ
779
780private:
781 void InitData();
782
783 wxGridCellAttrProviderData *m_data;
22f3361e
VZ
784
785 DECLARE_NO_COPY_CLASS(wxGridCellAttrProvider)
b99be8fb 786};
f85afd4e
MB
787
788//////////////////////////////////////////////////////////////////////
789//
790// Grid table classes
791//
792//////////////////////////////////////////////////////////////////////
793
794
afbd598c 795class WXDLLEXPORT wxGridTableBase : public wxObject, public wxClientDataContainer
f85afd4e 796{
60ff3b99 797public:
f85afd4e
MB
798 wxGridTableBase();
799 virtual ~wxGridTableBase();
800
801 // You must override these functions in a derived table class
802 //
e32352cf
SN
803 virtual int GetNumberRows() = 0;
804 virtual int GetNumberCols() = 0;
f85afd4e 805 virtual bool IsEmptyCell( int row, int col ) = 0;
f2d76237
RD
806 virtual wxString GetValue( int row, int col ) = 0;
807 virtual void SetValue( int row, int col, const wxString& value ) = 0;
808
809 // Data type determination and value access
810 virtual wxString GetTypeName( int row, int col );
811 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
812 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
813
814 virtual long GetValueAsLong( int row, int col );
815 virtual double GetValueAsDouble( int row, int col );
816 virtual bool GetValueAsBool( int row, int col );
817
818 virtual void SetValueAsLong( int row, int col, long value );
819 virtual void SetValueAsDouble( int row, int col, double value );
820 virtual void SetValueAsBool( int row, int col, bool value );
821
822 // For user defined types
823 virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
824 virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
825
60ff3b99 826
f85afd4e
MB
827 // Overriding these is optional
828 //
829 virtual void SetView( wxGrid *grid ) { m_view = grid; }
830 virtual wxGrid * GetView() const { return m_view; }
831
832 virtual void Clear() {}
833 virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
834 virtual bool AppendRows( size_t numRows = 1 );
835 virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
836 virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
837 virtual bool AppendCols( size_t numCols = 1 );
838 virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
839
840 virtual wxString GetRowLabelValue( int row );
841 virtual wxString GetColLabelValue( int col );
af111fc3
JS
842 virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {}
843 virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {}
60ff3b99 844
b99be8fb
VZ
845 // Attribute handling
846 //
847
848 // give us the attr provider to use - we take ownership of the pointer
849 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
850
851 // get the currently used attr provider (may be NULL)
852 wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; }
853
f2d76237
RD
854 // Does this table allow attributes? Default implementation creates
855 // a wxGridCellAttrProvider if necessary.
856 virtual bool CanHaveAttributes();
857
b99be8fb 858 // by default forwarded to wxGridCellAttrProvider if any. May be
f2d76237 859 // overridden to handle attributes directly in the table.
19d7140e
VZ
860 virtual wxGridCellAttr *GetAttr( int row, int col,
861 wxGridCellAttr::wxAttrKind kind );
862
b99be8fb 863
758cbedf
VZ
864 // these functions take ownership of the pointer
865 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
866 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
867 virtual void SetColAttr(wxGridCellAttr *attr, int col);
b99be8fb 868
60ff3b99
VZ
869private:
870 wxGrid * m_view;
b99be8fb 871 wxGridCellAttrProvider *m_attrProvider;
60ff3b99 872
f85afd4e 873 DECLARE_ABSTRACT_CLASS( wxGridTableBase );
22f3361e 874 DECLARE_NO_COPY_CLASS(wxGridTableBase)
f85afd4e
MB
875};
876
877
b99be8fb
VZ
878// ----------------------------------------------------------------------------
879// wxGridTableMessage
880// ----------------------------------------------------------------------------
f85afd4e
MB
881
882// IDs for messages sent from grid table to view
883//
60ff3b99
VZ
884enum wxGridTableRequest
885{
f85afd4e
MB
886 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
887 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
888 wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
889 wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
890 wxGRIDTABLE_NOTIFY_ROWS_DELETED,
891 wxGRIDTABLE_NOTIFY_COLS_INSERTED,
892 wxGRIDTABLE_NOTIFY_COLS_APPENDED,
893 wxGRIDTABLE_NOTIFY_COLS_DELETED
894};
895
2d66e025 896class WXDLLEXPORT wxGridTableMessage
f85afd4e 897{
60ff3b99 898public:
f85afd4e
MB
899 wxGridTableMessage();
900 wxGridTableMessage( wxGridTableBase *table, int id,
901 int comInt1 = -1,
902 int comInt2 = -1 );
903
904 void SetTableObject( wxGridTableBase *table ) { m_table = table; }
905 wxGridTableBase * GetTableObject() const { return m_table; }
906 void SetId( int id ) { m_id = id; }
907 int GetId() { return m_id; }
908 void SetCommandInt( int comInt1 ) { m_comInt1 = comInt1; }
909 int GetCommandInt() { return m_comInt1; }
910 void SetCommandInt2( int comInt2 ) { m_comInt2 = comInt2; }
60ff3b99
VZ
911 int GetCommandInt2() { return m_comInt2; }
912
913private:
914 wxGridTableBase *m_table;
915 int m_id;
916 int m_comInt1;
917 int m_comInt2;
22f3361e
VZ
918
919 DECLARE_NO_COPY_CLASS(wxGridTableMessage)
f85afd4e
MB
920};
921
922
923
924// ------ wxGridStringArray
925// A 2-dimensional array of strings for data values
926//
927
2d66e025
MB
928WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString, wxGridStringArray);
929
f85afd4e
MB
930
931
932// ------ wxGridStringTable
933//
934// Simplest type of data table for a grid for small tables of strings
935// that are stored in memory
936//
937
2d66e025 938class WXDLLEXPORT wxGridStringTable : public wxGridTableBase
f85afd4e 939{
60ff3b99 940public:
f85afd4e
MB
941 wxGridStringTable();
942 wxGridStringTable( int numRows, int numCols );
e669d97a 943 virtual ~wxGridStringTable();
f85afd4e
MB
944
945 // these are pure virtual in wxGridTableBase
946 //
e32352cf
SN
947 int GetNumberRows();
948 int GetNumberCols();
f85afd4e
MB
949 wxString GetValue( int row, int col );
950 void SetValue( int row, int col, const wxString& s );
951 bool IsEmptyCell( int row, int col );
60ff3b99 952
f85afd4e
MB
953 // overridden functions from wxGridTableBase
954 //
955 void Clear();
956 bool InsertRows( size_t pos = 0, size_t numRows = 1 );
957 bool AppendRows( size_t numRows = 1 );
958 bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
959 bool InsertCols( size_t pos = 0, size_t numCols = 1 );
960 bool AppendCols( size_t numCols = 1 );
961 bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
962
963 void SetRowLabelValue( int row, const wxString& );
964 void SetColLabelValue( int col, const wxString& );
965 wxString GetRowLabelValue( int row );
966 wxString GetColLabelValue( int col );
60ff3b99
VZ
967
968private:
969 wxGridStringArray m_data;
970
971 // These only get used if you set your own labels, otherwise the
972 // GetRow/ColLabelValue functions return wxGridTableBase defaults
973 //
974 wxArrayString m_rowLabels;
975 wxArrayString m_colLabels;
976
f85afd4e
MB
977 DECLARE_DYNAMIC_CLASS( wxGridStringTable )
978};
979
980
981
43947979 982// ============================================================================
f85afd4e 983// Grid view classes
43947979
VZ
984// ============================================================================
985
986// ----------------------------------------------------------------------------
987// wxGridCellCoords: location of a cell in the grid
988// ----------------------------------------------------------------------------
f85afd4e 989
2d66e025 990class WXDLLEXPORT wxGridCellCoords
f85afd4e 991{
60ff3b99 992public:
f85afd4e
MB
993 wxGridCellCoords() { m_row = m_col = -1; }
994 wxGridCellCoords( int r, int c ) { m_row = r; m_col = c; }
995
996 // default copy ctor is ok
997
e32352cf
SN
998 int GetRow() const { return m_row; }
999 void SetRow( int n ) { m_row = n; }
1000 int GetCol() const { return m_col; }
1001 void SetCol( int n ) { m_col = n; }
1002 void Set( int row, int col ) { m_row = row; m_col = col; }
60ff3b99 1003
f85afd4e
MB
1004 wxGridCellCoords& operator=( const wxGridCellCoords& other )
1005 {
1006 if ( &other != this )
1007 {
1008 m_row=other.m_row;
1009 m_col=other.m_col;
1010 }
1011 return *this;
1012 }
1013
508011ce 1014 bool operator==( const wxGridCellCoords& other ) const
f85afd4e
MB
1015 {
1016 return (m_row == other.m_row && m_col == other.m_col);
1017 }
1018
508011ce 1019 bool operator!=( const wxGridCellCoords& other ) const
f85afd4e
MB
1020 {
1021 return (m_row != other.m_row || m_col != other.m_col);
1022 }
1023
508011ce 1024 bool operator!() const
f85afd4e
MB
1025 {
1026 return (m_row == -1 && m_col == -1 );
1027 }
60ff3b99
VZ
1028
1029private:
e32352cf
SN
1030 int m_row;
1031 int m_col;
f85afd4e
MB
1032};
1033
1034
1035// For comparisons...
1036//
f6bcfd97
BP
1037extern WXDLLEXPORT wxGridCellCoords wxGridNoCellCoords;
1038extern WXDLLEXPORT wxRect wxGridNoCellRect;
f85afd4e 1039
2d66e025
MB
1040// An array of cell coords...
1041//
1042WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords, wxGridCellCoordsArray);
1043
b99be8fb
VZ
1044// ----------------------------------------------------------------------------
1045// wxGrid
1046// ----------------------------------------------------------------------------
f85afd4e 1047
60ff3b99
VZ
1048class WXDLLEXPORT wxGrid : public wxScrolledWindow
1049{
1050public:
f85afd4e 1051 wxGrid()
b99be8fb 1052 {
2c9a89e0 1053 Create();
58dd5b3b 1054 }
60ff3b99 1055
f85afd4e
MB
1056 wxGrid( wxWindow *parent,
1057 wxWindowID id,
1058 const wxPoint& pos = wxDefaultPosition,
1059 const wxSize& size = wxDefaultSize,
ebd773c6 1060 long style = wxWANTS_CHARS,
2d66e025
MB
1061 const wxString& name = wxPanelNameStr );
1062
e669d97a 1063 virtual ~wxGrid();
f85afd4e 1064
b5808881
SN
1065 enum wxGridSelectionModes {wxGridSelectCells,
1066 wxGridSelectRows,
1067 wxGridSelectColumns};
1068
1069 bool CreateGrid( int numRows, int numCols,
1070 wxGrid::wxGridSelectionModes selmode =
1071 wxGrid::wxGridSelectCells );
2d66e025 1072
f1567cdd 1073 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode);
aa5b8857 1074 wxGrid::wxGridSelectionModes GetSelectionMode() const;
60ff3b99 1075
2d66e025
MB
1076 // ------ grid dimensions
1077 //
1078 int GetNumberRows() { return m_numRows; }
1079 int GetNumberCols() { return m_numCols; }
1080
60ff3b99 1081
2d66e025
MB
1082 // ------ display update functions
1083 //
d10f4bf9 1084 wxArrayInt CalcRowLabelsExposed( const wxRegion& reg );
8fb66724 1085
d10f4bf9
VZ
1086 wxArrayInt CalcColLabelsExposed( const wxRegion& reg );
1087 wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg );
60ff3b99 1088
2d66e025 1089
2d66e025
MB
1090 // ------ event handlers
1091 //
1092 void ProcessRowLabelMouseEvent( wxMouseEvent& event );
1093 void ProcessColLabelMouseEvent( wxMouseEvent& event );
1094 void ProcessCornerLabelMouseEvent( wxMouseEvent& event );
60ff3b99 1095 void ProcessGridCellMouseEvent( wxMouseEvent& event );
2d66e025 1096 bool ProcessTableMessage( wxGridTableMessage& );
f85afd4e 1097
6d004f67
MB
1098 void DoEndDragResizeRow();
1099 void DoEndDragResizeCol();
60ff3b99 1100
f85afd4e 1101 wxGridTableBase * GetTable() const { return m_table; }
043d16b2 1102 bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE,
5c8fc7c1
SN
1103 wxGrid::wxGridSelectionModes selmode =
1104 wxGrid::wxGridSelectCells );
f85afd4e
MB
1105
1106 void ClearGrid();
1107 bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
1108 bool AppendRows( int numRows = 1, bool updateLabels=TRUE );
1109 bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
1110 bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
1111 bool AppendCols( int numCols = 1, bool updateLabels=TRUE );
60ff3b99 1112 bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
f85afd4e 1113
d10f4bf9 1114 void DrawGridCellArea( wxDC& dc , const wxGridCellCoordsArray& cells );
7c8a8ad5 1115 void DrawGridSpace( wxDC& dc );
2d66e025 1116 void DrawCellBorder( wxDC& dc, const wxGridCellCoords& );
4634a5d6 1117 void DrawAllGridLines( wxDC& dc, const wxRegion & reg );
2d66e025 1118 void DrawCell( wxDC& dc, const wxGridCellCoords& );
d10f4bf9 1119 void DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells);
d16c04bb
VZ
1120
1121 // this function is called when the current cell highlight must be redrawn
1122 // and may be overridden by the user
1123 virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
1f1ce288 1124
d10f4bf9 1125 void DrawRowLabels( wxDC& dc, const wxArrayInt& rows );
2d66e025 1126 void DrawRowLabel( wxDC& dc, int row );
8fb66724 1127
d10f4bf9 1128 void DrawColLabels( wxDC& dc, const wxArrayInt& cols );
2d66e025 1129 void DrawColLabel( wxDC& dc, int col );
60ff3b99 1130
f85afd4e 1131
2d66e025 1132 // ------ Cell text drawing functions
f85afd4e 1133 //
2d66e025 1134 void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
4c7277db 1135 int horizontalAlignment = wxALIGN_LEFT,
d43851f7
JS
1136 int verticalAlignment = wxALIGN_TOP,
1137 int textOrientation = wxHORIZONTAL );
30bc4a8f 1138
d10f4bf9
VZ
1139 void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect&,
1140 int horizontalAlignment = wxALIGN_LEFT,
d43851f7
JS
1141 int verticalAlignment = wxALIGN_TOP,
1142 int textOrientation = wxHORIZONTAL );
d10f4bf9 1143
f85afd4e 1144
2d66e025
MB
1145 // Split a string containing newline chararcters into an array of
1146 // strings and return the number of lines
1147 //
1148 void StringToLines( const wxString& value, wxArrayString& lines );
60ff3b99 1149
2d66e025 1150 void GetTextBoxSize( wxDC& dc,
d10f4bf9 1151 const wxArrayString& lines,
2d66e025 1152 long *width, long *height );
60ff3b99 1153
2d66e025 1154
f85afd4e
MB
1155 // ------
1156 // Code that does a lot of grid modification can be enclosed
1157 // between BeginBatch() and EndBatch() calls to avoid screen
1158 // flicker
1159 //
1160 void BeginBatch() { m_batchCount++; }
f6bcfd97
BP
1161 void EndBatch();
1162
f85afd4e
MB
1163 int GetBatchCount() { return m_batchCount; }
1164
b7282ad2
DW
1165 virtual void Refresh(bool eraseb = TRUE,
1166 const wxRect* rect = (const wxRect *) NULL);
27f35b66 1167
d8232393
MB
1168 // Use this, rather than wxWindow::Refresh(), to force an
1169 // immediate repainting of the grid. Has no effect if you are
1170 // already inside a BeginBatch / EndBatch block.
1171 //
1172 // This function is necessary because wxGrid has a minimal OnPaint()
1173 // handler to reduce screen flicker.
1174 //
1175 void ForceRefresh();
d2520c85 1176
2d66e025
MB
1177
1178 // ------ edit control functions
1179 //
84035150 1180 bool IsEditable() const { return m_editable; }
2d66e025
MB
1181 void EnableEditing( bool edit );
1182
b54ba671
VZ
1183 void EnableCellEditControl( bool enable = TRUE );
1184 void DisableCellEditControl() { EnableCellEditControl(FALSE); }
1185 bool CanEnableCellControl() const;
1186 bool IsCellEditControlEnabled() const;
f6bcfd97 1187 bool IsCellEditControlShown() const;
2d66e025 1188
b54ba671 1189 bool IsCurrentCellReadOnly() const;
2d66e025 1190
2d66e025
MB
1191 void ShowCellEditControl();
1192 void HideCellEditControl();
2d66e025
MB
1193 void SaveEditControlValue();
1194
60ff3b99 1195
2d66e025 1196 // ------ grid location functions
60ff3b99 1197 // Note that all of these functions work with the logical coordinates of
2d66e025
MB
1198 // grid cells and labels so you will need to convert from device
1199 // coordinates for mouse events etc.
1200 //
1201 void XYToCell( int x, int y, wxGridCellCoords& );
1202 int YToRow( int y );
1203 int XToCol( int x );
1204
1205 int YToEdgeOfRow( int y );
1206 int XToEdgeOfCol( int x );
1207
1208 wxRect CellToRect( int row, int col );
1209 wxRect CellToRect( const wxGridCellCoords& coords )
1210 { return CellToRect( coords.GetRow(), coords.GetCol() ); }
1211
1212 int GetGridCursorRow() { return m_currentCellCoords.GetRow(); }
1213 int GetGridCursorCol() { return m_currentCellCoords.GetCol(); }
60ff3b99 1214
2d66e025
MB
1215 // check to see if a cell is either wholly visible (the default arg) or
1216 // at least partially visible in the grid window
1217 //
1218 bool IsVisible( int row, int col, bool wholeCellVisible = TRUE );
1219 bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE )
1220 { return IsVisible( coords.GetRow(), coords.GetCol(), wholeCellVisible ); }
1221 void MakeCellVisible( int row, int col );
1222 void MakeCellVisible( const wxGridCellCoords& coords )
1223 { MakeCellVisible( coords.GetRow(), coords.GetCol() ); }
1224
60ff3b99 1225
2d66e025
MB
1226 // ------ grid cursor movement functions
1227 //
dfaf42d2 1228 void SetGridCursor( int row, int col )
b27f2615 1229 { SetCurrentCell( wxGridCellCoords(row, col) ); }
dfaf42d2 1230
5c8fc7c1
SN
1231 bool MoveCursorUp( bool expandSelection );
1232 bool MoveCursorDown( bool expandSelection );
1233 bool MoveCursorLeft( bool expandSelection );
1234 bool MoveCursorRight( bool expandSelection );
2d66e025
MB
1235 bool MovePageDown();
1236 bool MovePageUp();
5c8fc7c1
SN
1237 bool MoveCursorUpBlock( bool expandSelection );
1238 bool MoveCursorDownBlock( bool expandSelection );
1239 bool MoveCursorLeftBlock( bool expandSelection );
1240 bool MoveCursorRightBlock( bool expandSelection );
2d66e025 1241
60ff3b99 1242
f85afd4e
MB
1243 // ------ label and gridline formatting
1244 //
1245 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; }
1246 int GetRowLabelSize() { return m_rowLabelWidth; }
60ff3b99 1247 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; }
f85afd4e
MB
1248 int GetColLabelSize() { return m_colLabelHeight; }
1249 wxColour GetLabelBackgroundColour() { return m_labelBackgroundColour; }
1250 wxColour GetLabelTextColour() { return m_labelTextColour; }
1251 wxFont GetLabelFont() { return m_labelFont; }
1252 void GetRowLabelAlignment( int *horiz, int *vert );
1253 void GetColLabelAlignment( int *horiz, int *vert );
d43851f7 1254 int GetColLabelTextOrientation();
f85afd4e
MB
1255 wxString GetRowLabelValue( int row );
1256 wxString GetColLabelValue( int col );
1257 wxColour GetGridLineColour() { return m_gridLineColour; }
f6bcfd97 1258 wxColour GetCellHighlightColour() { return m_cellHighlightColour; }
d2520c85
RD
1259 int GetCellHighlightPenWidth() { return m_cellHighlightPenWidth; }
1260 int GetCellHighlightROPenWidth() { return m_cellHighlightROPenWidth; }
f85afd4e 1261
ab79958a 1262 void SetRowLabelSize( int width );
f85afd4e
MB
1263 void SetColLabelSize( int height );
1264 void SetLabelBackgroundColour( const wxColour& );
1265 void SetLabelTextColour( const wxColour& );
1266 void SetLabelFont( const wxFont& );
1267 void SetRowLabelAlignment( int horiz, int vert );
1268 void SetColLabelAlignment( int horiz, int vert );
d43851f7 1269 void SetColLabelTextOrientation( int textOrientation );
f85afd4e
MB
1270 void SetRowLabelValue( int row, const wxString& );
1271 void SetColLabelValue( int col, const wxString& );
1272 void SetGridLineColour( const wxColour& );
f6bcfd97 1273 void SetCellHighlightColour( const wxColour& );
d2520c85
RD
1274 void SetCellHighlightPenWidth(int width);
1275 void SetCellHighlightROPenWidth(int width);
28a77bc4 1276
6e8524b1
MB
1277 void EnableDragRowSize( bool enable = TRUE );
1278 void DisableDragRowSize() { EnableDragRowSize( FALSE ); }
1279 bool CanDragRowSize() { return m_canDragRowSize; }
1280 void EnableDragColSize( bool enable = TRUE );
1281 void DisableDragColSize() { EnableDragColSize( FALSE ); }
1282 bool CanDragColSize() { return m_canDragColSize; }
4cfa5de6
RD
1283 void EnableDragGridSize(bool enable = TRUE);
1284 void DisableDragGridSize() { EnableDragGridSize(FALSE); }
1285 bool CanDragGridSize() { return m_canDragGridSize; }
1286
27f35b66
SN
1287 // this sets the specified attribute for this cell or in this row/col
1288 void SetAttr(int row, int col, wxGridCellAttr *attr);
758cbedf
VZ
1289 void SetRowAttr(int row, wxGridCellAttr *attr);
1290 void SetColAttr(int col, wxGridCellAttr *attr);
1291
0b190b0f
VZ
1292 // shortcuts for setting the column parameters
1293
1294 // set the format for the data in the column: default is string
1295 void SetColFormatBool(int col);
1296 void SetColFormatNumber(int col);
1297 void SetColFormatFloat(int col, int width = -1, int precision = -1);
1298 void SetColFormatCustom(int col, const wxString& typeName);
1299
f85afd4e
MB
1300 void EnableGridLines( bool enable = TRUE );
1301 bool GridLinesEnabled() { return m_gridLinesEnabled; }
1302
f85afd4e
MB
1303 // ------ row and col formatting
1304 //
1305 int GetDefaultRowSize();
1306 int GetRowSize( int row );
1307 int GetDefaultColSize();
1308 int GetColSize( int col );
1309 wxColour GetDefaultCellBackgroundColour();
1310 wxColour GetCellBackgroundColour( int row, int col );
1311 wxColour GetDefaultCellTextColour();
1312 wxColour GetCellTextColour( int row, int col );
f85afd4e
MB
1313 wxFont GetDefaultCellFont();
1314 wxFont GetCellFont( int row, int col );
1315 void GetDefaultCellAlignment( int *horiz, int *vert );
1316 void GetCellAlignment( int row, int col, int *horiz, int *vert );
27f35b66
SN
1317 bool GetDefaultCellOverflow();
1318 bool GetCellOverflow( int row, int col );
1319 void GetCellSize( int row, int col, int *num_rows, int *num_cols );
60ff3b99 1320
f85afd4e
MB
1321 void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE );
1322 void SetRowSize( int row, int height );
1323 void SetDefaultColSize( int width, bool resizeExistingCols = FALSE );
8fb66724 1324
f85afd4e 1325 void SetColSize( int col, int width );
43947979 1326
af547d51
VZ
1327 // automatically size the column or row to fit to its contents, if
1328 // setAsMin is TRUE, this optimal width will also be set as minimal width
1329 // for this column
1330 void AutoSizeColumn( int col, bool setAsMin = TRUE )
1331 { AutoSizeColOrRow(col, setAsMin, TRUE); }
1332 void AutoSizeRow( int row, bool setAsMin = TRUE )
1333 { AutoSizeColOrRow(row, setAsMin, FALSE); }
65e4e78e
VZ
1334
1335 // auto size all columns (very ineffective for big grids!)
266e8367 1336 void AutoSizeColumns( bool setAsMin = TRUE )
ad115b2d 1337 { (void)SetOrCalcColumnSizes(FALSE, setAsMin); }
65e4e78e 1338
266e8367 1339 void AutoSizeRows( bool setAsMin = TRUE )
ad115b2d 1340 { (void)SetOrCalcRowSizes(FALSE, setAsMin); }
57c086ef
VZ
1341
1342 // auto size the grid, that is make the columns/rows of the "right" size
1343 // and also set the grid size to just fit its contents
1344 void AutoSize();
1345
d43851f7
JS
1346 // autosize row height depending on label text
1347 void AutoSizeRowLabelSize( int row );
1348
1349 // autosize column width depending on label text
1350 void AutoSizeColLabelSize( int col );
1351
43947979
VZ
1352 // column won't be resized to be lesser width - this must be called during
1353 // the grid creation because it won't resize the column if it's already
1354 // narrower than the minimal width
1355 void SetColMinimalWidth( int col, int width );
af547d51 1356 void SetRowMinimalHeight( int row, int width );
43947979 1357
b8d24d4e
RG
1358 /* These members can be used to query and modify the minimal
1359 * acceptable size of grid rows and columns. Call this function in
1360 * your code which creates the grid if you want to display cells
1361 * with a size smaller than the default acceptable minimum size.
1362 * Like the members SetColMinimalWidth and SetRowMinimalWidth,
1363 * the existing rows or columns will not be checked/resized.
1364 */
1365 void SetColMinimalAcceptableWidth( int width );
1366 void SetRowMinimalAcceptableHeight( int width );
1367 int GetColMinimalAcceptableWidth() const;
1368 int GetRowMinimalAcceptableHeight() const;
1369
f85afd4e
MB
1370 void SetDefaultCellBackgroundColour( const wxColour& );
1371 void SetCellBackgroundColour( int row, int col, const wxColour& );
1372 void SetDefaultCellTextColour( const wxColour& );
8fb66724 1373
f85afd4e 1374 void SetCellTextColour( int row, int col, const wxColour& );
f85afd4e
MB
1375 void SetDefaultCellFont( const wxFont& );
1376 void SetCellFont( int row, int col, const wxFont& );
1377 void SetDefaultCellAlignment( int horiz, int vert );
1378 void SetCellAlignment( int row, int col, int horiz, int vert );
27f35b66
SN
1379 void SetDefaultCellOverflow( bool allow );
1380 void SetCellOverflow( int row, int col, bool allow );
1381 void SetCellSize( int row, int col, int num_rows, int num_cols );
f85afd4e 1382
ab79958a 1383 // takes ownership of the pointer
2796cce3 1384 void SetDefaultRenderer(wxGridCellRenderer *renderer);
ab79958a 1385 void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
2796cce3
RD
1386 wxGridCellRenderer *GetDefaultRenderer() const;
1387 wxGridCellRenderer* GetCellRenderer(int row, int col);
1388
283b7808 1389 // takes ownership of the pointer
0ba143c9 1390 void SetDefaultEditor(wxGridCellEditor *editor);
9b4aede2 1391 void SetCellEditor(int row, int col, wxGridCellEditor *editor);
0ba143c9 1392 wxGridCellEditor *GetDefaultEditor() const;
9b4aede2
RD
1393 wxGridCellEditor* GetCellEditor(int row, int col);
1394
60a67569 1395
f2d76237 1396
f85afd4e
MB
1397 // ------ cell value accessors
1398 //
1399 wxString GetCellValue( int row, int col )
1400 {
1401 if ( m_table )
1402 {
1403 return m_table->GetValue( row, col );
1404 }
1405 else
1406 {
1407 return wxEmptyString;
1408 }
1409 }
1410
1411 wxString GetCellValue( const wxGridCellCoords& coords )
1412 { return GetCellValue( coords.GetRow(), coords.GetCol() ); }
60ff3b99 1413
f85afd4e
MB
1414 void SetCellValue( int row, int col, const wxString& s );
1415 void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
1416 { SetCellValue( coords.GetRow(), coords.GetCol(), s ); }
f85afd4e 1417
283b7808
VZ
1418 // returns TRUE if the cell can't be edited
1419 bool IsReadOnly(int row, int col) const;
60ff3b99 1420
283b7808
VZ
1421 // make the cell editable/readonly
1422 void SetReadOnly(int row, int col, bool isReadOnly = TRUE);
f85afd4e 1423
aa5b8857 1424 // ------ select blocks of cells
f85afd4e
MB
1425 //
1426 void SelectRow( int row, bool addToSelected = FALSE );
1427 void SelectCol( int col, bool addToSelected = FALSE );
60ff3b99 1428
c9097836
MB
1429 void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
1430 bool addToSelected = FALSE );
f85afd4e
MB
1431
1432 void SelectBlock( const wxGridCellCoords& topLeft,
c9097836
MB
1433 const wxGridCellCoords& bottomRight,
1434 bool addToSelected = FALSE )
f85afd4e 1435 { SelectBlock( topLeft.GetRow(), topLeft.GetCol(),
c9097836
MB
1436 bottomRight.GetRow(), bottomRight.GetCol(),
1437 addToSelected ); }
f85afd4e
MB
1438
1439 void SelectAll();
60ff3b99 1440
b5808881 1441 bool IsSelection();
f85afd4e 1442
aa5b8857 1443 // ------ deselect blocks or cells
f7b4b343
VZ
1444 //
1445 void DeselectRow( int row );
1446 void DeselectCol( int col );
1447 void DeselectCell( int row, int col );
1448
f85afd4e
MB
1449 void ClearSelection();
1450
84035150 1451 bool IsInSelection( int row, int col ) const;
f85afd4e 1452
84035150 1453 bool IsInSelection( const wxGridCellCoords& coords ) const
f85afd4e
MB
1454 { return IsInSelection( coords.GetRow(), coords.GetCol() ); }
1455
aa5b8857
SN
1456 wxGridCellCoordsArray GetSelectedCells() const;
1457 wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
1458 wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
1459 wxArrayInt GetSelectedRows() const;
1460 wxArrayInt GetSelectedCols() const;
c3baf426
SN
1461
1462 // This function returns the rectangle that encloses the block of cells
1463 // limited by TopLeft and BottomRight cell in device coords and clipped
1464 // to the client size of the grid window.
1465 //
58dd5b3b 1466 wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
b99be8fb 1467 const wxGridCellCoords & bottomRight );
c3baf426 1468
2796cce3
RD
1469 // Access or update the selection fore/back colours
1470 wxColour GetSelectionBackground() const
1471 { return m_selectionBackground; }
1472 wxColour GetSelectionForeground() const
1473 { return m_selectionForeground; }
1474
1475 void SetSelectionBackground(const wxColour& c) { m_selectionBackground = c; }
1476 void SetSelectionForeground(const wxColour& c) { m_selectionForeground = c; }
1477
1478
f2d76237
RD
1479 // Methods for a registry for mapping data types to Renderers/Editors
1480 void RegisterDataType(const wxString& typeName,
1481 wxGridCellRenderer* renderer,
1482 wxGridCellEditor* editor);
73145b0e
JS
1483 // DJC MAPTEK
1484 virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
99306db2
VZ
1485 wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
1486 { return GetDefaultEditorForCell(c.GetRow(), c.GetCol()); }
73145b0e
JS
1487 virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
1488 virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
1489 virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
f2d76237 1490
266e8367
VZ
1491 // grid may occupy more space than needed for its rows/columns, this
1492 // function allows to set how big this extra space is
1493 void SetMargins(int extraWidth, int extraHeight)
1494 {
1495 m_extraWidth = extraWidth;
1496 m_extraHeight = extraHeight;
b8125adf
VZ
1497
1498 CalcDimensions();
266e8367 1499 }
f85afd4e 1500
d2520c85
RD
1501 // Accessors for component windows
1502 wxWindow* GetGridWindow() { return (wxWindow*)m_gridWin; }
1503 wxWindow* GetGridRowLabelWindow() { return (wxWindow*)m_rowLabelWin; }
1504 wxWindow* GetGridColLabelWindow() { return (wxWindow*)m_colLabelWin; }
1505 wxWindow* GetGridCornerLabelWindow() { return (wxWindow*)m_cornerLabelWin; }
1506
1507
1508
f85afd4e
MB
1509 // ------ For compatibility with previous wxGrid only...
1510 //
1511 // ************************************************
1512 // ** Don't use these in new code because they **
1513 // ** are liable to disappear in a future **
1514 // ** revision **
1515 // ************************************************
1516 //
1517
1518 wxGrid( wxWindow *parent,
6daa30a0 1519 int x, int y, int w = -1, int h = -1,
ebd773c6 1520 long style = wxWANTS_CHARS,
f85afd4e 1521 const wxString& name = wxPanelNameStr )
f6bcfd97 1522 : wxScrolledWindow( parent, -1, wxPoint(x,y), wxSize(w,h),
ebd773c6 1523 (style|wxWANTS_CHARS), name )
60ff3b99 1524 {
f85afd4e 1525 Create();
60ff3b99 1526 }
f85afd4e
MB
1527
1528 void SetCellValue( const wxString& val, int row, int col )
1529 { SetCellValue( row, col, val ); }
60ff3b99 1530
f85afd4e
MB
1531 void UpdateDimensions()
1532 { CalcDimensions(); }
1533
1534 int GetRows() { return GetNumberRows(); }
1535 int GetCols() { return GetNumberCols(); }
1536 int GetCursorRow() { return GetGridCursorRow(); }
1537 int GetCursorColumn() { return GetGridCursorCol(); }
60ff3b99 1538
2d66e025
MB
1539 int GetScrollPosX() { return 0; }
1540 int GetScrollPosY() { return 0; }
60ff3b99 1541
aa5e1f75
SN
1542 void SetScrollX( int WXUNUSED(x) ) { }
1543 void SetScrollY( int WXUNUSED(y) ) { }
f85afd4e
MB
1544
1545 void SetColumnWidth( int col, int width )
1546 { SetColSize( col, width ); }
60ff3b99 1547
f85afd4e
MB
1548 int GetColumnWidth( int col )
1549 { return GetColSize( col ); }
60ff3b99 1550
f85afd4e
MB
1551 void SetRowHeight( int row, int height )
1552 { SetRowSize( row, height ); }
60ff3b99 1553
7c1cb261 1554 // GetRowHeight() is below
60ff3b99 1555
2d66e025
MB
1556 int GetViewHeight() // returned num whole rows visible
1557 { return 0; }
60ff3b99 1558
2d66e025
MB
1559 int GetViewWidth() // returned num whole cols visible
1560 { return 0; }
f85afd4e
MB
1561
1562 void SetLabelSize( int orientation, int sz )
1563 {
1564 if ( orientation == wxHORIZONTAL )
1565 SetColLabelSize( sz );
1566 else
1567 SetRowLabelSize( sz );
1568 }
1569
1570 int GetLabelSize( int orientation )
1571 {
1572 if ( orientation == wxHORIZONTAL )
1573 return GetColLabelSize();
1574 else
1575 return GetRowLabelSize();
1576 }
1577
1578 void SetLabelAlignment( int orientation, int align )
1579 {
1580 if ( orientation == wxHORIZONTAL )
1581 SetColLabelAlignment( align, -1 );
1582 else
1583 SetRowLabelAlignment( align, -1 );
1584 }
1585
af111fc3 1586 int GetLabelAlignment( int orientation, int WXUNUSED(align) )
f85afd4e
MB
1587 {
1588 int h, v;
1589 if ( orientation == wxHORIZONTAL )
1590 {
1591 GetColLabelAlignment( &h, &v );
1592 return h;
1593 }
1594 else
1595 {
1596 GetRowLabelAlignment( &h, &v );
1597 return h;
1598 }
1599 }
1600
1601 void SetLabelValue( int orientation, const wxString& val, int pos )
1602 {
1603 if ( orientation == wxHORIZONTAL )
1604 SetColLabelValue( pos, val );
1605 else
1606 SetRowLabelValue( pos, val );
1607 }
60ff3b99 1608
f85afd4e
MB
1609 wxString GetLabelValue( int orientation, int pos)
1610 {
1611 if ( orientation == wxHORIZONTAL )
1612 return GetColLabelValue( pos );
1613 else
1614 return GetRowLabelValue( pos );
1615 }
1616
60ff3b99 1617 wxFont GetCellTextFont() const
2796cce3 1618 { return m_defaultCellAttr->GetFont(); }
60ff3b99 1619
af111fc3 1620 wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const
2796cce3 1621 { return m_defaultCellAttr->GetFont(); }
60ff3b99 1622
f85afd4e
MB
1623 void SetCellTextFont(const wxFont& fnt)
1624 { SetDefaultCellFont( fnt ); }
60ff3b99 1625
f85afd4e
MB
1626 void SetCellTextFont(const wxFont& fnt, int row, int col)
1627 { SetCellFont( row, col, fnt ); }
60ff3b99 1628
f85afd4e
MB
1629 void SetCellTextColour(const wxColour& val, int row, int col)
1630 { SetCellTextColour( row, col, val ); }
60ff3b99 1631
f85afd4e
MB
1632 void SetCellTextColour(const wxColour& col)
1633 { SetDefaultCellTextColour( col ); }
60ff3b99 1634
f85afd4e
MB
1635 void SetCellBackgroundColour(const wxColour& col)
1636 { SetDefaultCellBackgroundColour( col ); }
60ff3b99 1637
f85afd4e
MB
1638 void SetCellBackgroundColour(const wxColour& colour, int row, int col)
1639 { SetCellBackgroundColour( row, col, colour ); }
60ff3b99 1640
f85afd4e
MB
1641 bool GetEditable() { return IsEditable(); }
1642 void SetEditable( bool edit = TRUE ) { EnableEditing( edit ); }
1643 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
8fb66724 1644
aa5e1f75 1645 void SetEditInPlace(bool WXUNUSED(edit) = TRUE) { }
f85afd4e 1646
60a67569 1647 void SetCellAlignment( int align, int row, int col)
4c7277db 1648 { SetCellAlignment(row, col, align, wxALIGN_CENTER); }
60a67569
JS
1649 void SetCellAlignment( int WXUNUSED(align) ) {}
1650 void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col))
1651 { }
1652 void SetDividerPen(const wxPen& WXUNUSED(pen)) { }
6fc0f38f 1653 wxPen& GetDividerPen() const;
60a67569 1654 void OnActivate(bool WXUNUSED(active)) {}
60ff3b99 1655
f85afd4e
MB
1656 // ******** End of compatibility functions **********
1657
2d66e025
MB
1658
1659
f85afd4e 1660 // ------ control IDs
2d66e025 1661 enum { wxGRID_CELLCTRL = 2000,
f85afd4e
MB
1662 wxGRID_TOPCTRL };
1663
1664 // ------ control types
2d66e025 1665 enum { wxGRID_TEXTCTRL = 2100,
f85afd4e
MB
1666 wxGRID_CHECKBOX,
1667 wxGRID_CHOICE,
1668 wxGRID_COMBOBOX };
1669
266e8367
VZ
1670 // overridden wxWindow methods
1671 virtual void Fit();
1672
60ff3b99 1673protected:
266e8367
VZ
1674 virtual wxSize DoGetBestSize() const;
1675
60ff3b99
VZ
1676 bool m_created;
1677
1678 wxGridWindow *m_gridWin;
1679 wxGridRowLabelWindow *m_rowLabelWin;
1680 wxGridColLabelWindow *m_colLabelWin;
1681 wxGridCornerLabelWindow *m_cornerLabelWin;
1682
60ff3b99 1683 wxGridTableBase *m_table;
2796cce3 1684 bool m_ownTable;
60ff3b99 1685
60ff3b99
VZ
1686 int m_numRows;
1687 int m_numCols;
1688
1689 wxGridCellCoords m_currentCellCoords;
1690
b5808881
SN
1691 wxGridCellCoords m_selectingTopLeft;
1692 wxGridCellCoords m_selectingBottomRight;
d95b0c2b 1693 wxGridCellCoords m_selectingKeyboard;
b5808881 1694 wxGridSelection *m_selection;
2796cce3
RD
1695 wxColour m_selectionBackground;
1696 wxColour m_selectionForeground;
60ff3b99 1697
7c1cb261
VZ
1698 // NB: *never* access m_row/col arrays directly because they are created
1699 // on demand, *always* use accessor functions instead!
1700
1701 // init the m_rowHeights/Bottoms arrays with default values
1702 void InitRowHeights();
1703
60ff3b99 1704 int m_defaultRowHeight;
b8d24d4e 1705 int m_minAcceptableRowHeight;
60ff3b99
VZ
1706 wxArrayInt m_rowHeights;
1707 wxArrayInt m_rowBottoms;
1708
7c1cb261
VZ
1709 // init the m_colWidths/Rights arrays
1710 void InitColWidths();
1711
60ff3b99 1712 int m_defaultColWidth;
b8d24d4e 1713 int m_minAcceptableColWidth;
60ff3b99
VZ
1714 wxArrayInt m_colWidths;
1715 wxArrayInt m_colRights;
7c1cb261
VZ
1716
1717 // get the col/row coords
1718 int GetColWidth(int col) const;
1719 int GetColLeft(int col) const;
1720 int GetColRight(int col) const;
1721
1722 // this function must be public for compatibility...
1723public:
1724 int GetRowHeight(int row) const;
1725protected:
1726
1727 int GetRowTop(int row) const;
1728 int GetRowBottom(int row) const;
1729
60ff3b99
VZ
1730 int m_rowLabelWidth;
1731 int m_colLabelHeight;
1732
266e8367
VZ
1733 // the size of the margin left to the right and bottom of the cell area
1734 int m_extraWidth,
1735 m_extraHeight;
1736
60ff3b99
VZ
1737 wxColour m_labelBackgroundColour;
1738 wxColour m_labelTextColour;
1739 wxFont m_labelFont;
1740
1741 int m_rowLabelHorizAlign;
1742 int m_rowLabelVertAlign;
1743 int m_colLabelHorizAlign;
1744 int m_colLabelVertAlign;
d43851f7 1745 int m_colLabelTextOrientation;
60ff3b99
VZ
1746
1747 bool m_defaultRowLabelValues;
1748 bool m_defaultColLabelValues;
1749
1750 wxColour m_gridLineColour;
1751 bool m_gridLinesEnabled;
f6bcfd97 1752 wxColour m_cellHighlightColour;
d2520c85
RD
1753 int m_cellHighlightPenWidth;
1754 int m_cellHighlightROPenWidth;
1755
60ff3b99 1756
266e8367
VZ
1757 // common part of AutoSizeColumn/Row() and GetBestSize()
1758 int SetOrCalcColumnSizes(bool calcOnly, bool setAsMin = TRUE);
1759 int SetOrCalcRowSizes(bool calcOnly, bool setAsMin = TRUE);
1760
af547d51
VZ
1761 // common part of AutoSizeColumn/Row()
1762 void AutoSizeColOrRow(int n, bool setAsMin, bool column /* or row? */);
1763
43947979
VZ
1764 // if a column has a minimal width, it will be the value for it in this
1765 // hash table
ba8c1601
MB
1766 wxLongToLongHashMap m_colMinWidths,
1767 m_rowMinHeights;
43947979 1768
af547d51
VZ
1769 // get the minimal width of the given column/row
1770 int GetColMinimalWidth(int col) const;
1771 int GetRowMinimalHeight(int col) const;
b99be8fb
VZ
1772
1773 // do we have some place to store attributes in?
1774 bool CanHaveAttributes();
60ff3b99 1775
2e9a6788
VZ
1776 // returns the attribute we may modify in place: a new one if this cell
1777 // doesn't have any yet or the existing one if it does
1778 //
1779 // DecRef() must be called on the returned pointer, as usual
0a976765
VZ
1780 wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
1781
1782 // cell attribute cache (currently we only cache 1, may be will do
1783 // more/better later)
1784 struct CachedAttr
1785 {
1786 int row, col;
1787 wxGridCellAttr *attr;
1788 } m_attrCache;
1789
1790 // invalidates the attribute cache
1791 void ClearAttrCache();
1792
1793 // adds an attribute to cache
1794 void CacheAttr(int row, int col, wxGridCellAttr *attr) const;
1795
1796 // looks for an attr in cache, returns TRUE if found
1797 bool LookupAttr(int row, int col, wxGridCellAttr **attr) const;
1798
1799 // looks for the attr in cache, if not found asks the table and caches the
1800 // result
2e9a6788 1801 wxGridCellAttr *GetCellAttr(int row, int col) const;
2c9a89e0
RD
1802 wxGridCellAttr *GetCellAttr(const wxGridCellCoords& coords )
1803 { return GetCellAttr( coords.GetRow(), coords.GetCol() ); }
2e9a6788 1804
2796cce3
RD
1805 // the default cell attr object for cells that don't have their own
1806 wxGridCellAttr* m_defaultCellAttr;
1807
1808
60ff3b99
VZ
1809 bool m_inOnKeyDown;
1810 int m_batchCount;
1811
f2d76237
RD
1812
1813 wxGridTypeRegistry* m_typeRegistry;
1814
e2b42eeb
VZ
1815 enum CursorMode
1816 {
1817 WXGRID_CURSOR_SELECT_CELL,
1818 WXGRID_CURSOR_RESIZE_ROW,
1819 WXGRID_CURSOR_RESIZE_COL,
1820 WXGRID_CURSOR_SELECT_ROW,
1821 WXGRID_CURSOR_SELECT_COL
60ff3b99
VZ
1822 };
1823
e2b42eeb
VZ
1824 // this method not only sets m_cursorMode but also sets the correct cursor
1825 // for the given mode and, if captureMouse is not FALSE releases the mouse
1826 // if it was captured and captures it if it must be captured
1827 //
1828 // for this to work, you should always use it and not set m_cursorMode
1829 // directly!
1830 void ChangeCursorMode(CursorMode mode,
1831 wxWindow *win = (wxWindow *)NULL,
1832 bool captureMouse = TRUE);
1833
1834 wxWindow *m_winCapture; // the window which captured the mouse
1835 CursorMode m_cursorMode;
1836
6e8524b1
MB
1837 bool m_canDragRowSize;
1838 bool m_canDragColSize;
4cfa5de6 1839 bool m_canDragGridSize;
07296f0b
RD
1840 int m_dragLastPos;
1841 int m_dragRowOrCol;
1842 bool m_isDragging;
1843 wxPoint m_startDragPos;
60ff3b99 1844
75ecbe45 1845 bool m_waitForSlowClick;
025562fe 1846
60ff3b99
VZ
1847 wxGridCellCoords m_selectionStart;
1848
1849 wxCursor m_rowResizeCursor;
1850 wxCursor m_colResizeCursor;
1851
b54ba671
VZ
1852 bool m_editable; // applies to whole grid
1853 bool m_cellEditCtrlEnabled; // is in-place edit currently shown?
60ff3b99
VZ
1854
1855
1856 void Create();
1857 void Init();
1858 void CalcDimensions();
7807d81c 1859 void CalcWindowSizes();
60ff3b99
VZ
1860 bool Redimension( wxGridTableMessage& );
1861
1862
fe7b9ed6
VZ
1863 int SendEvent( const wxEventType, int row, int col, wxMouseEvent& );
1864 int SendEvent( const wxEventType, int row, int col );
1865 int SendEvent( const wxEventType type)
b54ba671
VZ
1866 {
1867 return SendEvent(type,
1868 m_currentCellCoords.GetRow(),
1869 m_currentCellCoords.GetCol());
1870 }
60ff3b99
VZ
1871
1872 void OnPaint( wxPaintEvent& );
1873 void OnSize( wxSizeEvent& );
1874 void OnKeyDown( wxKeyEvent& );
f6bcfd97 1875 void OnKeyUp( wxKeyEvent& );
2796cce3 1876 void OnEraseBackground( wxEraseEvent& );
60ff3b99
VZ
1877
1878
1879 void SetCurrentCell( const wxGridCellCoords& coords );
1880 void SetCurrentCell( int row, int col )
1881 { SetCurrentCell( wxGridCellCoords(row, col) ); }
1882
c9097836
MB
1883 void HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCol );
1884
1885 void HighlightBlock( const wxGridCellCoords& topLeft,
d2520c85 1886 const wxGridCellCoords& bottomRight )
c9097836
MB
1887 { HighlightBlock( topLeft.GetRow(), topLeft.GetCol(),
1888 bottomRight.GetRow(), bottomRight.GetCol() ); }
60ff3b99
VZ
1889
1890 // ------ functions to get/send data (see also public functions)
1891 //
1892 bool GetModelValues();
1893 bool SetModelValues();
1894
2b5f62a0 1895 friend class WXDLLEXPORT wxGridSelection;
60ff3b99 1896
2d66e025 1897 DECLARE_DYNAMIC_CLASS( wxGrid )
f85afd4e 1898 DECLARE_EVENT_TABLE()
22f3361e 1899 DECLARE_NO_COPY_CLASS(wxGrid)
f85afd4e
MB
1900};
1901
b8d24d4e 1902
43947979
VZ
1903// ----------------------------------------------------------------------------
1904// Grid event class and event types
1905// ----------------------------------------------------------------------------
f85afd4e
MB
1906
1907class WXDLLEXPORT wxGridEvent : public wxNotifyEvent
1908{
60ff3b99 1909public:
f85afd4e
MB
1910 wxGridEvent()
1911 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
5c8fc7c1 1912 m_selecting(0), m_control(0), m_meta(0), m_shift(0), m_alt(0)
f85afd4e
MB
1913 {
1914 }
1915
1916 wxGridEvent(int id, wxEventType type, wxObject* obj,
5c8fc7c1 1917 int row=-1, int col=-1, int x=-1, int y=-1, bool sel = TRUE,
f85afd4e
MB
1918 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1919
1920 virtual int GetRow() { return m_row; }
1921 virtual int GetCol() { return m_col; }
1922 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
5c8fc7c1 1923 bool Selecting() { return m_selecting; }
f85afd4e
MB
1924 bool ControlDown() { return m_control; }
1925 bool MetaDown() { return m_meta; }
1926 bool ShiftDown() { return m_shift; }
1927 bool AltDown() { return m_alt; }
2d66e025 1928
60ff3b99
VZ
1929protected:
1930 int m_row;
1931 int m_col;
f85afd4e
MB
1932 int m_x;
1933 int m_y;
5c8fc7c1 1934 bool m_selecting;
f85afd4e
MB
1935 bool m_control;
1936 bool m_meta;
1937 bool m_shift;
1938 bool m_alt;
60ff3b99
VZ
1939
1940 DECLARE_DYNAMIC_CLASS(wxGridEvent)
1941};
1942
60ff3b99
VZ
1943class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent
1944{
1945public:
f85afd4e
MB
1946 wxGridSizeEvent()
1947 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1948 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1949 {
1950 }
1951
1952 wxGridSizeEvent(int id, wxEventType type, wxObject* obj,
1953 int rowOrCol=-1, int x=-1, int y=-1,
1954 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1955
1956 int GetRowOrCol() { return m_rowOrCol; }
1957 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
1958 bool ControlDown() { return m_control; }
1959 bool MetaDown() { return m_meta; }
1960 bool ShiftDown() { return m_shift; }
1961 bool AltDown() { return m_alt; }
2d66e025 1962
60ff3b99
VZ
1963protected:
1964 int m_rowOrCol;
1965 int m_x;
1966 int m_y;
1967 bool m_control;
1968 bool m_meta;
1969 bool m_shift;
1970 bool m_alt;
1971
2d66e025 1972 DECLARE_DYNAMIC_CLASS(wxGridSizeEvent)
f85afd4e
MB
1973};
1974
1975
1976class WXDLLEXPORT wxGridRangeSelectEvent : public wxNotifyEvent
1977{
60ff3b99 1978public:
f85afd4e 1979 wxGridRangeSelectEvent()
60ff3b99
VZ
1980 : wxNotifyEvent()
1981 {
1982 m_topLeft = wxGridNoCellCoords;
1983 m_bottomRight = wxGridNoCellCoords;
5c8fc7c1 1984 m_selecting = FALSE;
60ff3b99
VZ
1985 m_control = FALSE;
1986 m_meta = FALSE;
1987 m_shift = FALSE;
1988 m_alt = FALSE;
1989 }
f85afd4e
MB
1990
1991 wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj,
60ff3b99
VZ
1992 const wxGridCellCoords& topLeft,
1993 const wxGridCellCoords& bottomRight,
5c8fc7c1 1994 bool sel = TRUE,
60ff3b99
VZ
1995 bool control=FALSE, bool shift=FALSE,
1996 bool alt=FALSE, bool meta=FALSE);
f85afd4e
MB
1997
1998 wxGridCellCoords GetTopLeftCoords() { return m_topLeft; }
1999 wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; }
2000 int GetTopRow() { return m_topLeft.GetRow(); }
2001 int GetBottomRow() { return m_bottomRight.GetRow(); }
2002 int GetLeftCol() { return m_topLeft.GetCol(); }
2003 int GetRightCol() { return m_bottomRight.GetCol(); }
5c8fc7c1 2004 bool Selecting() { return m_selecting; }
f85afd4e
MB
2005 bool ControlDown() { return m_control; }
2006 bool MetaDown() { return m_meta; }
2007 bool ShiftDown() { return m_shift; }
2008 bool AltDown() { return m_alt; }
2d66e025 2009
60ff3b99
VZ
2010protected:
2011 wxGridCellCoords m_topLeft;
2012 wxGridCellCoords m_bottomRight;
5c8fc7c1 2013 bool m_selecting;
60ff3b99
VZ
2014 bool m_control;
2015 bool m_meta;
2016 bool m_shift;
2017 bool m_alt;
2018
2d66e025 2019 DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent)
f85afd4e
MB
2020};
2021
bf7945ce
RD
2022
2023class WXDLLEXPORT wxGridEditorCreatedEvent : public wxCommandEvent {
2024public:
2025 wxGridEditorCreatedEvent()
2026 : wxCommandEvent()
2027 {
2028 m_row = 0;
2029 m_col = 0;
2030 m_ctrl = NULL;
2031 }
2032
2033 wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
2034 int row, int col, wxControl* ctrl);
2035
2036 int GetRow() { return m_row; }
2037 int GetCol() { return m_col; }
2038 wxControl* GetControl() { return m_ctrl; }
2039 void SetRow(int row) { m_row = row; }
2040 void SetCol(int col) { m_col = col; }
2041 void SetControl(wxControl* ctrl) { m_ctrl = ctrl; }
2042
2043private:
2044 int m_row;
2045 int m_col;
2046 wxControl* m_ctrl;
2047
2048 DECLARE_DYNAMIC_CLASS(wxGridEditorCreatedEvent)
22f3361e 2049 DECLARE_NO_COPY_CLASS(wxGridEditorCreatedEvent)
bf7945ce
RD
2050};
2051
2052
2e4df4bf
VZ
2053BEGIN_DECLARE_EVENT_TYPES()
2054 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_LEFT_CLICK, 1580)
2055 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_RIGHT_CLICK, 1581)
2056 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_LEFT_DCLICK, 1582)
2057 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_RIGHT_DCLICK, 1583)
2058 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_LEFT_CLICK, 1584)
2059 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_RIGHT_CLICK, 1585)
2060 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_LEFT_DCLICK, 1586)
2061 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_RIGHT_DCLICK, 1587)
2062 DECLARE_EVENT_TYPE(wxEVT_GRID_ROW_SIZE, 1588)
2063 DECLARE_EVENT_TYPE(wxEVT_GRID_COL_SIZE, 1589)
2064 DECLARE_EVENT_TYPE(wxEVT_GRID_RANGE_SELECT, 1590)
2065 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_CHANGE, 1591)
2066 DECLARE_EVENT_TYPE(wxEVT_GRID_SELECT_CELL, 1592)
2067 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_SHOWN, 1593)
2068 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_HIDDEN, 1594)
bf7945ce 2069 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_CREATED, 1595)
2e4df4bf 2070END_DECLARE_EVENT_TYPES()
749692cc 2071
f85afd4e
MB
2072
2073typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&);
2074typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&);
2075typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&);
bf7945ce 2076typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction)(wxGridEditorCreatedEvent&);
f85afd4e 2077
2e4df4bf
VZ
2078#define EVT_GRID_CELL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2079#define EVT_GRID_CELL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2080#define EVT_GRID_CELL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2081#define EVT_GRID_CELL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2082#define EVT_GRID_LABEL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2083#define EVT_GRID_LABEL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2084#define EVT_GRID_LABEL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2085#define EVT_GRID_LABEL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2086#define EVT_GRID_ROW_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL ),
2087#define EVT_GRID_COL_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL ),
2088#define EVT_GRID_RANGE_SELECT(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL ),
2089#define EVT_GRID_CELL_CHANGE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2090#define EVT_GRID_SELECT_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2091#define EVT_GRID_EDITOR_SHOWN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_SHOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2092#define EVT_GRID_EDITOR_HIDDEN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_HIDDEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
bf7945ce 2093#define EVT_GRID_EDITOR_CREATED(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_CREATED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEditorCreatedEventFunction) &fn, NULL ),
f85afd4e
MB
2094
2095
2096#if 0 // TODO: implement these ? others ?
2097
77d4384e
RR
2098extern const int wxEVT_GRID_CREATE_CELL;
2099extern const int wxEVT_GRID_CHANGE_LABELS;
2100extern const int wxEVT_GRID_CHANGE_SEL_LABEL;
f85afd4e 2101
2e4df4bf
VZ
2102#define EVT_GRID_CREATE_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2103#define EVT_GRID_CHANGE_LABELS(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2104#define EVT_GRID_CHANGE_SEL_LABEL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
f85afd4e
MB
2105
2106#endif
2107
f7556ff0 2108#endif // ifndef wxUSE_GRID
f85afd4e 2109