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