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