1. Fixed slow-click timer.
[wxWidgets.git] / include / wx / generic / grid.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: grid.h
3 // Purpose: wxGrid and related classes
4 // Author: Michael Bedward (based on code by Julian Smart, Robin Dunn)
5 // Modified by:
6 // Created: 1/08/1999
7 // RCS-ID: $Id$
8 // Copyright: (c) Michael Bedward
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12
13 #include "wx/defs.h"
14
15 #if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID)
16 #include "gridg.h"
17 #else
18
19 #ifndef __WXGRID_H__
20 #define __WXGRID_H__
21
22 #ifdef __GNUG__
23 #pragma interface "grid.h"
24 #endif
25
26 #include "wx/panel.h"
27 #include "wx/scrolwin.h"
28 #include "wx/string.h"
29 #include "wx/scrolbar.h"
30 #include "wx/event.h"
31 #include "wx/textctrl.h"
32 #include "wx/combobox.h"
33 #include "wx/dynarray.h"
34 #include "wx/timer.h"
35
36 // Default parameters for wxGrid
37 //
38 #define WXGRID_DEFAULT_NUMBER_ROWS 10
39 #define WXGRID_DEFAULT_NUMBER_COLS 10
40 #ifdef __WXMSW__
41 #define WXGRID_DEFAULT_ROW_HEIGHT 25
42 #else
43 #define WXGRID_DEFAULT_ROW_HEIGHT 30
44 #endif // __WXMSW__
45 #define WXGRID_DEFAULT_COL_WIDTH 80
46 #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
47 #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
48 #define WXGRID_LABEL_EDGE_ZONE 5
49 #define WXGRID_MIN_ROW_HEIGHT 15
50 #define WXGRID_MIN_COL_WIDTH 15
51 #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
52
53 // ----------------------------------------------------------------------------
54 // forward declarations
55 // ----------------------------------------------------------------------------
56
57 class WXDLLEXPORT wxGrid;
58 class WXDLLEXPORT wxGridCellAttr;
59 class WXDLLEXPORT wxGridCellAttrProviderData;
60 class WXDLLEXPORT wxGridColLabelWindow;
61 class WXDLLEXPORT wxGridCornerLabelWindow;
62 class WXDLLEXPORT wxGridRowLabelWindow;
63 class WXDLLEXPORT wxGridTableBase;
64 class WXDLLEXPORT wxGridWindow;
65
66 // ----------------------------------------------------------------------------
67 // wxGridCellRenderer: this class is responsible for actually drawing the cell
68 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
69 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
70 // view of all cells. This is an ABC, you will normally use one of the
71 // predefined derived classes or derive oyur own class from it.
72 // ----------------------------------------------------------------------------
73
74 class WXDLLEXPORT wxGridCellRenderer
75 {
76 public:
77 // draw the given cell on the provided DC inside the given rectangle
78 // using the style specified by the attribute and the default or selected
79 // state corresponding to the isSelected value.
80 //
81 // this pure virtual function has a default implementation which will
82 // prepare the DC using the given attribute: it will draw the rectangle
83 // with the bg colour from attr and set the text colour and font
84 virtual void Draw(wxGrid& grid,
85 wxGridCellAttr& attr,
86 wxDC& dc,
87 const wxRect& rect,
88 int row, int col,
89 bool isSelected) = 0;
90 };
91
92 // the default renderer for the cells containing string data
93 class WXDLLEXPORT wxGridCellStringRenderer : public wxGridCellRenderer
94 {
95 public:
96 // draw the string
97 virtual void Draw(wxGrid& grid,
98 wxGridCellAttr& attr,
99 wxDC& dc,
100 const wxRect& rect,
101 int row, int col,
102 bool isSelected);
103 };
104
105
106 // ----------------------------------------------------------------------------
107 // wxGridCellEditor: This class is responsible for providing and manipulating
108 // the in-place edit controls for the grid. Instances of wxGridCellEditor
109 // (actually, instances of derived classes since it is an ABC) can be
110 // associated with the cell attributes for individual cells, rows, columns, or
111 // even for the entire grid.
112 // ----------------------------------------------------------------------------
113
114 class WXDLLEXPORT wxGridCellEditor
115 {
116 public:
117 wxGridCellEditor();
118 virtual ~wxGridCellEditor();
119
120 bool IsCreated() { return m_control != NULL; }
121
122 // Creates the actual edit control
123 virtual void Create(wxWindow* parent,
124 wxWindowID id,
125 const wxPoint& pos,
126 const wxSize& size,
127 wxEvtHandler* evtHandler) = 0;
128
129 // Size and position the edit control
130 virtual void SetSize(const wxRect& rect);
131
132 // Show or hide the edit control
133 virtual void Show(bool show);
134
135 // Fetch the value from the table and prepare the edit control
136 // to begin editing. Set the focus to the edit control.
137 virtual void BeginEdit(int row, int col, wxGrid* grid,
138 wxGridCellAttr* attr) = 0;
139
140 // Complete the editing of the current cell. If saveValue is
141 // true then send the new value back to the table. Returns true
142 // if the value has changed. If necessary, the control may be
143 // destroyed.
144 virtual bool EndEdit(int row, int col, bool saveValue,
145 wxGrid* grid, wxGridCellAttr* attr) = 0;
146
147 // Reset the value in the control back to its starting value
148 virtual void Reset() = 0;
149
150 // Some types of controls on some platforms may need some help
151 // with the Return key.
152 virtual void HandleReturn(wxKeyEvent& event);
153
154 // Final cleanup
155 virtual void Destroy();
156
157 protected:
158 wxControl* m_control;
159 };
160
161
162 class WXDLLEXPORT wxGridCellTextEditor : public wxGridCellEditor
163 {
164 public:
165 wxGridCellTextEditor();
166
167 virtual void Create(wxWindow* parent,
168 wxWindowID id,
169 const wxPoint& pos,
170 const wxSize& size,
171 wxEvtHandler* evtHandler);
172
173 virtual void BeginEdit(int row, int col, wxGrid* grid,
174 wxGridCellAttr* attr);
175
176 virtual bool EndEdit(int row, int col, bool saveValue,
177 wxGrid* grid, wxGridCellAttr* attr);
178
179 virtual void Reset();
180 virtual void HandleReturn(wxKeyEvent& event);
181
182
183 private:
184 wxString m_startValue;
185 };
186
187 // ----------------------------------------------------------------------------
188 // wxGridCellAttr: this class can be used to alter the cells appearance in
189 // the grid by changing their colour/font/... from default. An object of this
190 // class may be returned by wxGridTable::GetAttr().
191 // ----------------------------------------------------------------------------
192
193 class WXDLLEXPORT wxGridCellAttr
194 {
195 public:
196 // ctors
197 wxGridCellAttr()
198 {
199 Init();
200 SetAlignment(0, 0);
201 }
202
203 wxGridCellAttr(const wxColour& colText,
204 const wxColour& colBack,
205 const wxFont& font,
206 int hAlign,
207 int vAlign)
208 : m_colText(colText), m_colBack(colBack), m_font(font)
209 {
210 Init();
211 SetAlignment(hAlign, vAlign);
212 }
213
214 // default copy ctor ok
215
216 // this class is ref counted: it is created with ref count of 1, so
217 // calling DecRef() once will delete it. Calling IncRef() allows to lock
218 // it until the matching DecRef() is called
219 void IncRef() { m_nRef++; }
220 void DecRef() { if ( !--m_nRef ) delete this; }
221 void SafeIncRef() { if ( this ) IncRef(); }
222 void SafeDecRef() { if ( this ) DecRef(); }
223
224 // setters
225 void SetTextColour(const wxColour& colText) { m_colText = colText; }
226 void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
227 void SetFont(const wxFont& font) { m_font = font; }
228 void SetAlignment(int hAlign, int vAlign)
229 {
230 m_hAlign = hAlign;
231 m_vAlign = vAlign;
232 }
233
234 // takes ownership of the pointer
235 void SetRenderer(wxGridCellRenderer *renderer)
236 { delete m_renderer; m_renderer = renderer; }
237 void SetEditor(wxGridCellEditor* editor)
238 { delete m_editor; m_editor = editor; }
239
240 // accessors
241 bool HasTextColour() const { return m_colText.Ok(); }
242 bool HasBackgroundColour() const { return m_colBack.Ok(); }
243 bool HasFont() const { return m_font.Ok(); }
244 bool HasAlignment() const { return m_hAlign || m_vAlign; }
245 bool HasRenderer() const { return m_renderer != NULL; }
246 bool HasEditor() const { return m_editor != NULL; }
247
248 const wxColour& GetTextColour() const;
249 const wxColour& GetBackgroundColour() const;
250 const wxFont& GetFont() const;
251 void GetAlignment(int *hAlign, int *vAlign) const;
252 wxGridCellRenderer *GetRenderer() const;
253 wxGridCellEditor *GetEditor() const;
254
255 void SetDefAttr(wxGridCellAttr* defAttr) { m_defGridAttr = defAttr; }
256
257 private:
258 // the common part of all ctors
259 void Init() {
260 m_nRef = 1;
261 m_renderer = NULL;
262 m_editor = NULL;
263 }
264
265 // the dtor is private because only DecRef() can delete us
266 ~wxGridCellAttr() { delete m_renderer; delete m_editor; }
267
268 // the ref count - when it goes to 0, we die
269 size_t m_nRef;
270
271 wxColour m_colText,
272 m_colBack;
273 wxFont m_font;
274 int m_hAlign,
275 m_vAlign;
276
277 wxGridCellRenderer* m_renderer;
278 wxGridCellEditor* m_editor;
279 wxGridCellAttr* m_defGridAttr;
280
281 // suppress the stupid gcc warning about the class having private dtor and
282 // no friends
283 friend class wxGridCellAttrDummyFriend;
284 };
285
286 // ----------------------------------------------------------------------------
287 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
288 // cell attributes.
289 // ----------------------------------------------------------------------------
290
291 // implementation note: we separate it from wxGridTableBase because we wish to
292 // avoid deriving a new table class if possible, and sometimes it will be
293 // enough to just derive another wxGridCellAttrProvider instead
294 //
295 // the default implementation is reasonably efficient for the generic case,
296 // but you might still wish to implement your own for some specific situations
297 // if you have performance problems with the stock one
298 class WXDLLEXPORT wxGridCellAttrProvider
299 {
300 public:
301 wxGridCellAttrProvider();
302 virtual ~wxGridCellAttrProvider();
303
304 // DecRef() must be called on the returned pointer
305 virtual wxGridCellAttr *GetAttr(int row, int col) const;
306
307 // all these functions take ownership of the pointer, don't call DecRef()
308 // on it
309 virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
310 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
311 virtual void SetColAttr(wxGridCellAttr *attr, int col);
312
313 private:
314 void InitData();
315
316 wxGridCellAttrProviderData *m_data;
317 };
318
319 //////////////////////////////////////////////////////////////////////
320 //
321 // Grid table classes
322 //
323 //////////////////////////////////////////////////////////////////////
324
325
326 class WXDLLEXPORT wxGridTableBase : public wxObject
327 {
328 public:
329 wxGridTableBase();
330 virtual ~wxGridTableBase();
331
332 // You must override these functions in a derived table class
333 //
334 virtual long GetNumberRows() = 0;
335 virtual long GetNumberCols() = 0;
336 virtual wxString GetValue( int row, int col ) = 0;
337 virtual void SetValue( int row, int col, const wxString& s ) = 0;
338 virtual bool IsEmptyCell( int row, int col ) = 0;
339
340 // Overriding these is optional
341 //
342 virtual void SetView( wxGrid *grid ) { m_view = grid; }
343 virtual wxGrid * GetView() const { return m_view; }
344
345 virtual void Clear() {}
346 virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
347 virtual bool AppendRows( size_t numRows = 1 );
348 virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
349 virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
350 virtual bool AppendCols( size_t numCols = 1 );
351 virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
352
353 virtual wxString GetRowLabelValue( int row );
354 virtual wxString GetColLabelValue( int col );
355 virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {}
356 virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {}
357
358 // Attribute handling
359 //
360
361 // give us the attr provider to use - we take ownership of the pointer
362 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
363
364 // get the currently used attr provider (may be NULL)
365 wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; }
366
367 // by default forwarded to wxGridCellAttrProvider if any. May be
368 // overridden to handle attributes directly in this class.
369 virtual wxGridCellAttr *GetAttr( int row, int col );
370
371 // these functions take ownership of the pointer
372 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
373 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
374 virtual void SetColAttr(wxGridCellAttr *attr, int col);
375
376 private:
377 wxGrid * m_view;
378 wxGridCellAttrProvider *m_attrProvider;
379
380 DECLARE_ABSTRACT_CLASS( wxGridTableBase );
381 };
382
383
384 // ----------------------------------------------------------------------------
385 // wxGridTableMessage
386 // ----------------------------------------------------------------------------
387
388 // IDs for messages sent from grid table to view
389 //
390 enum wxGridTableRequest
391 {
392 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
393 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
394 wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
395 wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
396 wxGRIDTABLE_NOTIFY_ROWS_DELETED,
397 wxGRIDTABLE_NOTIFY_COLS_INSERTED,
398 wxGRIDTABLE_NOTIFY_COLS_APPENDED,
399 wxGRIDTABLE_NOTIFY_COLS_DELETED
400 };
401
402 class WXDLLEXPORT wxGridTableMessage
403 {
404 public:
405 wxGridTableMessage();
406 wxGridTableMessage( wxGridTableBase *table, int id,
407 int comInt1 = -1,
408 int comInt2 = -1 );
409
410 void SetTableObject( wxGridTableBase *table ) { m_table = table; }
411 wxGridTableBase * GetTableObject() const { return m_table; }
412 void SetId( int id ) { m_id = id; }
413 int GetId() { return m_id; }
414 void SetCommandInt( int comInt1 ) { m_comInt1 = comInt1; }
415 int GetCommandInt() { return m_comInt1; }
416 void SetCommandInt2( int comInt2 ) { m_comInt2 = comInt2; }
417 int GetCommandInt2() { return m_comInt2; }
418
419 private:
420 wxGridTableBase *m_table;
421 int m_id;
422 int m_comInt1;
423 int m_comInt2;
424 };
425
426
427
428 // ------ wxGridStringArray
429 // A 2-dimensional array of strings for data values
430 //
431
432 WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString, wxGridStringArray);
433
434
435
436 // ------ wxGridStringTable
437 //
438 // Simplest type of data table for a grid for small tables of strings
439 // that are stored in memory
440 //
441
442 class WXDLLEXPORT wxGridStringTable : public wxGridTableBase
443 {
444 public:
445 wxGridStringTable();
446 wxGridStringTable( int numRows, int numCols );
447 ~wxGridStringTable();
448
449 // these are pure virtual in wxGridTableBase
450 //
451 long GetNumberRows();
452 long GetNumberCols();
453 wxString GetValue( int row, int col );
454 void SetValue( int row, int col, const wxString& s );
455 bool IsEmptyCell( int row, int col );
456
457 // overridden functions from wxGridTableBase
458 //
459 void Clear();
460 bool InsertRows( size_t pos = 0, size_t numRows = 1 );
461 bool AppendRows( size_t numRows = 1 );
462 bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
463 bool InsertCols( size_t pos = 0, size_t numCols = 1 );
464 bool AppendCols( size_t numCols = 1 );
465 bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
466
467 void SetRowLabelValue( int row, const wxString& );
468 void SetColLabelValue( int col, const wxString& );
469 wxString GetRowLabelValue( int row );
470 wxString GetColLabelValue( int col );
471
472 private:
473 wxGridStringArray m_data;
474
475 // These only get used if you set your own labels, otherwise the
476 // GetRow/ColLabelValue functions return wxGridTableBase defaults
477 //
478 wxArrayString m_rowLabels;
479 wxArrayString m_colLabels;
480
481 DECLARE_DYNAMIC_CLASS( wxGridStringTable )
482 };
483
484
485
486 //////////////////////////////////////////////////////////////////////
487 //
488 // Grid view classes
489 //
490 //////////////////////////////////////////////////////////////////////
491
492 class WXDLLEXPORT wxGridCellCoords
493 {
494 public:
495 wxGridCellCoords() { m_row = m_col = -1; }
496 wxGridCellCoords( int r, int c ) { m_row = r; m_col = c; }
497
498 // default copy ctor is ok
499
500 long GetRow() const { return m_row; }
501 void SetRow( long n ) { m_row = n; }
502 long GetCol() const { return m_col; }
503 void SetCol( long n ) { m_col = n; }
504 void Set( long row, long col ) { m_row = row; m_col = col; }
505
506 wxGridCellCoords& operator=( const wxGridCellCoords& other )
507 {
508 if ( &other != this )
509 {
510 m_row=other.m_row;
511 m_col=other.m_col;
512 }
513 return *this;
514 }
515
516 bool operator==( const wxGridCellCoords& other )
517 {
518 return (m_row == other.m_row && m_col == other.m_col);
519 }
520
521 bool operator!=( const wxGridCellCoords& other )
522 {
523 return (m_row != other.m_row || m_col != other.m_col);
524 }
525
526 bool operator!()
527 {
528 return (m_row == -1 && m_col == -1 );
529 }
530
531 private:
532 long m_row;
533 long m_col;
534 };
535
536
537 // For comparisons...
538 //
539 extern wxGridCellCoords wxGridNoCellCoords;
540 extern wxRect wxGridNoCellRect;
541
542 // An array of cell coords...
543 //
544 WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords, wxGridCellCoordsArray);
545
546
547
548 // This set of classes is to provide for the use of different types of
549 // cell edit controls in the grid while avoiding the wx class info
550 // system in deference to wxPython
551
552 class WXDLLEXPORT wxGridTextCtrl : public wxTextCtrl
553 {
554 public:
555 wxGridTextCtrl() {}
556 wxGridTextCtrl( wxWindow *,
557 wxGrid *,
558 bool isCellControl,
559 wxWindowID id,
560 const wxString& value = wxEmptyString,
561 const wxPoint& pos = wxDefaultPosition,
562 const wxSize& size = wxDefaultSize,
563 long style = 0 );
564
565 void SetStartValue( const wxString& );
566 wxString GetStartValue() { return startValue; }
567
568 private:
569 wxGrid *m_grid;
570
571 // TRUE for controls placed over cells,
572 // FALSE for a control on a grid control panel
573 bool m_isCellControl;
574
575 wxString startValue;
576
577 void OnKeyDown( wxKeyEvent& );
578
579 DECLARE_DYNAMIC_CLASS( wxGridTextCtrl )
580 DECLARE_EVENT_TABLE()
581 };
582
583
584 // ----------------------------------------------------------------------------
585 // wxGrid
586 // ----------------------------------------------------------------------------
587
588 class WXDLLEXPORT wxGrid : public wxScrolledWindow
589 {
590 public:
591 wxGrid()
592 {
593 m_table = (wxGridTableBase *) NULL;
594 m_gridWin = (wxGridWindow *) NULL;
595 m_rowLabelWin = (wxGridRowLabelWindow *) NULL;
596 m_colLabelWin = (wxGridColLabelWindow *) NULL;
597 m_cornerLabelWin = (wxGridCornerLabelWindow *) NULL;
598 m_cellEditCtrl = (wxWindow *) NULL;
599 }
600
601 wxGrid( wxWindow *parent,
602 wxWindowID id,
603 const wxPoint& pos = wxDefaultPosition,
604 const wxSize& size = wxDefaultSize,
605 long style = 0,
606 const wxString& name = wxPanelNameStr );
607
608 ~wxGrid();
609
610 bool CreateGrid( int numRows, int numCols );
611
612
613 // ------ grid dimensions
614 //
615 int GetNumberRows() { return m_numRows; }
616 int GetNumberCols() { return m_numCols; }
617
618
619 // ------ display update functions
620 //
621 void CalcRowLabelsExposed( wxRegion& reg );
622
623 void CalcColLabelsExposed( wxRegion& reg );
624 void CalcCellsExposed( wxRegion& reg );
625
626
627 // ------ event handlers
628 //
629 void ProcessRowLabelMouseEvent( wxMouseEvent& event );
630 void ProcessColLabelMouseEvent( wxMouseEvent& event );
631 void ProcessCornerLabelMouseEvent( wxMouseEvent& event );
632 void ProcessGridCellMouseEvent( wxMouseEvent& event );
633 bool ProcessTableMessage( wxGridTableMessage& );
634
635 void DoEndDragResizeRow();
636 void DoEndDragResizeCol();
637
638 wxGridTableBase * GetTable() const { return m_table; }
639 bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE );
640
641 void ClearGrid();
642 bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
643 bool AppendRows( int numRows = 1, bool updateLabels=TRUE );
644 bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
645 bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
646 bool AppendCols( int numCols = 1, bool updateLabels=TRUE );
647 bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
648
649 void DrawGridCellArea( wxDC& dc );
650 void DrawCellBorder( wxDC& dc, const wxGridCellCoords& );
651 void DrawAllGridLines( wxDC& dc, const wxRegion & reg );
652 void DrawCell( wxDC& dc, const wxGridCellCoords& );
653 void DrawCellHighlight( wxDC& dc );
654
655 void DrawRowLabels( wxDC& dc );
656 void DrawRowLabel( wxDC& dc, int row );
657
658 void DrawColLabels( wxDC& dc );
659 void DrawColLabel( wxDC& dc, int col );
660
661
662 // ------ Cell text drawing functions
663 //
664 void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
665 int horizontalAlignment = wxLEFT,
666 int verticalAlignment = wxTOP );
667
668 // Split a string containing newline chararcters into an array of
669 // strings and return the number of lines
670 //
671 void StringToLines( const wxString& value, wxArrayString& lines );
672
673 void GetTextBoxSize( wxDC& dc,
674 wxArrayString& lines,
675 long *width, long *height );
676
677
678 // ------
679 // Code that does a lot of grid modification can be enclosed
680 // between BeginBatch() and EndBatch() calls to avoid screen
681 // flicker
682 //
683 void BeginBatch() { m_batchCount++; }
684 void EndBatch() { if ( m_batchCount > 0 ) m_batchCount--; }
685 int GetBatchCount() { return m_batchCount; }
686
687
688 // ------ edit control functions
689 //
690 bool IsEditable() { return m_editable; }
691 void EnableEditing( bool edit );
692
693 void EnableCellEditControl( bool enable );
694
695 bool IsCellEditControlEnabled()
696 { return (m_cellEditCtrl && m_cellEditCtrlEnabled); }
697
698 void ShowCellEditControl();
699 void HideCellEditControl();
700 void SetEditControlValue( const wxString& s = wxEmptyString );
701 void SaveEditControlValue();
702
703
704 // ------ grid location functions
705 // Note that all of these functions work with the logical coordinates of
706 // grid cells and labels so you will need to convert from device
707 // coordinates for mouse events etc.
708 //
709 void XYToCell( int x, int y, wxGridCellCoords& );
710 int YToRow( int y );
711 int XToCol( int x );
712
713 int YToEdgeOfRow( int y );
714 int XToEdgeOfCol( int x );
715
716 wxRect CellToRect( int row, int col );
717 wxRect CellToRect( const wxGridCellCoords& coords )
718 { return CellToRect( coords.GetRow(), coords.GetCol() ); }
719
720 int GetGridCursorRow() { return m_currentCellCoords.GetRow(); }
721 int GetGridCursorCol() { return m_currentCellCoords.GetCol(); }
722
723 // check to see if a cell is either wholly visible (the default arg) or
724 // at least partially visible in the grid window
725 //
726 bool IsVisible( int row, int col, bool wholeCellVisible = TRUE );
727 bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE )
728 { return IsVisible( coords.GetRow(), coords.GetCol(), wholeCellVisible ); }
729 void MakeCellVisible( int row, int col );
730 void MakeCellVisible( const wxGridCellCoords& coords )
731 { MakeCellVisible( coords.GetRow(), coords.GetCol() ); }
732
733
734 // ------ grid cursor movement functions
735 //
736 void SetGridCursor( int row, int col )
737 { SetCurrentCell( wxGridCellCoords(row, col) ); }
738
739 bool MoveCursorUp();
740 bool MoveCursorDown();
741 bool MoveCursorLeft();
742 bool MoveCursorRight();
743 bool MovePageDown();
744 bool MovePageUp();
745 bool MoveCursorUpBlock();
746 bool MoveCursorDownBlock();
747 bool MoveCursorLeftBlock();
748 bool MoveCursorRightBlock();
749
750
751 // ------ label and gridline formatting
752 //
753 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; }
754 int GetRowLabelSize() { return m_rowLabelWidth; }
755 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; }
756 int GetColLabelSize() { return m_colLabelHeight; }
757 wxColour GetLabelBackgroundColour() { return m_labelBackgroundColour; }
758 wxColour GetLabelTextColour() { return m_labelTextColour; }
759 wxFont GetLabelFont() { return m_labelFont; }
760 void GetRowLabelAlignment( int *horiz, int *vert );
761 void GetColLabelAlignment( int *horiz, int *vert );
762 wxString GetRowLabelValue( int row );
763 wxString GetColLabelValue( int col );
764 wxColour GetGridLineColour() { return m_gridLineColour; }
765
766 void SetRowLabelSize( int width );
767 void SetColLabelSize( int height );
768 void SetLabelBackgroundColour( const wxColour& );
769 void SetLabelTextColour( const wxColour& );
770 void SetLabelFont( const wxFont& );
771 void SetRowLabelAlignment( int horiz, int vert );
772 void SetColLabelAlignment( int horiz, int vert );
773 void SetRowLabelValue( int row, const wxString& );
774 void SetColLabelValue( int col, const wxString& );
775 void SetGridLineColour( const wxColour& );
776
777 // this sets the specified attribute for all cells in this row/col
778 void SetRowAttr(int row, wxGridCellAttr *attr);
779 void SetColAttr(int col, wxGridCellAttr *attr);
780
781 void EnableGridLines( bool enable = TRUE );
782 bool GridLinesEnabled() { return m_gridLinesEnabled; }
783
784 // ------ row and col formatting
785 //
786 int GetDefaultRowSize();
787 int GetRowSize( int row );
788 int GetDefaultColSize();
789 int GetColSize( int col );
790 wxColour GetDefaultCellBackgroundColour();
791 wxColour GetCellBackgroundColour( int row, int col );
792 wxColour GetDefaultCellTextColour();
793 wxColour GetCellTextColour( int row, int col );
794 wxFont GetDefaultCellFont();
795 wxFont GetCellFont( int row, int col );
796 void GetDefaultCellAlignment( int *horiz, int *vert );
797 void GetCellAlignment( int row, int col, int *horiz, int *vert );
798
799 void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE );
800 void SetRowSize( int row, int height );
801 void SetDefaultColSize( int width, bool resizeExistingCols = FALSE );
802
803 void SetColSize( int col, int width );
804 void SetDefaultCellBackgroundColour( const wxColour& );
805 void SetCellBackgroundColour( int row, int col, const wxColour& );
806 void SetDefaultCellTextColour( const wxColour& );
807
808 void SetCellTextColour( int row, int col, const wxColour& );
809 void SetDefaultCellFont( const wxFont& );
810 void SetCellFont( int row, int col, const wxFont& );
811 void SetDefaultCellAlignment( int horiz, int vert );
812 void SetCellAlignment( int row, int col, int horiz, int vert );
813
814 // takes ownership of the pointer
815 void SetDefaultRenderer(wxGridCellRenderer *renderer);
816 void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
817 wxGridCellRenderer *GetDefaultRenderer() const;
818 wxGridCellRenderer* GetCellRenderer(int row, int col);
819
820
821 // ------ cell value accessors
822 //
823 wxString GetCellValue( int row, int col )
824 {
825 if ( m_table )
826 {
827 return m_table->GetValue( row, col );
828 }
829 else
830 {
831 return wxEmptyString;
832 }
833 }
834
835 wxString GetCellValue( const wxGridCellCoords& coords )
836 { return GetCellValue( coords.GetRow(), coords.GetCol() ); }
837
838 void SetCellValue( int row, int col, const wxString& s );
839 void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
840 { SetCellValue( coords.GetRow(), coords.GetCol(), s ); }
841
842
843
844 // ------ selections of blocks of cells
845 //
846 void SelectRow( int row, bool addToSelected = FALSE );
847 void SelectCol( int col, bool addToSelected = FALSE );
848
849 void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol );
850
851 void SelectBlock( const wxGridCellCoords& topLeft,
852 const wxGridCellCoords& bottomRight )
853 { SelectBlock( topLeft.GetRow(), topLeft.GetCol(),
854 bottomRight.GetRow(), bottomRight.GetCol() ); }
855
856 void SelectAll();
857
858 bool IsSelection()
859 { return ( m_selectedTopLeft != wxGridNoCellCoords &&
860 m_selectedBottomRight != wxGridNoCellCoords );
861 }
862
863 void ClearSelection();
864
865 bool IsInSelection( int row, int col )
866 { return ( IsSelection() &&
867 row >= m_selectedTopLeft.GetRow() &&
868 col >= m_selectedTopLeft.GetCol() &&
869 row <= m_selectedBottomRight.GetRow() &&
870 col <= m_selectedBottomRight.GetCol() );
871 }
872
873 bool IsInSelection( const wxGridCellCoords& coords )
874 { return IsInSelection( coords.GetRow(), coords.GetCol() ); }
875
876 void GetSelection( int* topRow, int* leftCol, int* bottomRow, int* rightCol )
877 {
878 // these will all be -1 if there is no selected block
879 //
880 *topRow = m_selectedTopLeft.GetRow();
881 *leftCol = m_selectedTopLeft.GetCol();
882 *bottomRow = m_selectedBottomRight.GetRow();
883 *rightCol = m_selectedBottomRight.GetCol();
884 }
885
886
887 // This function returns the rectangle that encloses the block of cells
888 // limited by TopLeft and BottomRight cell in device coords and clipped
889 // to the client size of the grid window.
890 //
891 wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
892 const wxGridCellCoords & bottomRight );
893
894 // This function returns the rectangle that encloses the selected cells
895 // in device coords and clipped to the client size of the grid window.
896 //
897 wxRect SelectionToDeviceRect()
898 {
899 return BlockToDeviceRect( m_selectedTopLeft,
900 m_selectedBottomRight );
901 }
902
903 // Access or update the selection fore/back colours
904 wxColour GetSelectionBackground() const
905 { return m_selectionBackground; }
906 wxColour GetSelectionForeground() const
907 { return m_selectionForeground; }
908
909 void SetSelectionBackground(const wxColour& c) { m_selectionBackground = c; }
910 void SetSelectionForeground(const wxColour& c) { m_selectionForeground = c; }
911
912
913
914 // ------ For compatibility with previous wxGrid only...
915 //
916 // ************************************************
917 // ** Don't use these in new code because they **
918 // ** are liable to disappear in a future **
919 // ** revision **
920 // ************************************************
921 //
922
923 wxGrid( wxWindow *parent,
924 int x = -1, int y = -1, int w = -1, int h = -1,
925 long style = 0,
926 const wxString& name = wxPanelNameStr )
927 : wxScrolledWindow( parent, -1, wxPoint(x,y), wxSize(w,h), style, name )
928 {
929 Create();
930 }
931
932 void SetCellValue( const wxString& val, int row, int col )
933 { SetCellValue( row, col, val ); }
934
935 void UpdateDimensions()
936 { CalcDimensions(); }
937
938 int GetRows() { return GetNumberRows(); }
939 int GetCols() { return GetNumberCols(); }
940 int GetCursorRow() { return GetGridCursorRow(); }
941 int GetCursorColumn() { return GetGridCursorCol(); }
942
943 int GetScrollPosX() { return 0; }
944 int GetScrollPosY() { return 0; }
945
946 void SetScrollX( int x ) { }
947 void SetScrollY( int y ) { }
948
949 void SetColumnWidth( int col, int width )
950 { SetColSize( col, width ); }
951
952 int GetColumnWidth( int col )
953 { return GetColSize( col ); }
954
955 void SetRowHeight( int row, int height )
956 { SetRowSize( row, height ); }
957
958 int GetRowHeight( int row )
959 { return GetRowSize( row ); }
960
961 int GetViewHeight() // returned num whole rows visible
962 { return 0; }
963
964 int GetViewWidth() // returned num whole cols visible
965 { return 0; }
966
967 void SetLabelSize( int orientation, int sz )
968 {
969 if ( orientation == wxHORIZONTAL )
970 SetColLabelSize( sz );
971 else
972 SetRowLabelSize( sz );
973 }
974
975 int GetLabelSize( int orientation )
976 {
977 if ( orientation == wxHORIZONTAL )
978 return GetColLabelSize();
979 else
980 return GetRowLabelSize();
981 }
982
983 void SetLabelAlignment( int orientation, int align )
984 {
985 if ( orientation == wxHORIZONTAL )
986 SetColLabelAlignment( align, -1 );
987 else
988 SetRowLabelAlignment( align, -1 );
989 }
990
991 int GetLabelAlignment( int orientation, int WXUNUSED(align) )
992 {
993 int h, v;
994 if ( orientation == wxHORIZONTAL )
995 {
996 GetColLabelAlignment( &h, &v );
997 return h;
998 }
999 else
1000 {
1001 GetRowLabelAlignment( &h, &v );
1002 return h;
1003 }
1004 }
1005
1006 void SetLabelValue( int orientation, const wxString& val, int pos )
1007 {
1008 if ( orientation == wxHORIZONTAL )
1009 SetColLabelValue( pos, val );
1010 else
1011 SetRowLabelValue( pos, val );
1012 }
1013
1014 wxString GetLabelValue( int orientation, int pos)
1015 {
1016 if ( orientation == wxHORIZONTAL )
1017 return GetColLabelValue( pos );
1018 else
1019 return GetRowLabelValue( pos );
1020 }
1021
1022 wxFont GetCellTextFont() const
1023 { return m_defaultCellAttr->GetFont(); }
1024
1025 wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const
1026 { return m_defaultCellAttr->GetFont(); }
1027
1028 void SetCellTextFont(const wxFont& fnt)
1029 { SetDefaultCellFont( fnt ); }
1030
1031 void SetCellTextFont(const wxFont& fnt, int row, int col)
1032 { SetCellFont( row, col, fnt ); }
1033
1034 void SetCellTextColour(const wxColour& val, int row, int col)
1035 { SetCellTextColour( row, col, val ); }
1036
1037 void SetCellTextColour(const wxColour& col)
1038 { SetDefaultCellTextColour( col ); }
1039
1040 void SetCellBackgroundColour(const wxColour& col)
1041 { SetDefaultCellBackgroundColour( col ); }
1042
1043 void SetCellBackgroundColour(const wxColour& colour, int row, int col)
1044 { SetCellBackgroundColour( row, col, colour ); }
1045
1046 bool GetEditable() { return IsEditable(); }
1047 void SetEditable( bool edit = TRUE ) { EnableEditing( edit ); }
1048 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
1049
1050 void SetEditInPlace(bool edit = TRUE) { }
1051
1052 void SetCellAlignment( int align, int row, int col)
1053 { SetCellAlignment(row, col, align, wxCENTER); }
1054 void SetCellAlignment( int WXUNUSED(align) ) {}
1055 void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col))
1056 { }
1057 void SetDividerPen(const wxPen& WXUNUSED(pen)) { }
1058 wxPen& GetDividerPen() const { return wxNullPen; }
1059 void OnActivate(bool WXUNUSED(active)) {}
1060
1061 // ******** End of compatibility functions **********
1062
1063
1064
1065 // ------ control IDs
1066 enum { wxGRID_CELLCTRL = 2000,
1067 wxGRID_TOPCTRL };
1068
1069 // ------ control types
1070 enum { wxGRID_TEXTCTRL = 2100,
1071 wxGRID_CHECKBOX,
1072 wxGRID_CHOICE,
1073 wxGRID_COMBOBOX };
1074
1075 protected:
1076 bool m_created;
1077 bool m_displayed;
1078
1079 wxGridWindow *m_gridWin;
1080 wxGridRowLabelWindow *m_rowLabelWin;
1081 wxGridColLabelWindow *m_colLabelWin;
1082 wxGridCornerLabelWindow *m_cornerLabelWin;
1083
1084 wxGridTableBase *m_table;
1085 bool m_ownTable;
1086
1087 int m_left;
1088 int m_top;
1089 int m_right;
1090 int m_bottom;
1091
1092 int m_numRows;
1093 int m_numCols;
1094
1095 wxGridCellCoords m_currentCellCoords;
1096
1097 wxGridCellCoords m_selectedTopLeft;
1098 wxGridCellCoords m_selectedBottomRight;
1099 wxColour m_selectionBackground;
1100 wxColour m_selectionForeground;
1101
1102 int m_defaultRowHeight;
1103 wxArrayInt m_rowHeights;
1104 wxArrayInt m_rowBottoms;
1105
1106 int m_defaultColWidth;
1107 wxArrayInt m_colWidths;
1108 wxArrayInt m_colRights;
1109 int m_rowLabelWidth;
1110 int m_colLabelHeight;
1111
1112 wxColour m_labelBackgroundColour;
1113 wxColour m_labelTextColour;
1114 wxFont m_labelFont;
1115
1116 int m_rowLabelHorizAlign;
1117 int m_rowLabelVertAlign;
1118 int m_colLabelHorizAlign;
1119 int m_colLabelVertAlign;
1120
1121 bool m_defaultRowLabelValues;
1122 bool m_defaultColLabelValues;
1123
1124 wxColour m_gridLineColour;
1125 bool m_gridLinesEnabled;
1126
1127
1128 // do we have some place to store attributes in?
1129 bool CanHaveAttributes();
1130
1131 // returns the attribute we may modify in place: a new one if this cell
1132 // doesn't have any yet or the existing one if it does
1133 //
1134 // DecRef() must be called on the returned pointer, as usual
1135 wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
1136
1137 // cell attribute cache (currently we only cache 1, may be will do
1138 // more/better later)
1139 struct CachedAttr
1140 {
1141 int row, col;
1142 wxGridCellAttr *attr;
1143 } m_attrCache;
1144
1145 // invalidates the attribute cache
1146 void ClearAttrCache();
1147
1148 // adds an attribute to cache
1149 void CacheAttr(int row, int col, wxGridCellAttr *attr) const;
1150
1151 // looks for an attr in cache, returns TRUE if found
1152 bool LookupAttr(int row, int col, wxGridCellAttr **attr) const;
1153
1154 // looks for the attr in cache, if not found asks the table and caches the
1155 // result
1156 wxGridCellAttr *GetCellAttr(int row, int col) const;
1157
1158 // the default cell attr object for cells that don't have their own
1159 wxGridCellAttr* m_defaultCellAttr;
1160
1161
1162 wxGridCellCoordsArray m_cellsExposed;
1163 wxArrayInt m_rowsExposed;
1164 wxArrayInt m_colsExposed;
1165 wxArrayInt m_rowLabelsExposed;
1166 wxArrayInt m_colLabelsExposed;
1167
1168 bool m_inOnKeyDown;
1169 int m_batchCount;
1170
1171 enum CursorMode
1172 {
1173 WXGRID_CURSOR_SELECT_CELL,
1174 WXGRID_CURSOR_RESIZE_ROW,
1175 WXGRID_CURSOR_RESIZE_COL,
1176 WXGRID_CURSOR_SELECT_ROW,
1177 WXGRID_CURSOR_SELECT_COL
1178 };
1179
1180 // this method not only sets m_cursorMode but also sets the correct cursor
1181 // for the given mode and, if captureMouse is not FALSE releases the mouse
1182 // if it was captured and captures it if it must be captured
1183 //
1184 // for this to work, you should always use it and not set m_cursorMode
1185 // directly!
1186 void ChangeCursorMode(CursorMode mode,
1187 wxWindow *win = (wxWindow *)NULL,
1188 bool captureMouse = TRUE);
1189
1190 wxWindow *m_winCapture; // the window which captured the mouse
1191 CursorMode m_cursorMode;
1192
1193 int m_dragLastPos;
1194 int m_dragRowOrCol;
1195 bool m_isDragging;
1196 wxPoint m_startDragPos;
1197
1198 wxTimer* m_editTimer;
1199 bool m_waitForSlowClick;
1200
1201 wxGridCellCoords m_selectionStart;
1202
1203 wxCursor m_rowResizeCursor;
1204 wxCursor m_colResizeCursor;
1205
1206 bool m_editable; // applies to whole grid
1207 int m_editCtrlType; // for current cell
1208 wxWindow* m_cellEditCtrl;
1209 bool m_cellEditCtrlEnabled;
1210
1211
1212 void Create();
1213 void Init();
1214 void CalcDimensions();
1215 void CalcWindowSizes();
1216 bool Redimension( wxGridTableMessage& );
1217
1218
1219 bool SendEvent( const wxEventType,
1220 int row, int col,
1221 wxMouseEvent& );
1222
1223 bool SendEvent( const wxEventType,
1224 int row, int col );
1225
1226
1227 void OnPaint( wxPaintEvent& );
1228 void OnSize( wxSizeEvent& );
1229 void OnKeyDown( wxKeyEvent& );
1230 void OnEraseBackground( wxEraseEvent& );
1231 void OnEditTimer( wxTimerEvent& );
1232
1233
1234 void SetCurrentCell( const wxGridCellCoords& coords );
1235 void SetCurrentCell( int row, int col )
1236 { SetCurrentCell( wxGridCellCoords(row, col) ); }
1237
1238
1239 // ------ functions to get/send data (see also public functions)
1240 //
1241 bool GetModelValues();
1242 bool SetModelValues();
1243
1244
1245 DECLARE_DYNAMIC_CLASS( wxGrid )
1246 DECLARE_EVENT_TABLE()
1247 };
1248
1249
1250
1251
1252
1253 //
1254 // ------ Grid event class and event types
1255 //
1256
1257 class WXDLLEXPORT wxGridEvent : public wxNotifyEvent
1258 {
1259 public:
1260 wxGridEvent()
1261 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
1262 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1263 {
1264 }
1265
1266 wxGridEvent(int id, wxEventType type, wxObject* obj,
1267 int row=-1, int col=-1, int x=-1, int y=-1,
1268 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1269
1270 virtual int GetRow() { return m_row; }
1271 virtual int GetCol() { return m_col; }
1272 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
1273 bool ControlDown() { return m_control; }
1274 bool MetaDown() { return m_meta; }
1275 bool ShiftDown() { return m_shift; }
1276 bool AltDown() { return m_alt; }
1277
1278 protected:
1279 int m_row;
1280 int m_col;
1281 int m_x;
1282 int m_y;
1283 bool m_control;
1284 bool m_meta;
1285 bool m_shift;
1286 bool m_alt;
1287
1288 DECLARE_DYNAMIC_CLASS(wxGridEvent)
1289 };
1290
1291
1292 class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent
1293 {
1294 public:
1295 wxGridSizeEvent()
1296 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1297 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1298 {
1299 }
1300
1301 wxGridSizeEvent(int id, wxEventType type, wxObject* obj,
1302 int rowOrCol=-1, int x=-1, int y=-1,
1303 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1304
1305 int GetRowOrCol() { return m_rowOrCol; }
1306 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
1307 bool ControlDown() { return m_control; }
1308 bool MetaDown() { return m_meta; }
1309 bool ShiftDown() { return m_shift; }
1310 bool AltDown() { return m_alt; }
1311
1312 protected:
1313 int m_rowOrCol;
1314 int m_x;
1315 int m_y;
1316 bool m_control;
1317 bool m_meta;
1318 bool m_shift;
1319 bool m_alt;
1320
1321 DECLARE_DYNAMIC_CLASS(wxGridSizeEvent)
1322 };
1323
1324
1325 class WXDLLEXPORT wxGridRangeSelectEvent : public wxNotifyEvent
1326 {
1327 public:
1328 wxGridRangeSelectEvent()
1329 : wxNotifyEvent()
1330 {
1331 m_topLeft = wxGridNoCellCoords;
1332 m_bottomRight = wxGridNoCellCoords;
1333 m_control = FALSE;
1334 m_meta = FALSE;
1335 m_shift = FALSE;
1336 m_alt = FALSE;
1337 }
1338
1339 wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj,
1340 const wxGridCellCoords& topLeft,
1341 const wxGridCellCoords& bottomRight,
1342 bool control=FALSE, bool shift=FALSE,
1343 bool alt=FALSE, bool meta=FALSE);
1344
1345 wxGridCellCoords GetTopLeftCoords() { return m_topLeft; }
1346 wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; }
1347 int GetTopRow() { return m_topLeft.GetRow(); }
1348 int GetBottomRow() { return m_bottomRight.GetRow(); }
1349 int GetLeftCol() { return m_topLeft.GetCol(); }
1350 int GetRightCol() { return m_bottomRight.GetCol(); }
1351 bool ControlDown() { return m_control; }
1352 bool MetaDown() { return m_meta; }
1353 bool ShiftDown() { return m_shift; }
1354 bool AltDown() { return m_alt; }
1355
1356 protected:
1357 wxGridCellCoords m_topLeft;
1358 wxGridCellCoords m_bottomRight;
1359 bool m_control;
1360 bool m_meta;
1361 bool m_shift;
1362 bool m_alt;
1363
1364 DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent)
1365 };
1366
1367
1368 const wxEventType EVT_GRID_CELL_LEFT_CLICK = wxEVT_FIRST + 1580;
1369 const wxEventType EVT_GRID_CELL_RIGHT_CLICK = wxEVT_FIRST + 1581;
1370 const wxEventType EVT_GRID_CELL_LEFT_DCLICK = wxEVT_FIRST + 1582;
1371 const wxEventType EVT_GRID_CELL_RIGHT_DCLICK = wxEVT_FIRST + 1583;
1372 const wxEventType EVT_GRID_LABEL_LEFT_CLICK = wxEVT_FIRST + 1584;
1373 const wxEventType EVT_GRID_LABEL_RIGHT_CLICK = wxEVT_FIRST + 1585;
1374 const wxEventType EVT_GRID_LABEL_LEFT_DCLICK = wxEVT_FIRST + 1586;
1375 const wxEventType EVT_GRID_LABEL_RIGHT_DCLICK = wxEVT_FIRST + 1587;
1376 const wxEventType EVT_GRID_ROW_SIZE = wxEVT_FIRST + 1588;
1377 const wxEventType EVT_GRID_COL_SIZE = wxEVT_FIRST + 1589;
1378 const wxEventType EVT_GRID_RANGE_SELECT = wxEVT_FIRST + 1590;
1379 const wxEventType EVT_GRID_CELL_CHANGE = wxEVT_FIRST + 1591;
1380 const wxEventType EVT_GRID_SELECT_CELL = wxEVT_FIRST + 1592;
1381
1382
1383 typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&);
1384 typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&);
1385 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&);
1386
1387 #define EVT_GRID_CELL_LEFT_CLICK(fn) { EVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1388 #define EVT_GRID_CELL_RIGHT_CLICK(fn) { EVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1389 #define EVT_GRID_CELL_LEFT_DCLICK(fn) { EVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1390 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) { EVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1391 #define EVT_GRID_LABEL_LEFT_CLICK(fn) { EVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1392 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) { EVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1393 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) { EVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1394 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) { EVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1395 #define EVT_GRID_ROW_SIZE(fn) { EVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1396 #define EVT_GRID_COL_SIZE(fn) { EVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1397 #define EVT_GRID_RANGE_SELECT(fn) { EVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL },
1398 #define EVT_GRID_CELL_CHANGE(fn) { EVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1399 #define EVT_GRID_SELECT_CELL(fn) { EVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1400
1401
1402 #if 0 // TODO: implement these ? others ?
1403
1404 const wxEventType EVT_GRID_CREATE_CELL = wxEVT_FIRST + 1576;
1405 const wxEventType EVT_GRID_CHANGE_LABELS = wxEVT_FIRST + 1577;
1406 const wxEventType EVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578;
1407
1408 #define EVT_GRID_CREATE_CELL(fn) { EVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1409 #define EVT_GRID_CHANGE_LABELS(fn) { EVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1410 #define EVT_GRID_CHANGE_SEL_LABEL(fn) { EVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1411
1412 #endif
1413
1414 #endif // #ifndef __WXGRID_H__
1415
1416 #endif // ifndef wxUSE_NEW_GRID
1417