]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: grid.h | |
afe0e400 | 3 | // Purpose: interface of wxGrid and related classes |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
8b9ef005 BP |
9 | /** |
10 | @class wxGridCellRenderer | |
11 | ||
12 | This class is responsible for actually drawing the cell in the grid. You | |
13 | may pass it to the wxGridCellAttr (below) to change the format of one given | |
14 | cell or to wxGrid::SetDefaultRenderer() to change the view of all cells. | |
15 | This is an abstract class, and you will normally use one of the predefined | |
16 | derived classes or derive your own class from it. | |
17 | ||
18 | @library{wxadv} | |
19 | @category{grid} | |
20 | ||
db890987 VZ |
21 | @see wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer, |
22 | wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, | |
23 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
24 | wxGridCellStringRenderer | |
8b9ef005 | 25 | */ |
42dd5e3b | 26 | class wxGridCellRenderer : public wxClientDataContainer, public wxRefCounter |
8b9ef005 BP |
27 | { |
28 | public: | |
42dd5e3b RD |
29 | wxGridCellRenderer(); |
30 | ||
8b9ef005 BP |
31 | /** |
32 | This function must be implemented in derived classes to return a copy | |
33 | of itself. | |
34 | */ | |
35 | virtual wxGridCellRenderer* Clone() const = 0; | |
36 | ||
37 | /** | |
38 | Draw the given cell on the provided DC inside the given rectangle using | |
39 | the style specified by the attribute and the default or selected state | |
40 | corresponding to the isSelected value. | |
41 | ||
42 | This pure virtual function has a default implementation which will | |
43 | prepare the DC using the given attribute: it will draw the rectangle | |
44 | with the background colour from attr and set the text colour and font. | |
45 | */ | |
46 | virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
47 | const wxRect& rect, int row, int col, | |
48 | bool isSelected) = 0; | |
49 | ||
50 | /** | |
51 | Get the preferred size of the cell for its contents. | |
52 | */ | |
53 | virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
54 | int row, int col) = 0; | |
42dd5e3b RD |
55 | |
56 | protected: | |
57 | /** | |
58 | The destructor is private because only DecRef() can delete us. | |
59 | */ | |
60 | virtual ~wxGridCellRenderer(); | |
8b9ef005 BP |
61 | }; |
62 | ||
db890987 VZ |
63 | /** |
64 | @class wxGridCellAutoWrapStringRenderer | |
65 | ||
66 | This class may be used to format string data in a cell. The too | |
67 | long lines are wrapped to be shown entirely at word boundaries. | |
68 | ||
69 | @library{wxadv} | |
70 | @category{grid} | |
71 | ||
72 | @see wxGridCellRenderer, wxGridCellBoolRenderer, | |
73 | wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, | |
74 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
75 | wxGridCellStringRenderer | |
76 | */ | |
77 | ||
78 | class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer | |
79 | { | |
80 | public: | |
81 | /** | |
82 | Default constructor. | |
83 | */ | |
84 | wxGridCellAutoWrapStringRenderer(); | |
85 | }; | |
86 | ||
87 | ||
8b9ef005 BP |
88 | /** |
89 | @class wxGridCellBoolRenderer | |
90 | ||
91 | This class may be used to format boolean data in a cell. | |
92 | ||
93 | @library{wxadv} | |
94 | @category{grid} | |
95 | ||
db890987 VZ |
96 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, |
97 | wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, | |
98 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
8b9ef005 BP |
99 | wxGridCellStringRenderer |
100 | */ | |
101 | class wxGridCellBoolRenderer : public wxGridCellRenderer | |
102 | { | |
103 | public: | |
104 | /** | |
105 | Default constructor. | |
106 | */ | |
107 | wxGridCellBoolRenderer(); | |
108 | }; | |
109 | ||
db890987 VZ |
110 | /** |
111 | @class wxGridCellDateTimeRenderer | |
112 | ||
113 | This class may be used to format a date/time data in a cell. | |
114 | The class wxDateTime is used internally to display the local date/time | |
115 | or to parse the string date entered in the cell thanks to the defined format. | |
116 | ||
117 | @library{wxadv} | |
118 | @category{grid} | |
119 | ||
120 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, | |
121 | wxGridCellBoolRenderer, wxGridCellEnumRenderer, | |
122 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
123 | wxGridCellStringRenderer | |
124 | */ | |
125 | class wxGridCellDateTimeRenderer : public wxGridCellStringRenderer | |
126 | { | |
127 | public: | |
128 | /** | |
129 | Date/time renderer constructor. | |
130 | ||
131 | @param outformat | |
132 | strptime()-like format string used the parse the output date/time. | |
133 | @param informat | |
134 | strptime()-like format string used to parse the string entered in the cell. | |
135 | */ | |
136 | wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat, | |
137 | const wxString& informat = wxDefaultDateTimeFormat); | |
138 | ||
139 | ||
140 | /** | |
141 | Sets the strptime()-like format string which will be used to parse | |
142 | the date/time. | |
143 | ||
144 | @param params | |
145 | strptime()-like format string used to parse the date/time. | |
146 | */ | |
147 | virtual void SetParameters(const wxString& params); | |
148 | }; | |
149 | ||
150 | /** | |
151 | @class wxGridCellEnumRenderer | |
152 | ||
153 | This class may be used to render in a cell a number as a textual | |
154 | equivalent. | |
155 | ||
156 | The corresponding text strings are specified as comma-separated items in | |
157 | the string passed to this renderer ctor or SetParameters() method. For | |
158 | example, if this string is @c "John,Fred,Bob" the cell will be rendered as | |
159 | "John", "Fred" or "Bob" if its contents is 0, 1 or 2 respectively. | |
160 | ||
161 | @library{wxadv} | |
162 | @category{grid} | |
163 | ||
164 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, | |
165 | wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, | |
166 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
167 | wxGridCellStringRenderer | |
168 | */ | |
169 | class wxGridCellEnumRenderer : public wxGridCellStringRenderer | |
170 | { | |
171 | public: | |
172 | /** | |
173 | Enum renderer ctor. | |
174 | ||
175 | @param choices | |
176 | Comma separated string parameters "item1[,item2[...,itemN]]". | |
177 | */ | |
178 | wxGridCellEnumRenderer( const wxString& choices = wxEmptyString ); | |
179 | ||
180 | /** | |
181 | Sets the comma separated string content of the enum. | |
182 | ||
183 | @param params | |
184 | Comma separated string parameters "item1[,item2[...,itemN]]". | |
185 | */ | |
186 | virtual void SetParameters(const wxString& params); | |
187 | }; | |
188 | ||
1d8d3cc5 VZ |
189 | /** |
190 | Specifier used to format the data to string for the numbers handled by | |
191 | wxGridCellFloatRenderer and wxGridCellFloatEditor. | |
192 | ||
193 | @since 2.9.3 | |
194 | */ | |
195 | enum wxGridCellFloatFormat | |
196 | { | |
197 | /// Decimal floating point (%f). | |
198 | wxGRID_FLOAT_FORMAT_FIXED = 0x0010, | |
199 | ||
200 | /// Scientific notation (mantise/exponent) using e character (%e). | |
201 | wxGRID_FLOAT_FORMAT_SCIENTIFIC = 0x0020, | |
202 | ||
203 | /// Use the shorter of %e or %f (%g). | |
204 | wxGRID_FLOAT_FORMAT_COMPACT = 0x0040, | |
205 | ||
206 | /// To use in combination with one of the above formats for the upper | |
207 | /// case version (%F/%E/%G) | |
208 | wxGRID_FLOAT_FORMAT_UPPER = 0x0080, | |
209 | ||
210 | /// The format used by default (wxGRID_FLOAT_FORMAT_FIXED). | |
211 | wxGRID_FLOAT_FORMAT_DEFAULT = wxGRID_FLOAT_FORMAT_FIXED | |
212 | }; | |
213 | ||
23324ae1 FM |
214 | /** |
215 | @class wxGridCellFloatRenderer | |
7c913512 | 216 | |
23324ae1 | 217 | This class may be used to format floating point data in a cell. |
7c913512 | 218 | |
23324ae1 | 219 | @library{wxadv} |
42b5841f | 220 | @category{grid} |
7c913512 | 221 | |
db890987 VZ |
222 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, |
223 | wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, | |
224 | wxGridCellEnumRenderer, wxGridCellNumberRenderer, | |
afe0e400 | 225 | wxGridCellStringRenderer |
23324ae1 FM |
226 | */ |
227 | class wxGridCellFloatRenderer : public wxGridCellStringRenderer | |
228 | { | |
229 | public: | |
230 | /** | |
db890987 VZ |
231 | Float cell renderer ctor. |
232 | ||
7c913512 | 233 | @param width |
4cc4bfaf | 234 | Minimum number of characters to be shown. |
7c913512 | 235 | @param precision |
4cc4bfaf | 236 | Number of digits after the decimal dot. |
1d8d3cc5 VZ |
237 | @param format |
238 | The format used to display the string, must be a combination of | |
7920b94b | 239 | ::wxGridCellFloatFormat enum elements. This parameter is only |
1d8d3cc5 | 240 | available since wxWidgets 2.9.3. |
23324ae1 | 241 | */ |
1d8d3cc5 VZ |
242 | wxGridCellFloatRenderer(int width = -1, int precision = -1, |
243 | int format = wxGRID_FLOAT_FORMAT_DEFAULT); | |
244 | ||
245 | /** | |
246 | Returns the specifier used to format the data to string. | |
247 | ||
7920b94b | 248 | The returned value is a combination of ::wxGridCellFloatFormat elements. |
1d8d3cc5 VZ |
249 | |
250 | @since 2.9.3 | |
251 | */ | |
252 | int GetFormat() const; | |
23324ae1 FM |
253 | |
254 | /** | |
42b5841f | 255 | Returns the precision. |
23324ae1 | 256 | */ |
328f5751 | 257 | int GetPrecision() const; |
23324ae1 FM |
258 | |
259 | /** | |
42b5841f | 260 | Returns the width. |
23324ae1 | 261 | */ |
328f5751 | 262 | int GetWidth() const; |
23324ae1 FM |
263 | |
264 | /** | |
1d8d3cc5 VZ |
265 | Set the format to use for display the number. |
266 | ||
267 | @param format | |
7920b94b | 268 | Must be a combination of ::wxGridCellFloatFormat enum elements. |
1d8d3cc5 VZ |
269 | |
270 | @since 2.9.3 | |
271 | */ | |
272 | void SetFormat(int format); | |
273 | ||
274 | /** | |
275 | The parameters string format is "width[,precision[,format]]" where | |
8cddee2d | 276 | @c format should be chosen between f|e|g|E|G (f is used by default) |
23324ae1 | 277 | */ |
adaaa686 | 278 | virtual void SetParameters(const wxString& params); |
23324ae1 FM |
279 | |
280 | /** | |
42b5841f | 281 | Sets the precision. |
23324ae1 FM |
282 | */ |
283 | void SetPrecision(int precision); | |
284 | ||
285 | /** | |
42b5841f | 286 | Sets the width. |
23324ae1 FM |
287 | */ |
288 | void SetWidth(int width); | |
289 | }; | |
290 | ||
23324ae1 | 291 | /** |
8b9ef005 | 292 | @class wxGridCellNumberRenderer |
7c913512 | 293 | |
8b9ef005 | 294 | This class may be used to format integer data in a cell. |
5039f140 | 295 | |
8b9ef005 BP |
296 | @library{wxadv} |
297 | @category{grid} | |
5039f140 | 298 | |
db890987 VZ |
299 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, |
300 | wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, | |
301 | wxGridCellEnumRenderer, wxGridCellFloatRenderer, | |
8b9ef005 BP |
302 | wxGridCellStringRenderer |
303 | */ | |
304 | class wxGridCellNumberRenderer : public wxGridCellStringRenderer | |
305 | { | |
306 | public: | |
307 | /** | |
308 | Default constructor. | |
309 | */ | |
310 | wxGridCellNumberRenderer(); | |
311 | }; | |
5039f140 | 312 | |
8b9ef005 BP |
313 | /** |
314 | @class wxGridCellStringRenderer | |
315 | ||
316 | This class may be used to format string data in a cell; it is the default | |
317 | for string cells. | |
7c913512 | 318 | |
23324ae1 | 319 | @library{wxadv} |
42b5841f | 320 | @category{grid} |
8b9ef005 | 321 | |
db890987 VZ |
322 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, |
323 | wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, | |
324 | wxGridCellEnumRenderer, wxGridCellFloatRenderer, | |
8b9ef005 | 325 | wxGridCellNumberRenderer |
23324ae1 | 326 | */ |
8b9ef005 | 327 | class wxGridCellStringRenderer : public wxGridCellRenderer |
23324ae1 FM |
328 | { |
329 | public: | |
afe0e400 BP |
330 | /** |
331 | Default constructor. | |
8b9ef005 BP |
332 | */ |
333 | wxGridCellStringRenderer(); | |
334 | }; | |
23324ae1 | 335 | |
3c4f71cc | 336 | |
8b9ef005 BP |
337 | /** |
338 | @class wxGridCellEditor | |
23324ae1 | 339 | |
8b9ef005 BP |
340 | This class is responsible for providing and manipulating the in-place edit |
341 | controls for the grid. Instances of wxGridCellEditor (actually, instances | |
342 | of derived classes since it is an abstract class) can be associated with | |
343 | the cell attributes for individual cells, rows, columns, or even for the | |
344 | entire grid. | |
77d2c45c | 345 | |
8b9ef005 BP |
346 | @library{wxadv} |
347 | @category{grid} | |
3c4f71cc | 348 | |
db890987 VZ |
349 | @see wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor, |
350 | wxGridCellChoiceEditor, wxGridCellEnumEditor, | |
351 | wxGridCellFloatEditor, wxGridCellNumberEditor, | |
352 | wxGridCellTextEditor | |
8b9ef005 | 353 | */ |
42dd5e3b | 354 | class wxGridCellEditor : public wxClientDataContainer, public wxRefCounter |
8b9ef005 BP |
355 | { |
356 | public: | |
77d2c45c | 357 | /** |
8b9ef005 BP |
358 | Default constructor. |
359 | */ | |
360 | wxGridCellEditor(); | |
77d2c45c VZ |
361 | |
362 | /** | |
8b9ef005 | 363 | Fetch the value from the table and prepare the edit control to begin |
763163a8 VZ |
364 | editing. |
365 | ||
366 | This function should save the original value of the grid cell at the | |
367 | given @a row and @a col and show the control allowing the user to | |
368 | change it. | |
369 | ||
370 | @see EndEdit() | |
8b9ef005 BP |
371 | */ |
372 | virtual void BeginEdit(int row, int col, wxGrid* grid) = 0; | |
77d2c45c | 373 | |
8b9ef005 BP |
374 | /** |
375 | Create a new object which is the copy of this one. | |
376 | */ | |
377 | virtual wxGridCellEditor* Clone() const = 0; | |
23324ae1 FM |
378 | |
379 | /** | |
8b9ef005 BP |
380 | Creates the actual edit control. |
381 | */ | |
382 | virtual void Create(wxWindow* parent, wxWindowID id, | |
383 | wxEvtHandler* evtHandler) = 0; | |
3c4f71cc | 384 | |
afe0e400 | 385 | /** |
8b9ef005 BP |
386 | Final cleanup. |
387 | */ | |
388 | virtual void Destroy(); | |
23324ae1 | 389 | |
10a4531d | 390 | /** |
763163a8 | 391 | End editing the cell. |
10a4531d | 392 | |
763163a8 VZ |
393 | This function must check if the current value of the editing control is |
394 | valid and different from the original value (available as @a oldval in | |
395 | its string form and possibly saved internally using its real type by | |
78e78812 VZ |
396 | BeginEdit()). If it isn't, it just returns @false, otherwise it must do |
397 | the following: | |
ca25dffb VZ |
398 | - Save the new value internally so that ApplyEdit() could apply it. |
399 | - Fill @a newval (which is never @NULL) with the string | |
78e78812 | 400 | representation of the new value. |
ca25dffb | 401 | - Return @true |
78e78812 VZ |
402 | |
403 | Notice that it must @em not modify the grid as the change could still | |
404 | be vetoed. | |
763163a8 VZ |
405 | |
406 | If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto | |
407 | this change, ApplyEdit() will be called next. | |
8b9ef005 | 408 | */ |
78e78812 VZ |
409 | virtual bool EndEdit(int row, int col, const wxGrid* grid, |
410 | const wxString& oldval, wxString* newval) = 0; | |
10a4531d | 411 | |
763163a8 VZ |
412 | /** |
413 | Effectively save the changes in the grid. | |
414 | ||
415 | This function should save the value of the control in the grid. It is | |
416 | called only after EndEdit() returns @true. | |
417 | */ | |
418 | virtual void ApplyEdit(int row, int col, wxGrid* grid) = 0; | |
419 | ||
afe0e400 | 420 | /** |
8b9ef005 BP |
421 | Some types of controls on some platforms may need some help with the |
422 | Return key. | |
423 | */ | |
424 | virtual void HandleReturn(wxKeyEvent& event); | |
3c4f71cc | 425 | |
afe0e400 | 426 | /** |
8b9ef005 BP |
427 | Returns @true if the edit control has been created. |
428 | */ | |
429 | bool IsCreated(); | |
23324ae1 FM |
430 | |
431 | /** | |
8b9ef005 BP |
432 | Draws the part of the cell not occupied by the control: the base class |
433 | version just fills it with background colour from the attribute. | |
434 | */ | |
42dd5e3b | 435 | virtual void PaintBackground(wxDC& dc, const wxRect& rectCell, wxGridCellAttr& attr); |
23324ae1 FM |
436 | |
437 | /** | |
8b9ef005 BP |
438 | Reset the value in the control back to its starting value. |
439 | */ | |
440 | virtual void Reset() = 0; | |
3c4f71cc | 441 | |
8b9ef005 BP |
442 | /** |
443 | Size and position the edit control. | |
444 | */ | |
445 | virtual void SetSize(const wxRect& rect); | |
23324ae1 FM |
446 | |
447 | /** | |
8b9ef005 BP |
448 | Show or hide the edit control, use the specified attributes to set |
449 | colours/fonts for it. | |
450 | */ | |
451 | virtual void Show(bool show, wxGridCellAttr* attr = NULL); | |
3c4f71cc | 452 | |
8b9ef005 BP |
453 | /** |
454 | If the editor is enabled by clicking on the cell, this method will be | |
455 | called. | |
456 | */ | |
457 | virtual void StartingClick(); | |
23324ae1 FM |
458 | |
459 | /** | |
8b9ef005 BP |
460 | If the editor is enabled by pressing keys on the grid, this will be |
461 | called to let the editor do something about that first key if desired. | |
462 | */ | |
463 | virtual void StartingKey(wxKeyEvent& event); | |
3c4f71cc | 464 | |
42dd5e3b RD |
465 | /** |
466 | Returns the value currently in the editor control. | |
467 | */ | |
468 | virtual wxString GetValue() const = 0; | |
469 | ||
8b9ef005 | 470 | protected: |
23324ae1 FM |
471 | |
472 | /** | |
8b9ef005 BP |
473 | The destructor is private because only DecRef() can delete us. |
474 | */ | |
475 | virtual ~wxGridCellEditor(); | |
476 | }; | |
3c4f71cc | 477 | |
db890987 VZ |
478 | /** |
479 | @class wxGridCellAutoWrapStringEditor | |
480 | ||
481 | Grid cell editor for wrappable string/text data. | |
482 | ||
483 | @library{wxadv} | |
484 | @category{grid} | |
485 | ||
486 | @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
487 | wxGridCellEnumEditor, wxGridCellFloatEditor, | |
488 | wxGridCellNumberEditor, wxGridCellTextEditor | |
489 | */ | |
490 | class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor | |
491 | { | |
492 | public: | |
493 | wxGridCellAutoWrapStringEditor(); | |
494 | }; | |
495 | ||
8b9ef005 BP |
496 | /** |
497 | @class wxGridCellBoolEditor | |
23324ae1 | 498 | |
8b9ef005 | 499 | Grid cell editor for boolean data. |
23324ae1 | 500 | |
8b9ef005 BP |
501 | @library{wxadv} |
502 | @category{grid} | |
23324ae1 | 503 | |
db890987 VZ |
504 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
505 | wxGridCellChoiceEditor, wxGridCellEnumEditor, | |
506 | wxGridCellFloatEditor, wxGridCellNumberEditor, | |
507 | wxGridCellTextEditor | |
8b9ef005 BP |
508 | */ |
509 | class wxGridCellBoolEditor : public wxGridCellEditor | |
510 | { | |
511 | public: | |
23324ae1 | 512 | /** |
8b9ef005 BP |
513 | Default constructor. |
514 | */ | |
515 | wxGridCellBoolEditor(); | |
5039f140 | 516 | |
8b9ef005 BP |
517 | /** |
518 | Returns @true if the given @a value is equal to the string | |
519 | representation of the truth value we currently use (see | |
520 | UseStringValues()). | |
521 | */ | |
522 | static bool IsTrueValue(const wxString& value); | |
3c4f71cc | 523 | |
23324ae1 | 524 | /** |
8b9ef005 BP |
525 | This method allows you to customize the values returned by GetValue() |
526 | for the cell using this editor. By default, the default values of the | |
527 | arguments are used, i.e. @c "1" is returned if the cell is checked and | |
528 | an empty string otherwise. | |
529 | */ | |
530 | static void UseStringValues(const wxString& valueTrue = "1", | |
57bf907d | 531 | const wxString& valueFalse = wxEmptyString); |
8b9ef005 | 532 | }; |
3c4f71cc | 533 | |
8b9ef005 BP |
534 | /** |
535 | @class wxGridCellChoiceEditor | |
23324ae1 | 536 | |
8b9ef005 BP |
537 | Grid cell editor for string data providing the user a choice from a list of |
538 | strings. | |
5039f140 | 539 | |
8b9ef005 BP |
540 | @library{wxadv} |
541 | @category{grid} | |
23324ae1 | 542 | |
db890987 VZ |
543 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
544 | wxGridCellBoolEditor, wxGridCellEnumEditor, | |
545 | wxGridCellFloatEditor, wxGridCellNumberEditor, | |
546 | wxGridCellTextEditor | |
8b9ef005 BP |
547 | */ |
548 | class wxGridCellChoiceEditor : public wxGridCellEditor | |
549 | { | |
550 | public: | |
23324ae1 | 551 | /** |
db890987 VZ |
552 | Choice cell renderer ctor. |
553 | ||
8b9ef005 BP |
554 | @param count |
555 | Number of strings from which the user can choose. | |
556 | @param choices | |
557 | An array of strings from which the user can choose. | |
558 | @param allowOthers | |
559 | If allowOthers is @true, the user can type a string not in choices | |
560 | array. | |
561 | */ | |
562 | wxGridCellChoiceEditor(size_t count = 0, | |
563 | const wxString choices[] = NULL, | |
564 | bool allowOthers = false); | |
001f1f56 FM |
565 | |
566 | /** | |
567 | Choice cell renderer ctor. | |
568 | ||
569 | @param choices | |
570 | An array of strings from which the user can choose. | |
571 | @param allowOthers | |
572 | If allowOthers is @true, the user can type a string not in choices | |
573 | array. | |
574 | */ | |
8b9ef005 BP |
575 | wxGridCellChoiceEditor(const wxArrayString& choices, |
576 | bool allowOthers = false); | |
23324ae1 FM |
577 | |
578 | /** | |
8b9ef005 BP |
579 | Parameters string format is "item1[,item2[...,itemN]]" |
580 | */ | |
581 | virtual void SetParameters(const wxString& params); | |
582 | }; | |
23324ae1 | 583 | |
db890987 VZ |
584 | /** |
585 | @class wxGridCellEnumEditor | |
586 | ||
587 | Grid cell editor which displays an enum number as a textual equivalent | |
588 | (eg. data in cell is 0,1,2 ... n the cell could be displayed as | |
589 | "John","Fred"..."Bob" in the combo choice box). | |
590 | ||
591 | @library{wxadv} | |
592 | @category{grid} | |
593 | ||
594 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, | |
595 | wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
596 | wxGridCellTextEditor, wxGridCellFloatEditor, | |
597 | wxGridCellNumberEditor | |
598 | */ | |
599 | class wxGridCellEnumEditor : public wxGridCellChoiceEditor | |
600 | { | |
601 | public: | |
602 | /** | |
603 | Enum cell editor ctor. | |
604 | ||
605 | @param choices | |
606 | Comma separated choice parameters "item1[,item2[...,itemN]]". | |
607 | */ | |
608 | wxGridCellEnumEditor( const wxString& choices = wxEmptyString ); | |
609 | }; | |
610 | ||
8b9ef005 BP |
611 | /** |
612 | @class wxGridCellTextEditor | |
3c4f71cc | 613 | |
8b9ef005 | 614 | Grid cell editor for string/text data. |
23324ae1 | 615 | |
8b9ef005 BP |
616 | @library{wxadv} |
617 | @category{grid} | |
afe0e400 | 618 | |
db890987 VZ |
619 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
620 | wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
621 | wxGridCellEnumEditor, wxGridCellFloatEditor, | |
622 | wxGridCellNumberEditor | |
8b9ef005 BP |
623 | */ |
624 | class wxGridCellTextEditor : public wxGridCellEditor | |
625 | { | |
626 | public: | |
23324ae1 | 627 | /** |
8b9ef005 BP |
628 | Default constructor. |
629 | */ | |
630 | wxGridCellTextEditor(); | |
23324ae1 FM |
631 | |
632 | /** | |
8b9ef005 BP |
633 | The parameters string format is "n" where n is a number representing |
634 | the maximum width. | |
635 | */ | |
636 | virtual void SetParameters(const wxString& params); | |
637 | }; | |
5039f140 | 638 | |
8b9ef005 BP |
639 | /** |
640 | @class wxGridCellFloatEditor | |
23324ae1 | 641 | |
8b9ef005 | 642 | The editor for floating point numbers data. |
3c4f71cc | 643 | |
8b9ef005 BP |
644 | @library{wxadv} |
645 | @category{grid} | |
23324ae1 | 646 | |
db890987 VZ |
647 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
648 | wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
649 | wxGridCellEnumEditor, wxGridCellNumberEditor, | |
650 | wxGridCellTextEditor | |
8b9ef005 BP |
651 | */ |
652 | class wxGridCellFloatEditor : public wxGridCellTextEditor | |
653 | { | |
654 | public: | |
23324ae1 | 655 | /** |
db890987 VZ |
656 | Float cell editor ctor. |
657 | ||
8b9ef005 BP |
658 | @param width |
659 | Minimum number of characters to be shown. | |
660 | @param precision | |
661 | Number of digits after the decimal dot. | |
1d8d3cc5 VZ |
662 | @param format |
663 | The format to use for displaying the number, a combination of | |
7920b94b | 664 | ::wxGridCellFloatFormat enum elements. This parameter is only |
1d8d3cc5 | 665 | available since wxWidgets 2.9.3. |
8b9ef005 | 666 | */ |
1d8d3cc5 VZ |
667 | wxGridCellFloatEditor(int width = -1, int precision = -1, |
668 | int format = wxGRID_FLOAT_FORMAT_DEFAULT); | |
23324ae1 FM |
669 | |
670 | /** | |
1d8d3cc5 | 671 | The parameters string format is "width[,precision[,format]]" where |
8cddee2d | 672 | @c format should be chosen between f|e|g|E|G (f is used by default) |
8b9ef005 BP |
673 | */ |
674 | virtual void SetParameters(const wxString& params); | |
675 | }; | |
23324ae1 | 676 | |
8b9ef005 BP |
677 | /** |
678 | @class wxGridCellNumberEditor | |
3c4f71cc | 679 | |
8b9ef005 | 680 | Grid cell editor for numeric integer data. |
5039f140 | 681 | |
8b9ef005 BP |
682 | @library{wxadv} |
683 | @category{grid} | |
23324ae1 | 684 | |
db890987 VZ |
685 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
686 | wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
687 | wxGridCellEnumEditor, wxGridCellFloatEditor, | |
688 | wxGridCellTextEditor | |
8b9ef005 BP |
689 | */ |
690 | class wxGridCellNumberEditor : public wxGridCellTextEditor | |
691 | { | |
692 | public: | |
23324ae1 | 693 | /** |
8b9ef005 BP |
694 | Allows you to specify the range for acceptable data. Values equal to |
695 | -1 for both @a min and @a max indicate that no range checking should be | |
696 | done. | |
697 | */ | |
698 | wxGridCellNumberEditor(int min = -1, int max = -1); | |
3c4f71cc | 699 | |
23324ae1 | 700 | |
afe0e400 | 701 | /** |
8b9ef005 BP |
702 | Parameters string format is "min,max". |
703 | */ | |
704 | virtual void SetParameters(const wxString& params); | |
705 | ||
706 | protected: | |
3c4f71cc | 707 | |
afe0e400 | 708 | /** |
8b9ef005 BP |
709 | If the return value is @true, the editor uses a wxSpinCtrl to get user |
710 | input, otherwise it uses a wxTextCtrl. | |
711 | */ | |
712 | bool HasRange() const; | |
23324ae1 | 713 | |
afe0e400 | 714 | /** |
8b9ef005 BP |
715 | String representation of the value. |
716 | */ | |
717 | wxString GetString() const; | |
718 | }; | |
23324ae1 | 719 | |
23324ae1 | 720 | |
3c4f71cc | 721 | |
8b9ef005 BP |
722 | /** |
723 | @class wxGridCellAttr | |
23324ae1 | 724 | |
8b9ef005 BP |
725 | This class can be used to alter the cells' appearance in the grid by |
726 | changing their attributes from the defaults. An object of this class may be | |
727 | returned by wxGridTableBase::GetAttr(). | |
5039f140 | 728 | |
8b9ef005 BP |
729 | @library{wxadv} |
730 | @category{grid} | |
731 | */ | |
42dd5e3b | 732 | class wxGridCellAttr : public wxClientDataContainer, public wxRefCounter |
8b9ef005 BP |
733 | { |
734 | public: | |
62960a2c VZ |
735 | /** |
736 | Kind of the attribute to retrieve. | |
737 | ||
738 | @see wxGridCellAttrProvider::GetAttr(), wxGridTableBase::GetAttr() | |
739 | */ | |
740 | enum wxAttrKind | |
741 | { | |
742 | /// Return the combined effective attribute for the cell. | |
743 | Any, | |
744 | ||
745 | /// Return the attribute explicitly set for this cell. | |
746 | Cell, | |
747 | ||
748 | /// Return the attribute set for this cells row. | |
749 | Row, | |
750 | ||
751 | /// Return the attribute set for this cells column. | |
752 | Col | |
753 | }; | |
754 | ||
afe0e400 | 755 | /** |
8b9ef005 BP |
756 | Default constructor. |
757 | */ | |
ccf39540 | 758 | wxGridCellAttr(wxGridCellAttr* attrDefault = NULL); |
23324ae1 | 759 | /** |
8b9ef005 BP |
760 | Constructor specifying some of the often used attributes. |
761 | */ | |
762 | wxGridCellAttr(const wxColour& colText, const wxColour& colBack, | |
763 | const wxFont& font, int hAlign, int vAlign); | |
5039f140 | 764 | |
afe0e400 | 765 | /** |
8b9ef005 BP |
766 | Creates a new copy of this object. |
767 | */ | |
768 | wxGridCellAttr* Clone() const; | |
23324ae1 FM |
769 | |
770 | /** | |
8b9ef005 BP |
771 | This class is reference counted: it is created with ref count of 1, so |
772 | calling DecRef() once will delete it. Calling IncRef() allows to lock | |
773 | it until the matching DecRef() is called. | |
774 | */ | |
775 | void DecRef(); | |
23324ae1 FM |
776 | |
777 | /** | |
cfbc15ee VZ |
778 | Get the alignment to use for the cell with the given attribute. |
779 | ||
780 | If this attribute doesn't specify any alignment, the default attribute | |
781 | alignment is used (which can be changed using | |
782 | wxGrid::SetDefaultCellAlignment() but is left and top by default). | |
783 | ||
784 | Notice that @a hAlign and @a vAlign values are always overwritten by | |
785 | this function, use GetNonDefaultAlignment() if this is not desirable. | |
786 | ||
787 | @param hAlign | |
788 | Horizontal alignment is returned here if this argument is non-@NULL. | |
789 | It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. | |
790 | @param vAlign | |
791 | Vertical alignment is returned here if this argument is non-@NULL. | |
792 | It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM. | |
8b9ef005 BP |
793 | */ |
794 | void GetAlignment(int* hAlign, int* vAlign) const; | |
23324ae1 FM |
795 | |
796 | /** | |
8b9ef005 BP |
797 | Returns the background colour. |
798 | */ | |
799 | const wxColour& GetBackgroundColour() const; | |
23324ae1 | 800 | |
23324ae1 | 801 | /** |
8b9ef005 BP |
802 | Returns the cell editor. |
803 | */ | |
804 | wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const; | |
23324ae1 FM |
805 | |
806 | /** | |
8b9ef005 BP |
807 | Returns the font. |
808 | */ | |
809 | const wxFont& GetFont() const; | |
23324ae1 | 810 | |
cfbc15ee VZ |
811 | /** |
812 | Get the alignment defined by this attribute. | |
813 | ||
814 | Unlike GetAlignment() this function only modifies @a hAlign and @a | |
815 | vAlign if this attribute does define a non-default alignment. This | |
816 | means that they must be initialized before calling this function and | |
817 | that their values will be preserved unchanged if they are different | |
818 | from wxALIGN_INVALID. | |
819 | ||
820 | For example, the following fragment can be used to use the cell | |
821 | alignment if one is defined but right-align its contents by default | |
822 | (instead of left-aligning it by default) while still using the default | |
823 | vertical alignment: | |
824 | @code | |
825 | int hAlign = wxALIGN_RIGHT, | |
826 | vAlign = wxALIGN_INVALID; | |
827 | attr.GetNonDefaultAlignment(&hAlign, &vAlign); | |
828 | @endcode | |
829 | ||
830 | @since 2.9.1 | |
831 | */ | |
832 | void GetNonDefaultAlignment(int *hAlign, int *vAlign) const; | |
833 | ||
23324ae1 | 834 | /** |
8b9ef005 BP |
835 | Returns the cell renderer. |
836 | */ | |
837 | wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const; | |
23324ae1 FM |
838 | |
839 | /** | |
8b9ef005 BP |
840 | Returns the text colour. |
841 | */ | |
842 | const wxColour& GetTextColour() const; | |
5e6e278d FM |
843 | |
844 | /** | |
8b9ef005 BP |
845 | Returns @true if this attribute has a valid alignment set. |
846 | */ | |
847 | bool HasAlignment() const; | |
7c913512 | 848 | |
23324ae1 | 849 | /** |
8b9ef005 | 850 | Returns @true if this attribute has a valid background colour set. |
23324ae1 | 851 | */ |
8b9ef005 | 852 | bool HasBackgroundColour() const; |
23324ae1 | 853 | |
23324ae1 | 854 | /** |
8b9ef005 | 855 | Returns @true if this attribute has a valid cell editor set. |
23324ae1 | 856 | */ |
8b9ef005 | 857 | bool HasEditor() const; |
23324ae1 FM |
858 | |
859 | /** | |
8b9ef005 | 860 | Returns @true if this attribute has a valid font set. |
23324ae1 | 861 | */ |
8b9ef005 | 862 | bool HasFont() const; |
23324ae1 FM |
863 | |
864 | /** | |
8b9ef005 | 865 | Returns @true if this attribute has a valid cell renderer set. |
23324ae1 | 866 | */ |
8b9ef005 | 867 | bool HasRenderer() const; |
23324ae1 FM |
868 | |
869 | /** | |
8b9ef005 | 870 | Returns @true if this attribute has a valid text colour set. |
23324ae1 | 871 | */ |
8b9ef005 | 872 | bool HasTextColour() const; |
23324ae1 FM |
873 | |
874 | /** | |
8b9ef005 BP |
875 | This class is reference counted: it is created with ref count of 1, so |
876 | calling DecRef() once will delete it. Calling IncRef() allows to lock | |
877 | it until the matching DecRef() is called. | |
23324ae1 | 878 | */ |
8b9ef005 | 879 | void IncRef(); |
23324ae1 FM |
880 | |
881 | /** | |
8b9ef005 | 882 | Returns @true if this cell is set as read-only. |
23324ae1 | 883 | */ |
8b9ef005 | 884 | bool IsReadOnly() const; |
23324ae1 FM |
885 | |
886 | /** | |
8b9ef005 BP |
887 | Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT, |
888 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of | |
889 | @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
23324ae1 | 890 | */ |
8b9ef005 | 891 | void SetAlignment(int hAlign, int vAlign); |
23324ae1 FM |
892 | |
893 | /** | |
8b9ef005 | 894 | Sets the background colour. |
23324ae1 | 895 | */ |
8b9ef005 | 896 | void SetBackgroundColour(const wxColour& colBack); |
23324ae1 FM |
897 | |
898 | /** | |
8b9ef005 | 899 | @todo Needs documentation. |
23324ae1 | 900 | */ |
8b9ef005 | 901 | void SetDefAttr(wxGridCellAttr* defAttr); |
23324ae1 FM |
902 | |
903 | /** | |
8b9ef005 | 904 | Sets the editor to be used with the cells with this attribute. |
23324ae1 | 905 | */ |
8b9ef005 | 906 | void SetEditor(wxGridCellEditor* editor); |
23324ae1 FM |
907 | |
908 | /** | |
8b9ef005 | 909 | Sets the font. |
23324ae1 | 910 | */ |
8b9ef005 | 911 | void SetFont(const wxFont& font); |
23324ae1 FM |
912 | |
913 | /** | |
8b9ef005 | 914 | Sets the cell as read-only. |
23324ae1 | 915 | */ |
8b9ef005 | 916 | void SetReadOnly(bool isReadOnly = true); |
23324ae1 FM |
917 | |
918 | /** | |
8b9ef005 BP |
919 | Sets the renderer to be used for cells with this attribute. Takes |
920 | ownership of the pointer. | |
23324ae1 | 921 | */ |
8b9ef005 | 922 | void SetRenderer(wxGridCellRenderer* renderer); |
5e6e278d FM |
923 | |
924 | /** | |
8b9ef005 | 925 | Sets the text colour. |
5e6e278d | 926 | */ |
8b9ef005 | 927 | void SetTextColour(const wxColour& colText); |
42dd5e3b RD |
928 | |
929 | protected: | |
930 | ||
931 | /** | |
932 | The destructor is private because only DecRef() can delete us. | |
933 | */ | |
934 | virtual ~wxGridCellAttr(); | |
23324ae1 FM |
935 | }; |
936 | ||
ba9574c3 VZ |
937 | /** |
938 | Base class for corner window renderer. | |
939 | ||
940 | This is the simplest of all header renderers and only has a single | |
941 | function. | |
942 | ||
943 | @see wxGridCellAttrProvider::GetCornerRenderer() | |
944 | ||
945 | @since 2.9.1 | |
946 | */ | |
947 | class wxGridCornerHeaderRenderer | |
948 | { | |
949 | public: | |
950 | /** | |
951 | Called by the grid to draw the corner window border. | |
952 | ||
953 | This method is responsible for drawing the border inside the given @a | |
954 | rect and adjusting the rectangle size to correspond to the area inside | |
955 | the border, i.e. usually call wxRect::Deflate() to account for the | |
956 | border width. | |
957 | ||
958 | @param grid | |
959 | The grid whose corner window is being drawn. | |
960 | @param dc | |
961 | The device context to use for drawing. | |
962 | @param rect | |
963 | Input/output parameter which contains the border rectangle on input | |
964 | and should be updated to contain the area inside the border on | |
965 | function return. | |
966 | */ | |
967 | virtual void DrawBorder(const wxGrid& grid, | |
968 | wxDC& dc, | |
969 | wxRect& rect) const = 0; | |
970 | }; | |
cd64c053 | 971 | |
ba9574c3 VZ |
972 | /** |
973 | Common base class for row and column headers renderers. | |
974 | ||
975 | @see wxGridColumnHeaderRenderer, wxGridRowHeaderRenderer | |
976 | ||
977 | @since 2.9.1 | |
978 | */ | |
979 | class wxGridHeaderLabelsRenderer : public wxGridCornerHeaderRenderer | |
980 | { | |
981 | public: | |
982 | /** | |
983 | Called by the grid to draw the specified label. | |
984 | ||
985 | Notice that the base class DrawBorder() method is called before this | |
986 | one. | |
987 | ||
988 | The default implementation uses wxGrid::GetLabelTextColour() and | |
989 | wxGrid::GetLabelFont() to draw the label. | |
990 | */ | |
991 | virtual void DrawLabel(const wxGrid& grid, | |
992 | wxDC& dc, | |
993 | const wxString& value, | |
994 | const wxRect& rect, | |
995 | int horizAlign, | |
996 | int vertAlign, | |
997 | int textOrientation) const; | |
998 | }; | |
999 | ||
1000 | /** | |
1001 | Base class for row headers renderer. | |
1002 | ||
1003 | This is the same as wxGridHeaderLabelsRenderer currently but we still use a | |
1004 | separate class for it to distinguish it from wxGridColumnHeaderRenderer. | |
1005 | ||
1006 | @see wxGridRowHeaderRendererDefault | |
1007 | ||
1008 | @see wxGridCellAttrProvider::GetRowHeaderRenderer() | |
1009 | ||
1010 | @since 2.9.1 | |
1011 | */ | |
1012 | class wxGridRowHeaderRenderer : public wxGridHeaderLabelsRenderer | |
1013 | { | |
1014 | }; | |
1015 | ||
1016 | /** | |
1017 | Base class for column headers renderer. | |
1018 | ||
1019 | This is the same as wxGridHeaderLabelsRenderer currently but we still use a | |
1020 | separate class for it to distinguish it from wxGridRowHeaderRenderer. | |
1021 | ||
1022 | @see wxGridColumnHeaderRendererDefault | |
1023 | ||
1024 | @see wxGridCellAttrProvider::GetColumnHeaderRenderer() | |
1025 | ||
1026 | @since 2.9.1 | |
1027 | */ | |
1028 | class wxGridColumnHeaderRenderer : public wxGridHeaderLabelsRenderer | |
1029 | { | |
1030 | }; | |
1031 | ||
1032 | /** | |
1033 | Default row header renderer. | |
1034 | ||
1035 | You may derive from this class if you need to only override one of its | |
1036 | methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the | |
1037 | default implementation for the other one. | |
1038 | ||
1039 | @see wxGridColumnHeaderRendererDefault | |
1040 | ||
1041 | @since 2.9.1 | |
1042 | */ | |
163bd4f7 | 1043 | class wxGridRowHeaderRendererDefault : public wxGridRowHeaderRenderer |
ba9574c3 VZ |
1044 | { |
1045 | public: | |
1046 | /// Implement border drawing for the row labels. | |
1047 | virtual void DrawBorder(const wxGrid& grid, | |
1048 | wxDC& dc, | |
1049 | wxRect& rect) const; | |
1050 | }; | |
1051 | ||
1052 | /** | |
1053 | Default column header renderer. | |
1054 | ||
1055 | @see wxGridRowHeaderRendererDefault | |
1056 | ||
1057 | @since 2.9.1 | |
1058 | */ | |
1059 | class wxGridColumnHeaderRendererDefault : public wxGridColumnHeaderRenderer | |
1060 | { | |
1061 | public: | |
1062 | /// Implement border drawing for the column labels. | |
1063 | virtual void DrawBorder(const wxGrid& grid, | |
1064 | wxDC& dc, | |
1065 | wxRect& rect) const; | |
1066 | }; | |
1067 | ||
1068 | /** | |
1069 | Default corner window renderer. | |
1070 | ||
1071 | @see wxGridColumnHeaderRendererDefault, wxGridRowHeaderRendererDefault | |
1072 | ||
1073 | @since 2.9.1 | |
1074 | */ | |
1075 | class wxGridCornerHeaderRendererDefault : public wxGridCornerHeaderRenderer | |
1076 | { | |
1077 | public: | |
1078 | /// Implement border drawing for the corner window. | |
1079 | virtual void DrawBorder(const wxGrid& grid, | |
1080 | wxDC& dc, | |
1081 | wxRect& rect) const; | |
1082 | }; | |
1083 | ||
62960a2c VZ |
1084 | /** |
1085 | Class providing attributes to be used for the grid cells. | |
1086 | ||
1087 | This class both defines an interface which grid cell attributes providers | |
1088 | should implement -- and which can be implemented differently in derived | |
1089 | classes -- and a default implementation of this interface which is often | |
1090 | good enough to be used without modification, especially with not very large | |
1091 | grids for which the efficiency of attributes storage hardly matters (see | |
1092 | the discussion below). | |
1093 | ||
1094 | An object of this class can be associated with a wxGrid using | |
1095 | wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you | |
1096 | intend to use the default provider as it is used by wxGridTableBase by | |
1097 | default anyhow. | |
1098 | ||
1099 | Notice that while attributes provided by this class can be set for | |
1100 | individual cells using SetAttr() or the entire rows or columns using | |
1101 | SetRowAttr() and SetColAttr() they are always retrieved using GetAttr() | |
1102 | function. | |
1103 | ||
1104 | ||
1105 | The default implementation of this class stores the attributes passed to | |
1106 | its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A | |
1107 | derived class may use its knowledge about how the attributes are used in | |
1108 | your program to implement it much more efficiently: for example, using a | |
1109 | special background colour for all even-numbered rows can be implemented by | |
1110 | simply returning the same attribute from GetAttr() if the row number is | |
1111 | even instead of having to store N/2 row attributes where N is the total | |
1112 | number of rows in the grid. | |
1113 | ||
1114 | Notice that objects of this class can't be copied. | |
1115 | */ | |
1116 | class wxGridCellAttrProvider : public wxClientDataContainer | |
1117 | { | |
1118 | public: | |
1119 | /// Trivial default constructor. | |
1120 | wxGridCellAttrProvider(); | |
1121 | ||
1122 | /// Destructor releases any attributes held by this class. | |
1123 | virtual ~wxGridCellAttrProvider(); | |
1124 | ||
1125 | /** | |
1126 | Get the attribute to use for the specified cell. | |
1127 | ||
1128 | If wxGridCellAttr::Any is used as @a kind value, this function combines | |
1129 | the attributes set for this cell using SetAttr() and those for its row | |
1130 | or column (set with SetRowAttr() or SetColAttr() respectively), with | |
1131 | the cell attribute having the highest precedence. | |
1132 | ||
1133 | Notice that the caller must call DecRef() on the returned pointer if it | |
1134 | is non-@NULL. | |
1135 | ||
1136 | @param row | |
1137 | The row of the cell. | |
1138 | @param col | |
1139 | The column of the cell. | |
1140 | @param kind | |
1141 | The kind of the attribute to return. | |
1142 | @return | |
1143 | The attribute to use which should be DecRef()'d by caller or @NULL | |
1144 | if no attributes are defined for this cell. | |
1145 | */ | |
1146 | virtual wxGridCellAttr *GetAttr(int row, int col, | |
1147 | wxGridCellAttr::wxAttrKind kind) const; | |
1148 | ||
1149 | /** | |
1150 | Setting attributes. | |
1151 | ||
1152 | All these functions take ownership of the attribute passed to them, | |
1153 | i.e. will call DecRef() on it themselves later and so it should not be | |
1154 | destroyed by the caller. And the attribute can be @NULL to reset a | |
1155 | previously set value. | |
1156 | */ | |
1157 | //@{ | |
1158 | ||
1159 | /// Set attribute for the specified cell. | |
1160 | virtual void SetAttr(wxGridCellAttr *attr, int row, int col); | |
1161 | ||
1162 | /// Set attribute for the specified row. | |
1163 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); | |
1164 | ||
1165 | /// Set attribute for the specified column. | |
1166 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
1167 | ||
1168 | //@} | |
ba9574c3 VZ |
1169 | |
1170 | /** | |
1171 | Getting header renderers. | |
1172 | ||
1173 | These functions return the renderers for the given row or column header | |
1174 | label and the corner window. Unlike cell attributes, these objects are | |
1175 | not reference counted and are never @NULL so they are returned by | |
1176 | reference and not pointer and DecRef() shouldn't (and can't) be called | |
1177 | for them. | |
1178 | ||
1179 | All these functions were added in wxWidgets 2.9.1. | |
1180 | */ | |
1181 | //@{ | |
1182 | ||
1183 | /** | |
1184 | Return the renderer used for drawing column headers. | |
1185 | ||
1186 | By default wxGridColumnHeaderRendererDefault is returned. | |
1187 | ||
1188 | @see wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader() | |
1189 | ||
1190 | @since 2.9.1 | |
1191 | */ | |
1192 | virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col); | |
1193 | ||
1194 | /** | |
1195 | Return the renderer used for drawing row headers. | |
1196 | ||
1197 | By default wxGridRowHeaderRendererDefault is returned. | |
1198 | ||
1199 | @since 2.9.1 | |
1200 | */ | |
1201 | virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row); | |
1202 | ||
1203 | /** | |
1204 | Return the renderer used for drawing the corner window. | |
1205 | ||
1206 | By default wxGridCornerHeaderRendererDefault is returned. | |
1207 | ||
1208 | @since 2.9.1 | |
1209 | */ | |
1210 | virtual const wxGridCornerHeaderRenderer& GetCornerRenderer(); | |
1211 | ||
1212 | //@} | |
62960a2c | 1213 | }; |
23324ae1 | 1214 | |
daf1cbe4 VZ |
1215 | /** |
1216 | Represents coordinates of a grid cell. | |
1217 | ||
1218 | An object of this class is simply a (row, column) pair. | |
1219 | */ | |
1220 | class wxGridCellCoords | |
1221 | { | |
1222 | public: | |
1223 | /** | |
1224 | Default constructor initializes the object to invalid state. | |
1225 | ||
1226 | Initially the row and column are both invalid (-1) and so operator!() | |
1227 | for an uninitialized wxGridCellCoords returns false. | |
1228 | */ | |
1229 | wxGridCellCoords(); | |
1230 | ||
1231 | /** | |
1232 | Constructor taking a row and a column. | |
1233 | */ | |
1234 | wxGridCellCoords(int row, int col); | |
1235 | ||
1236 | /** | |
1237 | Return the row of the coordinate. | |
1238 | */ | |
1239 | int GetRow() const; | |
1240 | ||
1241 | /** | |
1242 | Set the row of the coordinate. | |
1243 | */ | |
1244 | void SetRow(int n); | |
1245 | ||
1246 | /** | |
1247 | Return the column of the coordinate. | |
1248 | */ | |
1249 | int GetCol() const; | |
1250 | ||
1251 | /** | |
1252 | Set the column of the coordinate. | |
1253 | */ | |
1254 | void SetCol(int n); | |
1255 | ||
1256 | /** | |
1257 | Set the row and column of the coordinate. | |
1258 | */ | |
1259 | void Set(int row, int col); | |
1260 | ||
1261 | /** | |
1262 | Assignment operator for coordinate types. | |
1263 | */ | |
1264 | wxGridCellCoords& operator=(const wxGridCellCoords& other); | |
1265 | ||
1266 | /** | |
1267 | Equality operator. | |
1268 | */ | |
1269 | bool operator==(const wxGridCellCoords& other) const; | |
1270 | ||
1271 | /** | |
1272 | Inequality operator. | |
1273 | */ | |
1274 | bool operator!=(const wxGridCellCoords& other) const; | |
1275 | ||
1276 | /** | |
1277 | Checks whether the coordinates are invalid. | |
1278 | ||
1279 | Returns false only if both row and column are -1. Notice that if either | |
1280 | row or column (but not both) are -1, this method returns true even if | |
1281 | the object is invalid. This is done because objects in such state | |
1282 | should actually never exist, i.e. either both coordinates should be -1 | |
1283 | or none of them should be -1. | |
1284 | */ | |
1285 | bool operator!() const; | |
1286 | }; | |
e54c96f1 | 1287 | |
23324ae1 | 1288 | /** |
8b9ef005 | 1289 | @class wxGridTableBase |
7c913512 | 1290 | |
8b9ef005 BP |
1291 | The almost abstract base class for grid tables. |
1292 | ||
1293 | A grid table is responsible for storing the grid data and, indirectly, grid | |
1294 | cell attributes. The data can be stored in the way most convenient for the | |
1295 | application but has to be provided in string form to wxGrid. It is also | |
1296 | possible to provide cells values in other formats if appropriate, e.g. as | |
1297 | numbers. | |
1298 | ||
1299 | This base class is not quite abstract as it implements a trivial strategy | |
1300 | for storing the attributes by forwarding it to wxGridCellAttrProvider and | |
1301 | also provides stubs for some other functions. However it does have a number | |
1302 | of pure virtual methods which must be implemented in the derived classes. | |
1303 | ||
1304 | @see wxGridStringTable | |
7c913512 | 1305 | |
23324ae1 | 1306 | @library{wxadv} |
42b5841f | 1307 | @category{grid} |
23324ae1 | 1308 | */ |
8b9ef005 | 1309 | class wxGridTableBase : public wxObject |
23324ae1 FM |
1310 | { |
1311 | public: | |
1312 | /** | |
1313 | Default constructor. | |
8b9ef005 BP |
1314 | */ |
1315 | wxGridTableBase(); | |
23324ae1 FM |
1316 | |
1317 | /** | |
8b9ef005 BP |
1318 | Destructor frees the attribute provider if it was created. |
1319 | */ | |
1320 | virtual ~wxGridTableBase(); | |
23324ae1 | 1321 | |
8b9ef005 BP |
1322 | /** |
1323 | Must be overridden to return the number of rows in the table. | |
e54c96f1 | 1324 | |
8b9ef005 BP |
1325 | For backwards compatibility reasons, this method is not const. |
1326 | Use GetRowsCount() instead of it in const methods of derived table | |
1327 | classes. | |
1328 | */ | |
1329 | virtual int GetNumberRows() = 0; | |
7c913512 | 1330 | |
8b9ef005 BP |
1331 | /** |
1332 | Must be overridden to return the number of columns in the table. | |
7c913512 | 1333 | |
8b9ef005 BP |
1334 | For backwards compatibility reasons, this method is not const. |
1335 | Use GetColsCount() instead of it in const methods of derived table | |
1336 | classes, | |
1337 | */ | |
1338 | virtual int GetNumberCols() = 0; | |
7c913512 | 1339 | |
23324ae1 | 1340 | /** |
8b9ef005 | 1341 | Return the number of rows in the table. |
23324ae1 | 1342 | |
8b9ef005 BP |
1343 | This method is not virtual and is only provided as a convenience for |
1344 | the derived classes which can't call GetNumberRows() without a | |
1345 | @c const_cast from their const methods. | |
1346 | */ | |
1347 | int GetRowsCount() const; | |
23324ae1 | 1348 | |
8b9ef005 BP |
1349 | /** |
1350 | Return the number of columns in the table. | |
e54c96f1 | 1351 | |
8b9ef005 BP |
1352 | This method is not virtual and is only provided as a convenience for |
1353 | the derived classes which can't call GetNumberCols() without a | |
1354 | @c const_cast from their const methods. | |
1355 | */ | |
1356 | int GetColsCount() const; | |
7c913512 | 1357 | |
7c913512 | 1358 | |
23324ae1 | 1359 | /** |
8b9ef005 BP |
1360 | @name Table Cell Accessors |
1361 | */ | |
1362 | //@{ | |
23324ae1 FM |
1363 | |
1364 | /** | |
8acad210 VZ |
1365 | May be overridden to implement testing for empty cells. |
1366 | ||
1367 | This method is used by the grid to test if the given cell is not used | |
1368 | and so whether a neighbouring cell may overflow into it. By default it | |
1369 | only returns true if the value of the given cell, as returned by | |
1370 | GetValue(), is empty. | |
8b9ef005 | 1371 | */ |
8acad210 | 1372 | virtual bool IsEmptyCell(int row, int col); |
e54c96f1 | 1373 | |
8b9ef005 BP |
1374 | /** |
1375 | Same as IsEmptyCell() but taking wxGridCellCoords. | |
7c913512 | 1376 | |
8b9ef005 BP |
1377 | Notice that this method is not virtual, only IsEmptyCell() should be |
1378 | overridden. | |
1379 | */ | |
1380 | bool IsEmpty(const wxGridCellCoords& coords); | |
7c913512 | 1381 | |
afe0e400 | 1382 | /** |
8b9ef005 BP |
1383 | Must be overridden to implement accessing the table values as text. |
1384 | */ | |
1385 | virtual wxString GetValue(int row, int col) = 0; | |
23324ae1 FM |
1386 | |
1387 | /** | |
8b9ef005 BP |
1388 | Must be overridden to implement setting the table values as text. |
1389 | */ | |
1390 | virtual void SetValue(int row, int col, const wxString& value) = 0; | |
23324ae1 FM |
1391 | |
1392 | /** | |
8b9ef005 | 1393 | Returns the type of the value in the given cell. |
23324ae1 | 1394 | |
8b9ef005 BP |
1395 | By default all cells are strings and this method returns |
1396 | @c wxGRID_VALUE_STRING. | |
1397 | */ | |
1398 | virtual wxString GetTypeName(int row, int col); | |
23324ae1 FM |
1399 | |
1400 | /** | |
8b9ef005 BP |
1401 | Returns true if the value of the given cell can be accessed as if it |
1402 | were of the specified type. | |
23324ae1 | 1403 | |
8b9ef005 BP |
1404 | By default the cells can only be accessed as strings. Note that a cell |
1405 | could be accessible in different ways, e.g. a numeric cell may return | |
1406 | @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING | |
1407 | indicating that the value can be coerced to a string form. | |
1408 | */ | |
1409 | virtual bool CanGetValueAs(int row, int col, const wxString& typeName); | |
23324ae1 FM |
1410 | |
1411 | /** | |
8b9ef005 BP |
1412 | Returns true if the value of the given cell can be set as if it were of |
1413 | the specified type. | |
23324ae1 | 1414 | |
8b9ef005 BP |
1415 | @see CanGetValueAs() |
1416 | */ | |
1417 | virtual bool CanSetValueAs(int row, int col, const wxString& typeName); | |
e54c96f1 | 1418 | |
8b9ef005 BP |
1419 | /** |
1420 | Returns the value of the given cell as a long. | |
7c913512 | 1421 | |
8b9ef005 BP |
1422 | This should only be called if CanGetValueAs() returns @true when called |
1423 | with @c wxGRID_VALUE_NUMBER argument. Default implementation always | |
1424 | return 0. | |
1425 | */ | |
1426 | virtual long GetValueAsLong(int row, int col); | |
7c913512 | 1427 | |
afe0e400 | 1428 | /** |
8b9ef005 | 1429 | Returns the value of the given cell as a double. |
23324ae1 | 1430 | |
8b9ef005 BP |
1431 | This should only be called if CanGetValueAs() returns @true when called |
1432 | with @c wxGRID_VALUE_FLOAT argument. Default implementation always | |
1433 | return 0.0. | |
1434 | */ | |
1435 | virtual double GetValueAsDouble(int row, int col); | |
23324ae1 FM |
1436 | |
1437 | /** | |
8b9ef005 | 1438 | Returns the value of the given cell as a boolean. |
23324ae1 | 1439 | |
8b9ef005 BP |
1440 | This should only be called if CanGetValueAs() returns @true when called |
1441 | with @c wxGRID_VALUE_BOOL argument. Default implementation always | |
1442 | return false. | |
1443 | */ | |
1444 | virtual bool GetValueAsBool(int row, int col); | |
23324ae1 FM |
1445 | |
1446 | /** | |
8b9ef005 BP |
1447 | Returns the value of the given cell as a user-defined type. |
1448 | ||
1449 | This should only be called if CanGetValueAs() returns @true when called | |
1450 | with @a typeName. Default implementation always return @NULL. | |
1451 | */ | |
1452 | virtual void *GetValueAsCustom(int row, int col, const wxString& typeName); | |
23324ae1 FM |
1453 | |
1454 | /** | |
8b9ef005 BP |
1455 | Sets the value of the given cell as a long. |
1456 | ||
1457 | This should only be called if CanSetValueAs() returns @true when called | |
1458 | with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do | |
1459 | anything. | |
1460 | */ | |
1461 | virtual void SetValueAsLong(int row, int col, long value); | |
23324ae1 FM |
1462 | |
1463 | /** | |
8b9ef005 BP |
1464 | Sets the value of the given cell as a double. |
1465 | ||
1466 | This should only be called if CanSetValueAs() returns @true when called | |
1467 | with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do | |
1468 | anything. | |
1469 | */ | |
1470 | virtual void SetValueAsDouble(int row, int col, double value); | |
23324ae1 FM |
1471 | |
1472 | /** | |
8b9ef005 BP |
1473 | Sets the value of the given cell as a boolean. |
1474 | ||
1475 | This should only be called if CanSetValueAs() returns @true when called | |
1476 | with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do | |
1477 | anything. | |
1478 | */ | |
1479 | virtual void SetValueAsBool( int row, int col, bool value ); | |
23324ae1 FM |
1480 | |
1481 | /** | |
8b9ef005 BP |
1482 | Sets the value of the given cell as a user-defined type. |
1483 | ||
1484 | This should only be called if CanSetValueAs() returns @true when called | |
1485 | with @a typeName. Default implementation doesn't do anything. | |
1486 | */ | |
1487 | virtual void SetValueAsCustom(int row, int col, const wxString& typeName, | |
1488 | void *value); | |
1489 | ||
1490 | //@} | |
1491 | ||
23324ae1 FM |
1492 | |
1493 | /** | |
8b9ef005 BP |
1494 | Called by the grid when the table is associated with it. |
1495 | ||
1496 | The default implementation stores the pointer and returns it from its | |
1497 | GetView() and so only makes sense if the table cannot be associated | |
1498 | with more than one grid at a time. | |
1499 | */ | |
1500 | virtual void SetView(wxGrid *grid); | |
23324ae1 FM |
1501 | |
1502 | /** | |
8b9ef005 BP |
1503 | Returns the last grid passed to SetView(). |
1504 | */ | |
1505 | virtual wxGrid *GetView() const; | |
1506 | ||
23324ae1 FM |
1507 | |
1508 | /** | |
8b9ef005 | 1509 | @name Table Structure Modifiers |
23324ae1 | 1510 | |
8b9ef005 BP |
1511 | Notice that none of these functions are pure virtual as they don't have |
1512 | to be implemented if the table structure is never modified after | |
1513 | creation, i.e. neither rows nor columns are never added or deleted but | |
1514 | that you do need to implement them if they are called, i.e. if your | |
1515 | code either calls them directly or uses the matching wxGrid methods, as | |
1516 | by default they simply do nothing which is definitely inappropriate. | |
1517 | */ | |
1518 | //@{ | |
23324ae1 | 1519 | |
8b9ef005 BP |
1520 | /** |
1521 | Clear the table contents. | |
e54c96f1 | 1522 | |
8b9ef005 BP |
1523 | This method is used by wxGrid::ClearGrid(). |
1524 | */ | |
1525 | virtual void Clear(); | |
7c913512 | 1526 | |
8b9ef005 BP |
1527 | /** |
1528 | Insert additional rows into the table. | |
7c913512 | 1529 | |
8b9ef005 BP |
1530 | @param pos |
1531 | The position of the first new row. | |
1532 | @param numRows | |
1533 | The number of rows to insert. | |
1534 | */ | |
1535 | virtual bool InsertRows(size_t pos = 0, size_t numRows = 1); | |
7c913512 | 1536 | |
23324ae1 | 1537 | /** |
8b9ef005 BP |
1538 | Append additional rows at the end of the table. |
1539 | ||
1540 | This method is provided in addition to InsertRows() as some data models | |
1541 | may only support appending rows to them but not inserting them at | |
1542 | arbitrary locations. In such case you may implement this method only | |
1543 | and leave InsertRows() unimplemented. | |
1544 | ||
1545 | @param numRows | |
1546 | The number of rows to add. | |
1547 | */ | |
1548 | virtual bool AppendRows(size_t numRows = 1); | |
23324ae1 FM |
1549 | |
1550 | /** | |
8b9ef005 | 1551 | Delete rows from the table. |
afe0e400 | 1552 | |
4d8e8355 VZ |
1553 | Notice that currently deleting a row intersecting a multi-cell (see |
1554 | SetCellSize()) is not supported and will result in a crash. | |
1555 | ||
8b9ef005 BP |
1556 | @param pos |
1557 | The first row to delete. | |
1558 | @param numRows | |
1559 | The number of rows to delete. | |
1560 | */ | |
1561 | virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1); | |
1562 | ||
1563 | /** | |
1564 | Exactly the same as InsertRows() but for columns. | |
1565 | */ | |
1566 | virtual bool InsertCols(size_t pos = 0, size_t numCols = 1); | |
23324ae1 FM |
1567 | |
1568 | /** | |
8b9ef005 BP |
1569 | Exactly the same as AppendRows() but for columns. |
1570 | */ | |
1571 | virtual bool AppendCols(size_t numCols = 1); | |
23324ae1 | 1572 | |
8b9ef005 BP |
1573 | /** |
1574 | Exactly the same as DeleteRows() but for columns. | |
1575 | */ | |
1576 | virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1); | |
e54c96f1 | 1577 | |
8b9ef005 | 1578 | //@} |
7c913512 | 1579 | |
8b9ef005 BP |
1580 | /** |
1581 | @name Table Row and Column Labels | |
7c913512 | 1582 | |
8b9ef005 BP |
1583 | By default the numbers are used for labeling rows and Latin letters for |
1584 | labeling columns. If the table has more than 26 columns, the pairs of | |
1585 | letters are used starting from the 27-th one and so on, i.e. the | |
1586 | sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ, | |
1587 | AAA, ... | |
1588 | */ | |
1589 | //@{ | |
7c913512 | 1590 | |
23324ae1 | 1591 | /** |
8b9ef005 BP |
1592 | Return the label of the specified row. |
1593 | */ | |
1594 | virtual wxString GetRowLabelValue(int row); | |
23324ae1 | 1595 | |
8b9ef005 BP |
1596 | /** |
1597 | Return the label of the specified column. | |
1598 | */ | |
1599 | virtual wxString GetColLabelValue(int col); | |
5e6e278d | 1600 | |
23324ae1 | 1601 | /** |
8b9ef005 | 1602 | Set the given label for the specified row. |
5e6e278d | 1603 | |
8b9ef005 BP |
1604 | The default version does nothing, i.e. the label is not stored. You |
1605 | must override this method in your derived class if you wish | |
1606 | wxGrid::SetRowLabelValue() to work. | |
1607 | */ | |
1608 | virtual void SetRowLabelValue(int row, const wxString& label); | |
23324ae1 FM |
1609 | |
1610 | /** | |
8b9ef005 BP |
1611 | Exactly the same as SetRowLabelValue() but for columns. |
1612 | */ | |
1613 | virtual void SetColLabelValue(int col, const wxString& label); | |
23324ae1 | 1614 | |
8b9ef005 | 1615 | //@} |
23324ae1 FM |
1616 | |
1617 | ||
8b9ef005 BP |
1618 | /** |
1619 | @name Attributes Management | |
e54c96f1 | 1620 | |
8b9ef005 BP |
1621 | By default the attributes management is delegated to |
1622 | wxGridCellAttrProvider class. You may override the methods in this | |
1623 | section to handle the attributes directly if, for example, they can be | |
1624 | computed from the cell values. | |
1625 | */ | |
1626 | //@{ | |
7c913512 | 1627 | |
8b9ef005 BP |
1628 | /** |
1629 | Associate this attributes provider with the table. | |
7c913512 | 1630 | |
8b9ef005 BP |
1631 | The table takes ownership of @a attrProvider pointer and will delete it |
1632 | when it doesn't need it any more. The pointer can be @NULL, however | |
1633 | this won't disable attributes management in the table but will just | |
1634 | result in a default attributes being recreated the next time any of the | |
1635 | other functions in this section is called. To completely disable the | |
1636 | attributes support, should this be needed, you need to override | |
1637 | CanHaveAttributes() to return @false. | |
1638 | */ | |
1639 | void SetAttrProvider(wxGridCellAttrProvider *attrProvider); | |
afe0e400 | 1640 | |
23324ae1 | 1641 | /** |
8b9ef005 | 1642 | Returns the attribute provider currently being used. |
23324ae1 | 1643 | |
8b9ef005 BP |
1644 | This function may return @NULL if the attribute provider hasn't been |
1645 | neither associated with this table by SetAttrProvider() nor created on | |
1646 | demand by any other methods. | |
1647 | */ | |
1648 | wxGridCellAttrProvider *GetAttrProvider() const; | |
23324ae1 FM |
1649 | |
1650 | /** | |
8b9ef005 | 1651 | Return the attribute for the given cell. |
23324ae1 | 1652 | |
8b9ef005 BP |
1653 | By default this function is simply forwarded to |
1654 | wxGridCellAttrProvider::GetAttr() but it may be overridden to handle | |
1655 | attributes directly in the table. | |
1656 | */ | |
1657 | virtual wxGridCellAttr *GetAttr(int row, int col, | |
1658 | wxGridCellAttr::wxAttrKind kind); | |
23324ae1 FM |
1659 | |
1660 | /** | |
8b9ef005 | 1661 | Set attribute of the specified cell. |
23324ae1 | 1662 | |
8b9ef005 BP |
1663 | By default this function is simply forwarded to |
1664 | wxGridCellAttrProvider::SetAttr(). | |
1665 | ||
1666 | The table takes ownership of @a attr, i.e. will call DecRef() on it. | |
1667 | */ | |
1668 | virtual void SetAttr(wxGridCellAttr* attr, int row, int col); | |
23324ae1 FM |
1669 | |
1670 | /** | |
8b9ef005 | 1671 | Set attribute of the specified row. |
23324ae1 | 1672 | |
8b9ef005 BP |
1673 | By default this function is simply forwarded to |
1674 | wxGridCellAttrProvider::SetRowAttr(). | |
23324ae1 | 1675 | |
8b9ef005 BP |
1676 | The table takes ownership of @a attr, i.e. will call DecRef() on it. |
1677 | */ | |
1678 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); | |
e54c96f1 | 1679 | |
8b9ef005 BP |
1680 | /** |
1681 | Set attribute of the specified column. | |
7c913512 | 1682 | |
8b9ef005 BP |
1683 | By default this function is simply forwarded to |
1684 | wxGridCellAttrProvider::SetColAttr(). | |
7c913512 | 1685 | |
8b9ef005 BP |
1686 | The table takes ownership of @a attr, i.e. will call DecRef() on it. |
1687 | */ | |
1688 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
1689 | ||
1690 | //@} | |
7c913512 | 1691 | |
23324ae1 | 1692 | /** |
8b9ef005 BP |
1693 | Returns true if this table supports attributes or false otherwise. |
1694 | ||
1695 | By default, the table automatically creates a wxGridCellAttrProvider | |
1696 | when this function is called if it had no attribute provider before and | |
1697 | returns @true. | |
1698 | */ | |
1699 | virtual bool CanHaveAttributes(); | |
23324ae1 FM |
1700 | }; |
1701 | ||
cd64c053 RD |
1702 | |
1703 | ||
1704 | enum wxGridTableRequest | |
1705 | { | |
1706 | wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000, | |
1707 | wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES, | |
1708 | wxGRIDTABLE_NOTIFY_ROWS_INSERTED, | |
1709 | wxGRIDTABLE_NOTIFY_ROWS_APPENDED, | |
1710 | wxGRIDTABLE_NOTIFY_ROWS_DELETED, | |
1711 | wxGRIDTABLE_NOTIFY_COLS_INSERTED, | |
1712 | wxGRIDTABLE_NOTIFY_COLS_APPENDED, | |
1713 | wxGRIDTABLE_NOTIFY_COLS_DELETED | |
1714 | }; | |
1715 | ||
1716 | ||
1717 | /** | |
1718 | @class wxGridTableMessage | |
1719 | ||
1720 | A simple class used to pass messages from the table to the grid. | |
1721 | ||
1722 | @library{wxadv} | |
1723 | @category{grid} | |
1724 | */ | |
1725 | class wxGridTableMessage | |
1726 | { | |
1727 | public: | |
1728 | wxGridTableMessage(); | |
1729 | wxGridTableMessage( wxGridTableBase *table, int id, | |
1730 | int comInt1 = -1, | |
1731 | int comInt2 = -1 ); | |
1732 | ||
1733 | void SetTableObject( wxGridTableBase *table ); | |
1734 | wxGridTableBase * GetTableObject() const; | |
1735 | void SetId( int id ); | |
1736 | int GetId(); | |
1737 | void SetCommandInt( int comInt1 ); | |
1738 | int GetCommandInt(); | |
1739 | void SetCommandInt2( int comInt2 ); | |
1740 | int GetCommandInt2(); | |
1741 | }; | |
1742 | ||
1743 | ||
1744 | ||
1745 | /** | |
1746 | @class wxGridStringTable | |
1747 | ||
1748 | Simplest type of data table for a grid for small tables of strings | |
1749 | that are stored in memory | |
1750 | */ | |
1751 | class wxGridStringTable : public wxGridTableBase | |
1752 | { | |
1753 | public: | |
1754 | wxGridStringTable(); | |
1755 | wxGridStringTable( int numRows, int numCols ); | |
1756 | ||
1757 | // these are pure virtual in wxGridTableBase | |
1758 | virtual int GetNumberRows(); | |
1759 | virtual int GetNumberCols(); | |
1760 | virtual wxString GetValue( int row, int col ); | |
1761 | virtual void SetValue( int row, int col, const wxString& value ); | |
1762 | ||
1763 | // overridden functions from wxGridTableBase | |
1764 | void Clear(); | |
1765 | bool InsertRows( size_t pos = 0, size_t numRows = 1 ); | |
1766 | bool AppendRows( size_t numRows = 1 ); | |
1767 | bool DeleteRows( size_t pos = 0, size_t numRows = 1 ); | |
1768 | bool InsertCols( size_t pos = 0, size_t numCols = 1 ); | |
1769 | bool AppendCols( size_t numCols = 1 ); | |
1770 | bool DeleteCols( size_t pos = 0, size_t numCols = 1 ); | |
1771 | ||
1772 | void SetRowLabelValue( int row, const wxString& ); | |
1773 | void SetColLabelValue( int col, const wxString& ); | |
1774 | wxString GetRowLabelValue( int row ); | |
1775 | wxString GetColLabelValue( int col ); | |
1776 | }; | |
1777 | ||
1778 | ||
1779 | ||
1780 | ||
1781 | ||
1782 | ||
574e1c5a VZ |
1783 | /** |
1784 | @class wxGridSizesInfo | |
1785 | ||
1786 | wxGridSizesInfo stores information about sizes of all wxGrid rows or | |
d455444a | 1787 | columns. |
574e1c5a VZ |
1788 | |
1789 | It assumes that most of the rows or columns (which are both called elements | |
1790 | here as the difference between them doesn't matter at this class level) | |
1791 | have the default size and so stores it separately. And it uses a wxHashMap | |
1792 | to store the sizes of all elements which have the non-default size. | |
1793 | ||
1794 | This structure is particularly useful for serializing the sizes of all | |
1795 | wxGrid elements at once. | |
1796 | ||
1797 | @library{wxadv} | |
1798 | @category{grid} | |
1799 | */ | |
1800 | struct wxGridSizesInfo | |
1801 | { | |
1802 | /** | |
1803 | Default constructor. | |
1804 | ||
1805 | m_sizeDefault and m_customSizes must be initialized later. | |
1806 | */ | |
1807 | wxGridSizesInfo(); | |
1808 | ||
1809 | /** | |
1810 | Constructor. | |
1811 | ||
1812 | This constructor is used by wxGrid::GetRowSizes() and GetColSizes() | |
1813 | methods. User code will usually use the default constructor instead. | |
1814 | ||
1815 | @param defSize | |
1816 | The default element size. | |
d455444a | 1817 | @param allSizes |
574e1c5a VZ |
1818 | Array containing the sizes of @em all elements, including those |
1819 | which have the default size. | |
1820 | */ | |
1821 | wxGridSizesInfo(int defSize, const wxArrayInt& allSizes); | |
1822 | ||
1823 | /** | |
1824 | Get the element size. | |
1825 | ||
1826 | @param pos | |
1827 | The index of the element. | |
1828 | @return | |
1829 | The size for this element, using m_customSizes if @a pos is in it | |
1830 | or m_sizeDefault otherwise. | |
1831 | */ | |
1832 | int GetSize(unsigned pos) const; | |
1833 | ||
1834 | ||
1835 | /// Default size | |
1836 | int m_sizeDefault; | |
1837 | ||
1838 | /** | |
1839 | Map with element indices as keys and their sizes as values. | |
1840 | ||
1841 | This map only contains the elements with non-default size. | |
1842 | */ | |
1843 | wxUnsignedToIntHashMap m_customSizes; | |
1844 | }; | |
23324ae1 | 1845 | |
e54c96f1 | 1846 | |
42dd5e3b RD |
1847 | |
1848 | /** | |
1849 | Rendering styles supported by wxGrid::Render() method. | |
1850 | ||
1851 | @since 2.9.4 | |
1852 | */ | |
1853 | enum wxGridRenderStyle | |
1854 | { | |
1855 | /// Draw grid row header labels. | |
1856 | wxGRID_DRAW_ROWS_HEADER = 0x001, | |
1857 | ||
1858 | /// Draw grid column header labels. | |
1859 | wxGRID_DRAW_COLS_HEADER = 0x002, | |
1860 | ||
1861 | /// Draw grid cell border lines. | |
1862 | wxGRID_DRAW_CELL_LINES = 0x004, | |
1863 | ||
1864 | /** | |
1865 | Draw a bounding rectangle around the rendered cell area. | |
1866 | ||
1867 | Useful where row or column headers are not drawn or where there is | |
1868 | multi row or column cell clipping and therefore no cell border at | |
1869 | the rendered outer boundary. | |
1870 | */ | |
1871 | wxGRID_DRAW_BOX_RECT = 0x008, | |
1872 | ||
1873 | /** | |
1874 | Draw the grid cell selection highlight if a selection is present. | |
1875 | ||
1876 | At present the highlight colour drawn depends on whether the grid | |
1877 | window loses focus before drawing begins. | |
1878 | */ | |
1879 | wxGRID_DRAW_SELECTION = 0x010, | |
1880 | ||
1881 | /** | |
1882 | The default render style. | |
1883 | ||
1884 | Includes all except wxGRID_DRAW_SELECTION. | |
1885 | */ | |
1886 | wxGRID_DRAW_DEFAULT = wxGRID_DRAW_ROWS_HEADER | | |
1887 | wxGRID_DRAW_COLS_HEADER | | |
1888 | wxGRID_DRAW_CELL_LINES | | |
1889 | wxGRID_DRAW_BOX_RECT | |
1890 | }; | |
1891 | ||
1892 | ||
1893 | ||
23324ae1 | 1894 | /** |
8b9ef005 | 1895 | @class wxGrid |
7c913512 | 1896 | |
8b9ef005 | 1897 | wxGrid and its related classes are used for displaying and editing tabular |
caac7804 BP |
1898 | data. They provide a rich set of features for display, editing, and |
1899 | interacting with a variety of data sources. For simple applications, and to | |
1900 | help you get started, wxGrid is the only class you need to refer to | |
1901 | directly. It will set up default instances of the other classes and manage | |
1902 | them for you. For more complex applications you can derive your own classes | |
1903 | for custom grid views, grid data tables, cell editors and renderers. The | |
1904 | @ref overview_grid has examples of simple and more complex applications, | |
8b9ef005 BP |
1905 | explains the relationship between the various grid classes and has a |
1906 | summary of the keyboard shortcuts and mouse functions provided by wxGrid. | |
7c913512 | 1907 | |
8b9ef005 BP |
1908 | A wxGridTableBase class holds the actual data to be displayed by a wxGrid |
1909 | class. One or more wxGrid classes may act as a view for one table class. | |
1910 | The default table class is called wxGridStringTable and holds an array of | |
caac7804 | 1911 | strings. An instance of such a class is created by CreateGrid(). |
23324ae1 | 1912 | |
d13b34d3 | 1913 | wxGridCellRenderer is the abstract base class for rendering contents in a |
8b9ef005 | 1914 | cell. The following renderers are predefined: |
caac7804 BP |
1915 | |
1916 | - wxGridCellBoolRenderer | |
1917 | - wxGridCellFloatRenderer | |
1918 | - wxGridCellNumberRenderer | |
1919 | - wxGridCellStringRenderer | |
1920 | ||
8b9ef005 | 1921 | The look of a cell can be further defined using wxGridCellAttr. An object |
caac7804 | 1922 | of this type may be returned by wxGridTableBase::GetAttr(). |
3c4f71cc | 1923 | |
8b9ef005 BP |
1924 | wxGridCellEditor is the abstract base class for editing the value of a |
1925 | cell. The following editors are predefined: | |
caac7804 BP |
1926 | |
1927 | - wxGridCellBoolEditor | |
1928 | - wxGridCellChoiceEditor | |
1929 | - wxGridCellFloatEditor | |
1930 | - wxGridCellNumberEditor | |
1931 | - wxGridCellTextEditor | |
f8f31de6 | 1932 | |
caac7804 BP |
1933 | Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and |
1934 | wxGridEditorCreatedEvent for the documentation of all event types you can | |
1935 | use with wxGrid. | |
8b9ef005 BP |
1936 | |
1937 | @library{wxadv} | |
1938 | @category{grid} | |
23324ae1 | 1939 | |
caac7804 | 1940 | @see @ref overview_grid, wxGridUpdateLocker |
8b9ef005 BP |
1941 | */ |
1942 | class wxGrid : public wxScrolledWindow | |
1943 | { | |
1944 | public: | |
caac7804 | 1945 | |
23324ae1 | 1946 | /** |
8b9ef005 BP |
1947 | Different selection modes supported by the grid. |
1948 | */ | |
1949 | enum wxGridSelectionModes | |
1950 | { | |
1951 | /** | |
1952 | The default selection mode allowing selection of the individual | |
1953 | cells as well as of the entire rows and columns. | |
1954 | */ | |
1955 | wxGridSelectCells, | |
23324ae1 | 1956 | |
8b9ef005 BP |
1957 | /** |
1958 | The selection mode allowing the selection of the entire rows only. | |
3c4f71cc | 1959 | |
8b9ef005 BP |
1960 | The user won't be able to select any cells or columns in this mode. |
1961 | */ | |
1962 | wxGridSelectRows, | |
23324ae1 | 1963 | |
8b9ef005 BP |
1964 | /** |
1965 | The selection mode allowing the selection of the entire columns only. | |
3c4f71cc | 1966 | |
8b9ef005 BP |
1967 | The user won't be able to select any cells or rows in this mode. |
1968 | */ | |
b08cf4f4 VZ |
1969 | wxGridSelectColumns, |
1970 | ||
1971 | /** | |
1972 | The selection mode allowing the user to select either the entire | |
1973 | columns or the entire rows but not individual cells nor blocks. | |
1974 | ||
1975 | Notice that while this constant is defined as @code | |
1976 | wxGridSelectColumns | wxGridSelectRows @endcode this doesn't mean | |
1977 | that all the other combinations are valid -- at least currently | |
1978 | they are not. | |
1979 | ||
1980 | @since 2.9.1 | |
1981 | */ | |
1982 | wxGridSelectRowsOrColumns | |
8b9ef005 | 1983 | }; |
23324ae1 | 1984 | |
ea99e8e3 VZ |
1985 | /** |
1986 | Return values for GetCellSize(). | |
1987 | ||
1988 | @since 2.9.1 | |
1989 | */ | |
1990 | enum CellSpan | |
1991 | { | |
1992 | /// This cell is inside a span covered by another cell. | |
1993 | CellSpan_Inside = -1, | |
1994 | ||
1995 | /// This is a normal, non-spanning cell. | |
1996 | CellSpan_None = 0, | |
1997 | ||
1998 | /// This cell spans several physical wxGrid cells. | |
1999 | CellSpan_Main | |
2000 | }; | |
caac7804 | 2001 | |
1dc17bca VZ |
2002 | /** |
2003 | Constants defining different support built-in TAB handling behaviours. | |
2004 | ||
2005 | The elements of this enum determine what happens when TAB is pressed | |
2006 | when the cursor is in the rightmost column (or Shift-TAB is pressed | |
2007 | when the cursor is in the leftmost one). | |
2008 | ||
2009 | @see SetTabBehaviour(), @c wxEVT_GRID_TABBING | |
2010 | ||
2011 | @since 2.9.5 | |
2012 | */ | |
2013 | enum TabBehaviour | |
2014 | { | |
2015 | /// Do nothing, this is default. | |
2016 | Tab_Stop, | |
2017 | ||
2018 | /// Move to the beginning of the next (or the end of the previous) row. | |
2019 | Tab_Wrap, | |
2020 | ||
2021 | /// Move to the next (or the previous) control after the grid. | |
2022 | Tab_Leave | |
2023 | }; | |
2024 | ||
caac7804 BP |
2025 | /** |
2026 | @name Constructors and Initialization | |
2027 | */ | |
2028 | //@{ | |
2029 | ||
23324ae1 | 2030 | /** |
8b9ef005 | 2031 | Default constructor. |
3c4f71cc | 2032 | |
8b9ef005 BP |
2033 | You must call Create() to really create the grid window and also call |
2034 | CreateGrid() or SetTable() to initialize the grid contents. | |
2035 | */ | |
2036 | wxGrid(); | |
23324ae1 | 2037 | /** |
8b9ef005 | 2038 | Constructor creating the grid window. |
3c4f71cc | 2039 | |
8b9ef005 BP |
2040 | You must call either CreateGrid() or SetTable() to initialize the grid |
2041 | contents before using it. | |
23324ae1 | 2042 | */ |
caac7804 | 2043 | wxGrid(wxWindow* parent, wxWindowID id, |
8b9ef005 BP |
2044 | const wxPoint& pos = wxDefaultPosition, |
2045 | const wxSize& size = wxDefaultSize, | |
2046 | long style = wxWANTS_CHARS, | |
2047 | const wxString& name = wxGridNameStr); | |
23324ae1 | 2048 | |
caac7804 BP |
2049 | /** |
2050 | Destructor. | |
2051 | ||
2052 | This will also destroy the associated grid table unless you passed a | |
2053 | table object to the grid and specified that the grid should not take | |
2054 | ownership of the table (see SetTable()). | |
2055 | */ | |
2056 | virtual ~wxGrid(); | |
2057 | ||
23324ae1 | 2058 | /** |
8b9ef005 BP |
2059 | Creates the grid window for an object initialized using the default |
2060 | constructor. | |
3c4f71cc | 2061 | |
8b9ef005 BP |
2062 | You must call either CreateGrid() or SetTable() to initialize the grid |
2063 | contents before using it. | |
2064 | */ | |
caac7804 | 2065 | bool Create(wxWindow* parent, wxWindowID id, |
8b9ef005 BP |
2066 | const wxPoint& pos = wxDefaultPosition, |
2067 | const wxSize& size = wxDefaultSize, | |
2068 | long style = wxWANTS_CHARS, | |
2069 | const wxString& name = wxGridNameStr); | |
23324ae1 FM |
2070 | |
2071 | /** | |
caac7804 | 2072 | Creates a grid with the specified initial number of rows and columns. |
3c4f71cc | 2073 | |
caac7804 BP |
2074 | Call this directly after the grid constructor. When you use this |
2075 | function wxGrid will create and manage a simple table of string values | |
2076 | for you. All of the grid data will be stored in memory. | |
2077 | ||
2078 | For applications with more complex data types or relationships, or for | |
2079 | dealing with very large datasets, you should derive your own grid table | |
2080 | class and pass a table object to the grid with SetTable(). | |
23324ae1 | 2081 | */ |
caac7804 BP |
2082 | bool CreateGrid(int numRows, int numCols, |
2083 | wxGridSelectionModes selmode = wxGridSelectCells); | |
23324ae1 FM |
2084 | |
2085 | /** | |
caac7804 | 2086 | Passes a pointer to a custom grid table to be used by the grid. |
3c4f71cc | 2087 | |
caac7804 BP |
2088 | This should be called after the grid constructor and before using the |
2089 | grid object. If @a takeOwnership is set to @true then the table will be | |
2090 | deleted by the wxGrid destructor. | |
3c4f71cc | 2091 | |
caac7804 BP |
2092 | Use this function instead of CreateGrid() when your application |
2093 | involves complex or non-string data or data sets that are too large to | |
2094 | fit wholly in memory. | |
23324ae1 | 2095 | */ |
caac7804 BP |
2096 | bool SetTable(wxGridTableBase* table, bool takeOwnership = false, |
2097 | wxGridSelectionModes selmode = wxGridSelectCells); | |
23324ae1 | 2098 | |
cd64c053 RD |
2099 | /** |
2100 | Receive and handle a message from the table. | |
2101 | */ | |
2102 | bool ProcessTableMessage(wxGridTableMessage& msg); | |
2103 | ||
caac7804 | 2104 | //@} |
8b9ef005 | 2105 | |
3c4f71cc | 2106 | |
caac7804 BP |
2107 | /** |
2108 | @name Grid Line Formatting | |
2109 | */ | |
2110 | //@{ | |
2111 | ||
2112 | /** | |
2113 | Turns the drawing of grid lines on or off. | |
23324ae1 | 2114 | */ |
caac7804 | 2115 | void EnableGridLines(bool enable = true); |
23324ae1 FM |
2116 | |
2117 | /** | |
caac7804 | 2118 | Returns the pen used for vertical grid lines. |
3c4f71cc | 2119 | |
caac7804 BP |
2120 | This virtual function may be overridden in derived classes in order to |
2121 | change the appearance of individual grid lines for the given column | |
2122 | @a col. | |
23324ae1 | 2123 | |
caac7804 BP |
2124 | See GetRowGridLinePen() for an example. |
2125 | */ | |
2126 | virtual wxPen GetColGridLinePen(int col); | |
23324ae1 FM |
2127 | |
2128 | /** | |
caac7804 | 2129 | Returns the pen used for grid lines. |
23324ae1 | 2130 | |
caac7804 BP |
2131 | This virtual function may be overridden in derived classes in order to |
2132 | change the appearance of grid lines. Note that currently the pen width | |
2133 | must be 1. | |
3c4f71cc | 2134 | |
caac7804 BP |
2135 | @see GetColGridLinePen(), GetRowGridLinePen() |
2136 | */ | |
2137 | virtual wxPen GetDefaultGridLinePen(); | |
23324ae1 FM |
2138 | |
2139 | /** | |
caac7804 BP |
2140 | Returns the colour used for grid lines. |
2141 | ||
2142 | @see GetDefaultGridLinePen() | |
23324ae1 | 2143 | */ |
caac7804 | 2144 | wxColour GetGridLineColour() const; |
23324ae1 FM |
2145 | |
2146 | /** | |
caac7804 BP |
2147 | Returns the pen used for horizontal grid lines. |
2148 | ||
2149 | This virtual function may be overridden in derived classes in order to | |
2150 | change the appearance of individual grid line for the given @a row. | |
2151 | ||
2152 | Example: | |
2153 | @code | |
2154 | // in a grid displaying music notation, use a solid black pen between | |
2155 | // octaves (C0=row 127, C1=row 115 etc.) | |
2156 | wxPen MidiGrid::GetRowGridLinePen(int row) | |
2157 | { | |
2158 | if ( row % 12 == 7 ) | |
2159 | return wxPen(*wxBLACK, 1, wxSOLID); | |
2160 | else | |
2161 | return GetDefaultGridLinePen(); | |
2162 | } | |
2163 | @endcode | |
23324ae1 | 2164 | */ |
caac7804 | 2165 | virtual wxPen GetRowGridLinePen(int row); |
23324ae1 FM |
2166 | |
2167 | /** | |
caac7804 | 2168 | Returns @true if drawing of grid lines is turned on, @false otherwise. |
23324ae1 | 2169 | */ |
caac7804 | 2170 | bool GridLinesEnabled() const; |
23324ae1 FM |
2171 | |
2172 | /** | |
caac7804 | 2173 | Sets the colour used to draw grid lines. |
23324ae1 | 2174 | */ |
caac7804 BP |
2175 | void SetGridLineColour(const wxColour& colour); |
2176 | ||
2177 | //@} | |
2178 | ||
23324ae1 FM |
2179 | |
2180 | /** | |
caac7804 BP |
2181 | @name Label Values and Formatting |
2182 | */ | |
2183 | //@{ | |
23324ae1 FM |
2184 | |
2185 | /** | |
caac7804 BP |
2186 | Sets the arguments to the current column label alignment values. |
2187 | ||
2188 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE | |
2189 | or @c wxALIGN_RIGHT. | |
2190 | ||
2191 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
2192 | @c wxALIGN_BOTTOM. | |
23324ae1 | 2193 | */ |
caac7804 | 2194 | void GetColLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
2195 | |
2196 | /** | |
caac7804 BP |
2197 | Returns the orientation of the column labels (either @c wxHORIZONTAL or |
2198 | @c wxVERTICAL). | |
23324ae1 | 2199 | */ |
caac7804 | 2200 | int GetColLabelTextOrientation() const; |
23324ae1 FM |
2201 | |
2202 | /** | |
caac7804 | 2203 | Returns the specified column label. |
7c913512 | 2204 | |
caac7804 BP |
2205 | The default grid table class provides column labels of the form |
2206 | A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can | |
2207 | override wxGridTableBase::GetColLabelValue() to provide your own | |
2208 | labels. | |
23324ae1 | 2209 | */ |
caac7804 | 2210 | wxString GetColLabelValue(int col) const; |
23324ae1 | 2211 | |
8b9ef005 | 2212 | /** |
caac7804 BP |
2213 | Returns the colour used for the background of row and column labels. |
2214 | */ | |
2215 | wxColour GetLabelBackgroundColour() const; | |
e54c96f1 | 2216 | |
caac7804 BP |
2217 | /** |
2218 | Returns the font used for row and column labels. | |
2219 | */ | |
2220 | wxFont GetLabelFont() const; | |
7c913512 | 2221 | |
caac7804 BP |
2222 | /** |
2223 | Returns the colour used for row and column label text. | |
8b9ef005 | 2224 | */ |
caac7804 | 2225 | wxColour GetLabelTextColour() const; |
7c913512 | 2226 | |
23324ae1 | 2227 | /** |
caac7804 | 2228 | Returns the alignment used for row labels. |
3c4f71cc | 2229 | |
caac7804 BP |
2230 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
2231 | or @c wxALIGN_RIGHT. | |
2232 | ||
2233 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
2234 | @c wxALIGN_BOTTOM. | |
23324ae1 | 2235 | */ |
caac7804 | 2236 | void GetRowLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
2237 | |
2238 | /** | |
caac7804 | 2239 | Returns the specified row label. |
23324ae1 | 2240 | |
caac7804 BP |
2241 | The default grid table class provides numeric row labels. If you are |
2242 | using a custom grid table you can override | |
2243 | wxGridTableBase::GetRowLabelValue() to provide your own labels. | |
23324ae1 | 2244 | */ |
caac7804 | 2245 | wxString GetRowLabelValue(int row) const; |
23324ae1 FM |
2246 | |
2247 | /** | |
caac7804 BP |
2248 | Hides the column labels by calling SetColLabelSize() with a size of 0. |
2249 | Show labels again by calling that method with a width greater than 0. | |
23324ae1 | 2250 | */ |
caac7804 | 2251 | void HideColLabels(); |
23324ae1 FM |
2252 | |
2253 | /** | |
caac7804 | 2254 | Hides the row labels by calling SetRowLabelSize() with a size of 0. |
23324ae1 | 2255 | |
caac7804 BP |
2256 | The labels can be shown again by calling SetRowLabelSize() with a width |
2257 | greater than 0. | |
23324ae1 | 2258 | */ |
caac7804 | 2259 | void HideRowLabels(); |
23324ae1 FM |
2260 | |
2261 | /** | |
caac7804 | 2262 | Sets the horizontal and vertical alignment of column label text. |
23324ae1 | 2263 | |
caac7804 BP |
2264 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
2265 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one | |
2266 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
23324ae1 | 2267 | */ |
caac7804 | 2268 | void SetColLabelAlignment(int horiz, int vert); |
23324ae1 FM |
2269 | |
2270 | /** | |
caac7804 BP |
2271 | Sets the orientation of the column labels (either @c wxHORIZONTAL or |
2272 | @c wxVERTICAL). | |
8b9ef005 | 2273 | */ |
caac7804 | 2274 | void SetColLabelTextOrientation(int textOrientation); |
7c913512 | 2275 | |
23324ae1 | 2276 | /** |
caac7804 | 2277 | Set the value for the given column label. |
8b9ef005 | 2278 | |
caac7804 BP |
2279 | If you are using a custom grid table you must override |
2280 | wxGridTableBase::SetColLabelValue() for this to have any effect. | |
23324ae1 | 2281 | */ |
caac7804 | 2282 | void SetColLabelValue(int col, const wxString& value); |
23324ae1 FM |
2283 | |
2284 | /** | |
caac7804 | 2285 | Sets the background colour for row and column labels. |
23324ae1 | 2286 | */ |
caac7804 | 2287 | void SetLabelBackgroundColour(const wxColour& colour); |
23324ae1 | 2288 | |
8b9ef005 | 2289 | /** |
caac7804 BP |
2290 | Sets the font for row and column labels. |
2291 | */ | |
2292 | void SetLabelFont(const wxFont& font); | |
55f0bf1f | 2293 | |
8b9ef005 | 2294 | /** |
caac7804 BP |
2295 | Sets the colour for row and column label text. |
2296 | */ | |
2297 | void SetLabelTextColour(const wxColour& colour); | |
55f0bf1f | 2298 | |
8b9ef005 | 2299 | /** |
caac7804 | 2300 | Sets the horizontal and vertical alignment of row label text. |
7c913512 | 2301 | |
caac7804 BP |
2302 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
2303 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one | |
2304 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
8b9ef005 | 2305 | */ |
caac7804 | 2306 | void SetRowLabelAlignment(int horiz, int vert); |
7c913512 | 2307 | |
23324ae1 | 2308 | /** |
caac7804 | 2309 | Sets the value for the given row label. |
55f0bf1f | 2310 | |
caac7804 BP |
2311 | If you are using a derived grid table you must override |
2312 | wxGridTableBase::SetRowLabelValue() for this to have any effect. | |
8b9ef005 | 2313 | */ |
caac7804 | 2314 | void SetRowLabelValue(int row, const wxString& value); |
55f0bf1f | 2315 | |
8b9ef005 | 2316 | /** |
caac7804 | 2317 | Call this in order to make the column labels use a native look by using |
03faec76 | 2318 | wxRendererNative::DrawHeaderButton() internally. |
55f0bf1f | 2319 | |
caac7804 BP |
2320 | There is no equivalent method for drawing row columns as there is not |
2321 | native look for that. This option is useful when using wxGrid for | |
2322 | displaying tables and not as a spread-sheet. | |
ad805b9e | 2323 | |
03faec76 | 2324 | @see UseNativeColHeader() |
8b9ef005 | 2325 | */ |
caac7804 | 2326 | void SetUseNativeColLabels(bool native = true); |
55f0bf1f | 2327 | |
ad805b9e VZ |
2328 | /** |
2329 | Enable the use of native header window for column labels. | |
2330 | ||
2331 | If this function is called with @true argument, a wxHeaderCtrl is used | |
2332 | instead to display the column labels instead of drawing them in wxGrid | |
2333 | code itself. This has the advantage of making the grid look and feel | |
2334 | perfectly the same as native applications (using SetUseNativeColLabels() | |
2335 | the grid can be made to look more natively but it still doesn't feel | |
2336 | natively, notably the column resizing and dragging still works slightly | |
2337 | differently as it is implemented in wxWidgets itself) but results in | |
2338 | different behaviour for column and row headers, for which there is no | |
2339 | equivalent function, and, most importantly, is unsuitable for grids | |
2340 | with huge numbers of columns as wxHeaderCtrl doesn't support virtual | |
2341 | mode. Because of this, by default the grid does not use the native | |
2342 | header control but you should call this function to enable it if you | |
2343 | are using the grid to display tabular data and don't have thousands of | |
2344 | columns in it. | |
2345 | ||
4a07d706 VZ |
2346 | Another difference between the default behaviour and the native header |
2347 | behaviour is that the latter provides the user with a context menu | |
2348 | (which appears on right clicking the header) allowing to rearrange the | |
2349 | grid columns if CanDragColMove() returns @true. If you want to prevent | |
2350 | this from happening for some reason, you need to define a handler for | |
2351 | @c wxEVT_GRID_LABEL_RIGHT_CLICK event which simply does nothing (in | |
2352 | particular doesn't skip the event) as this will prevent the default | |
2353 | right click handling from working. | |
2354 | ||
2355 | Also note that currently @c wxEVT_GRID_LABEL_RIGHT_DCLICK event is not | |
2356 | generated for the column labels if the native columns header is used | |
2357 | (but this limitation could possibly be lifted in the future). | |
ad805b9e VZ |
2358 | */ |
2359 | void UseNativeColHeader(bool native = true); | |
2360 | ||
caac7804 | 2361 | //@} |
55f0bf1f | 2362 | |
55f0bf1f VZ |
2363 | |
2364 | /** | |
caac7804 | 2365 | @name Cell Formatting |
55f0bf1f | 2366 | |
caac7804 BP |
2367 | Note that wxGridCellAttr can be used alternatively to most of these |
2368 | methods. See the "Attributes Management" of wxGridTableBase. | |
2369 | */ | |
2370 | //@{ | |
23324ae1 FM |
2371 | |
2372 | /** | |
caac7804 BP |
2373 | Sets the arguments to the horizontal and vertical text alignment values |
2374 | for the grid cell at the specified location. | |
55f0bf1f | 2375 | |
caac7804 BP |
2376 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
2377 | or @c wxALIGN_RIGHT. | |
2378 | ||
2379 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
2380 | @c wxALIGN_BOTTOM. | |
8b9ef005 | 2381 | */ |
caac7804 | 2382 | void GetCellAlignment(int row, int col, int* horiz, int* vert) const; |
55f0bf1f VZ |
2383 | |
2384 | /** | |
caac7804 | 2385 | Returns the background colour of the cell at the specified location. |
23324ae1 | 2386 | */ |
caac7804 | 2387 | wxColour GetCellBackgroundColour(int row, int col) const; |
23324ae1 FM |
2388 | |
2389 | /** | |
caac7804 BP |
2390 | Returns the font for text in the grid cell at the specified location. |
2391 | */ | |
2392 | wxFont GetCellFont(int row, int col) const; | |
55f0bf1f | 2393 | |
caac7804 BP |
2394 | /** |
2395 | Returns the text colour for the grid cell at the specified location. | |
23324ae1 | 2396 | */ |
caac7804 | 2397 | wxColour GetCellTextColour(int row, int col) const; |
23324ae1 FM |
2398 | |
2399 | /** | |
caac7804 BP |
2400 | Returns the default cell alignment. |
2401 | ||
2402 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE | |
2403 | or @c wxALIGN_RIGHT. | |
55f0bf1f | 2404 | |
caac7804 BP |
2405 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or |
2406 | @c wxALIGN_BOTTOM. | |
2407 | ||
2408 | @see SetDefaultCellAlignment() | |
8b9ef005 | 2409 | */ |
caac7804 | 2410 | void GetDefaultCellAlignment(int* horiz, int* vert) const; |
55f0bf1f | 2411 | |
8b9ef005 | 2412 | /** |
caac7804 | 2413 | Returns the current default background colour for grid cells. |
23324ae1 | 2414 | */ |
caac7804 | 2415 | wxColour GetDefaultCellBackgroundColour() const; |
23324ae1 | 2416 | |
9f7aee01 | 2417 | /** |
caac7804 | 2418 | Returns the current default font for grid cell text. |
8b9ef005 | 2419 | */ |
caac7804 | 2420 | wxFont GetDefaultCellFont() const; |
9f7aee01 | 2421 | |
8b9ef005 | 2422 | /** |
caac7804 | 2423 | Returns the current default colour for grid cell text. |
8b9ef005 | 2424 | */ |
caac7804 | 2425 | wxColour GetDefaultCellTextColour() const; |
9f7aee01 | 2426 | |
8b9ef005 | 2427 | /** |
caac7804 BP |
2428 | Sets the horizontal and vertical alignment for grid cell text at the |
2429 | specified location. | |
9f7aee01 | 2430 | |
caac7804 BP |
2431 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
2432 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2433 | ||
2434 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2435 | or @c wxALIGN_BOTTOM. | |
2436 | */ | |
2437 | void SetCellAlignment(int row, int col, int horiz, int vert); | |
9f7aee01 | 2438 | /** |
caac7804 BP |
2439 | Sets the horizontal and vertical alignment for grid cell text at the |
2440 | specified location. | |
9f7aee01 | 2441 | |
caac7804 BP |
2442 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
2443 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
9f7aee01 | 2444 | |
caac7804 BP |
2445 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE |
2446 | or @c wxALIGN_BOTTOM. | |
8b9ef005 | 2447 | */ |
caac7804 | 2448 | void SetCellAlignment(int align, int row, int col); |
9f7aee01 | 2449 | |
23324ae1 | 2450 | /** |
caac7804 | 2451 | Set the background colour for the given cell or all cells by default. |
23324ae1 | 2452 | */ |
caac7804 | 2453 | void SetCellBackgroundColour(int row, int col, const wxColour& colour); |
23324ae1 FM |
2454 | |
2455 | /** | |
caac7804 BP |
2456 | Sets the font for text in the grid cell at the specified location. |
2457 | */ | |
2458 | void SetCellFont(int row, int col, const wxFont& font); | |
8b9ef005 | 2459 | |
caac7804 BP |
2460 | /** |
2461 | Sets the text colour for the given cell. | |
2462 | */ | |
2463 | void SetCellTextColour(int row, int col, const wxColour& colour); | |
2464 | /** | |
2465 | Sets the text colour for the given cell. | |
2466 | */ | |
2467 | void SetCellTextColour(const wxColour& val, int row, int col); | |
2468 | /** | |
2469 | Sets the text colour for all cells by default. | |
2470 | */ | |
2471 | void SetCellTextColour(const wxColour& colour); | |
8b9ef005 | 2472 | |
caac7804 BP |
2473 | /** |
2474 | Sets the default horizontal and vertical alignment for grid cell text. | |
2475 | ||
2476 | Horizontal alignment should be one of @c wxALIGN_LEFT, | |
2477 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one | |
2478 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
23324ae1 | 2479 | */ |
caac7804 | 2480 | void SetDefaultCellAlignment(int horiz, int vert); |
23324ae1 FM |
2481 | |
2482 | /** | |
caac7804 | 2483 | Sets the default background colour for grid cells. |
23324ae1 | 2484 | */ |
caac7804 | 2485 | void SetDefaultCellBackgroundColour(const wxColour& colour); |
23324ae1 FM |
2486 | |
2487 | /** | |
caac7804 BP |
2488 | Sets the default font to be used for grid cell text. |
2489 | */ | |
2490 | void SetDefaultCellFont(const wxFont& font); | |
8b9ef005 | 2491 | |
caac7804 BP |
2492 | /** |
2493 | Sets the current default colour for grid cell text. | |
23324ae1 | 2494 | */ |
caac7804 BP |
2495 | void SetDefaultCellTextColour(const wxColour& colour); |
2496 | ||
2497 | //@} | |
2498 | ||
2499 | ||
2500 | /** | |
2501 | @name Cell Values, Editors, and Renderers | |
2502 | ||
2503 | Note that wxGridCellAttr can be used alternatively to most of these | |
2504 | methods. See the "Attributes Management" of wxGridTableBase. | |
2505 | */ | |
2506 | //@{ | |
23324ae1 FM |
2507 | |
2508 | /** | |
caac7804 BP |
2509 | Returns @true if the in-place edit control for the current grid cell |
2510 | can be used and @false otherwise. | |
2511 | ||
2512 | This function always returns @false for the read-only cells. | |
23324ae1 | 2513 | */ |
caac7804 | 2514 | bool CanEnableCellControl() const; |
23324ae1 FM |
2515 | |
2516 | /** | |
caac7804 | 2517 | Disables in-place editing of grid cells. |
8b9ef005 | 2518 | |
caac7804 BP |
2519 | Equivalent to calling EnableCellEditControl(@false). |
2520 | */ | |
2521 | void DisableCellEditControl(); | |
8b9ef005 | 2522 | |
caac7804 BP |
2523 | /** |
2524 | Enables or disables in-place editing of grid cell data. | |
2525 | ||
2526 | The grid will issue either a @c wxEVT_GRID_EDITOR_SHOWN or | |
2527 | @c wxEVT_GRID_EDITOR_HIDDEN event. | |
23324ae1 | 2528 | */ |
caac7804 | 2529 | void EnableCellEditControl(bool enable = true); |
23324ae1 FM |
2530 | |
2531 | /** | |
caac7804 BP |
2532 | Makes the grid globally editable or read-only. |
2533 | ||
2534 | If the edit argument is @false this function sets the whole grid as | |
2535 | read-only. If the argument is @true the grid is set to the default | |
2536 | state where cells may be editable. In the default state you can set | |
2537 | single grid cells and whole rows and columns to be editable or | |
2538 | read-only via wxGridCellAttr::SetReadOnly(). For single cells you | |
2539 | can also use the shortcut function SetReadOnly(). | |
2540 | ||
2541 | For more information about controlling grid cell attributes see the | |
2542 | wxGridCellAttr class and the @ref overview_grid. | |
23324ae1 | 2543 | */ |
caac7804 | 2544 | void EnableEditing(bool edit); |
23324ae1 FM |
2545 | |
2546 | /** | |
8b9ef005 | 2547 | Returns a pointer to the editor for the cell at the specified location. |
3c4f71cc | 2548 | |
caac7804 BP |
2549 | See wxGridCellEditor and the @ref overview_grid for more information |
2550 | about cell editors and renderers. | |
3c4f71cc | 2551 | |
8b9ef005 | 2552 | The caller must call DecRef() on the returned pointer. |
23324ae1 | 2553 | */ |
8b9ef005 | 2554 | wxGridCellEditor* GetCellEditor(int row, int col) const; |
23324ae1 | 2555 | |
8b9ef005 BP |
2556 | /** |
2557 | Returns a pointer to the renderer for the grid cell at the specified | |
2558 | location. | |
08dd9b5a | 2559 | |
caac7804 BP |
2560 | See wxGridCellRenderer and the @ref overview_grid for more information |
2561 | about cell editors and renderers. | |
8b9ef005 BP |
2562 | |
2563 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 2564 | */ |
8b9ef005 | 2565 | wxGridCellRenderer* GetCellRenderer(int row, int col) const; |
23324ae1 FM |
2566 | |
2567 | /** | |
caac7804 | 2568 | Returns the string contained in the cell at the specified location. |
23324ae1 | 2569 | |
caac7804 BP |
2570 | For simple applications where a grid object automatically uses a |
2571 | default grid table of string values you use this function together with | |
2572 | SetCellValue() to access cell values. For more complex applications | |
2573 | where you have derived your own grid table class that contains various | |
2574 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2575 | you only use this function for those cells that contain string values. | |
2576 | ||
2577 | See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for | |
2578 | more information. | |
2579 | */ | |
2580 | wxString GetCellValue(int row, int col) const; | |
23324ae1 | 2581 | /** |
8b9ef005 | 2582 | Returns the string contained in the cell at the specified location. |
08dd9b5a | 2583 | |
8b9ef005 BP |
2584 | For simple applications where a grid object automatically uses a |
2585 | default grid table of string values you use this function together with | |
2586 | SetCellValue() to access cell values. For more complex applications | |
2587 | where you have derived your own grid table class that contains various | |
2588 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2589 | you only use this function for those cells that contain string values. | |
2590 | ||
caac7804 BP |
2591 | See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for |
2592 | more information. | |
23324ae1 | 2593 | */ |
882678eb | 2594 | wxString GetCellValue(const wxGridCellCoords& coords) const; |
23324ae1 FM |
2595 | |
2596 | /** | |
caac7804 BP |
2597 | Returns a pointer to the current default grid cell editor. |
2598 | ||
2599 | See wxGridCellEditor and the @ref overview_grid for more information | |
2600 | about cell editors and renderers. | |
23324ae1 | 2601 | */ |
caac7804 | 2602 | wxGridCellEditor* GetDefaultEditor() const; |
23324ae1 FM |
2603 | |
2604 | /** | |
caac7804 | 2605 | Returns the default editor for the specified cell. |
08dd9b5a | 2606 | |
caac7804 BP |
2607 | The base class version returns the editor appropriate for the current |
2608 | cell type but this method may be overridden in the derived classes to | |
2609 | use custom editors for some cells by default. | |
8b9ef005 | 2610 | |
caac7804 BP |
2611 | Notice that the same may be achieved in a usually simpler way by |
2612 | associating a custom editor with the given cell or cells. | |
23324ae1 | 2613 | |
caac7804 BP |
2614 | The caller must call DecRef() on the returned pointer. |
2615 | */ | |
2616 | virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; | |
23324ae1 | 2617 | /** |
caac7804 | 2618 | Returns the default editor for the specified cell. |
08dd9b5a | 2619 | |
caac7804 BP |
2620 | The base class version returns the editor appropriate for the current |
2621 | cell type but this method may be overridden in the derived classes to | |
2622 | use custom editors for some cells by default. | |
8b9ef005 | 2623 | |
caac7804 BP |
2624 | Notice that the same may be achieved in a usually simpler way by |
2625 | associating a custom editor with the given cell or cells. | |
23324ae1 | 2626 | |
caac7804 | 2627 | The caller must call DecRef() on the returned pointer. |
23324ae1 | 2628 | */ |
caac7804 | 2629 | wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const; |
23324ae1 FM |
2630 | |
2631 | /** | |
caac7804 BP |
2632 | Returns the default editor for the cells containing values of the given |
2633 | type. | |
55f0bf1f | 2634 | |
caac7804 BP |
2635 | The base class version returns the editor which was associated with the |
2636 | specified @a typeName when it was registered RegisterDataType() but | |
2637 | this function may be overridden to return something different. This | |
2638 | allows to override an editor used for one of the standard types. | |
2639 | ||
2640 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 2641 | */ |
caac7804 | 2642 | virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; |
23324ae1 FM |
2643 | |
2644 | /** | |
caac7804 | 2645 | Returns a pointer to the current default grid cell renderer. |
8b9ef005 | 2646 | |
caac7804 BP |
2647 | See wxGridCellRenderer and the @ref overview_grid for more information |
2648 | about cell editors and renderers. | |
2649 | ||
2650 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 2651 | */ |
caac7804 | 2652 | wxGridCellRenderer* GetDefaultRenderer() const; |
23324ae1 | 2653 | |
9f7aee01 | 2654 | /** |
caac7804 BP |
2655 | Returns the default renderer for the given cell. |
2656 | ||
2657 | The base class version returns the renderer appropriate for the current | |
2658 | cell type but this method may be overridden in the derived classes to | |
2659 | use custom renderers for some cells by default. | |
2660 | ||
2661 | The caller must call DecRef() on the returned pointer. | |
8b9ef005 | 2662 | */ |
caac7804 | 2663 | virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; |
9f7aee01 | 2664 | |
8b9ef005 | 2665 | /** |
caac7804 BP |
2666 | Returns the default renderer for the cell containing values of the |
2667 | given type. | |
9f7aee01 | 2668 | |
caac7804 | 2669 | @see GetDefaultEditorForType() |
8b9ef005 | 2670 | */ |
caac7804 | 2671 | virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; |
08dd9b5a | 2672 | |
8b9ef005 | 2673 | /** |
caac7804 | 2674 | Hides the in-place cell edit control. |
23324ae1 | 2675 | */ |
caac7804 | 2676 | void HideCellEditControl(); |
23324ae1 FM |
2677 | |
2678 | /** | |
caac7804 | 2679 | Returns @true if the in-place edit control is currently enabled. |
8b9ef005 | 2680 | */ |
caac7804 | 2681 | bool IsCellEditControlEnabled() const; |
3c4f71cc | 2682 | |
8b9ef005 | 2683 | /** |
caac7804 | 2684 | Returns @true if the current cell is read-only. |
3c4f71cc | 2685 | |
caac7804 | 2686 | @see SetReadOnly(), IsReadOnly() |
23324ae1 | 2687 | */ |
caac7804 | 2688 | bool IsCurrentCellReadOnly() const; |
23324ae1 FM |
2689 | |
2690 | /** | |
caac7804 BP |
2691 | Returns @false if the whole grid has been set as read-only or @true |
2692 | otherwise. | |
2693 | ||
2694 | See EnableEditing() for more information about controlling the editing | |
2695 | status of grid cells. | |
8b9ef005 | 2696 | */ |
caac7804 | 2697 | bool IsEditable() const; |
23324ae1 | 2698 | |
8b9ef005 | 2699 | /** |
caac7804 | 2700 | Returns @true if the cell at the specified location can't be edited. |
55f0bf1f | 2701 | |
caac7804 | 2702 | @see SetReadOnly(), IsCurrentCellReadOnly() |
23324ae1 | 2703 | */ |
caac7804 | 2704 | bool IsReadOnly(int row, int col) const; |
23324ae1 FM |
2705 | |
2706 | /** | |
caac7804 | 2707 | Register a new data type. |
08dd9b5a | 2708 | |
caac7804 BP |
2709 | The data types allow to naturally associate specific renderers and |
2710 | editors to the cells containing values of the given type. For example, | |
2711 | the grid automatically registers a data type with the name | |
2712 | @c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and | |
2713 | wxGridCellTextEditor as its renderer and editor respectively -- this is | |
2714 | the data type used by all the cells of the default wxGridStringTable, | |
2715 | so this renderer and editor are used by default for all grid cells. | |
8b9ef005 | 2716 | |
caac7804 BP |
2717 | However if a custom table returns @c wxGRID_VALUE_BOOL from its |
2718 | wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and | |
2719 | wxGridCellBoolEditor are used for it because the grid also registers a | |
2720 | boolean data type with this name. | |
8b9ef005 | 2721 | |
caac7804 BP |
2722 | And as this mechanism is completely generic, you may register your own |
2723 | data types using your own custom renderers and editors. Just remember | |
2724 | that the table must identify a cell as being of the given type for them | |
2725 | to be used for this cell. | |
2726 | ||
2727 | @param typeName | |
2728 | Name of the new type. May be any string, but if the type name is | |
2729 | the same as the name of an already registered type, including one | |
2730 | of the standard ones (which are @c wxGRID_VALUE_STRING, @c | |
2731 | wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT | |
2732 | and @c wxGRID_VALUE_CHOICE), then the new registration information | |
2733 | replaces the previously used renderer and editor. | |
2734 | @param renderer | |
2735 | The renderer to use for the cells of this type. Its ownership is | |
2736 | taken by the grid, i.e. it will call DecRef() on this pointer when | |
2737 | it doesn't need it any longer. | |
2738 | @param editor | |
2739 | The editor to use for the cells of this type. Its ownership is also | |
2740 | taken by the grid. | |
23324ae1 | 2741 | */ |
caac7804 BP |
2742 | void RegisterDataType(const wxString& typeName, |
2743 | wxGridCellRenderer* renderer, | |
2744 | wxGridCellEditor* editor); | |
23324ae1 FM |
2745 | |
2746 | /** | |
caac7804 BP |
2747 | Sets the value of the current grid cell to the current in-place edit |
2748 | control value. | |
55f0bf1f | 2749 | |
caac7804 BP |
2750 | This is called automatically when the grid cursor moves from the |
2751 | current cell to a new cell. It is also a good idea to call this | |
2752 | function when closing a grid since any edits to the final cell location | |
2753 | will not be saved otherwise. | |
23324ae1 | 2754 | */ |
caac7804 | 2755 | void SaveEditControlValue(); |
23324ae1 FM |
2756 | |
2757 | /** | |
caac7804 | 2758 | Sets the editor for the grid cell at the specified location. |
55f0bf1f | 2759 | |
caac7804 | 2760 | The grid will take ownership of the pointer. |
8b9ef005 | 2761 | |
caac7804 BP |
2762 | See wxGridCellEditor and the @ref overview_grid for more information |
2763 | about cell editors and renderers. | |
23324ae1 | 2764 | */ |
caac7804 | 2765 | void SetCellEditor(int row, int col, wxGridCellEditor* editor); |
23324ae1 FM |
2766 | |
2767 | /** | |
caac7804 | 2768 | Sets the renderer for the grid cell at the specified location. |
55f0bf1f | 2769 | |
caac7804 | 2770 | The grid will take ownership of the pointer. |
8b9ef005 | 2771 | |
caac7804 BP |
2772 | See wxGridCellRenderer and the @ref overview_grid for more information |
2773 | about cell editors and renderers. | |
23324ae1 | 2774 | */ |
caac7804 | 2775 | void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer); |
23324ae1 FM |
2776 | |
2777 | /** | |
caac7804 | 2778 | Sets the string value for the cell at the specified location. |
55f0bf1f | 2779 | |
caac7804 BP |
2780 | For simple applications where a grid object automatically uses a |
2781 | default grid table of string values you use this function together with | |
2782 | GetCellValue() to access cell values. For more complex applications | |
2783 | where you have derived your own grid table class that contains various | |
2784 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2785 | you only use this function for those cells that contain string values. | |
8b9ef005 | 2786 | |
caac7804 BP |
2787 | See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for |
2788 | more information. | |
23324ae1 | 2789 | */ |
caac7804 | 2790 | void SetCellValue(int row, int col, const wxString& s); |
23324ae1 | 2791 | /** |
caac7804 | 2792 | Sets the string value for the cell at the specified location. |
55f0bf1f | 2793 | |
caac7804 BP |
2794 | For simple applications where a grid object automatically uses a |
2795 | default grid table of string values you use this function together with | |
2796 | GetCellValue() to access cell values. For more complex applications | |
2797 | where you have derived your own grid table class that contains various | |
2798 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2799 | you only use this function for those cells that contain string values. | |
23324ae1 | 2800 | |
caac7804 BP |
2801 | See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for |
2802 | more information. | |
23324ae1 | 2803 | */ |
caac7804 | 2804 | void SetCellValue(const wxGridCellCoords& coords, const wxString& s); |
23324ae1 | 2805 | /** |
caac7804 BP |
2806 | @deprecated Please use SetCellValue(int,int,const wxString&) or |
2807 | SetCellValue(const wxGridCellCoords&,const wxString&) | |
2808 | instead. | |
23324ae1 | 2809 | |
caac7804 | 2810 | Sets the string value for the cell at the specified location. |
23324ae1 | 2811 | |
caac7804 BP |
2812 | For simple applications where a grid object automatically uses a |
2813 | default grid table of string values you use this function together with | |
2814 | GetCellValue() to access cell values. For more complex applications | |
2815 | where you have derived your own grid table class that contains various | |
2816 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2817 | you only use this function for those cells that contain string values. | |
2818 | ||
2819 | See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for | |
2820 | more information. | |
23324ae1 | 2821 | */ |
caac7804 | 2822 | void SetCellValue(const wxString& val, int row, int col); |
23324ae1 FM |
2823 | |
2824 | /** | |
caac7804 | 2825 | Sets the specified column to display boolean values. |
55f0bf1f | 2826 | |
caac7804 | 2827 | @see SetColFormatCustom() |
23324ae1 | 2828 | */ |
caac7804 | 2829 | void SetColFormatBool(int col); |
23324ae1 FM |
2830 | |
2831 | /** | |
caac7804 | 2832 | Sets the specified column to display data in a custom format. |
23324ae1 | 2833 | |
caac7804 BP |
2834 | This method provides an alternative to defining a custom grid table |
2835 | which would return @a typeName from its GetTypeName() method for the | |
2836 | cells in this column: while it doesn't really change the type of the | |
2837 | cells in this column, it does associate the renderer and editor used | |
2838 | for the cells of the specified type with them. | |
23324ae1 | 2839 | |
caac7804 BP |
2840 | See the @ref overview_grid for more information on working with custom |
2841 | data types. | |
23324ae1 | 2842 | */ |
caac7804 | 2843 | void SetColFormatCustom(int col, const wxString& typeName); |
23324ae1 FM |
2844 | |
2845 | /** | |
caac7804 BP |
2846 | Sets the specified column to display floating point values with the |
2847 | given width and precision. | |
55f0bf1f | 2848 | |
caac7804 | 2849 | @see SetColFormatCustom() |
23324ae1 | 2850 | */ |
caac7804 | 2851 | void SetColFormatFloat(int col, int width = -1, int precision = -1); |
23324ae1 FM |
2852 | |
2853 | /** | |
caac7804 | 2854 | Sets the specified column to display integer values. |
8b9ef005 | 2855 | |
caac7804 | 2856 | @see SetColFormatCustom() |
23324ae1 | 2857 | */ |
caac7804 | 2858 | void SetColFormatNumber(int col); |
23324ae1 FM |
2859 | |
2860 | /** | |
caac7804 | 2861 | Sets the default editor for grid cells. |
3c4f71cc | 2862 | |
caac7804 | 2863 | The grid will take ownership of the pointer. |
55f0bf1f | 2864 | |
caac7804 BP |
2865 | See wxGridCellEditor and the @ref overview_grid for more information |
2866 | about cell editors and renderers. | |
23324ae1 | 2867 | */ |
caac7804 | 2868 | void SetDefaultEditor(wxGridCellEditor* editor); |
23324ae1 FM |
2869 | |
2870 | /** | |
caac7804 | 2871 | Sets the default renderer for grid cells. |
8b9ef005 | 2872 | |
caac7804 | 2873 | The grid will take ownership of the pointer. |
8b9ef005 | 2874 | |
caac7804 BP |
2875 | See wxGridCellRenderer and the @ref overview_grid for more information |
2876 | about cell editors and renderers. | |
23324ae1 | 2877 | */ |
caac7804 | 2878 | void SetDefaultRenderer(wxGridCellRenderer* renderer); |
23324ae1 FM |
2879 | |
2880 | /** | |
caac7804 | 2881 | Makes the cell at the specified location read-only or editable. |
08dd9b5a | 2882 | |
caac7804 | 2883 | @see IsReadOnly() |
23324ae1 | 2884 | */ |
caac7804 | 2885 | void SetReadOnly(int row, int col, bool isReadOnly = true); |
23324ae1 FM |
2886 | |
2887 | /** | |
caac7804 | 2888 | Displays the in-place cell edit control for the current cell. |
23324ae1 | 2889 | */ |
caac7804 | 2890 | void ShowCellEditControl(); |
23324ae1 | 2891 | |
caac7804 | 2892 | //@} |
23324ae1 | 2893 | |
23324ae1 | 2894 | |
23324ae1 | 2895 | /** |
caac7804 | 2896 | @name Column and Row Sizes |
82edfbe7 | 2897 | |
32bcf974 | 2898 | @see @ref overview_grid_resizing |
caac7804 BP |
2899 | */ |
2900 | //@{ | |
08dd9b5a | 2901 | |
caac7804 BP |
2902 | /** |
2903 | Automatically sets the height and width of all rows and columns to fit | |
2904 | their contents. | |
23324ae1 | 2905 | */ |
caac7804 | 2906 | void AutoSize(); |
23324ae1 FM |
2907 | |
2908 | /** | |
caac7804 | 2909 | Automatically adjusts width of the column to fit its label. |
23324ae1 | 2910 | */ |
caac7804 | 2911 | void AutoSizeColLabelSize(int col); |
23324ae1 FM |
2912 | |
2913 | /** | |
caac7804 BP |
2914 | Automatically sizes the column to fit its contents. If @a setAsMin is |
2915 | @true the calculated width will also be set as the minimal width for | |
2916 | the column. | |
2917 | */ | |
2918 | void AutoSizeColumn(int col, bool setAsMin = true); | |
23324ae1 FM |
2919 | |
2920 | /** | |
caac7804 BP |
2921 | Automatically sizes all columns to fit their contents. If @a setAsMin |
2922 | is @true the calculated widths will also be set as the minimal widths | |
2923 | for the columns. | |
23324ae1 | 2924 | */ |
caac7804 | 2925 | void AutoSizeColumns(bool setAsMin = true); |
23324ae1 FM |
2926 | |
2927 | /** | |
caac7804 BP |
2928 | Automatically sizes the row to fit its contents. If @a setAsMin is |
2929 | @true the calculated height will also be set as the minimal height for | |
2930 | the row. | |
23324ae1 | 2931 | */ |
caac7804 | 2932 | void AutoSizeRow(int row, bool setAsMin = true); |
23324ae1 | 2933 | |
23324ae1 | 2934 | /** |
caac7804 | 2935 | Automatically adjusts height of the row to fit its label. |
23324ae1 | 2936 | */ |
caac7804 | 2937 | void AutoSizeRowLabelSize(int col); |
23324ae1 | 2938 | |
23324ae1 | 2939 | /** |
caac7804 BP |
2940 | Automatically sizes all rows to fit their contents. If @a setAsMin is |
2941 | @true the calculated heights will also be set as the minimal heights | |
2942 | for the rows. | |
23324ae1 | 2943 | */ |
caac7804 | 2944 | void AutoSizeRows(bool setAsMin = true); |
23324ae1 | 2945 | |
bf472047 VZ |
2946 | /** |
2947 | Returns @true if the cell value can overflow. | |
2948 | ||
2949 | A cell can overflow if the next cell in the row is empty. | |
2950 | */ | |
2951 | bool GetCellOverflow(int row, int col) const; | |
2952 | ||
23324ae1 | 2953 | /** |
caac7804 | 2954 | Returns the current height of the column labels. |
23324ae1 | 2955 | */ |
caac7804 | 2956 | int GetColLabelSize() const; |
23324ae1 FM |
2957 | |
2958 | /** | |
caac7804 | 2959 | Returns the minimal width to which a column may be resized. |
08dd9b5a | 2960 | |
caac7804 BP |
2961 | Use SetColMinimalAcceptableWidth() to change this value globally or |
2962 | SetColMinimalWidth() to do it for individual columns. | |
08dd9b5a | 2963 | |
caac7804 | 2964 | @see GetRowMinimalAcceptableHeight() |
23324ae1 | 2965 | */ |
caac7804 | 2966 | int GetColMinimalAcceptableWidth() const; |
23324ae1 FM |
2967 | |
2968 | /** | |
caac7804 | 2969 | Returns the width of the specified column. |
23324ae1 | 2970 | */ |
caac7804 | 2971 | int GetColSize(int col) const; |
23324ae1 | 2972 | |
fe79f76b VZ |
2973 | /** |
2974 | Returns @true if the specified column is not currently hidden. | |
2975 | */ | |
2976 | bool IsColShown(int col) const; | |
2977 | ||
bf472047 VZ |
2978 | /** |
2979 | Returns @true if the cells can overflow by default. | |
2980 | */ | |
2981 | bool GetDefaultCellOverflow() const; | |
2982 | ||
23324ae1 | 2983 | /** |
caac7804 | 2984 | Returns the default height for column labels. |
23324ae1 | 2985 | */ |
caac7804 | 2986 | int GetDefaultColLabelSize() const; |
23324ae1 FM |
2987 | |
2988 | /** | |
caac7804 | 2989 | Returns the current default width for grid columns. |
23324ae1 | 2990 | */ |
caac7804 | 2991 | int GetDefaultColSize() const; |
23324ae1 FM |
2992 | |
2993 | /** | |
caac7804 BP |
2994 | Returns the default width for the row labels. |
2995 | */ | |
2996 | int GetDefaultRowLabelSize() const; | |
08dd9b5a | 2997 | |
caac7804 BP |
2998 | /** |
2999 | Returns the current default height for grid rows. | |
23324ae1 | 3000 | */ |
caac7804 | 3001 | int GetDefaultRowSize() const; |
23324ae1 | 3002 | |
23324ae1 | 3003 | /** |
caac7804 | 3004 | Returns the minimal size to which rows can be resized. |
08dd9b5a | 3005 | |
caac7804 BP |
3006 | Use SetRowMinimalAcceptableHeight() to change this value globally or |
3007 | SetRowMinimalHeight() to do it for individual cells. | |
23324ae1 | 3008 | |
caac7804 | 3009 | @see GetColMinimalAcceptableWidth() |
23324ae1 | 3010 | */ |
caac7804 | 3011 | int GetRowMinimalAcceptableHeight() const; |
23324ae1 FM |
3012 | |
3013 | /** | |
caac7804 | 3014 | Returns the current width of the row labels. |
23324ae1 | 3015 | */ |
caac7804 | 3016 | int GetRowLabelSize() const; |
23324ae1 FM |
3017 | |
3018 | /** | |
caac7804 | 3019 | Returns the height of the specified row. |
8b9ef005 | 3020 | */ |
caac7804 | 3021 | int GetRowSize(int row) const; |
08dd9b5a | 3022 | |
fe79f76b VZ |
3023 | /** |
3024 | Returns @true if the specified row is not currently hidden. | |
3025 | */ | |
3026 | bool IsRowShown(int row) const; | |
3027 | ||
bf472047 VZ |
3028 | /** |
3029 | Sets the overflow permission of the cell. | |
3030 | */ | |
3031 | void SetCellOverflow(int row, int col, bool allow); | |
3032 | ||
8b9ef005 | 3033 | /** |
caac7804 | 3034 | Sets the height of the column labels. |
08dd9b5a | 3035 | |
caac7804 BP |
3036 | If @a height equals to @c wxGRID_AUTOSIZE then height is calculated |
3037 | automatically so that no label is truncated. Note that this could be | |
3038 | slow for a large table. | |
23324ae1 | 3039 | */ |
caac7804 | 3040 | void SetColLabelSize(int height); |
23324ae1 FM |
3041 | |
3042 | /** | |
caac7804 | 3043 | Sets the minimal @a width to which the user can resize columns. |
08dd9b5a | 3044 | |
caac7804 | 3045 | @see GetColMinimalAcceptableWidth() |
23324ae1 | 3046 | */ |
caac7804 | 3047 | void SetColMinimalAcceptableWidth(int width); |
23324ae1 FM |
3048 | |
3049 | /** | |
caac7804 | 3050 | Sets the minimal @a width for the specified column @a col. |
3c4f71cc | 3051 | |
caac7804 BP |
3052 | It is usually best to call this method during grid creation as calling |
3053 | it later will not resize the column to the given minimal width even if | |
3054 | it is currently narrower than it. | |
23324ae1 | 3055 | |
caac7804 BP |
3056 | @a width must be greater than the minimal acceptable column width as |
3057 | returned by GetColMinimalAcceptableWidth(). | |
23324ae1 | 3058 | */ |
caac7804 | 3059 | void SetColMinimalWidth(int col, int width); |
23324ae1 FM |
3060 | |
3061 | /** | |
caac7804 BP |
3062 | Sets the width of the specified column. |
3063 | ||
caac7804 BP |
3064 | @param col |
3065 | The column index. | |
3066 | @param width | |
009c7216 VZ |
3067 | The new column width in pixels, 0 to hide the column or -1 to fit |
3068 | the column width to its label width. | |
23324ae1 | 3069 | */ |
caac7804 | 3070 | void SetColSize(int col, int width); |
23324ae1 | 3071 | |
009c7216 VZ |
3072 | /** |
3073 | Hides the specified column. | |
3074 | ||
3075 | To show the column later you need to call SetColSize() with non-0 | |
30496905 VZ |
3076 | width or ShowCol() to restore the previous column width. |
3077 | ||
2328f468 | 3078 | If the column is already hidden, this method doesn't do anything. |
009c7216 VZ |
3079 | |
3080 | @param col | |
3081 | The column index. | |
3082 | */ | |
3083 | void HideCol(int col); | |
3084 | ||
3085 | /** | |
3086 | Shows the previously hidden column by resizing it to non-0 size. | |
3087 | ||
30496905 VZ |
3088 | The column is shown again with the same width that it had before |
3089 | HideCol() call. | |
3090 | ||
2328f468 | 3091 | If the column is currently shown, this method doesn't do anything. |
30496905 | 3092 | |
009c7216 VZ |
3093 | @see HideCol(), SetColSize() |
3094 | */ | |
3095 | void ShowCol(int col); | |
3096 | ||
3097 | ||
bf472047 VZ |
3098 | /** |
3099 | Sets the default overflow permission of the cells. | |
3100 | */ | |
3101 | void SetDefaultCellOverflow( bool allow ); | |
3102 | ||
23324ae1 | 3103 | /** |
caac7804 | 3104 | Sets the default width for columns in the grid. |
23324ae1 | 3105 | |
caac7804 BP |
3106 | This will only affect columns subsequently added to the grid unless |
3107 | @a resizeExistingCols is @true. | |
3108 | ||
3109 | If @a width is less than GetColMinimalAcceptableWidth(), then the | |
3110 | minimal acceptable width is used instead of it. | |
23324ae1 | 3111 | */ |
caac7804 | 3112 | void SetDefaultColSize(int width, bool resizeExistingCols = false); |
23324ae1 FM |
3113 | |
3114 | /** | |
caac7804 | 3115 | Sets the default height for rows in the grid. |
3c4f71cc | 3116 | |
caac7804 BP |
3117 | This will only affect rows subsequently added to the grid unless |
3118 | @a resizeExistingRows is @true. | |
3119 | ||
3120 | If @a height is less than GetRowMinimalAcceptableHeight(), then the | |
d13b34d3 | 3121 | minimal acceptable height is used instead of it. |
23324ae1 | 3122 | */ |
caac7804 | 3123 | void SetDefaultRowSize(int height, bool resizeExistingRows = false); |
23324ae1 FM |
3124 | |
3125 | /** | |
caac7804 BP |
3126 | Sets the width of the row labels. |
3127 | ||
3128 | If @a width equals @c wxGRID_AUTOSIZE then width is calculated | |
3129 | automatically so that no label is truncated. Note that this could be | |
3130 | slow for a large table. | |
23324ae1 | 3131 | */ |
caac7804 | 3132 | void SetRowLabelSize(int width); |
23324ae1 FM |
3133 | |
3134 | /** | |
caac7804 | 3135 | Sets the minimal row @a height used by default. |
8b9ef005 | 3136 | |
caac7804 | 3137 | See SetColMinimalAcceptableWidth() for more information. |
23324ae1 | 3138 | */ |
caac7804 | 3139 | void SetRowMinimalAcceptableHeight(int height); |
23324ae1 FM |
3140 | |
3141 | /** | |
caac7804 BP |
3142 | Sets the minimal @a height for the specified @a row. |
3143 | ||
3144 | See SetColMinimalWidth() for more information. | |
23324ae1 | 3145 | */ |
caac7804 | 3146 | void SetRowMinimalHeight(int row, int height); |
23324ae1 FM |
3147 | |
3148 | /** | |
caac7804 | 3149 | Sets the height of the specified row. |
08dd9b5a | 3150 | |
caac7804 | 3151 | See SetColSize() for more information. |
23324ae1 | 3152 | */ |
caac7804 BP |
3153 | void SetRowSize(int row, int height); |
3154 | ||
009c7216 VZ |
3155 | /** |
3156 | Hides the specified row. | |
3157 | ||
3158 | To show the row later you need to call SetRowSize() with non-0 | |
30496905 | 3159 | width or ShowRow() to restore its original height. |
009c7216 | 3160 | |
2328f468 VZ |
3161 | If the row is already hidden, this method doesn't do anything. |
3162 | ||
009c7216 VZ |
3163 | @param col |
3164 | The row index. | |
3165 | */ | |
3166 | void HideRow(int col); | |
3167 | ||
3168 | /** | |
30496905 VZ |
3169 | Shows the previously hidden row. |
3170 | ||
3171 | The row is shown again with the same height that it had before | |
3172 | HideRow() call. | |
009c7216 | 3173 | |
2328f468 VZ |
3174 | If the row is currently shown, this method doesn't do anything. |
3175 | ||
009c7216 VZ |
3176 | @see HideRow(), SetRowSize() |
3177 | */ | |
3178 | void ShowRow(int col); | |
3179 | ||
574e1c5a VZ |
3180 | /** |
3181 | Get size information for all columns at once. | |
3182 | ||
3183 | This method is useful when the information about all column widths | |
3184 | needs to be saved. The widths can be later restored using | |
3185 | SetColSizes(). | |
3186 | ||
3187 | @sa wxGridSizesInfo, GetRowSizes() | |
3188 | */ | |
3189 | wxGridSizesInfo GetColSizes() const; | |
3190 | ||
3191 | /** | |
3192 | Get size information for all row at once. | |
3193 | ||
3194 | @sa wxGridSizesInfo, GetColSizes() | |
3195 | */ | |
3196 | wxGridSizesInfo GetRowSizes() const; | |
3197 | ||
3198 | /** | |
3199 | Restore all columns sizes. | |
3200 | ||
3201 | This is usually called with wxGridSizesInfo object previously returned | |
3202 | by GetColSizes(). | |
3203 | ||
3204 | @sa SetRowSizes() | |
3205 | */ | |
3206 | void SetColSizes(const wxGridSizesInfo& sizeInfo); | |
3207 | ||
3208 | /** | |
3209 | Restore all rows sizes. | |
3210 | ||
3211 | @sa SetColSizes() | |
3212 | */ | |
3213 | void SetRowSizes(const wxGridSizesInfo& sizeInfo); | |
3214 | ||
ea99e8e3 VZ |
3215 | /** |
3216 | Set the size of the cell. | |
3217 | ||
3218 | Specifying a value of more than 1 in @a num_rows or @a num_cols will | |
3219 | make the cell at (@a row, @a col) span the block of the specified size, | |
3220 | covering the other cells which would be normally shown in it. Passing 1 | |
3221 | for both arguments resets the cell to normal appearance. | |
3222 | ||
3223 | @see GetCellSize() | |
3224 | ||
3225 | @param row | |
3226 | The row of the cell. | |
3227 | @param col | |
3228 | The column of the cell. | |
3229 | @param num_rows | |
3230 | Number of rows to be occupied by this cell, must be >= 1. | |
3231 | @param num_cols | |
3232 | Number of columns to be occupied by this cell, must be >= 1. | |
3233 | */ | |
3234 | void SetCellSize(int row, int col, int num_rows, int num_cols); | |
3235 | ||
3236 | /** | |
3237 | Get the size of the cell in number of cells covered by it. | |
3238 | ||
3239 | For normal cells, the function fills both @a num_rows and @a num_cols | |
3240 | with 1 and returns CellSpan_None. For cells which span multiple cells, i.e. | |
3241 | for which SetCellSize() had been called, the returned values are the | |
3242 | same ones as were passed to SetCellSize() call and the function return | |
3243 | value is CellSpan_Main. | |
3244 | ||
3245 | More unexpectedly, perhaps, the returned values may be @em negative for | |
3246 | the cells which are inside a span covered by a cell occupying multiple | |
3247 | rows or columns. They correspond to the offset of the main cell of the | |
3248 | span from the cell passed to this functions and the function returns | |
3249 | CellSpan_Inside value to indicate this. | |
3250 | ||
3251 | As an example, consider a 3*3 grid with the cell (1, 1) (the one in the | |
3252 | middle) having a span of 2 rows and 2 columns, i.e. the grid looks like | |
3253 | @code | |
3254 | +----+----+----+ | |
3255 | | | | | | |
3256 | +----+----+----+ | |
3257 | | | | | |
3258 | +----+ | | |
3259 | | | | | |
3260 | +----+----+----+ | |
3261 | @endcode | |
3262 | Then the function returns 2 and 2 in @a num_rows and @a num_cols for | |
3263 | the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1 | |
3264 | and 0 for the cell (2, 1). | |
3265 | ||
3266 | @param row | |
3267 | The row of the cell. | |
3268 | @param col | |
3269 | The column of the cell. | |
3270 | @param num_rows | |
3271 | Pointer to variable receiving the number of rows, must not be @NULL. | |
3272 | @param num_cols | |
3273 | Pointer to variable receiving the number of columns, must not be | |
3274 | @NULL. | |
3275 | @return | |
3276 | The kind of this cell span (the return value is new in wxWidgets | |
3277 | 2.9.1, this function was void in previous wxWidgets versions). | |
3278 | */ | |
3279 | CellSpan GetCellSize( int row, int col, int *num_rows, int *num_cols ) const; | |
3280 | ||
3281 | /** | |
3282 | Get the number of rows and columns allocated for this cell. | |
3283 | ||
3284 | This overload doesn't return a CellSpan value but the values returned | |
3285 | may still be negative, see GetCellSize(int, int, int *, int *) for | |
3286 | details. | |
3287 | */ | |
3288 | wxSize GetCellSize(const wxGridCellCoords& coords); | |
3289 | ||
8b9ef005 | 3290 | //@} |
23324ae1 | 3291 | |
caac7804 | 3292 | |
23324ae1 | 3293 | /** |
caac7804 | 3294 | @name User-Resizing and Dragging |
82edfbe7 VZ |
3295 | |
3296 | Functions controlling various interactive mouse operations. | |
3297 | ||
3298 | By default, columns and rows can be resized by dragging the edges of | |
3299 | their labels (this can be disabled using DisableDragColSize() and | |
3300 | DisableDragRowSize() methods). And if grid line dragging is enabled with | |
3301 | EnableDragGridSize() they can also be resized by dragging the right or | |
3302 | bottom edge of the grid cells. | |
3303 | ||
3304 | Columns can also be moved to interactively change their order but this | |
3305 | needs to be explicitly enabled with EnableDragColMove(). | |
caac7804 BP |
3306 | */ |
3307 | //@{ | |
08dd9b5a | 3308 | |
caac7804 BP |
3309 | /** |
3310 | Return @true if the dragging of cells is enabled or @false otherwise. | |
23324ae1 | 3311 | */ |
caac7804 | 3312 | bool CanDragCell() const; |
23324ae1 FM |
3313 | |
3314 | /** | |
caac7804 | 3315 | Returns @true if columns can be moved by dragging with the mouse. |
08dd9b5a | 3316 | |
caac7804 | 3317 | Columns can be moved by dragging on their labels. |
23324ae1 | 3318 | */ |
caac7804 | 3319 | bool CanDragColMove() const; |
23324ae1 FM |
3320 | |
3321 | /** | |
82edfbe7 VZ |
3322 | Returns @true if the given column can be resized by dragging with the |
3323 | mouse. | |
8b9ef005 | 3324 | |
82edfbe7 VZ |
3325 | This function returns @true if resizing the columns interactively is |
3326 | globally enabled, i.e. if DisableDragColSize() hadn't been called, and | |
3327 | if this column wasn't explicitly marked as non-resizable with | |
3328 | DisableColResize(). | |
23324ae1 | 3329 | */ |
82edfbe7 | 3330 | bool CanDragColSize(int col) const; |
23324ae1 FM |
3331 | |
3332 | /** | |
caac7804 BP |
3333 | Return @true if the dragging of grid lines to resize rows and columns |
3334 | is enabled or @false otherwise. | |
3335 | */ | |
3336 | bool CanDragGridSize() const; | |
3337 | ||
3338 | /** | |
82edfbe7 VZ |
3339 | Returns @true if the given row can be resized by dragging with the |
3340 | mouse. | |
caac7804 | 3341 | |
82edfbe7 | 3342 | This is the same as CanDragColSize() but for rows. |
caac7804 | 3343 | */ |
82edfbe7 VZ |
3344 | bool CanDragRowSize(int row) const; |
3345 | ||
3346 | /** | |
3347 | Disable interactive resizing of the specified column. | |
3348 | ||
3349 | This method allows to disable resizing of an individual column in a | |
3350 | grid where the columns are otherwise resizable (which is the case by | |
3351 | default). | |
3352 | ||
3353 | Notice that currently there is no way to make some columns resizable in | |
3354 | a grid where columns can't be resized by default as there doesn't seem | |
3355 | to be any need for this in practice. There is also no way to make the | |
d13b34d3 | 3356 | column marked as fixed using this method resizable again because it is |
82edfbe7 VZ |
3357 | supposed that fixed columns are used for static parts of the grid and |
3358 | so should remain fixed during the entire grid lifetime. | |
3359 | ||
3360 | Also notice that disabling interactive column resizing will not prevent | |
3361 | the program from changing the column size. | |
3362 | ||
3363 | @see EnableDragColSize() | |
3364 | */ | |
3365 | void DisableColResize(int col); | |
3366 | ||
3367 | /** | |
3368 | Disable interactive resizing of the specified row. | |
3369 | ||
3370 | This is the same as DisableColResize() but for rows. | |
3371 | ||
3372 | @see EnableDragRowSize() | |
3373 | */ | |
3374 | void DisableRowResize(int row); | |
caac7804 BP |
3375 | |
3376 | /** | |
3377 | Disables column moving by dragging with the mouse. | |
3378 | ||
3379 | Equivalent to passing @false to EnableDragColMove(). | |
3380 | */ | |
3381 | void DisableDragColMove(); | |
3382 | ||
3383 | /** | |
3384 | Disables column sizing by dragging with the mouse. | |
3385 | ||
3386 | Equivalent to passing @false to EnableDragColSize(). | |
3387 | */ | |
3388 | void DisableDragColSize(); | |
3389 | ||
3390 | /** | |
3391 | Disable mouse dragging of grid lines to resize rows and columns. | |
3392 | ||
3393 | Equivalent to passing @false to EnableDragGridSize() | |
3394 | */ | |
3395 | void DisableDragGridSize(); | |
3396 | ||
3397 | /** | |
3398 | Disables row sizing by dragging with the mouse. | |
3399 | ||
3400 | Equivalent to passing @false to EnableDragRowSize(). | |
3401 | */ | |
3402 | void DisableDragRowSize(); | |
3403 | ||
3404 | /** | |
3405 | Enables or disables cell dragging with the mouse. | |
3406 | */ | |
3407 | void EnableDragCell(bool enable = true); | |
3408 | ||
3409 | /** | |
3410 | Enables or disables column moving by dragging with the mouse. | |
3411 | */ | |
3412 | void EnableDragColMove(bool enable = true); | |
3413 | ||
3414 | /** | |
3415 | Enables or disables column sizing by dragging with the mouse. | |
82edfbe7 VZ |
3416 | |
3417 | @see DisableColResize() | |
caac7804 BP |
3418 | */ |
3419 | void EnableDragColSize(bool enable = true); | |
3420 | ||
3421 | /** | |
3422 | Enables or disables row and column resizing by dragging gridlines with | |
3423 | the mouse. | |
3424 | */ | |
3425 | void EnableDragGridSize(bool enable = true); | |
3426 | ||
3427 | /** | |
3428 | Enables or disables row sizing by dragging with the mouse. | |
82edfbe7 VZ |
3429 | |
3430 | @see DisableRowResize() | |
caac7804 BP |
3431 | */ |
3432 | void EnableDragRowSize(bool enable = true); | |
3433 | ||
3434 | /** | |
3435 | Returns the column ID of the specified column position. | |
3436 | */ | |
3437 | int GetColAt(int colPos) const; | |
3438 | ||
3439 | /** | |
3440 | Returns the position of the specified column. | |
3441 | */ | |
3442 | int GetColPos(int colID) const; | |
3443 | ||
3444 | /** | |
3445 | Sets the position of the specified column. | |
3446 | */ | |
3447 | void SetColPos(int colID, int newPos); | |
3448 | ||
31ec8b4e VZ |
3449 | /** |
3450 | Sets the positions of all columns at once. | |
3451 | ||
3452 | This method takes an array containing the indices of the columns in | |
3453 | their display order, i.e. uses the same convention as | |
3454 | wxHeaderCtrl::SetColumnsOrder(). | |
f8f31de6 | 3455 | */ |
31ec8b4e VZ |
3456 | void SetColumnsOrder(const wxArrayInt& order); |
3457 | ||
009c7216 VZ |
3458 | /** |
3459 | Resets the position of the columns to the default. | |
f8f31de6 | 3460 | */ |
009c7216 VZ |
3461 | void ResetColPos(); |
3462 | ||
caac7804 BP |
3463 | //@} |
3464 | ||
3465 | ||
3466 | /** | |
3467 | @name Cursor Movement | |
f8f31de6 | 3468 | */ |
caac7804 BP |
3469 | //@{ |
3470 | ||
3471 | /** | |
3472 | Returns the current grid cell column position. | |
3473 | */ | |
3474 | int GetGridCursorCol() const; | |
3475 | ||
3476 | /** | |
3477 | Returns the current grid cell row position. | |
3478 | */ | |
3479 | int GetGridCursorRow() const; | |
3480 | ||
3481 | /** | |
3482 | Make the given cell current and ensure it is visible. | |
3483 | ||
3484 | This method is equivalent to calling MakeCellVisible() and | |
3485 | SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL | |
3486 | event is generated by it and the selected cell doesn't change if the | |
3487 | event is vetoed. | |
3488 | */ | |
3489 | void GoToCell(int row, int col); | |
3490 | /** | |
3491 | Make the given cell current and ensure it is visible. | |
3492 | ||
3493 | This method is equivalent to calling MakeCellVisible() and | |
3494 | SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL | |
3495 | event is generated by it and the selected cell doesn't change if the | |
3496 | event is vetoed. | |
3497 | */ | |
3498 | void GoToCell(const wxGridCellCoords& coords); | |
3499 | ||
3500 | /** | |
3501 | Moves the grid cursor down by one row. | |
3502 | ||
3503 | If a block of cells was previously selected it will expand if the | |
3504 | argument is @true or be cleared if the argument is @false. | |
3505 | */ | |
3506 | bool MoveCursorDown(bool expandSelection); | |
3507 | ||
3508 | /** | |
3509 | Moves the grid cursor down in the current column such that it skips to | |
3510 | the beginning or end of a block of non-empty cells. | |
3511 | ||
3512 | If a block of cells was previously selected it will expand if the | |
3513 | argument is @true or be cleared if the argument is @false. | |
3514 | */ | |
3515 | bool MoveCursorDownBlock(bool expandSelection); | |
3516 | ||
3517 | /** | |
3518 | Moves the grid cursor left by one column. | |
08dd9b5a | 3519 | |
8b9ef005 BP |
3520 | If a block of cells was previously selected it will expand if the |
3521 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3522 | */ |
8b9ef005 | 3523 | bool MoveCursorLeft(bool expandSelection); |
23324ae1 FM |
3524 | |
3525 | /** | |
8b9ef005 BP |
3526 | Moves the grid cursor left in the current row such that it skips to the |
3527 | beginning or end of a block of non-empty cells. | |
3528 | ||
3529 | If a block of cells was previously selected it will expand if the | |
3530 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3531 | */ |
8b9ef005 | 3532 | bool MoveCursorLeftBlock(bool expandSelection); |
23324ae1 FM |
3533 | |
3534 | /** | |
8b9ef005 | 3535 | Moves the grid cursor right by one column. |
08dd9b5a | 3536 | |
8b9ef005 BP |
3537 | If a block of cells was previously selected it will expand if the |
3538 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3539 | */ |
8b9ef005 | 3540 | bool MoveCursorRight(bool expandSelection); |
23324ae1 FM |
3541 | |
3542 | /** | |
8b9ef005 BP |
3543 | Moves the grid cursor right in the current row such that it skips to |
3544 | the beginning or end of a block of non-empty cells. | |
08dd9b5a | 3545 | |
8b9ef005 BP |
3546 | If a block of cells was previously selected it will expand if the |
3547 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3548 | */ |
8b9ef005 | 3549 | bool MoveCursorRightBlock(bool expandSelection); |
23324ae1 | 3550 | |
23324ae1 | 3551 | /** |
8b9ef005 BP |
3552 | Moves the grid cursor up by one row. |
3553 | ||
3554 | If a block of cells was previously selected it will expand if the | |
3555 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3556 | */ |
8b9ef005 | 3557 | bool MoveCursorUp(bool expandSelection); |
23324ae1 FM |
3558 | |
3559 | /** | |
8b9ef005 BP |
3560 | Moves the grid cursor up in the current column such that it skips to |
3561 | the beginning or end of a block of non-empty cells. | |
3c4f71cc | 3562 | |
8b9ef005 BP |
3563 | If a block of cells was previously selected it will expand if the |
3564 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3565 | */ |
8b9ef005 | 3566 | bool MoveCursorUpBlock(bool expandSelection); |
23324ae1 FM |
3567 | |
3568 | /** | |
8b9ef005 BP |
3569 | Moves the grid cursor down by some number of rows so that the previous |
3570 | bottom visible row becomes the top visible row. | |
3571 | */ | |
3572 | bool MovePageDown(); | |
3c4f71cc | 3573 | |
8b9ef005 BP |
3574 | /** |
3575 | Moves the grid cursor up by some number of rows so that the previous | |
3576 | top visible row becomes the bottom visible row. | |
23324ae1 | 3577 | */ |
8b9ef005 | 3578 | bool MovePageUp(); |
23324ae1 FM |
3579 | |
3580 | /** | |
caac7804 | 3581 | Set the grid cursor to the specified cell. |
08dd9b5a | 3582 | |
caac7804 BP |
3583 | The grid cursor indicates the current cell and can be moved by the user |
3584 | using the arrow keys or the mouse. | |
8b9ef005 | 3585 | |
caac7804 BP |
3586 | Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and |
3587 | if the event handler vetoes this event, the cursor is not moved. | |
8b9ef005 | 3588 | |
caac7804 BP |
3589 | This function doesn't make the target call visible, use GoToCell() to |
3590 | do this. | |
23324ae1 | 3591 | */ |
caac7804 | 3592 | void SetGridCursor(int row, int col); |
23324ae1 | 3593 | /** |
caac7804 | 3594 | Set the grid cursor to the specified cell. |
23324ae1 | 3595 | |
caac7804 BP |
3596 | The grid cursor indicates the current cell and can be moved by the user |
3597 | using the arrow keys or the mouse. | |
bb778cae | 3598 | |
caac7804 BP |
3599 | Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and |
3600 | if the event handler vetoes this event, the cursor is not moved. | |
8b9ef005 | 3601 | |
caac7804 BP |
3602 | This function doesn't make the target call visible, use GoToCell() to |
3603 | do this. | |
23324ae1 | 3604 | */ |
caac7804 BP |
3605 | void SetGridCursor(const wxGridCellCoords& coords); |
3606 | ||
1dc17bca VZ |
3607 | /** |
3608 | Set the grid's behaviour when the user presses the TAB key. | |
3609 | ||
3610 | Pressing the TAB key moves the grid cursor right in the current row, if | |
3611 | there is a cell at the right and, similarly, Shift-TAB moves the cursor | |
3612 | to the left in the current row if it's not in the first column. | |
3613 | ||
3614 | What happens if the cursor can't be moved because it it's already at | |
3615 | the beginning or end of the row can be configured using this function, | |
3616 | see wxGrid::TabBehaviour documentation for the detailed description. | |
3617 | ||
3618 | IF none of the standard behaviours is appropriate, you can always | |
3619 | handle @c wxEVT_GRID_TABBING event directly to implement a custom | |
3620 | TAB-handling logic. | |
3621 | ||
3622 | @since 2.9.5 | |
3623 | */ | |
3624 | void SetTabBehaviour(TabBehaviour behaviour); | |
3625 | ||
8b9ef005 | 3626 | //@} |
23324ae1 | 3627 | |
8b9ef005 | 3628 | |
caac7804 BP |
3629 | /** |
3630 | @name User Selection | |
3631 | */ | |
3632 | //@{ | |
8b9ef005 | 3633 | |
caac7804 BP |
3634 | /** |
3635 | Deselects all cells that are currently selected. | |
23324ae1 | 3636 | */ |
caac7804 | 3637 | void ClearSelection(); |
23324ae1 FM |
3638 | |
3639 | /** | |
caac7804 | 3640 | Returns an array of individually selected cells. |
08dd9b5a | 3641 | |
caac7804 BP |
3642 | Notice that this array does @em not contain all the selected cells in |
3643 | general as it doesn't include the cells selected as part of column, row | |
3644 | or block selection. You must use this method, GetSelectedCols(), | |
3645 | GetSelectedRows() and GetSelectionBlockTopLeft() and | |
3646 | GetSelectionBlockBottomRight() methods to obtain the entire selection | |
3647 | in general. | |
08dd9b5a | 3648 | |
caac7804 BP |
3649 | Please notice this behaviour is by design and is needed in order to |
3650 | support grids of arbitrary size (when an entire column is selected in | |
3651 | a grid with a million of columns, we don't want to create an array with | |
3652 | a million of entries in this function, instead it returns an empty | |
3653 | array and GetSelectedCols() returns an array containing one element). | |
23324ae1 | 3654 | */ |
caac7804 | 3655 | wxGridCellCoordsArray GetSelectedCells() const; |
23324ae1 FM |
3656 | |
3657 | /** | |
caac7804 | 3658 | Returns an array of selected columns. |
08dd9b5a | 3659 | |
caac7804 BP |
3660 | Please notice that this method alone is not sufficient to find all the |
3661 | selected columns as it contains only the columns which were | |
3662 | individually selected but not those being part of the block selection | |
3663 | or being selected in virtue of all of their cells being selected | |
3664 | individually, please see GetSelectedCells() for more details. | |
23324ae1 | 3665 | */ |
caac7804 | 3666 | wxArrayInt GetSelectedCols() const; |
23324ae1 FM |
3667 | |
3668 | /** | |
caac7804 | 3669 | Returns an array of selected rows. |
23324ae1 | 3670 | |
caac7804 BP |
3671 | Please notice that this method alone is not sufficient to find all the |
3672 | selected rows as it contains only the rows which were individually | |
3673 | selected but not those being part of the block selection or being | |
3674 | selected in virtue of all of their cells being selected individually, | |
3675 | please see GetSelectedCells() for more details. | |
23324ae1 | 3676 | */ |
caac7804 | 3677 | wxArrayInt GetSelectedRows() const; |
23324ae1 FM |
3678 | |
3679 | /** | |
caac7804 | 3680 | Returns the colour used for drawing the selection background. |
23324ae1 | 3681 | */ |
caac7804 | 3682 | wxColour GetSelectionBackground() const; |
23324ae1 | 3683 | |
8a3e536c | 3684 | /** |
caac7804 BP |
3685 | Returns an array of the bottom right corners of blocks of selected |
3686 | cells. | |
8a3e536c | 3687 | |
caac7804 BP |
3688 | Please see GetSelectedCells() for more information about the selection |
3689 | representation in wxGrid. | |
23324ae1 | 3690 | |
caac7804 | 3691 | @see GetSelectionBlockTopLeft() |
23324ae1 | 3692 | */ |
caac7804 | 3693 | wxGridCellCoordsArray GetSelectionBlockBottomRight() const; |
8b9ef005 | 3694 | |
8b9ef005 | 3695 | /** |
caac7804 | 3696 | Returns an array of the top left corners of blocks of selected cells. |
8b9ef005 | 3697 | |
caac7804 BP |
3698 | Please see GetSelectedCells() for more information about the selection |
3699 | representation in wxGrid. | |
23324ae1 | 3700 | |
caac7804 | 3701 | @see GetSelectionBlockBottomRight() |
23324ae1 | 3702 | */ |
caac7804 | 3703 | wxGridCellCoordsArray GetSelectionBlockTopLeft() const; |
23324ae1 FM |
3704 | |
3705 | /** | |
caac7804 | 3706 | Returns the colour used for drawing the selection foreground. |
23324ae1 | 3707 | */ |
caac7804 | 3708 | wxColour GetSelectionForeground() const; |
23324ae1 FM |
3709 | |
3710 | /** | |
caac7804 | 3711 | Returns the current selection mode. |
23324ae1 | 3712 | |
caac7804 | 3713 | @see SetSelectionMode(). |
23324ae1 | 3714 | */ |
caac7804 | 3715 | wxGridSelectionModes GetSelectionMode() const; |
23324ae1 FM |
3716 | |
3717 | /** | |
caac7804 BP |
3718 | Returns @true if the given cell is selected. |
3719 | */ | |
3720 | bool IsInSelection(int row, int col) const; | |
3721 | /** | |
3722 | Returns @true if the given cell is selected. | |
3723 | */ | |
3724 | bool IsInSelection(const wxGridCellCoords& coords) const; | |
08dd9b5a | 3725 | |
caac7804 BP |
3726 | /** |
3727 | Returns @true if there are currently any selected cells, rows, columns | |
3728 | or blocks. | |
3729 | */ | |
3730 | bool IsSelection() const; | |
08dd9b5a | 3731 | |
caac7804 BP |
3732 | /** |
3733 | Selects all cells in the grid. | |
23324ae1 | 3734 | */ |
caac7804 | 3735 | void SelectAll(); |
23324ae1 FM |
3736 | |
3737 | /** | |
caac7804 | 3738 | Selects a rectangular block of cells. |
8b9ef005 | 3739 | |
caac7804 BP |
3740 | If @a addToSelected is @false then any existing selection will be |
3741 | deselected; if @true the column will be added to the existing | |
3742 | selection. | |
23324ae1 | 3743 | */ |
caac7804 BP |
3744 | void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, |
3745 | bool addToSelected = false); | |
23324ae1 | 3746 | /** |
caac7804 | 3747 | Selects a rectangular block of cells. |
08dd9b5a | 3748 | |
caac7804 BP |
3749 | If @a addToSelected is @false then any existing selection will be |
3750 | deselected; if @true the column will be added to the existing | |
3751 | selection. | |
23324ae1 | 3752 | */ |
caac7804 BP |
3753 | void SelectBlock(const wxGridCellCoords& topLeft, |
3754 | const wxGridCellCoords& bottomRight, | |
3755 | bool addToSelected = false); | |
23324ae1 FM |
3756 | |
3757 | /** | |
caac7804 | 3758 | Selects the specified column. |
08dd9b5a | 3759 | |
caac7804 BP |
3760 | If @a addToSelected is @false then any existing selection will be |
3761 | deselected; if @true the column will be added to the existing | |
3762 | selection. | |
3763 | ||
3764 | This method won't select anything if the current selection mode is | |
3765 | wxGridSelectRows. | |
23324ae1 | 3766 | */ |
caac7804 | 3767 | void SelectCol(int col, bool addToSelected = false); |
23324ae1 | 3768 | |
23324ae1 | 3769 | /** |
caac7804 | 3770 | Selects the specified row. |
8b9ef005 | 3771 | |
caac7804 BP |
3772 | If @a addToSelected is @false then any existing selection will be |
3773 | deselected; if @true the row will be added to the existing selection. | |
3774 | ||
3775 | This method won't select anything if the current selection mode is | |
3776 | wxGridSelectColumns. | |
23324ae1 | 3777 | */ |
caac7804 | 3778 | void SelectRow(int row, bool addToSelected = false); |
23324ae1 FM |
3779 | |
3780 | /** | |
caac7804 BP |
3781 | Set the colour to be used for drawing the selection background. |
3782 | */ | |
3783 | void SetSelectionBackground(const wxColour& c); | |
08dd9b5a | 3784 | |
caac7804 BP |
3785 | /** |
3786 | Set the colour to be used for drawing the selection foreground. | |
23324ae1 | 3787 | */ |
caac7804 | 3788 | void SetSelectionForeground(const wxColour& c); |
23324ae1 FM |
3789 | |
3790 | /** | |
caac7804 | 3791 | Set the selection behaviour of the grid. |
8b9ef005 | 3792 | |
caac7804 BP |
3793 | The existing selection is converted to conform to the new mode if |
3794 | possible and discarded otherwise (e.g. any individual selected cells | |
3795 | are deselected if the new mode allows only the selection of the entire | |
3796 | rows or columns). | |
23324ae1 | 3797 | */ |
caac7804 | 3798 | void SetSelectionMode(wxGridSelectionModes selmode); |
23324ae1 | 3799 | |
caac7804 | 3800 | //@} |
08dd9b5a | 3801 | |
8b9ef005 | 3802 | |
caac7804 BP |
3803 | /** |
3804 | @name Scrolling | |
3805 | */ | |
3806 | //@{ | |
23324ae1 | 3807 | |
23324ae1 | 3808 | /** |
caac7804 BP |
3809 | Returns the number of pixels per horizontal scroll increment. |
3810 | ||
3811 | The default is 15. | |
3812 | ||
3813 | @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY() | |
23324ae1 | 3814 | */ |
caac7804 | 3815 | int GetScrollLineX() const; |
23324ae1 FM |
3816 | |
3817 | /** | |
caac7804 | 3818 | Returns the number of pixels per vertical scroll increment. |
08dd9b5a | 3819 | |
caac7804 | 3820 | The default is 15. |
8b9ef005 | 3821 | |
caac7804 | 3822 | @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY() |
23324ae1 | 3823 | */ |
caac7804 | 3824 | int GetScrollLineY() const; |
23324ae1 FM |
3825 | |
3826 | /** | |
caac7804 BP |
3827 | Returns @true if a cell is either entirely or at least partially |
3828 | visible in the grid window. | |
08dd9b5a | 3829 | |
caac7804 BP |
3830 | By default, the cell must be entirely visible for this function to |
3831 | return @true but if @a wholeCellVisible is @false, the function returns | |
3832 | @true even if the cell is only partially visible. | |
23324ae1 | 3833 | */ |
caac7804 | 3834 | bool IsVisible(int row, int col, bool wholeCellVisible = true) const; |
23324ae1 | 3835 | /** |
caac7804 BP |
3836 | Returns @true if a cell is either entirely or at least partially |
3837 | visible in the grid window. | |
3838 | ||
3839 | By default, the cell must be entirely visible for this function to | |
3840 | return @true but if @a wholeCellVisible is @false, the function returns | |
3841 | @true even if the cell is only partially visible. | |
23324ae1 | 3842 | */ |
caac7804 BP |
3843 | bool IsVisible(const wxGridCellCoords& coords, |
3844 | bool wholeCellVisible = true) const; | |
23324ae1 FM |
3845 | |
3846 | /** | |
caac7804 BP |
3847 | Brings the specified cell into the visible grid cell area with minimal |
3848 | scrolling. | |
23324ae1 | 3849 | |
caac7804 BP |
3850 | Does nothing if the cell is already visible. |
3851 | */ | |
3852 | void MakeCellVisible(int row, int col); | |
23324ae1 | 3853 | /** |
caac7804 BP |
3854 | Brings the specified cell into the visible grid cell area with minimal |
3855 | scrolling. | |
3856 | ||
3857 | Does nothing if the cell is already visible. | |
23324ae1 | 3858 | */ |
caac7804 | 3859 | void MakeCellVisible(const wxGridCellCoords& coords); |
23324ae1 FM |
3860 | |
3861 | /** | |
caac7804 | 3862 | Sets the number of pixels per horizontal scroll increment. |
08dd9b5a | 3863 | |
caac7804 | 3864 | The default is 15. |
8b9ef005 | 3865 | |
caac7804 | 3866 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY() |
23324ae1 | 3867 | */ |
caac7804 | 3868 | void SetScrollLineX(int x); |
23324ae1 FM |
3869 | |
3870 | /** | |
caac7804 | 3871 | Sets the number of pixels per vertical scroll increment. |
08dd9b5a | 3872 | |
caac7804 | 3873 | The default is 15. |
8b9ef005 | 3874 | |
caac7804 | 3875 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX() |
23324ae1 | 3876 | */ |
caac7804 | 3877 | void SetScrollLineY(int y); |
23324ae1 | 3878 | |
caac7804 | 3879 | //@} |
08dd9b5a | 3880 | |
23324ae1 | 3881 | |
caac7804 BP |
3882 | /** |
3883 | @name Cell and Device Coordinate Translation | |
3884 | */ | |
3885 | //@{ | |
23324ae1 FM |
3886 | |
3887 | /** | |
caac7804 | 3888 | Convert grid cell coordinates to grid window pixel coordinates. |
8b9ef005 | 3889 | |
caac7804 BP |
3890 | This function returns the rectangle that encloses the block of cells |
3891 | limited by @a topLeft and @a bottomRight cell in device coords and | |
3892 | clipped to the client size of the grid window. | |
8b9ef005 | 3893 | |
caac7804 | 3894 | @see CellToRect() |
23324ae1 | 3895 | */ |
caac7804 BP |
3896 | wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft, |
3897 | const wxGridCellCoords& bottomRight) const; | |
23324ae1 FM |
3898 | |
3899 | /** | |
caac7804 BP |
3900 | Return the rectangle corresponding to the grid cell's size and position |
3901 | in logical coordinates. | |
08dd9b5a | 3902 | |
caac7804 BP |
3903 | @see BlockToDeviceRect() |
3904 | */ | |
3905 | wxRect CellToRect(int row, int col) const; | |
3906 | /** | |
3907 | Return the rectangle corresponding to the grid cell's size and position | |
3908 | in logical coordinates. | |
08dd9b5a | 3909 | |
caac7804 | 3910 | @see BlockToDeviceRect() |
23324ae1 | 3911 | */ |
882678eb | 3912 | wxRect CellToRect(const wxGridCellCoords& coords) const; |
23324ae1 | 3913 | |
23324ae1 | 3914 | /** |
caac7804 BP |
3915 | Returns the column at the given pixel position. |
3916 | ||
3917 | @param x | |
3918 | The x position to evaluate. | |
3919 | @param clipToMinMax | |
3920 | If @true, rather than returning @c wxNOT_FOUND, it returns either | |
3921 | the first or last column depending on whether @a x is too far to | |
3922 | the left or right respectively. | |
3923 | @return | |
3924 | The column index or @c wxNOT_FOUND. | |
23324ae1 | 3925 | */ |
caac7804 | 3926 | int XToCol(int x, bool clipToMinMax = false) const; |
23324ae1 FM |
3927 | |
3928 | /** | |
caac7804 BP |
3929 | Returns the column whose right hand edge is close to the given logical |
3930 | @a x position. | |
3931 | ||
3932 | If no column edge is near to this position @c wxNOT_FOUND is returned. | |
23324ae1 | 3933 | */ |
caac7804 | 3934 | int XToEdgeOfCol(int x) const; |
23324ae1 | 3935 | |
23324ae1 | 3936 | /** |
caac7804 BP |
3937 | Translates logical pixel coordinates to the grid cell coordinates. |
3938 | ||
3939 | Notice that this function expects logical coordinates on input so if | |
3940 | you use this function in a mouse event handler you need to translate | |
3941 | the mouse position, which is expressed in device coordinates, to | |
3942 | logical ones. | |
3943 | ||
3944 | @see XToCol(), YToRow() | |
3945 | */ | |
3946 | wxGridCellCoords XYToCell(int x, int y) const; | |
3947 | /** | |
3948 | Translates logical pixel coordinates to the grid cell coordinates. | |
3949 | ||
3950 | Notice that this function expects logical coordinates on input so if | |
3951 | you use this function in a mouse event handler you need to translate | |
3952 | the mouse position, which is expressed in device coordinates, to | |
3953 | logical ones. | |
3954 | ||
3955 | @see XToCol(), YToRow() | |
3956 | */ | |
3957 | wxGridCellCoords XYToCell(const wxPoint& pos) const; | |
3958 | // XYToCell(int, int, wxGridCellCoords&) overload is intentionally | |
3959 | // undocumented, using it is ugly and non-const reference parameters are | |
3960 | // not used in wxWidgets API | |
08dd9b5a | 3961 | |
8b9ef005 | 3962 | /** |
caac7804 BP |
3963 | Returns the row whose bottom edge is close to the given logical @a y |
3964 | position. | |
3965 | ||
3966 | If no row edge is near to this position @c wxNOT_FOUND is returned. | |
23324ae1 | 3967 | */ |
caac7804 | 3968 | int YToEdgeOfRow(int y) const; |
23324ae1 FM |
3969 | |
3970 | /** | |
caac7804 | 3971 | Returns the grid row that corresponds to the logical @a y coordinate. |
08dd9b5a | 3972 | |
caac7804 | 3973 | Returns @c wxNOT_FOUND if there is no row at the @a y position. |
8b9ef005 | 3974 | */ |
caac7804 BP |
3975 | int YToRow(int y, bool clipToMinMax = false) const; |
3976 | ||
3977 | //@} | |
3978 | ||
08dd9b5a | 3979 | |
8b9ef005 | 3980 | /** |
caac7804 BP |
3981 | @name Miscellaneous Functions |
3982 | */ | |
3983 | //@{ | |
8b9ef005 | 3984 | |
caac7804 BP |
3985 | /** |
3986 | Appends one or more new columns to the right of the grid. | |
3987 | ||
3988 | The @a updateLabels argument is not used at present. If you are using a | |
3989 | derived grid table class you will need to override | |
3990 | wxGridTableBase::AppendCols(). See InsertCols() for further | |
3991 | information. | |
3992 | ||
3993 | @return @true on success or @false if appending columns failed. | |
23324ae1 | 3994 | */ |
caac7804 | 3995 | bool AppendCols(int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
3996 | |
3997 | /** | |
caac7804 | 3998 | Appends one or more new rows to the bottom of the grid. |
08dd9b5a | 3999 | |
caac7804 BP |
4000 | The @a updateLabels argument is not used at present. If you are using a |
4001 | derived grid table class you will need to override | |
4002 | wxGridTableBase::AppendRows(). See InsertRows() for further | |
4003 | information. | |
23324ae1 | 4004 | |
caac7804 | 4005 | @return @true on success or @false if appending rows failed. |
23324ae1 | 4006 | */ |
caac7804 | 4007 | bool AppendRows(int numRows = 1, bool updateLabels = true); |
23324ae1 | 4008 | |
23324ae1 | 4009 | /** |
caac7804 BP |
4010 | Return @true if the horizontal grid lines stop at the last column |
4011 | boundary or @false if they continue to the end of the window. | |
3c4f71cc | 4012 | |
caac7804 BP |
4013 | The default is to clip grid lines. |
4014 | ||
4015 | @see ClipHorzGridLines(), AreVertGridLinesClipped() | |
4016 | */ | |
4017 | bool AreHorzGridLinesClipped() const; | |
23324ae1 FM |
4018 | |
4019 | /** | |
caac7804 BP |
4020 | Return @true if the vertical grid lines stop at the last row |
4021 | boundary or @false if they continue to the end of the window. | |
8b9ef005 | 4022 | |
caac7804 BP |
4023 | The default is to clip grid lines. |
4024 | ||
4025 | @see ClipVertGridLines(), AreHorzGridLinesClipped() | |
4026 | */ | |
4027 | bool AreVertGridLinesClipped() const; | |
23324ae1 FM |
4028 | |
4029 | /** | |
caac7804 | 4030 | Increments the grid's batch count. |
08dd9b5a | 4031 | |
caac7804 BP |
4032 | When the count is greater than zero repainting of the grid is |
4033 | suppressed. Each call to BeginBatch must be matched by a later call to | |
4034 | EndBatch(). Code that does a lot of grid modification can be enclosed | |
4035 | between BeginBatch() and EndBatch() calls to avoid screen flicker. The | |
4036 | final EndBatch() call will cause the grid to be repainted. | |
4037 | ||
4038 | Notice that you should use wxGridUpdateLocker which ensures that there | |
4039 | is always a matching EndBatch() call for this BeginBatch() if possible | |
4040 | instead of calling this method directly. | |
8b9ef005 | 4041 | */ |
caac7804 | 4042 | void BeginBatch(); |
08dd9b5a | 4043 | |
8b9ef005 | 4044 | /** |
caac7804 | 4045 | Clears all data in the underlying grid table and repaints the grid. |
8b9ef005 | 4046 | |
caac7804 BP |
4047 | The table is not deleted by this function. If you are using a derived |
4048 | table class then you need to override wxGridTableBase::Clear() for this | |
4049 | function to have any effect. | |
23324ae1 | 4050 | */ |
caac7804 | 4051 | void ClearGrid(); |
23324ae1 FM |
4052 | |
4053 | /** | |
caac7804 BP |
4054 | Change whether the horizontal grid lines are clipped by the end of the |
4055 | last column. | |
8b9ef005 | 4056 | |
caac7804 BP |
4057 | By default the grid lines are not drawn beyond the end of the last |
4058 | column but after calling this function with @a clip set to @false they | |
4059 | will be drawn across the entire grid window. | |
4060 | ||
4061 | @see AreHorzGridLinesClipped(), ClipVertGridLines() | |
4062 | */ | |
4063 | void ClipHorzGridLines(bool clip); | |
23324ae1 FM |
4064 | |
4065 | /** | |
caac7804 BP |
4066 | Change whether the vertical grid lines are clipped by the end of the |
4067 | last row. | |
08dd9b5a | 4068 | |
caac7804 BP |
4069 | By default the grid lines are not drawn beyond the end of the last |
4070 | row but after calling this function with @a clip set to @false they | |
4071 | will be drawn across the entire grid window. | |
4072 | ||
4073 | @see AreVertGridLinesClipped(), ClipHorzGridLines() | |
4074 | */ | |
4075 | void ClipVertGridLines(bool clip); | |
08dd9b5a | 4076 | |
8b9ef005 | 4077 | /** |
caac7804 BP |
4078 | Deletes one or more columns from a grid starting at the specified |
4079 | position. | |
8b9ef005 | 4080 | |
caac7804 BP |
4081 | The @a updateLabels argument is not used at present. If you are using a |
4082 | derived grid table class you will need to override | |
4083 | wxGridTableBase::DeleteCols(). See InsertCols() for further | |
4084 | information. | |
8b9ef005 | 4085 | |
caac7804 | 4086 | @return @true on success or @false if deleting columns failed. |
23324ae1 | 4087 | */ |
caac7804 | 4088 | bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 | 4089 | |
23324ae1 | 4090 | /** |
caac7804 BP |
4091 | Deletes one or more rows from a grid starting at the specified |
4092 | position. | |
8b9ef005 | 4093 | |
caac7804 BP |
4094 | The @a updateLabels argument is not used at present. If you are using a |
4095 | derived grid table class you will need to override | |
4096 | wxGridTableBase::DeleteRows(). See InsertRows() for further | |
4097 | information. | |
8b9ef005 | 4098 | |
caac7804 | 4099 | @return @true on success or @false if appending rows failed. |
23324ae1 | 4100 | */ |
caac7804 | 4101 | bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true); |
23324ae1 | 4102 | |
23324ae1 | 4103 | /** |
caac7804 BP |
4104 | Decrements the grid's batch count. |
4105 | ||
4106 | When the count is greater than zero repainting of the grid is | |
4107 | suppressed. Each previous call to BeginBatch() must be matched by a | |
4108 | later call to EndBatch(). Code that does a lot of grid modification can | |
4109 | be enclosed between BeginBatch() and EndBatch() calls to avoid screen | |
4110 | flicker. The final EndBatch() will cause the grid to be repainted. | |
4111 | ||
4112 | @see wxGridUpdateLocker | |
8b9ef005 | 4113 | */ |
caac7804 | 4114 | void EndBatch(); |
08dd9b5a | 4115 | |
8b9ef005 | 4116 | /** |
caac7804 | 4117 | Overridden wxWindow method. |
8b9ef005 | 4118 | */ |
caac7804 | 4119 | virtual void Fit(); |
08dd9b5a | 4120 | |
8b9ef005 | 4121 | /** |
caac7804 | 4122 | Causes immediate repainting of the grid. |
8b9ef005 | 4123 | |
caac7804 | 4124 | Use this instead of the usual wxWindow::Refresh(). |
23324ae1 | 4125 | */ |
caac7804 | 4126 | void ForceRefresh(); |
23324ae1 FM |
4127 | |
4128 | /** | |
caac7804 BP |
4129 | Returns the number of times that BeginBatch() has been called without |
4130 | (yet) matching calls to EndBatch(). While the grid's batch count is | |
4131 | greater than zero the display will not be updated. | |
4132 | */ | |
4133 | int GetBatchCount(); | |
08dd9b5a | 4134 | |
caac7804 BP |
4135 | /** |
4136 | Returns the total number of grid columns. | |
8b9ef005 | 4137 | |
caac7804 | 4138 | This is the same as the number of columns in the underlying grid table. |
23324ae1 | 4139 | */ |
caac7804 | 4140 | int GetNumberCols() const; |
23324ae1 FM |
4141 | |
4142 | /** | |
caac7804 | 4143 | Returns the total number of grid rows. |
08dd9b5a | 4144 | |
caac7804 | 4145 | This is the same as the number of rows in the underlying grid table. |
23324ae1 | 4146 | */ |
caac7804 | 4147 | int GetNumberRows() const; |
23324ae1 FM |
4148 | |
4149 | /** | |
caac7804 BP |
4150 | Returns the attribute for the given cell creating one if necessary. |
4151 | ||
4152 | If the cell already has an attribute, it is returned. Otherwise a new | |
4153 | attribute is created, associated with the cell and returned. In any | |
4154 | case the caller must call DecRef() on the returned pointer. | |
4155 | ||
4156 | This function may only be called if CanHaveAttributes() returns @true. | |
8b9ef005 | 4157 | */ |
caac7804 | 4158 | wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const; |
08dd9b5a | 4159 | |
8b9ef005 | 4160 | /** |
caac7804 | 4161 | Returns a base pointer to the current table object. |
08dd9b5a | 4162 | |
caac7804 | 4163 | The returned pointer is still owned by the grid. |
23324ae1 | 4164 | */ |
caac7804 | 4165 | wxGridTableBase *GetTable() const; |
23324ae1 FM |
4166 | |
4167 | /** | |
caac7804 BP |
4168 | Inserts one or more new columns into a grid with the first new column |
4169 | at the specified position. | |
08dd9b5a | 4170 | |
caac7804 BP |
4171 | Notice that inserting the columns in the grid requires grid table |
4172 | cooperation: when this method is called, grid object begins by | |
4173 | requesting the underlying grid table to insert new columns. If this is | |
4174 | successful the table notifies the grid and the grid updates the | |
4175 | display. For a default grid (one where you have called CreateGrid()) | |
4176 | this process is automatic. If you are using a custom grid table | |
4177 | (specified with SetTable()) then you must override | |
4178 | wxGridTableBase::InsertCols() in your derived table class. | |
4179 | ||
4180 | @param pos | |
4181 | The position which the first newly inserted column will have. | |
4182 | @param numCols | |
4183 | The number of columns to insert. | |
4184 | @param updateLabels | |
4185 | Currently not used. | |
4186 | @return | |
4187 | @true if the columns were successfully inserted, @false if an error | |
4188 | occurred (most likely the table couldn't be updated). | |
23324ae1 | 4189 | */ |
caac7804 | 4190 | bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
4191 | |
4192 | /** | |
caac7804 BP |
4193 | Inserts one or more new rows into a grid with the first new row at the |
4194 | specified position. | |
8b9ef005 | 4195 | |
caac7804 BP |
4196 | Notice that you must implement wxGridTableBase::InsertRows() if you use |
4197 | a grid with a custom table, please see InsertCols() for more | |
4198 | information. | |
8b9ef005 | 4199 | |
caac7804 BP |
4200 | @param pos |
4201 | The position which the first newly inserted row will have. | |
4202 | @param numRows | |
4203 | The number of rows to insert. | |
4204 | @param updateLabels | |
4205 | Currently not used. | |
4206 | @return | |
4207 | @true if the rows were successfully inserted, @false if an error | |
4208 | occurred (most likely the table couldn't be updated). | |
4209 | */ | |
4210 | bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true); | |
8b9ef005 | 4211 | |
b99450ee VZ |
4212 | /** |
4213 | Invalidates the cached attribute for the given cell. | |
4214 | ||
4215 | For efficiency reasons, wxGrid may cache the recently used attributes | |
4216 | (currently it caches only the single most recently used one, in fact) | |
4217 | which can result in the cell appearance not being refreshed even when | |
4218 | the attribute returned by your custom wxGridCellAttrProvider-derived | |
4219 | class has changed. To force the grid to refresh the cell attribute, | |
4220 | this function may be used. Notice that calling it will not result in | |
4221 | actually redrawing the cell, you still need to call | |
4222 | wxWindow::RefreshRect() to invalidate the area occupied by the cell in | |
4223 | the window to do this. Also note that you don't need to call this | |
4224 | function if you store the attributes in wxGrid itself, i.e. use its | |
4225 | SetAttr() and similar methods, it is only useful when using a separate | |
4226 | custom attributes provider. | |
4227 | ||
4228 | @param row | |
4229 | The row of the cell whose attribute needs to be queried again. | |
4230 | @param col | |
4231 | The column of the cell whose attribute needs to be queried again. | |
4232 | ||
4233 | @since 2.9.2 | |
4234 | */ | |
4235 | void RefreshAttr(int row, int col); | |
4236 | ||
779e28da VZ |
4237 | /** |
4238 | Draws part or all of a wxGrid on a wxDC for printing or display. | |
4239 | ||
4240 | Pagination can be accomplished by using sequential Render() calls | |
4241 | with appropriate values in wxGridCellCoords topLeft and bottomRight. | |
4242 | ||
4243 | @param dc | |
4244 | The wxDC to be drawn on. | |
4245 | @param pos | |
4246 | The position on the wxDC where rendering should begin. If not | |
4247 | specified drawing will begin at the wxDC MaxX() and MaxY(). | |
4248 | @param size | |
4249 | The size of the area on the wxDC that the rendered wxGrid should | |
4250 | occupy. If not specified the drawing will be scaled to fit the | |
4251 | available dc width or height. The wxGrid's aspect ratio is | |
4252 | maintained whether or not size is specified. | |
4253 | @param topLeft | |
4254 | The top left cell of the block to be drawn. Defaults to ( 0, 0 ). | |
4255 | @param bottomRight | |
4256 | The bottom right cell of the block to be drawn. Defaults to row and | |
4257 | column counts. | |
4258 | @param style | |
4259 | A combination of values from wxGridRenderStyle. | |
4260 | ||
4261 | @since 2.9.4 | |
4262 | */ | |
4263 | void Render( wxDC& dc, | |
4264 | const wxPoint& pos = wxDefaultPosition, | |
4265 | const wxSize& size = wxDefaultSize, | |
4266 | const wxGridCellCoords& topLeft = wxGridCellCoords( -1, -1 ), | |
4267 | const wxGridCellCoords& bottomRight = wxGridCellCoords( -1, -1 ), | |
4268 | int style = wxGRID_DRAW_DEFAULT ); | |
4269 | ||
caac7804 BP |
4270 | /** |
4271 | Sets the cell attributes for all cells in the specified column. | |
08dd9b5a | 4272 | |
caac7804 BP |
4273 | For more information about controlling grid cell attributes see the |
4274 | wxGridCellAttr cell attribute class and the @ref overview_grid. | |
4275 | */ | |
4276 | void SetColAttr(int col, wxGridCellAttr* attr); | |
23324ae1 FM |
4277 | |
4278 | /** | |
caac7804 | 4279 | Sets the extra margins used around the grid area. |
08dd9b5a | 4280 | |
caac7804 BP |
4281 | A grid may occupy more space than needed for its data display and |
4282 | this function allows to set how big this extra space is | |
23324ae1 | 4283 | */ |
caac7804 | 4284 | void SetMargins(int extraWidth, int extraHeight); |
23324ae1 FM |
4285 | |
4286 | /** | |
caac7804 | 4287 | Sets the cell attributes for all cells in the specified row. |
08dd9b5a | 4288 | |
caac7804 BP |
4289 | The grid takes ownership of the attribute pointer. |
4290 | ||
4291 | See the wxGridCellAttr class for more information about controlling | |
4292 | cell attributes. | |
23324ae1 | 4293 | */ |
caac7804 BP |
4294 | void SetRowAttr(int row, wxGridCellAttr* attr); |
4295 | ||
4296 | //@} | |
23324ae1 | 4297 | |
11393d29 VZ |
4298 | |
4299 | /** | |
4300 | @name Sorting support. | |
4301 | ||
4302 | wxGrid doesn't provide any support for sorting the data but it does | |
4303 | generate events allowing the user code to sort it and supports | |
4304 | displaying the sort indicator in the column used for sorting. | |
4305 | ||
4306 | To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT | |
4307 | event (and not veto it) and resort the data displayed in the grid. The | |
4308 | grid will automatically update the sorting indicator on the column | |
4309 | which was clicked. | |
4310 | ||
4311 | You can also call the functions in this section directly to update the | |
4312 | sorting indicator. Once again, they don't do anything with the grid | |
4313 | data, it remains your responsibility to actually sort it appropriately. | |
4314 | */ | |
4315 | //@{ | |
4316 | ||
4317 | /** | |
4318 | Return the column in which the sorting indicator is currently | |
4319 | displayed. | |
4320 | ||
4321 | Returns @c wxNOT_FOUND if sorting indicator is not currently displayed | |
4322 | at all. | |
4323 | ||
4324 | @see SetSortingColumn() | |
4325 | */ | |
4326 | int GetSortingColumn() const; | |
4327 | ||
4328 | /** | |
4329 | Return @true if this column is currently used for sorting. | |
4330 | ||
4331 | @see GetSortingColumn() | |
4332 | */ | |
4333 | bool IsSortingBy(int col) const; | |
4334 | ||
4335 | /** | |
4336 | Return @true if the current sorting order is ascending or @false if it | |
4337 | is descending. | |
4338 | ||
4339 | It only makes sense to call this function if GetSortingColumn() returns | |
4340 | a valid column index and not @c wxNOT_FOUND. | |
4341 | ||
4342 | @see SetSortingColumn() | |
4343 | */ | |
4344 | bool IsSortOrderAscending() const; | |
4345 | ||
4346 | /** | |
4347 | Set the column to display the sorting indicator in and its direction. | |
4348 | ||
4349 | @param col | |
4350 | The column to display the sorting indicator in or @c wxNOT_FOUND to | |
4351 | remove any currently displayed sorting indicator. | |
4352 | @param ascending | |
4353 | If @true, display the ascending sort indicator, otherwise display | |
4354 | the descending sort indicator. | |
4355 | ||
4356 | @see GetSortingColumn(), IsSortOrderAscending() | |
4357 | */ | |
4358 | void SetSortingColumn(int col, bool ascending = true); | |
4359 | ||
4360 | /** | |
4361 | Remove any currently shown sorting indicator. | |
4362 | ||
4363 | This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND | |
4364 | first argument. | |
4365 | */ | |
4366 | void UnsetSortingColumn(); | |
4367 | //@} | |
3039ade9 | 4368 | |
882678eb | 4369 | |
3039ade9 VZ |
4370 | /** |
4371 | @name Accessors for component windows. | |
4372 | ||
4373 | Return the various child windows of wxGrid. | |
4374 | ||
4375 | wxGrid is an empty parent window for 4 children representing the column | |
4376 | labels window (top), the row labels window (left), the corner window | |
4377 | (top left) and the main grid window. It may be necessary to use these | |
4378 | individual windows and not the wxGrid window itself if you need to | |
4379 | handle events for them (this can be done using wxEvtHandler::Connect() | |
4380 | or wxWindow::PushEventHandler()) or do something else requiring the use | |
4381 | of the correct window pointer. Notice that you should not, however, | |
4382 | change these windows (e.g. reposition them or draw over them) because | |
4383 | they are managed by wxGrid itself. | |
4384 | */ | |
4385 | //@{ | |
4386 | ||
4387 | /** | |
4388 | Return the main grid window containing the grid cells. | |
4389 | ||
4390 | This window is always shown. | |
4391 | */ | |
4392 | wxWindow *GetGridWindow() const; | |
4393 | ||
4394 | /** | |
4395 | Return the row labels window. | |
4396 | ||
4397 | This window is not shown if the row labels were hidden using | |
4398 | HideRowLabels(). | |
4399 | */ | |
4400 | wxWindow *GetGridRowLabelWindow() const; | |
4401 | ||
4402 | /** | |
4403 | Return the column labels window. | |
4404 | ||
4405 | This window is not shown if the columns labels were hidden using | |
4406 | HideColLabels(). | |
4407 | ||
4408 | Depending on whether UseNativeColHeader() was called or not this can be | |
4409 | either a wxHeaderCtrl or a plain wxWindow. This function returns a valid | |
4410 | window pointer in either case but in the former case you can also use | |
4411 | GetGridColHeader() to access it if you need wxHeaderCtrl-specific | |
4412 | functionality. | |
4413 | */ | |
600e986a | 4414 | wxWindow *GetGridColLabelWindow() const; |
3039ade9 VZ |
4415 | |
4416 | /** | |
4417 | Return the window in the top left grid corner. | |
4418 | ||
4419 | This window is shown only of both columns and row labels are shown and | |
4420 | normally doesn't contain anything. Clicking on it is handled by wxGrid | |
4421 | however and can be used to select the entire grid. | |
4422 | */ | |
4423 | wxWindow *GetGridCornerLabelWindow() const; | |
4424 | ||
4425 | /** | |
4426 | Return the header control used for column labels display. | |
4427 | ||
4428 | This function can only be called if UseNativeColHeader() had been | |
4429 | called. | |
4430 | */ | |
4431 | wxHeaderCtrl *GetGridColHeader() const; | |
4432 | ||
4433 | //@} | |
882678eb FM |
4434 | |
4435 | protected: | |
4436 | /** | |
4437 | Returns @true if this grid has support for cell attributes. | |
4438 | ||
4439 | The grid supports attributes if it has the associated table which, in | |
4440 | turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes() | |
4441 | returns @true. | |
4442 | */ | |
4443 | bool CanHaveAttributes() const; | |
4444 | ||
4445 | /** | |
4446 | Get the minimal width of the given column/row. | |
4447 | ||
4448 | The value returned by this function may be different than that returned | |
4449 | by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been | |
4450 | called for this column. | |
4451 | */ | |
4452 | int GetColMinimalWidth(int col) const; | |
4453 | ||
4454 | /** | |
4455 | Returns the coordinate of the right border specified column. | |
4456 | */ | |
4457 | int GetColRight(int col) const; | |
4458 | ||
4459 | /** | |
4460 | Returns the coordinate of the left border specified column. | |
4461 | */ | |
4462 | int GetColLeft(int col) const; | |
4463 | ||
4464 | /** | |
4465 | Returns the minimal size for the given column. | |
4466 | ||
4467 | The value returned by this function may be different than that returned | |
4468 | by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been | |
4469 | called for this row. | |
4470 | */ | |
4471 | int GetRowMinimalHeight(int col) const; | |
8b9ef005 | 4472 | }; |
23324ae1 | 4473 | |
08dd9b5a | 4474 | |
23324ae1 | 4475 | |
8b9ef005 BP |
4476 | /** |
4477 | @class wxGridUpdateLocker | |
23324ae1 | 4478 | |
8b9ef005 BP |
4479 | This small class can be used to prevent wxGrid from redrawing during its |
4480 | lifetime by calling wxGrid::BeginBatch() in its constructor and | |
4481 | wxGrid::EndBatch() in its destructor. It is typically used in a function | |
4482 | performing several operations with a grid which would otherwise result in | |
4483 | flicker. For example: | |
23324ae1 | 4484 | |
8b9ef005 BP |
4485 | @code |
4486 | void MyFrame::Foo() | |
4487 | { | |
4488 | m_grid = new wxGrid(this, ...); | |
23324ae1 | 4489 | |
8b9ef005 BP |
4490 | wxGridUpdateLocker noUpdates(m_grid); |
4491 | m_grid-AppendColumn(); | |
4492 | // ... many other operations with m_grid ... | |
4493 | m_grid-AppendRow(); | |
08dd9b5a | 4494 | |
8b9ef005 BP |
4495 | // destructor called, grid refreshed |
4496 | } | |
4497 | @endcode | |
08dd9b5a | 4498 | |
8b9ef005 BP |
4499 | Using this class is easier and safer than calling wxGrid::BeginBatch() and |
4500 | wxGrid::EndBatch() because you don't risk missing the call the latter (due | |
4501 | to an exception for example). | |
23324ae1 | 4502 | |
8b9ef005 BP |
4503 | @library{wxadv} |
4504 | @category{grid} | |
4505 | */ | |
4506 | class wxGridUpdateLocker | |
4507 | { | |
4508 | public: | |
23324ae1 | 4509 | /** |
8b9ef005 BP |
4510 | Creates an object preventing the updates of the specified @a grid. The |
4511 | parameter could be @NULL in which case nothing is done. If @a grid is | |
4512 | non-@NULL then the grid must exist for longer than this | |
4513 | wxGridUpdateLocker object itself. | |
08dd9b5a | 4514 | |
8b9ef005 BP |
4515 | The default constructor could be followed by a call to Create() to set |
4516 | the grid object later. | |
23324ae1 | 4517 | */ |
8b9ef005 | 4518 | wxGridUpdateLocker(wxGrid* grid = NULL); |
23324ae1 FM |
4519 | |
4520 | /** | |
8b9ef005 BP |
4521 | Destructor reenables updates for the grid this object is associated |
4522 | with. | |
23324ae1 | 4523 | */ |
8b9ef005 | 4524 | ~wxGridUpdateLocker(); |
23324ae1 FM |
4525 | |
4526 | /** | |
8b9ef005 BP |
4527 | This method can be called if the object had been constructed using the |
4528 | default constructor. It must not be called more than once. | |
4529 | */ | |
4530 | void Create(wxGrid* grid); | |
4531 | }; | |
08dd9b5a | 4532 | |
08dd9b5a | 4533 | |
23324ae1 | 4534 | |
8b9ef005 BP |
4535 | /** |
4536 | @class wxGridEvent | |
08dd9b5a | 4537 | |
8b9ef005 | 4538 | This event class contains information about various grid events. |
8a3e536c | 4539 | |
2b1f9fa0 VZ |
4540 | Notice that all grid event table macros are available in two versions: |
4541 | @c EVT_GRID_XXX and @c EVT_GRID_CMD_XXX. The only difference between the | |
4542 | two is that the former doesn't allow to specify the grid window identifier | |
4543 | and so takes a single parameter, the event handler, but is not suitable if | |
4544 | there is more than one grid control in the window where the event table is | |
4545 | used (as it would catch the events from all the grids). The version with @c | |
4546 | CMD takes the id as first argument and the event handler as the second one | |
4547 | and so can be used with multiple grids as well. Otherwise there are no | |
4548 | difference between the two and only the versions without the id are | |
4549 | documented below for brevity. | |
4550 | ||
8b9ef005 | 4551 | @beginEventTable{wxGridEvent} |
763163a8 VZ |
4552 | @event{EVT_GRID_CELL_CHANGING(func)} |
4553 | The user is about to change the data in a cell. The new cell value as | |
4554 | string is available from GetString() event object method. This event | |
f8f31de6 FM |
4555 | can be vetoed if the change is not allowed. |
4556 | Processes a @c wxEVT_GRID_CELL_CHANGING event type. | |
763163a8 VZ |
4557 | @event{EVT_GRID_CELL_CHANGED(func)} |
4558 | The user changed the data in a cell. The old cell value as string is | |
4559 | available from GetString() event object method. Notice that vetoing | |
4560 | this event still works for backwards compatibility reasons but any new | |
4561 | code should only veto EVT_GRID_CELL_CHANGING event and not this one. | |
4562 | Processes a @c wxEVT_GRID_CELL_CHANGED event type. | |
8b9ef005 BP |
4563 | @event{EVT_GRID_CELL_LEFT_CLICK(func)} |
4564 | The user clicked a cell with the left mouse button. Processes a | |
4565 | @c wxEVT_GRID_CELL_LEFT_CLICK event type. | |
4566 | @event{EVT_GRID_CELL_LEFT_DCLICK(func)} | |
4567 | The user double-clicked a cell with the left mouse button. Processes a | |
4568 | @c wxEVT_GRID_CELL_LEFT_DCLICK event type. | |
4569 | @event{EVT_GRID_CELL_RIGHT_CLICK(func)} | |
4570 | The user clicked a cell with the right mouse button. Processes a | |
4571 | @c wxEVT_GRID_CELL_RIGHT_CLICK event type. | |
4572 | @event{EVT_GRID_CELL_RIGHT_DCLICK(func)} | |
4573 | The user double-clicked a cell with the right mouse button. Processes a | |
4574 | @c wxEVT_GRID_CELL_RIGHT_DCLICK event type. | |
4575 | @event{EVT_GRID_EDITOR_HIDDEN(func)} | |
4576 | The editor for a cell was hidden. Processes a | |
4577 | @c wxEVT_GRID_EDITOR_HIDDEN event type. | |
4578 | @event{EVT_GRID_EDITOR_SHOWN(func)} | |
4579 | The editor for a cell was shown. Processes a | |
4580 | @c wxEVT_GRID_EDITOR_SHOWN event type. | |
4581 | @event{EVT_GRID_LABEL_LEFT_CLICK(func)} | |
4582 | The user clicked a label with the left mouse button. Processes a | |
4583 | @c wxEVT_GRID_LABEL_LEFT_CLICK event type. | |
4584 | @event{EVT_GRID_LABEL_LEFT_DCLICK(func)} | |
4585 | The user double-clicked a label with the left mouse button. Processes a | |
4586 | @c wxEVT_GRID_LABEL_LEFT_DCLICK event type. | |
4587 | @event{EVT_GRID_LABEL_RIGHT_CLICK(func)} | |
4588 | The user clicked a label with the right mouse button. Processes a | |
4589 | @c wxEVT_GRID_LABEL_RIGHT_CLICK event type. | |
4590 | @event{EVT_GRID_LABEL_RIGHT_DCLICK(func)} | |
4591 | The user double-clicked a label with the right mouse button. Processes | |
4592 | a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type. | |
4593 | @event{EVT_GRID_SELECT_CELL(func)} | |
c6cc8b15 VZ |
4594 | The given cell was made current, either by user or by the program via a |
4595 | call to SetGridCursor() or GoToCell(). Processes a | |
8b9ef005 | 4596 | @c wxEVT_GRID_SELECT_CELL event type. |
cd68daf5 VZ |
4597 | @event{EVT_GRID_COL_MOVE(func)} |
4598 | The user tries to change the order of the columns in the grid by | |
4599 | dragging the column specified by GetCol(). This event can be vetoed to | |
4600 | either prevent the user from reordering the column change completely | |
4601 | (but notice that if you don't want to allow it at all, you simply | |
4602 | shouldn't call wxGrid::EnableDragColMove() in the first place), vetoed | |
4603 | but handled in some way in the handler, e.g. by really moving the | |
4604 | column to the new position at the associated table level, or allowed to | |
4605 | proceed in which case wxGrid::SetColPos() is used to reorder the | |
4606 | columns display order without affecting the use of the column indices | |
4607 | otherwise. | |
4608 | This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type. | |
11393d29 VZ |
4609 | @event{EVT_GRID_COL_SORT(func)} |
4610 | This event is generated when a column is clicked by the user and its | |
4611 | name is explained by the fact that the custom reaction to a click on a | |
4612 | column is to sort the grid contents by this column. However the grid | |
4613 | itself has no special support for sorting and it's up to the handler of | |
4614 | this event to update the associated table. But if the event is handled | |
4615 | (and not vetoed) the grid supposes that the table was indeed resorted | |
4616 | and updates the column to indicate the new sort order and refreshes | |
4617 | itself. | |
11393d29 | 4618 | This event macro corresponds to @c wxEVT_GRID_COL_SORT event type. |
1dc17bca VZ |
4619 | @event{EVT_GRID_TABBING(func)} |
4620 | This event is generated when the user presses TAB or Shift-TAB in the | |
4621 | grid. It can be used to customize the simple default TAB handling | |
4622 | logic, e.g. to go to the next non-empty cell instead of just the next | |
4623 | cell. See also wxGrid::SetTabBehaviour(). This event is new since | |
4624 | wxWidgets 2.9.5. | |
8b9ef005 | 4625 | @endEventTable |
8a3e536c | 4626 | |
8b9ef005 | 4627 | @library{wxadv} |
87638422 | 4628 | @category{grid,events} |
8b9ef005 BP |
4629 | */ |
4630 | class wxGridEvent : public wxNotifyEvent | |
4631 | { | |
4632 | public: | |
4633 | /** | |
4634 | Default constructor. | |
23324ae1 | 4635 | */ |
8b9ef005 | 4636 | wxGridEvent(); |
23324ae1 | 4637 | /** |
8b9ef005 | 4638 | Constructor for initializing all event attributes. |
23324ae1 | 4639 | */ |
8b9ef005 BP |
4640 | wxGridEvent(int id, wxEventType type, wxObject* obj, |
4641 | int row = -1, int col = -1, int x = -1, int y = -1, | |
ccf39540 | 4642 | bool sel = true, const wxKeyboardState& kbd = wxKeyboardState()); |
23324ae1 FM |
4643 | |
4644 | /** | |
8b9ef005 | 4645 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 4646 | */ |
8b9ef005 | 4647 | bool AltDown() const; |
23324ae1 FM |
4648 | |
4649 | /** | |
8b9ef005 | 4650 | Returns @true if the Control key was down at the time of the event. |
23324ae1 | 4651 | */ |
8b9ef005 | 4652 | bool ControlDown() const; |
23324ae1 FM |
4653 | |
4654 | /** | |
8b9ef005 | 4655 | Column at which the event occurred. |
204530b0 VZ |
4656 | |
4657 | Notice that for a @c wxEVT_GRID_SELECT_CELL event this column is the | |
4658 | column of the newly selected cell while the previously selected cell | |
4659 | can be retrieved using wxGrid::GetGridCursorCol(). | |
23324ae1 | 4660 | */ |
8b9ef005 | 4661 | virtual int GetCol(); |
23324ae1 FM |
4662 | |
4663 | /** | |
8b9ef005 | 4664 | Position in pixels at which the event occurred. |
23324ae1 | 4665 | */ |
8b9ef005 | 4666 | wxPoint GetPosition(); |
23324ae1 FM |
4667 | |
4668 | /** | |
8b9ef005 | 4669 | Row at which the event occurred. |
204530b0 VZ |
4670 | |
4671 | Notice that for a @c wxEVT_GRID_SELECT_CELL event this row is the row | |
4672 | of the newly selected cell while the previously selected cell can be | |
4673 | retrieved using wxGrid::GetGridCursorRow(). | |
23324ae1 | 4674 | */ |
8b9ef005 | 4675 | virtual int GetRow(); |
23324ae1 FM |
4676 | |
4677 | /** | |
8b9ef005 | 4678 | Returns @true if the Meta key was down at the time of the event. |
23324ae1 | 4679 | */ |
8b9ef005 | 4680 | bool MetaDown() const; |
23324ae1 FM |
4681 | |
4682 | /** | |
8b9ef005 BP |
4683 | Returns @true if the user is selecting grid cells, or @false if |
4684 | deselecting. | |
23324ae1 | 4685 | */ |
8b9ef005 | 4686 | bool Selecting(); |
23324ae1 FM |
4687 | |
4688 | /** | |
8b9ef005 | 4689 | Returns @true if the Shift key was down at the time of the event. |
23324ae1 | 4690 | */ |
8b9ef005 BP |
4691 | bool ShiftDown() const; |
4692 | }; | |
23324ae1 | 4693 | |
08dd9b5a | 4694 | |
8b9ef005 BP |
4695 | |
4696 | /** | |
4697 | @class wxGridSizeEvent | |
4698 | ||
4699 | This event class contains information about a row/column resize event. | |
4700 | ||
4701 | @beginEventTable{wxGridSizeEvent} | |
8b9ef005 | 4702 | @event{EVT_GRID_CMD_COL_SIZE(id, func)} |
27bb2c8c VZ |
4703 | The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event |
4704 | type. | |
8b9ef005 | 4705 | @event{EVT_GRID_CMD_ROW_SIZE(id, func)} |
27bb2c8c VZ |
4706 | The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event |
4707 | type. | |
4708 | @event{EVT_GRID_COL_SIZE(func)} | |
4709 | Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id. | |
4710 | @event{EVT_GRID_ROW_SIZE(func)} | |
4711 | Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id. | |
8b9ef005 BP |
4712 | @endEventTable |
4713 | ||
4714 | @library{wxadv} | |
87638422 | 4715 | @category{grid,events} |
8b9ef005 BP |
4716 | */ |
4717 | class wxGridSizeEvent : public wxNotifyEvent | |
4718 | { | |
4719 | public: | |
4720 | /** | |
4721 | Default constructor. | |
23324ae1 | 4722 | */ |
8b9ef005 | 4723 | wxGridSizeEvent(); |
23324ae1 | 4724 | /** |
8b9ef005 | 4725 | Constructor for initializing all event attributes. |
23324ae1 | 4726 | */ |
8b9ef005 BP |
4727 | wxGridSizeEvent(int id, wxEventType type, wxObject* obj, |
4728 | int rowOrCol = -1, int x = -1, int y = -1, | |
ccf39540 | 4729 | const wxKeyboardState& kbd = wxKeyboardState()); |
23324ae1 FM |
4730 | |
4731 | /** | |
8b9ef005 | 4732 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 4733 | */ |
8b9ef005 | 4734 | bool AltDown() const; |
23324ae1 FM |
4735 | |
4736 | /** | |
8b9ef005 | 4737 | Returns @true if the Control key was down at the time of the event. |
23324ae1 | 4738 | */ |
8b9ef005 | 4739 | bool ControlDown() const; |
23324ae1 FM |
4740 | |
4741 | /** | |
8b9ef005 | 4742 | Position in pixels at which the event occurred. |
23324ae1 | 4743 | */ |
8b9ef005 | 4744 | wxPoint GetPosition(); |
23324ae1 FM |
4745 | |
4746 | /** | |
8b9ef005 | 4747 | Row or column at that was resized. |
23324ae1 | 4748 | */ |
8b9ef005 | 4749 | int GetRowOrCol(); |
23324ae1 FM |
4750 | |
4751 | /** | |
8b9ef005 | 4752 | Returns @true if the Meta key was down at the time of the event. |
23324ae1 | 4753 | */ |
8b9ef005 | 4754 | bool MetaDown() const; |
23324ae1 FM |
4755 | |
4756 | /** | |
8b9ef005 | 4757 | Returns @true if the Shift key was down at the time of the event. |
23324ae1 | 4758 | */ |
8b9ef005 BP |
4759 | bool ShiftDown() const; |
4760 | }; | |
23324ae1 | 4761 | |
3c4f71cc | 4762 | |
23324ae1 | 4763 | |
8b9ef005 BP |
4764 | /** |
4765 | @class wxGridRangeSelectEvent | |
08dd9b5a | 4766 | |
8b9ef005 BP |
4767 | @beginEventTable{wxGridRangeSelectEvent} |
4768 | @event{EVT_GRID_RANGE_SELECT(func)} | |
4769 | The user selected a group of contiguous cells. Processes a | |
4770 | @c wxEVT_GRID_RANGE_SELECT event type. | |
4771 | @event{EVT_GRID_CMD_RANGE_SELECT(id, func)} | |
4772 | The user selected a group of contiguous cells; variant taking a window | |
4773 | identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type. | |
4774 | @endEventTable | |
08dd9b5a | 4775 | |
8b9ef005 | 4776 | @library{wxadv} |
87638422 | 4777 | @category{grid,events} |
8b9ef005 BP |
4778 | */ |
4779 | class wxGridRangeSelectEvent : public wxNotifyEvent | |
4780 | { | |
4781 | public: | |
4782 | /** | |
4783 | Default constructor. | |
23324ae1 | 4784 | */ |
8b9ef005 | 4785 | wxGridRangeSelectEvent(); |
23324ae1 | 4786 | /** |
8b9ef005 | 4787 | Constructor for initializing all event attributes. |
23324ae1 | 4788 | */ |
8b9ef005 BP |
4789 | wxGridRangeSelectEvent(int id, wxEventType type, |
4790 | wxObject* obj, | |
4791 | const wxGridCellCoords& topLeft, | |
4792 | const wxGridCellCoords& bottomRight, | |
ccf39540 | 4793 | bool sel = true, const wxKeyboardState& kbd = wxKeyboardState()); |
23324ae1 FM |
4794 | |
4795 | /** | |
8b9ef005 | 4796 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 4797 | */ |
8b9ef005 | 4798 | bool AltDown() const; |
23324ae1 FM |
4799 | |
4800 | /** | |
8b9ef005 | 4801 | Returns @true if the Control key was down at the time of the event. |
23324ae1 | 4802 | */ |
8b9ef005 | 4803 | bool ControlDown() const; |
23324ae1 FM |
4804 | |
4805 | /** | |
8b9ef005 | 4806 | Top left corner of the rectangular area that was (de)selected. |
23324ae1 | 4807 | */ |
8b9ef005 | 4808 | wxGridCellCoords GetBottomRightCoords(); |
23324ae1 | 4809 | |
8a3e536c | 4810 | /** |
8b9ef005 BP |
4811 | Bottom row of the rectangular area that was (de)selected. |
4812 | */ | |
4813 | int GetBottomRow(); | |
8a3e536c | 4814 | |
23324ae1 | 4815 | /** |
8b9ef005 | 4816 | Left column of the rectangular area that was (de)selected. |
23324ae1 | 4817 | */ |
8b9ef005 | 4818 | int GetLeftCol(); |
23324ae1 FM |
4819 | |
4820 | /** | |
8b9ef005 | 4821 | Right column of the rectangular area that was (de)selected. |
23324ae1 | 4822 | */ |
8b9ef005 | 4823 | int GetRightCol(); |
5e6e278d | 4824 | |
5e6e278d | 4825 | /** |
8b9ef005 | 4826 | Top left corner of the rectangular area that was (de)selected. |
5e6e278d | 4827 | */ |
8b9ef005 | 4828 | wxGridCellCoords GetTopLeftCoords(); |
5e6e278d FM |
4829 | |
4830 | /** | |
8b9ef005 | 4831 | Top row of the rectangular area that was (de)selected. |
5e6e278d | 4832 | */ |
8b9ef005 | 4833 | int GetTopRow(); |
5e6e278d FM |
4834 | |
4835 | /** | |
8b9ef005 | 4836 | Returns @true if the Meta key was down at the time of the event. |
5e6e278d | 4837 | */ |
8b9ef005 | 4838 | bool MetaDown() const; |
5e6e278d FM |
4839 | |
4840 | /** | |
8b9ef005 | 4841 | Returns @true if the area was selected, @false otherwise. |
5e6e278d | 4842 | */ |
8b9ef005 | 4843 | bool Selecting(); |
5e6e278d FM |
4844 | |
4845 | /** | |
8b9ef005 | 4846 | Returns @true if the Shift key was down at the time of the event. |
5e6e278d | 4847 | */ |
8b9ef005 | 4848 | bool ShiftDown() const; |
23324ae1 FM |
4849 | }; |
4850 | ||
4851 | ||
e54c96f1 | 4852 | |
23324ae1 | 4853 | /** |
8b9ef005 | 4854 | @class wxGridEditorCreatedEvent |
7c913512 | 4855 | |
8b9ef005 BP |
4856 | @beginEventTable{wxGridEditorCreatedEvent} |
4857 | @event{EVT_GRID_EDITOR_CREATED(func)} | |
4858 | The editor for a cell was created. Processes a | |
4859 | @c wxEVT_GRID_EDITOR_CREATED event type. | |
4860 | @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)} | |
4861 | The editor for a cell was created; variant taking a window identifier. | |
4862 | Processes a @c wxEVT_GRID_EDITOR_CREATED event type. | |
4863 | @endEventTable | |
7c913512 | 4864 | |
23324ae1 | 4865 | @library{wxadv} |
87638422 | 4866 | @category{grid,events} |
23324ae1 | 4867 | */ |
8b9ef005 | 4868 | class wxGridEditorCreatedEvent : public wxCommandEvent |
23324ae1 FM |
4869 | { |
4870 | public: | |
4871 | /** | |
4872 | Default constructor. | |
4873 | */ | |
8b9ef005 | 4874 | wxGridEditorCreatedEvent(); |
23324ae1 | 4875 | /** |
8b9ef005 | 4876 | Constructor for initializing all event attributes. |
23324ae1 | 4877 | */ |
8b9ef005 BP |
4878 | wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj, |
4879 | int row, int col, wxControl* ctrl); | |
23324ae1 FM |
4880 | |
4881 | /** | |
8b9ef005 | 4882 | Returns the column at which the event occurred. |
23324ae1 | 4883 | */ |
8b9ef005 | 4884 | int GetCol(); |
7c913512 | 4885 | |
8b9ef005 BP |
4886 | /** |
4887 | Returns the edit control. | |
4888 | */ | |
4889 | wxControl* GetControl(); | |
7c913512 | 4890 | |
8b9ef005 BP |
4891 | /** |
4892 | Returns the row at which the event occurred. | |
4893 | */ | |
4894 | int GetRow(); | |
7c913512 | 4895 | |
23324ae1 | 4896 | /** |
8b9ef005 | 4897 | Sets the column at which the event occurred. |
23324ae1 | 4898 | */ |
8b9ef005 | 4899 | void SetCol(int col); |
23324ae1 FM |
4900 | |
4901 | /** | |
8b9ef005 | 4902 | Sets the edit control. |
23324ae1 | 4903 | */ |
8b9ef005 | 4904 | void SetControl(wxControl* ctrl); |
23324ae1 FM |
4905 | |
4906 | /** | |
8b9ef005 | 4907 | Sets the row at which the event occurred. |
23324ae1 | 4908 | */ |
8b9ef005 | 4909 | void SetRow(int row); |
23324ae1 | 4910 | }; |
e54c96f1 | 4911 | |
cd64c053 RD |
4912 | |
4913 | wxEventType wxEVT_GRID_CELL_LEFT_CLICK; | |
4914 | wxEventType wxEVT_GRID_CELL_RIGHT_CLICK; | |
4915 | wxEventType wxEVT_GRID_CELL_LEFT_DCLICK; | |
4916 | wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK; | |
4917 | wxEventType wxEVT_GRID_LABEL_LEFT_CLICK; | |
4918 | wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK; | |
4919 | wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK; | |
4920 | wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK; | |
4921 | wxEventType wxEVT_GRID_ROW_SIZE; | |
4922 | wxEventType wxEVT_GRID_COL_SIZE; | |
4923 | wxEventType wxEVT_GRID_RANGE_SELECT; | |
4924 | wxEventType wxEVT_GRID_CELL_CHANGING; | |
4925 | wxEventType wxEVT_GRID_CELL_CHANGED; | |
4926 | wxEventType wxEVT_GRID_SELECT_CELL; | |
4927 | wxEventType wxEVT_GRID_EDITOR_SHOWN; | |
4928 | wxEventType wxEVT_GRID_EDITOR_HIDDEN; | |
4929 | wxEventType wxEVT_GRID_EDITOR_CREATED; | |
4930 | wxEventType wxEVT_GRID_CELL_BEGIN_DRAG; | |
4931 | wxEventType wxEVT_GRID_COL_MOVE; | |
4932 | wxEventType wxEVT_GRID_COL_SORT; | |
4933 | wxEventType wxEVT_GRID_TABBING; | |
4934 |