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