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