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