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