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