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