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