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