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