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