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