]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: grid.h | |
e54c96f1 | 3 | // Purpose: interface of wxGridCellFloatRenderer |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxGridCellFloatRenderer | |
7c913512 | 11 | |
23324ae1 | 12 | This class may be used to format floating point data in a cell. |
7c913512 | 13 | |
23324ae1 | 14 | @library{wxadv} |
42b5841f | 15 | @category{grid} |
7c913512 | 16 | |
e54c96f1 | 17 | @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer, |
23324ae1 FM |
18 | wxGridCellBoolRenderer |
19 | */ | |
20 | class wxGridCellFloatRenderer : public wxGridCellStringRenderer | |
21 | { | |
22 | public: | |
23 | /** | |
7c913512 | 24 | @param width |
4cc4bfaf | 25 | Minimum number of characters to be shown. |
7c913512 | 26 | @param precision |
4cc4bfaf | 27 | Number of digits after the decimal dot. |
23324ae1 FM |
28 | */ |
29 | wxGridCellFloatRenderer(int width = -1, int precision = -1); | |
30 | ||
31 | /** | |
42b5841f | 32 | Returns the precision. |
23324ae1 | 33 | */ |
328f5751 | 34 | int GetPrecision() const; |
23324ae1 FM |
35 | |
36 | /** | |
42b5841f | 37 | Returns the width. |
23324ae1 | 38 | */ |
328f5751 | 39 | int GetWidth() const; |
23324ae1 FM |
40 | |
41 | /** | |
42 | Parameters string format is "width[,precision]". | |
43 | */ | |
adaaa686 | 44 | virtual void SetParameters(const wxString& params); |
23324ae1 FM |
45 | |
46 | /** | |
42b5841f | 47 | Sets the precision. |
23324ae1 FM |
48 | */ |
49 | void SetPrecision(int precision); | |
50 | ||
51 | /** | |
42b5841f | 52 | Sets the width. |
23324ae1 FM |
53 | */ |
54 | void SetWidth(int width); | |
55 | }; | |
56 | ||
57 | ||
e54c96f1 | 58 | |
23324ae1 FM |
59 | /** |
60 | @class wxGridTableBase | |
7c913512 | 61 | |
5039f140 VZ |
62 | The almost abstract base class for grid tables. |
63 | ||
64 | A grid table is responsible for storing the grid data and, indirectly, grid | |
65 | cell attributes. The data can be stored in the way most convenient for the | |
66 | application but has to be provided in string form to wxGrid. It is also | |
67 | possible to provide cells values in other formats if appropriate, e.g. as | |
68 | numbers. | |
69 | ||
70 | This base class is not quite abstract as it implements a trivial strategy | |
71 | for storing the attributes by forwarding it to wxGridCellAttrProvider and | |
72 | also provides stubs for some other functions. However it does have a number | |
73 | of pure virtual methods which must be implemented in the derived classes. | |
74 | ||
75 | @see wxGridStringTable | |
7c913512 | 76 | |
23324ae1 | 77 | @library{wxadv} |
42b5841f | 78 | @category{grid} |
23324ae1 FM |
79 | */ |
80 | class wxGridTableBase : public wxObject | |
81 | { | |
82 | public: | |
5039f140 | 83 | /// Default constructor. |
23324ae1 FM |
84 | wxGridTableBase(); |
85 | ||
5039f140 VZ |
86 | /// Destructor frees the attribute provider if it was created. |
87 | virtual ~wxGridTableBase(); | |
3c4f71cc | 88 | |
77d2c45c VZ |
89 | /** |
90 | Must be overridden to return the number of rows in the table. | |
91 | ||
92 | For backwards compatibility reasons, this method is not const. | |
93 | Use GetRowsCount() instead of it in const methods of derived table | |
94 | classes. | |
95 | */ | |
5039f140 | 96 | virtual int GetNumberRows() = 0; |
23324ae1 | 97 | |
77d2c45c VZ |
98 | /** |
99 | Must be overridden to return the number of columns in the table. | |
100 | ||
101 | For backwards compatibility reasons, this method is not const. | |
102 | Use GetColsCount() instead of it in const methods of derived table | |
103 | classes, | |
104 | */ | |
5039f140 | 105 | virtual int GetNumberCols() = 0; |
3c4f71cc | 106 | |
77d2c45c VZ |
107 | /** |
108 | Return the number of rows in the table. | |
109 | ||
110 | This method is not virtual and is only provided as a convenience for | |
111 | the derived classes which can't call GetNumberRows() without a @c | |
112 | const_cast from their const methods. | |
113 | */ | |
114 | int GetRowsCount() const; | |
115 | ||
116 | /** | |
117 | Return the number of columns in the table. | |
118 | ||
119 | This method is not virtual and is only provided as a convenience for | |
120 | the derived classes which can't call GetNumberCols() without a @c | |
121 | const_cast from their const methods. | |
122 | */ | |
123 | int GetColsCount() const; | |
124 | ||
23324ae1 FM |
125 | |
126 | /** | |
5039f140 VZ |
127 | Accessing table cells. |
128 | */ | |
129 | //@{ | |
3c4f71cc | 130 | |
5039f140 VZ |
131 | /// Must be overridden to implement testing for empty cells. |
132 | virtual bool IsEmptyCell(int row, int col) = 0; | |
23324ae1 | 133 | |
10a4531d VZ |
134 | /** |
135 | Same as IsEmptyCell() but taking wxGridCellCoords. | |
136 | ||
137 | Notice that this method is not virtual, only IsEmptyCell() should be | |
138 | overridden. | |
139 | */ | |
140 | bool IsEmpty(const wxGridCellCoords& coords); | |
141 | ||
5039f140 VZ |
142 | /// Must be overridden to implement accessing the table values as text. |
143 | virtual wxString GetValue(int row, int col) = 0; | |
3c4f71cc | 144 | |
5039f140 VZ |
145 | /// Must be overridden to implement setting the table values as text. |
146 | virtual void SetValue(int row, int col, const wxString& value) = 0; | |
23324ae1 FM |
147 | |
148 | /** | |
5039f140 VZ |
149 | Returns the type of the value in the given cell. |
150 | ||
151 | By default all cells are strings and this method returns @c | |
152 | wxGRID_VALUE_STRING. | |
153 | */ | |
154 | virtual wxString GetTypeName(int row, int col); | |
23324ae1 FM |
155 | |
156 | /** | |
5039f140 VZ |
157 | Returns true if the value of the given cell can be accessed as if it |
158 | were of the specified type. | |
3c4f71cc | 159 | |
5039f140 VZ |
160 | By default the cells can only be accessed as strings. Note that a cell |
161 | could be accessible in different ways, e.g. a numeric cell may return | |
162 | @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING | |
163 | indicating that the value can be coerced to a string form. | |
164 | */ | |
165 | virtual bool CanGetValueAs(int row, int col, const wxString& typeName); | |
23324ae1 FM |
166 | |
167 | /** | |
5039f140 VZ |
168 | Returns true if the value of the given cell can be set as if it were of |
169 | the specified type. | |
3c4f71cc | 170 | |
5039f140 VZ |
171 | @see CanGetValueAs() |
172 | */ | |
173 | virtual bool CanSetValueAs(int row, int col, const wxString& typeName); | |
23324ae1 FM |
174 | |
175 | /** | |
5039f140 | 176 | Returns the value of the given cell as a long. |
3c4f71cc | 177 | |
5039f140 VZ |
178 | This should only be called if CanGetValueAs() returns @true when called |
179 | with @c wxGRID_VALUE_NUMBER argument. Default implementation always | |
180 | return 0. | |
181 | */ | |
182 | virtual long GetValueAsLong(int row, int col); | |
23324ae1 FM |
183 | |
184 | /** | |
5039f140 | 185 | Returns the value of the given cell as a double. |
3c4f71cc | 186 | |
5039f140 VZ |
187 | This should only be called if CanGetValueAs() returns @true when called |
188 | with @c wxGRID_VALUE_FLOAT argument. Default implementation always | |
189 | return 0.0. | |
190 | */ | |
191 | virtual double GetValueAsDouble(int row, int col); | |
23324ae1 FM |
192 | |
193 | /** | |
5039f140 | 194 | Returns the value of the given cell as a boolean. |
23324ae1 | 195 | |
5039f140 VZ |
196 | This should only be called if CanGetValueAs() returns @true when called |
197 | with @c wxGRID_VALUE_BOOL argument. Default implementation always | |
198 | return false. | |
199 | */ | |
200 | virtual bool GetValueAsBool(int row, int col); | |
23324ae1 FM |
201 | |
202 | /** | |
5039f140 VZ |
203 | Returns the value of the given cell as a user-defined type. |
204 | ||
205 | This should only be called if CanGetValueAs() returns @true when called | |
206 | with @a typeName. Default implementation always return @NULL. | |
207 | */ | |
208 | virtual void *GetValueAsCustom(int row, int col, const wxString& typeName); | |
3c4f71cc | 209 | |
23324ae1 FM |
210 | |
211 | /** | |
5039f140 | 212 | Sets the value of the given cell as a long. |
3c4f71cc | 213 | |
5039f140 VZ |
214 | This should only be called if CanSetValueAs() returns @true when called |
215 | with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do | |
216 | anything. | |
217 | */ | |
218 | virtual void SetValueAsLong(int row, int col, long value); | |
23324ae1 FM |
219 | |
220 | /** | |
5039f140 VZ |
221 | Sets the value of the given cell as a double. |
222 | ||
223 | This should only be called if CanSetValueAs() returns @true when called | |
224 | with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do | |
225 | anything. | |
226 | */ | |
227 | virtual void SetValueAsDouble(int row, int col, double value); | |
23324ae1 FM |
228 | |
229 | /** | |
5039f140 | 230 | Sets the value of the given cell as a boolean. |
3c4f71cc | 231 | |
5039f140 VZ |
232 | This should only be called if CanSetValueAs() returns @true when called |
233 | with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do | |
234 | anything. | |
235 | */ | |
236 | virtual void SetValueAsBool( int row, int col, bool value ); | |
23324ae1 FM |
237 | |
238 | /** | |
5039f140 | 239 | Sets the value of the given cell as a user-defined type. |
23324ae1 | 240 | |
5039f140 VZ |
241 | This should only be called if CanSetValueAs() returns @true when called |
242 | with @a typeName. Default implementation doesn't do anything. | |
243 | */ | |
244 | virtual void SetValueAsCustom(int row, int col, const wxString& typeName, | |
245 | void *value); | |
3c4f71cc | 246 | |
5039f140 | 247 | //@} |
23324ae1 FM |
248 | |
249 | /** | |
5039f140 | 250 | Called by the grid when the table is associated with it. |
3c4f71cc | 251 | |
5039f140 VZ |
252 | The default implementation stores the pointer and returns it from its |
253 | GetView() and so only makes sense if the table cannot be associated | |
254 | with more than one grid at a time. | |
255 | */ | |
256 | virtual void SetView(wxGrid *grid); | |
23324ae1 FM |
257 | |
258 | /** | |
5039f140 VZ |
259 | Returns the last grid passed to SetView(). |
260 | */ | |
261 | virtual wxGrid *GetView() const; | |
262 | ||
23324ae1 FM |
263 | |
264 | /** | |
5039f140 | 265 | Modifying the table structure. |
3c4f71cc | 266 | |
5039f140 VZ |
267 | Notice that none of these functions are pure virtual as they don't have |
268 | to be implemented if the table structure is never modified after | |
269 | creation, i.e. neither rows nor columns are never added or deleted but | |
270 | that you do need to implement them if they are called, i.e. if your | |
271 | code either calls them directly or uses the matching wxGrid methods, as | |
272 | by default they simply do nothing which is definitely inappropriate. | |
273 | */ | |
274 | //@{ | |
23324ae1 FM |
275 | |
276 | /** | |
5039f140 | 277 | Clear the table contents. |
3c4f71cc | 278 | |
5039f140 VZ |
279 | This method is used by wxGrid::ClearGrid(). |
280 | */ | |
281 | virtual void Clear(); | |
23324ae1 FM |
282 | |
283 | /** | |
5039f140 | 284 | Insert additional rows into the table. |
3c4f71cc | 285 | |
5039f140 VZ |
286 | @param pos |
287 | The position of the first new row. | |
288 | @param numRows | |
289 | The number of rows to insert. | |
290 | */ | |
291 | virtual bool InsertRows(size_t pos = 0, size_t numRows = 1); | |
23324ae1 FM |
292 | |
293 | /** | |
5039f140 | 294 | Append additional rows at the end of the table. |
3c4f71cc | 295 | |
5039f140 VZ |
296 | This method is provided in addition to InsertRows() as some data models |
297 | may only support appending rows to them but not inserting them at | |
298 | arbitrary locations. In such case you may implement this method only | |
299 | and leave InsertRows() unimplemented. | |
300 | ||
301 | @param pos | |
302 | The position of the first new row. | |
303 | @param numRows | |
304 | The number of rows to add. | |
305 | */ | |
306 | virtual bool AppendRows(size_t numRows = 1); | |
23324ae1 FM |
307 | |
308 | /** | |
5039f140 | 309 | Delete rows from the table. |
3c4f71cc | 310 | |
5039f140 VZ |
311 | @param pos |
312 | The first row to delete. | |
313 | @param numRows | |
314 | The number of rows to delete. | |
315 | */ | |
316 | virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1); | |
23324ae1 | 317 | |
5039f140 VZ |
318 | /// Exactly the same as InsertRows() but for columns. |
319 | virtual bool InsertCols(size_t pos = 0, size_t numCols = 1); | |
3c4f71cc | 320 | |
5039f140 VZ |
321 | /// Exactly the same as AppendRows() but for columns. |
322 | virtual bool AppendCols(size_t numCols = 1); | |
23324ae1 | 323 | |
5039f140 VZ |
324 | /// Exactly the same as DeleteRows() but for columns. |
325 | virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1); | |
23324ae1 | 326 | |
5039f140 | 327 | //@} |
23324ae1 FM |
328 | |
329 | /** | |
5039f140 | 330 | Table rows and columns labels. |
3c4f71cc | 331 | |
5039f140 VZ |
332 | By default the numbers are used for labeling rows and Latin letters for |
333 | labeling columns. If the table has more than 26 columns, the pairs of | |
334 | letters are used starting from the 27-th one and so on, i.e. the | |
335 | sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ, | |
336 | AAA, ... | |
337 | */ | |
338 | //@{ | |
23324ae1 | 339 | |
5039f140 VZ |
340 | /// Return the label of the specified row. |
341 | virtual wxString GetRowLabelValue(int row); | |
342 | ||
343 | /// Return the label of the specified column. | |
344 | virtual wxString GetColLabelValue(int col); | |
23324ae1 FM |
345 | |
346 | /** | |
5039f140 | 347 | Set the given label for the specified row. |
3c4f71cc | 348 | |
5039f140 VZ |
349 | The default version does nothing, i.e. the label is not stored. You |
350 | must override this method in your derived class if you wish | |
351 | wxGrid::SetRowLabelValue() to work. | |
352 | */ | |
353 | virtual void SetRowLabelValue(int row, const wxString& label); | |
354 | ||
355 | /// Exactly the same as SetRowLabelValue() but for columns. | |
356 | virtual void SetColLabelValue(int col, const wxString& label); | |
357 | ||
358 | //@} | |
23324ae1 | 359 | |
23324ae1 FM |
360 | |
361 | /** | |
5039f140 | 362 | Attributes management. |
3c4f71cc | 363 | |
5039f140 VZ |
364 | By default the attributes management is delegated to |
365 | wxGridCellAttrProvider class. You may override the methods in this | |
366 | section to handle the attributes directly if, for example, they can be | |
367 | computed from the cell values. | |
368 | */ | |
369 | //@{ | |
23324ae1 FM |
370 | |
371 | /** | |
5039f140 | 372 | Associate this attributes provider with the table. |
3c4f71cc | 373 | |
5039f140 VZ |
374 | The table takes ownership of @a attrProvider pointer and will delete it |
375 | when it doesn't need it any more. The pointer can be @NULL, however | |
376 | this won't disable attributes management in the table but will just | |
377 | result in a default attributes being recreated the next time any of the | |
378 | other functions in this section is called. To completely disable the | |
379 | attributes support, should this be needed, you need to override | |
380 | CanHaveAttributes() to return @false. | |
381 | */ | |
382 | void SetAttrProvider(wxGridCellAttrProvider *attrProvider); | |
23324ae1 FM |
383 | |
384 | /** | |
5039f140 | 385 | Returns the attribute provider currently being used. |
3c4f71cc | 386 | |
5039f140 VZ |
387 | This function may return @NULL if the attribute provider hasn't been |
388 | neither associated with this table by SetAttrProvider() nor created on | |
389 | demand by any other methods. | |
390 | */ | |
391 | wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; } | |
23324ae1 FM |
392 | |
393 | /** | |
5039f140 | 394 | Returns true if this table supports attributes or false otherwise. |
3c4f71cc | 395 | |
5039f140 VZ |
396 | By default, the table automatically creates a wxGridCellAttrProvider |
397 | when this function is called if it had no attribute provider before and | |
398 | returns @true. | |
399 | */ | |
400 | virtual bool CanHaveAttributes(); | |
23324ae1 FM |
401 | |
402 | /** | |
5039f140 | 403 | Return the attribute for the given cell. |
3c4f71cc | 404 | |
5039f140 VZ |
405 | By default this function is simply forwarded to |
406 | wxGridCellAttrProvider::GetAttr() but it may be overridden to handle | |
407 | attributes directly in the table. | |
408 | */ | |
409 | virtual wxGridCellAttr *GetAttr(int row, int col, | |
410 | wxGridCellAttr::wxAttrKind kind); | |
23324ae1 FM |
411 | |
412 | /** | |
5039f140 VZ |
413 | Set attribute of the specified cell. |
414 | ||
415 | By default this function is simply forwarded to | |
416 | wxGridCellAttrProvider::SetAttr(). | |
417 | ||
418 | The table takes ownership of @a attr, i.e. will call DecRef() on it. | |
419 | */ | |
420 | virtual void SetAttr(wxGridCellAttr* attr, int row, int col); | |
23324ae1 FM |
421 | |
422 | /** | |
5039f140 | 423 | Set attribute of the specified row. |
3c4f71cc | 424 | |
5039f140 VZ |
425 | By default this function is simply forwarded to |
426 | wxGridCellAttrProvider::SetRowAttr(). | |
427 | ||
428 | The table takes ownership of @a attr, i.e. will call DecRef() on it. | |
429 | */ | |
430 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); | |
23324ae1 FM |
431 | |
432 | /** | |
5039f140 VZ |
433 | Set attribute of the specified column. |
434 | ||
435 | By default this function is simply forwarded to | |
436 | wxGridCellAttrProvider::SetColAttr(). | |
437 | ||
438 | The table takes ownership of @a attr, i.e. will call DecRef() on it. | |
439 | */ | |
440 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
441 | ||
442 | //@} | |
23324ae1 FM |
443 | }; |
444 | ||
445 | ||
e54c96f1 | 446 | |
23324ae1 FM |
447 | /** |
448 | @class wxGridCellEditor | |
7c913512 | 449 | |
23324ae1 FM |
450 | This class is responsible for providing and manipulating |
451 | the in-place edit controls for the grid. Instances of wxGridCellEditor | |
452 | (actually, instances of derived classes since it is an abstract class) can be | |
453 | associated with the cell attributes for individual cells, rows, columns, or | |
454 | even for the entire grid. | |
7c913512 | 455 | |
23324ae1 | 456 | @library{wxadv} |
42b5841f | 457 | @category{grid} |
7c913512 | 458 | |
e54c96f1 | 459 | @see wxGridCellTextEditor, wxGridCellFloatEditor, wxGridCellBoolEditor, |
23324ae1 FM |
460 | wxGridCellNumberEditor, wxGridCellChoiceEditor |
461 | */ | |
7c913512 | 462 | class wxGridCellEditor |
23324ae1 FM |
463 | { |
464 | public: | |
465 | /** | |
3c4f71cc | 466 | |
23324ae1 FM |
467 | */ |
468 | wxGridCellEditor(); | |
469 | ||
470 | /** | |
471 | The dtor is private because only DecRef() can delete us. | |
472 | */ | |
0004982c | 473 | virtual ~wxGridCellEditor(); |
23324ae1 FM |
474 | |
475 | /** | |
476 | Fetch the value from the table and prepare the edit control | |
477 | to begin editing. Set the focus to the edit control. | |
478 | */ | |
da1ed74c | 479 | virtual void BeginEdit(int row, int col, wxGrid* grid) = 0; |
23324ae1 FM |
480 | |
481 | /** | |
482 | Create a new object which is the copy of this one. | |
483 | */ | |
da1ed74c | 484 | virtual wxGridCellEditor* Clone() const = 0; |
23324ae1 FM |
485 | |
486 | /** | |
487 | Creates the actual edit control. | |
488 | */ | |
489 | void Create(wxWindow* parent, wxWindowID id, | |
490 | wxEvtHandler* evtHandler); | |
491 | ||
492 | /** | |
493 | Final cleanup. | |
494 | */ | |
adaaa686 | 495 | virtual void Destroy(); |
23324ae1 FM |
496 | |
497 | /** | |
498 | Complete the editing of the current cell. Returns @true if the value has | |
499 | changed. If necessary, the control may be destroyed. | |
500 | */ | |
da1ed74c | 501 | virtual bool EndEdit(int row, int col, wxGrid* grid) = 0; |
23324ae1 FM |
502 | |
503 | /** | |
504 | Some types of controls on some platforms may need some help | |
505 | with the Return key. | |
506 | */ | |
adaaa686 | 507 | virtual void HandleReturn(wxKeyEvent& event); |
23324ae1 FM |
508 | |
509 | /** | |
3c4f71cc | 510 | |
23324ae1 FM |
511 | */ |
512 | bool IsCreated(); | |
513 | ||
514 | /** | |
515 | Draws the part of the cell not occupied by the control: the base class | |
516 | version just fills it with background colour from the attribute. | |
517 | */ | |
518 | void PaintBackground(const wxRect& rectCell, | |
519 | wxGridCellAttr* attr); | |
520 | ||
521 | /** | |
522 | Reset the value in the control back to its starting value. | |
523 | */ | |
da1ed74c | 524 | virtual void Reset() = 0; |
23324ae1 FM |
525 | |
526 | /** | |
527 | Size and position the edit control. | |
528 | */ | |
adaaa686 | 529 | virtual void SetSize(const wxRect& rect); |
23324ae1 FM |
530 | |
531 | /** | |
532 | Show or hide the edit control, use the specified attributes to set | |
533 | colours/fonts for it. | |
534 | */ | |
adaaa686 | 535 | virtual void Show(bool show, wxGridCellAttr* attr = NULL); |
23324ae1 FM |
536 | |
537 | /** | |
538 | If the editor is enabled by clicking on the cell, this method will be | |
539 | called. | |
540 | */ | |
adaaa686 | 541 | virtual void StartingClick(); |
23324ae1 FM |
542 | |
543 | /** | |
544 | If the editor is enabled by pressing keys on the grid, | |
545 | this will be called to let the editor do something about | |
546 | that first key if desired. | |
547 | */ | |
adaaa686 | 548 | virtual void StartingKey(wxKeyEvent& event); |
23324ae1 FM |
549 | }; |
550 | ||
551 | ||
e54c96f1 | 552 | |
23324ae1 FM |
553 | /** |
554 | @class wxGridCellTextEditor | |
7c913512 | 555 | |
23324ae1 | 556 | The editor for string/text data. |
7c913512 | 557 | |
23324ae1 | 558 | @library{wxadv} |
42b5841f | 559 | @category{grid} |
7c913512 | 560 | |
e54c96f1 | 561 | @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor, |
23324ae1 FM |
562 | wxGridCellNumberEditor, wxGridCellChoiceEditor |
563 | */ | |
564 | class wxGridCellTextEditor : public wxGridCellEditor | |
565 | { | |
566 | public: | |
567 | /** | |
568 | Default constructor. | |
569 | */ | |
570 | wxGridCellTextEditor(); | |
571 | ||
572 | /** | |
573 | The parameters string format is "n" where n is a number representing the | |
574 | maximum width. | |
575 | */ | |
adaaa686 | 576 | virtual void SetParameters(const wxString& params); |
23324ae1 FM |
577 | }; |
578 | ||
579 | ||
e54c96f1 | 580 | |
23324ae1 FM |
581 | /** |
582 | @class wxGridCellStringRenderer | |
7c913512 | 583 | |
23324ae1 FM |
584 | This class may be used to format string data in a cell; it is the default |
585 | for string cells. | |
7c913512 | 586 | |
23324ae1 | 587 | @library{wxadv} |
42b5841f | 588 | @category{grid} |
7c913512 | 589 | |
e54c96f1 | 590 | @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer, |
23324ae1 FM |
591 | wxGridCellBoolRenderer |
592 | */ | |
593 | class wxGridCellStringRenderer : public wxGridCellRenderer | |
594 | { | |
595 | public: | |
596 | /** | |
597 | Default constructor | |
598 | */ | |
599 | wxGridCellStringRenderer(); | |
600 | }; | |
601 | ||
602 | ||
e54c96f1 | 603 | |
23324ae1 FM |
604 | /** |
605 | @class wxGridCellChoiceEditor | |
7c913512 | 606 | |
23324ae1 | 607 | The editor for string data allowing to choose from a list of strings. |
7c913512 | 608 | |
23324ae1 | 609 | @library{wxadv} |
42b5841f | 610 | @category{grid} |
7c913512 | 611 | |
e54c96f1 | 612 | @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor, |
23324ae1 FM |
613 | wxGridCellTextEditor, wxGridCellNumberEditor |
614 | */ | |
615 | class wxGridCellChoiceEditor : public wxGridCellEditor | |
616 | { | |
617 | public: | |
618 | //@{ | |
619 | /** | |
7c913512 | 620 | @param count |
4cc4bfaf | 621 | Number of strings from which the user can choose. |
7c913512 | 622 | @param choices |
4cc4bfaf | 623 | An array of strings from which the user can choose. |
7c913512 | 624 | @param allowOthers |
4cc4bfaf | 625 | If allowOthers is @true, the user can type a string not in choices array. |
23324ae1 FM |
626 | */ |
627 | wxGridCellChoiceEditor(size_t count = 0, | |
4cc4bfaf FM |
628 | const wxString choices[] = NULL, |
629 | bool allowOthers = false); | |
7c913512 | 630 | wxGridCellChoiceEditor(const wxArrayString& choices, |
4cc4bfaf | 631 | bool allowOthers = false); |
23324ae1 FM |
632 | //@} |
633 | ||
634 | /** | |
635 | Parameters string format is "item1[,item2[...,itemN]]" | |
636 | */ | |
adaaa686 | 637 | virtual void SetParameters(const wxString& params); |
23324ae1 FM |
638 | }; |
639 | ||
640 | ||
e54c96f1 | 641 | |
23324ae1 FM |
642 | /** |
643 | @class wxGridEditorCreatedEvent | |
7c913512 FM |
644 | |
645 | ||
23324ae1 | 646 | @library{wxadv} |
42b5841f | 647 | @category{grid} |
23324ae1 FM |
648 | */ |
649 | class wxGridEditorCreatedEvent : public wxCommandEvent | |
650 | { | |
651 | public: | |
652 | //@{ | |
653 | /** | |
3c4f71cc | 654 | |
23324ae1 FM |
655 | */ |
656 | wxGridEditorCreatedEvent(); | |
7c913512 FM |
657 | wxGridEditorCreatedEvent(int id, wxEventType type, |
658 | wxObject* obj, | |
659 | int row, | |
660 | int col, | |
661 | wxControl* ctrl); | |
23324ae1 FM |
662 | //@} |
663 | ||
664 | /** | |
665 | Returns the column at which the event occurred. | |
666 | */ | |
667 | int GetCol(); | |
668 | ||
669 | /** | |
670 | Returns the edit control. | |
671 | */ | |
672 | wxControl* GetControl(); | |
673 | ||
674 | /** | |
675 | Returns the row at which the event occurred. | |
676 | */ | |
677 | int GetRow(); | |
678 | ||
679 | /** | |
680 | Sets the column at which the event occurred. | |
681 | */ | |
682 | void SetCol(int col); | |
683 | ||
684 | /** | |
685 | Sets the edit control. | |
686 | */ | |
687 | void SetControl(wxControl* ctrl); | |
688 | ||
689 | /** | |
690 | Sets the row at which the event occurred. | |
691 | */ | |
692 | void SetRow(int row); | |
693 | }; | |
694 | ||
695 | ||
e54c96f1 | 696 | |
23324ae1 FM |
697 | /** |
698 | @class wxGridRangeSelectEvent | |
7c913512 FM |
699 | |
700 | ||
23324ae1 | 701 | @library{wxadv} |
42b5841f | 702 | @category{grid} |
23324ae1 FM |
703 | */ |
704 | class wxGridRangeSelectEvent : public wxNotifyEvent | |
705 | { | |
706 | public: | |
707 | //@{ | |
708 | /** | |
3c4f71cc | 709 | |
23324ae1 FM |
710 | */ |
711 | wxGridRangeSelectEvent(); | |
7c913512 FM |
712 | wxGridRangeSelectEvent(int id, wxEventType type, |
713 | wxObject* obj, | |
714 | const wxGridCellCoords& topLeft, | |
715 | const wxGridCellCoords& bottomRight, | |
4cc4bfaf FM |
716 | bool sel = true, |
717 | bool control = false, | |
718 | bool shift = false, | |
719 | bool alt = false, | |
720 | bool meta = false); | |
23324ae1 FM |
721 | //@} |
722 | ||
723 | /** | |
724 | Returns @true if the Alt key was down at the time of the event. | |
725 | */ | |
0004982c | 726 | bool AltDown() const; |
23324ae1 FM |
727 | |
728 | /** | |
729 | Returns @true if the Control key was down at the time of the event. | |
730 | */ | |
0004982c | 731 | bool ControlDown() const; |
23324ae1 FM |
732 | |
733 | /** | |
734 | Top left corner of the rectangular area that was (de)selected. | |
735 | */ | |
736 | wxGridCellCoords GetBottomRightCoords(); | |
737 | ||
738 | /** | |
739 | Bottom row of the rectangular area that was (de)selected. | |
740 | */ | |
741 | int GetBottomRow(); | |
742 | ||
743 | /** | |
744 | Left column of the rectangular area that was (de)selected. | |
745 | */ | |
746 | int GetLeftCol(); | |
747 | ||
748 | /** | |
749 | Right column of the rectangular area that was (de)selected. | |
750 | */ | |
751 | int GetRightCol(); | |
752 | ||
753 | /** | |
754 | Top left corner of the rectangular area that was (de)selected. | |
755 | */ | |
756 | wxGridCellCoords GetTopLeftCoords(); | |
757 | ||
758 | /** | |
759 | Top row of the rectangular area that was (de)selected. | |
760 | */ | |
761 | int GetTopRow(); | |
762 | ||
763 | /** | |
764 | Returns @true if the Meta key was down at the time of the event. | |
765 | */ | |
0004982c | 766 | bool MetaDown() const; |
23324ae1 FM |
767 | |
768 | /** | |
769 | Returns @true if the area was selected, @false otherwise. | |
770 | */ | |
771 | bool Selecting(); | |
772 | ||
773 | /** | |
774 | Returns @true if the Shift key was down at the time of the event. | |
775 | */ | |
0004982c | 776 | bool ShiftDown() const; |
23324ae1 FM |
777 | }; |
778 | ||
779 | ||
e54c96f1 | 780 | |
23324ae1 FM |
781 | /** |
782 | @class wxGridCellRenderer | |
7c913512 | 783 | |
23324ae1 FM |
784 | This class is responsible for actually drawing the cell |
785 | in the grid. You may pass it to the wxGridCellAttr (below) to change the | |
786 | format of one given cell or to wxGrid::SetDefaultRenderer() to change the | |
787 | view of all cells. This is an abstract class, and you will normally use one of | |
788 | the | |
789 | predefined derived classes or derive your own class from it. | |
7c913512 | 790 | |
23324ae1 | 791 | @library{wxadv} |
42b5841f | 792 | @category{grid} |
7c913512 | 793 | |
e54c96f1 FM |
794 | @see wxGridCellStringRenderer, wxGridCellNumberRenderer, |
795 | wxGridCellFloatRenderer, wxGridCellBoolRenderer | |
23324ae1 | 796 | */ |
7c913512 | 797 | class wxGridCellRenderer |
23324ae1 FM |
798 | { |
799 | public: | |
800 | /** | |
3c4f71cc | 801 | |
23324ae1 | 802 | */ |
da1ed74c | 803 | virtual wxGridCellRenderer* Clone() const = 0; |
23324ae1 FM |
804 | |
805 | /** | |
806 | Draw the given cell on the provided DC inside the given rectangle | |
807 | using the style specified by the attribute and the default or selected | |
808 | state corresponding to the isSelected value. | |
23324ae1 FM |
809 | This pure virtual function has a default implementation which will |
810 | prepare the DC using the given attribute: it will draw the rectangle | |
811 | with the background colour from attr and set the text colour and font. | |
812 | */ | |
da1ed74c FM |
813 | virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, |
814 | const wxRect& rect, int row, int col, | |
815 | bool isSelected) = 0; | |
23324ae1 FM |
816 | |
817 | /** | |
818 | Get the preferred size of the cell for its contents. | |
819 | */ | |
820 | wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
821 | int row, int col); | |
822 | }; | |
823 | ||
824 | ||
e54c96f1 | 825 | |
23324ae1 FM |
826 | /** |
827 | @class wxGridCellNumberEditor | |
7c913512 | 828 | |
23324ae1 | 829 | The editor for numeric integer data. |
7c913512 | 830 | |
23324ae1 | 831 | @library{wxadv} |
42b5841f | 832 | @category{grid} |
7c913512 | 833 | |
e54c96f1 | 834 | @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor, |
23324ae1 FM |
835 | wxGridCellTextEditor, wxGridCellChoiceEditor |
836 | */ | |
837 | class wxGridCellNumberEditor : public wxGridCellTextEditor | |
838 | { | |
839 | public: | |
840 | /** | |
841 | Allows to specify the range for acceptable data; | |
842 | if min == max == -1, no range checking is done | |
843 | */ | |
844 | wxGridCellNumberEditor(int min = -1, int max = -1); | |
845 | ||
846 | /** | |
847 | String representation of the value. | |
848 | */ | |
328f5751 | 849 | wxString GetString() const; |
23324ae1 FM |
850 | |
851 | /** | |
852 | If the return value is @true, the editor uses a wxSpinCtrl to get user input, | |
853 | otherwise it uses a wxTextCtrl. | |
854 | */ | |
328f5751 | 855 | bool HasRange() const; |
23324ae1 FM |
856 | |
857 | /** | |
858 | Parameters string format is "min,max". | |
859 | */ | |
adaaa686 | 860 | virtual void SetParameters(const wxString& params); |
23324ae1 FM |
861 | }; |
862 | ||
863 | ||
e54c96f1 | 864 | |
23324ae1 FM |
865 | /** |
866 | @class wxGridSizeEvent | |
7c913512 | 867 | |
23324ae1 | 868 | This event class contains information about a row/column resize event. |
7c913512 | 869 | |
23324ae1 | 870 | @library{wxadv} |
42b5841f | 871 | @category{grid} |
23324ae1 FM |
872 | */ |
873 | class wxGridSizeEvent : public wxNotifyEvent | |
874 | { | |
875 | public: | |
876 | //@{ | |
877 | /** | |
3c4f71cc | 878 | |
23324ae1 FM |
879 | */ |
880 | wxGridSizeEvent(); | |
7c913512 FM |
881 | wxGridSizeEvent(int id, wxEventType type, wxObject* obj, |
882 | int rowOrCol = -1, | |
883 | int x = -1, | |
884 | int y = -1, | |
4cc4bfaf FM |
885 | bool control = false, |
886 | bool shift = false, | |
887 | bool alt = false, | |
888 | bool meta = false); | |
23324ae1 FM |
889 | //@} |
890 | ||
891 | /** | |
892 | Returns @true if the Alt key was down at the time of the event. | |
893 | */ | |
0004982c | 894 | bool AltDown() const; |
23324ae1 FM |
895 | |
896 | /** | |
897 | Returns @true if the Control key was down at the time of the event. | |
898 | */ | |
0004982c | 899 | bool ControlDown() const; |
23324ae1 FM |
900 | |
901 | /** | |
902 | Position in pixels at which the event occurred. | |
903 | */ | |
904 | wxPoint GetPosition(); | |
905 | ||
906 | /** | |
907 | Row or column at that was resized. | |
908 | */ | |
909 | int GetRowOrCol(); | |
910 | ||
911 | /** | |
912 | Returns @true if the Meta key was down at the time of the event. | |
913 | */ | |
0004982c | 914 | bool MetaDown() const; |
23324ae1 FM |
915 | |
916 | /** | |
917 | Returns @true if the Shift key was down at the time of the event. | |
918 | */ | |
0004982c | 919 | bool ShiftDown() const; |
23324ae1 FM |
920 | }; |
921 | ||
922 | ||
e54c96f1 | 923 | |
23324ae1 FM |
924 | /** |
925 | @class wxGridCellNumberRenderer | |
7c913512 | 926 | |
23324ae1 | 927 | This class may be used to format integer data in a cell. |
7c913512 | 928 | |
23324ae1 | 929 | @library{wxadv} |
42b5841f | 930 | @category{grid} |
7c913512 | 931 | |
e54c96f1 | 932 | @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer, |
23324ae1 FM |
933 | wxGridCellBoolRenderer |
934 | */ | |
935 | class wxGridCellNumberRenderer : public wxGridCellStringRenderer | |
936 | { | |
937 | public: | |
938 | /** | |
939 | Default constructor | |
940 | */ | |
941 | wxGridCellNumberRenderer(); | |
942 | }; | |
943 | ||
944 | ||
e54c96f1 | 945 | |
23324ae1 FM |
946 | /** |
947 | @class wxGridCellAttr | |
7c913512 | 948 | |
23324ae1 FM |
949 | This class can be used to alter the cells' appearance in |
950 | the grid by changing their colour/font/... from default. An object of this | |
951 | class may be returned by wxGridTableBase::GetAttr. | |
7c913512 | 952 | |
23324ae1 | 953 | @library{wxadv} |
42b5841f | 954 | @category{grid} |
23324ae1 | 955 | */ |
7c913512 | 956 | class wxGridCellAttr |
23324ae1 FM |
957 | { |
958 | public: | |
959 | //@{ | |
960 | /** | |
961 | Constructor specifying some of the often used attributes. | |
962 | */ | |
963 | wxGridCellAttr(); | |
7c913512 FM |
964 | wxGridCellAttr(const wxColour& colText, |
965 | const wxColour& colBack, | |
966 | const wxFont& font, | |
967 | int hAlign, int vAlign); | |
23324ae1 FM |
968 | //@} |
969 | ||
970 | /** | |
971 | Creates a new copy of this object. | |
972 | */ | |
328f5751 | 973 | wxGridCellAttr* Clone() const; |
23324ae1 FM |
974 | |
975 | /** | |
3c4f71cc | 976 | |
23324ae1 FM |
977 | */ |
978 | void DecRef(); | |
979 | ||
980 | /** | |
981 | See SetAlignment() for the returned values. | |
982 | */ | |
328f5751 | 983 | void GetAlignment(int* hAlign, int* vAlign) const; |
23324ae1 FM |
984 | |
985 | /** | |
3c4f71cc | 986 | |
23324ae1 | 987 | */ |
328f5751 | 988 | const wxColour GetBackgroundColour() const; |
23324ae1 FM |
989 | |
990 | /** | |
3c4f71cc | 991 | |
23324ae1 | 992 | */ |
328f5751 | 993 | wxGridCellEditor* GetEditor(wxGrid* grid, int row, int col) const; |
23324ae1 FM |
994 | |
995 | /** | |
3c4f71cc | 996 | |
23324ae1 | 997 | */ |
328f5751 | 998 | const wxFont GetFont() const; |
23324ae1 FM |
999 | |
1000 | /** | |
3c4f71cc | 1001 | |
23324ae1 | 1002 | */ |
328f5751 | 1003 | wxGridCellRenderer* GetRenderer(wxGrid* grid, int row, int col) const; |
23324ae1 FM |
1004 | |
1005 | /** | |
3c4f71cc | 1006 | |
23324ae1 | 1007 | */ |
328f5751 | 1008 | const wxColour GetTextColour() const; |
23324ae1 FM |
1009 | |
1010 | /** | |
3c4f71cc | 1011 | |
23324ae1 | 1012 | */ |
328f5751 | 1013 | bool HasAlignment() const; |
23324ae1 FM |
1014 | |
1015 | /** | |
3c4f71cc | 1016 | |
23324ae1 | 1017 | */ |
328f5751 | 1018 | bool HasBackgroundColour() const; |
23324ae1 FM |
1019 | |
1020 | /** | |
3c4f71cc | 1021 | |
23324ae1 | 1022 | */ |
328f5751 | 1023 | bool HasEditor() const; |
23324ae1 FM |
1024 | |
1025 | /** | |
3c4f71cc | 1026 | |
23324ae1 | 1027 | */ |
328f5751 | 1028 | bool HasFont() const; |
23324ae1 FM |
1029 | |
1030 | /** | |
3c4f71cc | 1031 | |
23324ae1 | 1032 | */ |
328f5751 | 1033 | bool HasRenderer() const; |
23324ae1 FM |
1034 | |
1035 | /** | |
1036 | accessors | |
1037 | */ | |
328f5751 | 1038 | bool HasTextColour() const; |
23324ae1 FM |
1039 | |
1040 | /** | |
1041 | This class is ref counted: it is created with ref count of 1, so | |
1042 | calling DecRef() once will delete it. Calling IncRef() allows to lock | |
1043 | it until the matching DecRef() is called | |
1044 | */ | |
1045 | void IncRef(); | |
1046 | ||
1047 | /** | |
3c4f71cc | 1048 | |
23324ae1 | 1049 | */ |
328f5751 | 1050 | bool IsReadOnly() const; |
23324ae1 FM |
1051 | |
1052 | /** | |
4cc4bfaf FM |
1053 | Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT, |
1054 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one | |
23324ae1 FM |
1055 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. |
1056 | */ | |
1057 | void SetAlignment(int hAlign, int vAlign); | |
1058 | ||
1059 | /** | |
1060 | Sets the background colour. | |
1061 | */ | |
1062 | void SetBackgroundColour(const wxColour& colBack); | |
1063 | ||
1064 | /** | |
3c4f71cc | 1065 | |
23324ae1 FM |
1066 | */ |
1067 | void SetDefAttr(wxGridCellAttr* defAttr); | |
1068 | ||
1069 | /** | |
3c4f71cc | 1070 | |
23324ae1 FM |
1071 | */ |
1072 | void SetEditor(wxGridCellEditor* editor); | |
1073 | ||
1074 | /** | |
1075 | Sets the font. | |
1076 | */ | |
1077 | void SetFont(const wxFont& font); | |
1078 | ||
1079 | /** | |
3c4f71cc | 1080 | |
23324ae1 | 1081 | */ |
4cc4bfaf | 1082 | void SetReadOnly(bool isReadOnly = true); |
23324ae1 FM |
1083 | |
1084 | /** | |
1085 | takes ownership of the pointer | |
1086 | */ | |
1087 | void SetRenderer(wxGridCellRenderer* renderer); | |
1088 | ||
1089 | /** | |
1090 | Sets the text colour. | |
1091 | */ | |
1092 | void SetTextColour(const wxColour& colText); | |
1093 | }; | |
1094 | ||
1095 | ||
e54c96f1 | 1096 | |
23324ae1 FM |
1097 | /** |
1098 | @class wxGridCellBoolRenderer | |
7c913512 | 1099 | |
23324ae1 FM |
1100 | This class may be used to format boolean data in a cell. |
1101 | for string cells. | |
7c913512 | 1102 | |
23324ae1 | 1103 | @library{wxadv} |
42b5841f | 1104 | @category{grid} |
7c913512 | 1105 | |
e54c96f1 | 1106 | @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer, |
23324ae1 FM |
1107 | wxGridCellNumberRenderer |
1108 | */ | |
1109 | class wxGridCellBoolRenderer : public wxGridCellRenderer | |
1110 | { | |
1111 | public: | |
1112 | /** | |
1113 | Default constructor | |
1114 | */ | |
1115 | wxGridCellBoolRenderer(); | |
1116 | }; | |
1117 | ||
1118 | ||
e54c96f1 | 1119 | |
23324ae1 FM |
1120 | /** |
1121 | @class wxGridEvent | |
7c913512 | 1122 | |
23324ae1 | 1123 | This event class contains information about various grid events. |
7c913512 | 1124 | |
23324ae1 | 1125 | @library{wxadv} |
42b5841f | 1126 | @category{grid} |
23324ae1 FM |
1127 | */ |
1128 | class wxGridEvent : public wxNotifyEvent | |
1129 | { | |
1130 | public: | |
1131 | //@{ | |
1132 | /** | |
3c4f71cc | 1133 | |
23324ae1 FM |
1134 | */ |
1135 | wxGridEvent(); | |
7c913512 FM |
1136 | wxGridEvent(int id, wxEventType type, wxObject* obj, |
1137 | int row = -1, int col = -1, | |
1138 | int x = -1, int y = -1, | |
4cc4bfaf FM |
1139 | bool sel = true, |
1140 | bool control = false, | |
1141 | bool shift = false, | |
1142 | bool alt = false, | |
1143 | bool meta = false); | |
23324ae1 FM |
1144 | //@} |
1145 | ||
1146 | /** | |
1147 | Returns @true if the Alt key was down at the time of the event. | |
1148 | */ | |
0004982c | 1149 | bool AltDown() const; |
23324ae1 FM |
1150 | |
1151 | /** | |
1152 | Returns @true if the Control key was down at the time of the event. | |
1153 | */ | |
0004982c | 1154 | bool ControlDown() const; |
23324ae1 FM |
1155 | |
1156 | /** | |
1157 | Column at which the event occurred. | |
1158 | */ | |
adaaa686 | 1159 | virtual int GetCol(); |
23324ae1 FM |
1160 | |
1161 | /** | |
1162 | Position in pixels at which the event occurred. | |
1163 | */ | |
1164 | wxPoint GetPosition(); | |
1165 | ||
1166 | /** | |
1167 | Row at which the event occurred. | |
1168 | */ | |
adaaa686 | 1169 | virtual int GetRow(); |
23324ae1 FM |
1170 | |
1171 | /** | |
1172 | Returns @true if the Meta key was down at the time of the event. | |
1173 | */ | |
0004982c | 1174 | bool MetaDown() const; |
23324ae1 FM |
1175 | |
1176 | /** | |
1177 | Returns @true if the user is selecting grid cells, @false -- if | |
1178 | deselecting. | |
1179 | */ | |
1180 | bool Selecting(); | |
1181 | ||
1182 | /** | |
1183 | Returns @true if the Shift key was down at the time of the event. | |
1184 | */ | |
0004982c | 1185 | bool ShiftDown() const; |
23324ae1 FM |
1186 | }; |
1187 | ||
1188 | ||
e54c96f1 | 1189 | |
23324ae1 FM |
1190 | /** |
1191 | @class wxGridCellFloatEditor | |
7c913512 | 1192 | |
23324ae1 | 1193 | The editor for floating point numbers data. |
7c913512 | 1194 | |
23324ae1 | 1195 | @library{wxadv} |
42b5841f | 1196 | @category{grid} |
7c913512 | 1197 | |
e54c96f1 | 1198 | @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor, |
23324ae1 FM |
1199 | wxGridCellTextEditor, wxGridCellChoiceEditor |
1200 | */ | |
1201 | class wxGridCellFloatEditor : public wxGridCellTextEditor | |
1202 | { | |
1203 | public: | |
1204 | /** | |
7c913512 | 1205 | @param width |
4cc4bfaf | 1206 | Minimum number of characters to be shown. |
7c913512 | 1207 | @param precision |
4cc4bfaf | 1208 | Number of digits after the decimal dot. |
23324ae1 FM |
1209 | */ |
1210 | wxGridCellFloatEditor(int width = -1, int precision = -1); | |
1211 | ||
1212 | /** | |
1213 | Parameters string format is "width,precision" | |
1214 | */ | |
adaaa686 | 1215 | virtual void SetParameters(const wxString& params); |
23324ae1 FM |
1216 | }; |
1217 | ||
1218 | ||
e54c96f1 | 1219 | |
23324ae1 FM |
1220 | /** |
1221 | @class wxGrid | |
7c913512 | 1222 | |
23324ae1 | 1223 | wxGrid and its related classes are used for displaying and editing tabular |
55f0bf1f VZ |
1224 | data. |
1225 | They provide a rich set of features for display, editing, and interacting | |
1226 | with a variety of data sources. For simple applications, and to help you | |
1227 | get started, wxGrid is the only class you need to refer to directly. It | |
1228 | will set up default instances of the other classes and manage them for you. | |
1229 | For more complex applications you can derive your own classes for custom | |
1230 | grid views, grid data tables, cell editors and renderers. The @ref | |
c7d4ca81 | 1231 | overview_grid "wxGrid overview" has examples of simple and more complex applications, |
55f0bf1f VZ |
1232 | explains the relationship between the various grid classes and has a |
1233 | summary of the keyboard shortcuts and mouse functions provided by wxGrid. | |
1234 | ||
1235 | wxGrid has been greatly expanded and redesigned for wxWidgets 2.2 onwards. | |
1236 | The new grid classes are reasonably backward-compatible but there are some | |
1237 | exceptions. There are also easier ways of doing many things compared to the | |
1238 | previous implementation. | |
1239 | ||
1240 | A wxGridTableBase class holds the actual data to be displayed by a wxGrid | |
1241 | class. One or more wxGrid classes may act as a view for one table class. | |
1242 | The default table class is called wxGridStringTable and holds an array of | |
1243 | strings. An instance of such a class is created by wxGrid::CreateGrid. | |
1244 | ||
1245 | wxGridCellRenderer is the abstract base class for rendereing contents in a | |
1246 | cell. The following renderers are predefined: | |
1247 | - wxGridCellStringRenderer, | |
1248 | - wxGridCellBoolRenderer, | |
1249 | - wxGridCellFloatRenderer, | |
1250 | - wxGridCellNumberRenderer. | |
1251 | The look of a cell can be further defined using wxGridCellAttr. An object | |
1252 | of this type may be returned by wxGridTableBase::GetAttr. | |
1253 | ||
1254 | wxGridCellEditor is the abstract base class for editing the value of a | |
1255 | cell. The following editors are predefined: | |
1256 | - wxGridCellTextEditor | |
1257 | - wxGridCellBoolEditor | |
1258 | - wxGridCellChoiceEditor | |
1259 | - wxGridCellNumberEditor. | |
7c913512 | 1260 | |
23324ae1 | 1261 | @library{wxadv} |
55f0bf1f | 1262 | @category{grid} |
7c913512 | 1263 | |
c7d4ca81 | 1264 | @see @ref overview_grid "wxGrid overview" |
23324ae1 FM |
1265 | */ |
1266 | class wxGrid : public wxScrolledWindow | |
1267 | { | |
1268 | public: | |
23324ae1 | 1269 | /** |
55f0bf1f VZ |
1270 | Different selection modes supported by the grid. |
1271 | */ | |
1272 | enum wxGridSelectionModes | |
1273 | { | |
1274 | /** | |
1275 | The default selection mode allowing selection of the individual | |
1276 | cells as well as of the entire rows and columns. | |
1277 | */ | |
1278 | wxGridSelectCells, | |
1279 | ||
1280 | /** | |
1281 | The selection mode allowing the selection of the entire rows only. | |
1282 | ||
1283 | The user won't be able to select any cells or columns in this mode. | |
1284 | */ | |
1285 | wxGridSelectRows, | |
1286 | ||
1287 | /** | |
1288 | The selection mode allowing the selection of the entire columns only. | |
1289 | ||
1290 | The user won't be able to select any cells or rows in this mode. | |
1291 | */ | |
1292 | wxGridSelectColumns | |
1293 | }; | |
1294 | ||
1295 | /** | |
1296 | Default constructor. | |
1297 | ||
1298 | You must call Create() to really create the grid window and also call | |
1299 | CreateGrid() or SetTable() to initialize the grid contents. | |
1300 | */ | |
23324ae1 | 1301 | wxGrid(); |
55f0bf1f VZ |
1302 | |
1303 | /** | |
1304 | Constructor creating the grid window. | |
1305 | ||
1306 | You must call either CreateGrid() or SetTable() to initialize the grid | |
1307 | contents before using it. | |
1308 | */ | |
1309 | wxGrid(wxWindow* parent, | |
1310 | wxWindowID id, | |
7c913512 FM |
1311 | const wxPoint& pos = wxDefaultPosition, |
1312 | const wxSize& size = wxDefaultSize, | |
1313 | long style = wxWANTS_CHARS, | |
55f0bf1f | 1314 | const wxString& name = wxGridNameStr); |
23324ae1 FM |
1315 | |
1316 | /** | |
55f0bf1f VZ |
1317 | Creates the grid window for an object initialized using the default |
1318 | constructor. | |
1319 | ||
1320 | You must call either CreateGrid() or SetTable() to initialize the grid | |
1321 | contents before using it. | |
1322 | */ | |
1323 | bool Create(wxWindow* parent, | |
1324 | wxWindowID id, | |
1325 | const wxPoint& pos = wxDefaultPosition, | |
1326 | const wxSize& size = wxDefaultSize, | |
1327 | long style = wxWANTS_CHARS, | |
1328 | const wxString& name = wxGridNameStr); | |
1329 | ||
1330 | /** | |
1331 | Destructor. | |
1332 | ||
1333 | This will also destroy the associated grid table unless you passed a | |
1334 | table object to the grid and specified that the grid should not take | |
1335 | ownership of the table (see wxGrid::SetTable). | |
23324ae1 | 1336 | */ |
55f0bf1f | 1337 | virtual ~wxGrid(); |
23324ae1 FM |
1338 | |
1339 | /** | |
55f0bf1f VZ |
1340 | Appends one or more new columns to the right of the grid. |
1341 | ||
1342 | The @a updateLabels argument is not used at present. If you are using a | |
1343 | derived grid table class you will need to override | |
1344 | wxGridTableBase::AppendCols. See InsertCols() for further information. | |
1345 | ||
1346 | @return @true on success or @false if appending columns failed. | |
23324ae1 | 1347 | */ |
4cc4bfaf | 1348 | bool AppendCols(int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
1349 | |
1350 | /** | |
55f0bf1f VZ |
1351 | Appends one or more new rows to the bottom of the grid. |
1352 | ||
1353 | The @a updateLabels argument is not used at present. If you are using a | |
1354 | derived grid table class you will need to override | |
1355 | wxGridTableBase::AppendRows. See InsertRows() for further information. | |
1356 | ||
1357 | @return @true on success or @false if appending rows failed. | |
23324ae1 | 1358 | */ |
4cc4bfaf | 1359 | bool AppendRows(int numRows = 1, bool updateLabels = true); |
23324ae1 | 1360 | |
9f7aee01 VZ |
1361 | /** |
1362 | Return @true if the horizontal grid lines stop at the last column | |
1363 | boundary or @false if they continue to the end of the window. | |
1364 | ||
1365 | The default is to clip grid lines. | |
1366 | ||
1367 | @see ClipHorzGridLines(), AreVertGridLinesClipped() | |
1368 | */ | |
1369 | bool AreHorzGridLinesClipped() const; | |
1370 | ||
1371 | /** | |
1372 | Return @true if the vertical grid lines stop at the last row | |
1373 | boundary or @false if they continue to the end of the window. | |
1374 | ||
1375 | The default is to clip grid lines. | |
1376 | ||
1377 | @see ClipVertGridLines(), AreHorzGridLinesClipped() | |
1378 | */ | |
1379 | bool AreVertGridLinesClipped() const; | |
1380 | ||
23324ae1 FM |
1381 | /** |
1382 | Automatically sets the height and width of all rows and columns to fit their | |
1383 | contents. | |
1384 | */ | |
1385 | void AutoSize(); | |
1386 | ||
1387 | /** | |
1388 | Automatically adjusts width of the column to fit its label. | |
1389 | */ | |
1390 | void AutoSizeColLabelSize(int col); | |
1391 | ||
1392 | /** | |
1393 | Automatically sizes the column to fit its contents. If setAsMin is @true the | |
1394 | calculated width will | |
1395 | also be set as the minimal width for the column. | |
1396 | */ | |
4cc4bfaf | 1397 | void AutoSizeColumn(int col, bool setAsMin = true); |
23324ae1 FM |
1398 | |
1399 | /** | |
1400 | Automatically sizes all columns to fit their contents. If setAsMin is @true the | |
1401 | calculated widths will | |
1402 | also be set as the minimal widths for the columns. | |
1403 | */ | |
4cc4bfaf | 1404 | void AutoSizeColumns(bool setAsMin = true); |
23324ae1 FM |
1405 | |
1406 | /** | |
1407 | Automatically sizes the row to fit its contents. If setAsMin is @true the | |
1408 | calculated height will | |
1409 | also be set as the minimal height for the row. | |
1410 | */ | |
4cc4bfaf | 1411 | void AutoSizeRow(int row, bool setAsMin = true); |
23324ae1 FM |
1412 | |
1413 | /** | |
1414 | Automatically adjusts height of the row to fit its label. | |
1415 | */ | |
1416 | void AutoSizeRowLabelSize(int col); | |
1417 | ||
1418 | /** | |
1419 | Automatically sizes all rows to fit their contents. If setAsMin is @true the | |
1420 | calculated heights will | |
1421 | also be set as the minimal heights for the rows. | |
1422 | */ | |
4cc4bfaf | 1423 | void AutoSizeRows(bool setAsMin = true); |
23324ae1 FM |
1424 | |
1425 | /** | |
55f0bf1f | 1426 | Increments the grid's batch count. |
3c4f71cc | 1427 | |
55f0bf1f VZ |
1428 | When the count is greater than zero repainting of the grid is |
1429 | suppressed. Each call to BeginBatch must be matched by a later call to | |
1430 | EndBatch(). Code that does a lot of grid modification can be enclosed | |
1431 | between BeginBatch and EndBatch calls to avoid screen flicker. The | |
1432 | final EndBatch will cause the grid to be repainted. | |
3c4f71cc | 1433 | |
55f0bf1f VZ |
1434 | Notice that you should use wxGridUpdateLocker which ensures that there |
1435 | is always a matching EndBatch() call for this BeginBatch() if possible | |
1436 | instead of calling this method directly. | |
23324ae1 FM |
1437 | */ |
1438 | void BeginBatch(); | |
1439 | ||
1440 | /** | |
08dd9b5a VZ |
1441 | Convert grid cell coordinates to grid window pixel coordinates. |
1442 | ||
23324ae1 | 1443 | This function returns the rectangle that encloses the block of cells |
08dd9b5a VZ |
1444 | limited by @a topLeft and @a bottomRight cell in device coords and |
1445 | clipped to the client size of the grid window. | |
1446 | ||
1447 | @see CellToRect() | |
23324ae1 | 1448 | */ |
4cc4bfaf | 1449 | wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft, |
328f5751 | 1450 | const wxGridCellCoords& bottomRight) const; |
23324ae1 FM |
1451 | |
1452 | /** | |
55f0bf1f VZ |
1453 | Returns @true if columns can be moved by dragging with the mouse. |
1454 | ||
1455 | Columns can be moved by dragging on their labels. | |
23324ae1 | 1456 | */ |
328f5751 | 1457 | bool CanDragColMove() const; |
23324ae1 FM |
1458 | |
1459 | /** | |
55f0bf1f | 1460 | Returns @true if columns can be resized by dragging with the mouse. |
08dd9b5a | 1461 | |
55f0bf1f VZ |
1462 | Columns can be resized by dragging the edges of their labels. If grid |
1463 | line dragging is enabled they can also be resized by dragging the right | |
1464 | edge of the column in the grid cell area (see | |
1465 | wxGrid::EnableDragGridSize). | |
23324ae1 | 1466 | */ |
328f5751 | 1467 | bool CanDragColSize() const; |
23324ae1 FM |
1468 | |
1469 | /** | |
08dd9b5a VZ |
1470 | Return @true if the dragging of grid lines to resize rows and columns |
1471 | is enabled or @false otherwise. | |
23324ae1 | 1472 | */ |
328f5751 | 1473 | bool CanDragGridSize() const; |
23324ae1 FM |
1474 | |
1475 | /** | |
55f0bf1f | 1476 | Returns @true if rows can be resized by dragging with the mouse. |
08dd9b5a | 1477 | |
55f0bf1f VZ |
1478 | Rows can be resized by dragging the edges of their labels. If grid line |
1479 | dragging is enabled they can also be resized by dragging the lower edge | |
1480 | of the row in the grid cell area (see wxGrid::EnableDragGridSize). | |
23324ae1 | 1481 | */ |
328f5751 | 1482 | bool CanDragRowSize() const; |
23324ae1 FM |
1483 | |
1484 | /** | |
08dd9b5a VZ |
1485 | Returns @true if the in-place edit control for the current grid cell |
1486 | can be used and @false otherwise. | |
1487 | ||
1488 | This function always returns @false for the read-only cells. | |
23324ae1 | 1489 | */ |
328f5751 | 1490 | bool CanEnableCellControl() const; |
23324ae1 FM |
1491 | |
1492 | /** | |
08dd9b5a VZ |
1493 | Returns @true if this grid has support for cell attributes. |
1494 | ||
1495 | The grid supports attributes if it has the associated table which, in | |
1496 | turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes() | |
1497 | returns @true. | |
23324ae1 | 1498 | */ |
328f5751 | 1499 | bool CanHaveAttributes() const; |
23324ae1 | 1500 | |
23324ae1 FM |
1501 | //@{ |
1502 | /** | |
08dd9b5a VZ |
1503 | Return the rectangle corresponding to the grid cell's size and position |
1504 | in logical coordinates. | |
1505 | ||
1506 | @see BlockToDeviceRect() | |
23324ae1 | 1507 | */ |
328f5751 | 1508 | wxRect CellToRect(int row, int col) const; |
08dd9b5a VZ |
1509 | const wxRect CellToRect(const wxGridCellCoords& coords) const; |
1510 | ||
23324ae1 FM |
1511 | //@} |
1512 | ||
1513 | /** | |
55f0bf1f VZ |
1514 | Clears all data in the underlying grid table and repaints the grid. |
1515 | ||
1516 | The table is not deleted by this function. If you are using a derived | |
1517 | table class then you need to override wxGridTableBase::Clear() for this | |
1518 | function to have any effect. | |
23324ae1 FM |
1519 | */ |
1520 | void ClearGrid(); | |
1521 | ||
1522 | /** | |
1523 | Deselects all cells that are currently selected. | |
1524 | */ | |
1525 | void ClearSelection(); | |
1526 | ||
9f7aee01 VZ |
1527 | /** |
1528 | Change whether the horizontal grid lines are clipped by the end of the | |
1529 | last column. | |
1530 | ||
1531 | By default the grid lines are not drawn beyond the end of the last | |
1532 | column but after calling this function with @a clip set to @false they | |
1533 | will be drawn across the entire grid window. | |
1534 | ||
1535 | @see AreHorzGridLinesClipped(), ClipVertGridLines() | |
1536 | */ | |
1537 | void ClipHorzGridLines(bool clip); | |
1538 | ||
1539 | /** | |
1540 | Change whether the vertical grid lines are clipped by the end of the | |
1541 | last row. | |
1542 | ||
1543 | By default the grid lines are not drawn beyond the end of the last | |
1544 | row but after calling this function with @a clip set to @false they | |
1545 | will be drawn across the entire grid window. | |
1546 | ||
1547 | @see AreVertzGridLinesClipped(), ClipHorzGridLines() | |
1548 | */ | |
1549 | void ClipVertzGridLines(bool clip); | |
1550 | ||
23324ae1 FM |
1551 | /** |
1552 | Creates a grid with the specified initial number of rows and columns. | |
08dd9b5a | 1553 | |
23324ae1 FM |
1554 | Call this directly after the grid constructor. When you use this |
1555 | function wxGrid will create and manage a simple table of string values | |
1556 | for you. All of the grid data will be stored in memory. | |
23324ae1 FM |
1557 | For applications with more complex data types or relationships, or for |
1558 | dealing with very large datasets, you should derive your own grid table | |
1559 | class and pass a table object to the grid with SetTable(). | |
1560 | */ | |
1561 | bool CreateGrid(int numRows, int numCols, | |
55f0bf1f | 1562 | wxGridSelectionModes selmode = wxGridSelectCells); |
23324ae1 FM |
1563 | |
1564 | /** | |
55f0bf1f VZ |
1565 | Deletes one or more columns from a grid starting at the specified |
1566 | position. | |
3c4f71cc | 1567 | |
55f0bf1f VZ |
1568 | The @a updateLabels argument is not used at present. If you are using a |
1569 | derived grid table class you will need to override | |
1570 | wxGridTableBase::DeleteCols. See InsertCols() for further information. | |
3c4f71cc | 1571 | |
55f0bf1f | 1572 | @return @true on success or @false if deleting columns failed. |
23324ae1 | 1573 | */ |
55f0bf1f | 1574 | bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
1575 | |
1576 | /** | |
55f0bf1f | 1577 | Deletes one or more rows from a grid starting at the specified position. |
23324ae1 | 1578 | |
55f0bf1f VZ |
1579 | The @a updateLabels argument is not used at present. If you are using a |
1580 | derived grid table class you will need to override | |
1581 | wxGridTableBase::DeleteRows. See InsertRows() for further information. | |
1582 | ||
1583 | @return @true on success or @false if appending rows failed. | |
23324ae1 | 1584 | */ |
55f0bf1f | 1585 | bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true); |
23324ae1 FM |
1586 | |
1587 | /** | |
1588 | Disables in-place editing of grid cells. | |
08dd9b5a | 1589 | |
23324ae1 FM |
1590 | Equivalent to calling EnableCellEditControl(@false). |
1591 | */ | |
1592 | void DisableCellEditControl(); | |
1593 | ||
1594 | /** | |
55f0bf1f VZ |
1595 | Disables column moving by dragging with the mouse. |
1596 | ||
1597 | Equivalent to passing @false to EnableDragColMove(). | |
23324ae1 FM |
1598 | */ |
1599 | void DisableDragColMove(); | |
1600 | ||
1601 | /** | |
55f0bf1f VZ |
1602 | Disables column sizing by dragging with the mouse. |
1603 | ||
1604 | Equivalent to passing @false to EnableDragColSize(). | |
23324ae1 FM |
1605 | */ |
1606 | void DisableDragColSize(); | |
1607 | ||
1608 | /** | |
55f0bf1f VZ |
1609 | Disable mouse dragging of grid lines to resize rows and columns. |
1610 | ||
1611 | Equivalent to passing @false to EnableDragGridSize() | |
23324ae1 FM |
1612 | */ |
1613 | void DisableDragGridSize(); | |
1614 | ||
1615 | /** | |
55f0bf1f VZ |
1616 | Disables row sizing by dragging with the mouse. |
1617 | ||
1618 | Equivalent to passing @false to EnableDragRowSize(). | |
23324ae1 FM |
1619 | */ |
1620 | void DisableDragRowSize(); | |
1621 | ||
1622 | /** | |
55f0bf1f VZ |
1623 | Enables or disables in-place editing of grid cell data. |
1624 | ||
1625 | The grid will issue either a wxEVT_GRID_EDITOR_SHOWN or | |
1626 | wxEVT_GRID_EDITOR_HIDDEN event. | |
23324ae1 | 1627 | */ |
4cc4bfaf | 1628 | void EnableCellEditControl(bool enable = true); |
23324ae1 FM |
1629 | |
1630 | /** | |
1631 | Enables or disables column moving by dragging with the mouse. | |
1632 | */ | |
4cc4bfaf | 1633 | void EnableDragColMove(bool enable = true); |
23324ae1 FM |
1634 | |
1635 | /** | |
1636 | Enables or disables column sizing by dragging with the mouse. | |
1637 | */ | |
4cc4bfaf | 1638 | void EnableDragColSize(bool enable = true); |
23324ae1 FM |
1639 | |
1640 | /** | |
1641 | Enables or disables row and column resizing by dragging gridlines with the | |
1642 | mouse. | |
1643 | */ | |
4cc4bfaf | 1644 | void EnableDragGridSize(bool enable = true); |
23324ae1 FM |
1645 | |
1646 | /** | |
1647 | Enables or disables row sizing by dragging with the mouse. | |
1648 | */ | |
4cc4bfaf | 1649 | void EnableDragRowSize(bool enable = true); |
23324ae1 FM |
1650 | |
1651 | /** | |
55f0bf1f VZ |
1652 | Makes the grid globally editable or read-only. |
1653 | ||
1654 | If the edit argument is @false this function sets the whole grid as | |
1655 | read-only. If the argument is @true the grid is set to the default | |
1656 | state where cells may be editable. In the default state you can set | |
1657 | single grid cells and whole rows and columns to be editable or | |
1658 | read-only via wxGridCellAttribute::SetReadOnly. For single cells you | |
1659 | can also use the shortcut function SetReadOnly(). | |
1660 | ||
23324ae1 FM |
1661 | For more information about controlling grid cell attributes see the |
1662 | wxGridCellAttr cell attribute class and the | |
c7d4ca81 | 1663 | @ref overview_grid "wxGrid overview". |
23324ae1 FM |
1664 | */ |
1665 | void EnableEditing(bool edit); | |
1666 | ||
1667 | /** | |
1668 | Turns the drawing of grid lines on or off. | |
1669 | */ | |
4cc4bfaf | 1670 | void EnableGridLines(bool enable = true); |
23324ae1 FM |
1671 | |
1672 | /** | |
55f0bf1f VZ |
1673 | Decrements the grid's batch count. |
1674 | ||
1675 | When the count is greater than zero repainting of the grid is | |
1676 | suppressed. Each previous call to BeginBatch() must be matched by a | |
1677 | later call to EndBatch. Code that does a lot of grid modification can | |
1678 | be enclosed between BeginBatch and EndBatch calls to avoid screen | |
1679 | flicker. The final EndBatch will cause the grid to be repainted. | |
3c4f71cc | 1680 | |
4cc4bfaf | 1681 | @see wxGridUpdateLocker |
23324ae1 FM |
1682 | */ |
1683 | void EndBatch(); | |
1684 | ||
1685 | /** | |
1686 | Overridden wxWindow method. | |
1687 | */ | |
4cc4bfaf | 1688 | void Fit(); |
23324ae1 FM |
1689 | |
1690 | /** | |
55f0bf1f VZ |
1691 | Causes immediate repainting of the grid. |
1692 | ||
1693 | Use this instead of the usual wxWindow::Refresh. | |
23324ae1 FM |
1694 | */ |
1695 | void ForceRefresh(); | |
1696 | ||
1697 | /** | |
1698 | Returns the number of times that BeginBatch() has been called | |
1699 | without (yet) matching calls to EndBatch(). While | |
1700 | the grid's batch count is greater than zero the display will not be updated. | |
1701 | */ | |
adaaa686 | 1702 | int GetBatchCount(); |
23324ae1 FM |
1703 | |
1704 | /** | |
55f0bf1f VZ |
1705 | Sets the arguments to the horizontal and vertical text alignment values |
1706 | for the grid cell at the specified location. | |
3c4f71cc | 1707 | |
55f0bf1f VZ |
1708 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1709 | or @c wxALIGN_RIGHT. | |
1710 | ||
1711 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1712 | @c wxALIGN_BOTTOM. | |
23324ae1 | 1713 | */ |
328f5751 | 1714 | void GetCellAlignment(int row, int col, int* horiz, int* vert) const; |
23324ae1 FM |
1715 | |
1716 | /** | |
1717 | Returns the background colour of the cell at the specified location. | |
1718 | */ | |
328f5751 | 1719 | wxColour GetCellBackgroundColour(int row, int col) const; |
23324ae1 FM |
1720 | |
1721 | /** | |
1722 | Returns a pointer to the editor for the cell at the specified location. | |
08dd9b5a | 1723 | |
c7d4ca81 RR |
1724 | See wxGridCellEditor and the @ref overview_grid "wxGrid overview" |
1725 | for more information about cell editors and renderers. | |
08dd9b5a VZ |
1726 | |
1727 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1728 | */ |
328f5751 | 1729 | wxGridCellEditor* GetCellEditor(int row, int col) const; |
23324ae1 FM |
1730 | |
1731 | /** | |
1732 | Returns the font for text in the grid cell at the specified location. | |
1733 | */ | |
328f5751 | 1734 | wxFont GetCellFont(int row, int col) const; |
23324ae1 FM |
1735 | |
1736 | /** | |
08dd9b5a VZ |
1737 | Returns a pointer to the renderer for the grid cell at the specified |
1738 | location. | |
1739 | ||
c7d4ca81 RR |
1740 | See wxGridCellRenderer and the @ref overview_grid "wxGrid overview" |
1741 | for more information about cell editors and renderers. | |
08dd9b5a VZ |
1742 | |
1743 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1744 | */ |
328f5751 | 1745 | wxGridCellRenderer* GetCellRenderer(int row, int col) const; |
23324ae1 FM |
1746 | |
1747 | /** | |
1748 | Returns the text colour for the grid cell at the specified location. | |
1749 | */ | |
328f5751 | 1750 | wxColour GetCellTextColour(int row, int col) const; |
23324ae1 FM |
1751 | |
1752 | //@{ | |
1753 | /** | |
08dd9b5a VZ |
1754 | Returns the string contained in the cell at the specified location. |
1755 | ||
1756 | For simple applications where a grid object automatically uses a | |
1757 | default grid table of string values you use this function together with | |
1758 | SetCellValue() to access cell values. For more complex applications | |
1759 | where you have derived your own grid table class that contains various | |
1760 | data types (e.g. numeric, boolean or user-defined custom types) then | |
1761 | you only use this function for those cells that contain string values. | |
1762 | ||
c7d4ca81 RR |
1763 | See wxGridTableBase::CanGetValueAs and the @ref overview_grid "wxGrid overview" |
1764 | for more information. | |
23324ae1 | 1765 | */ |
328f5751 FM |
1766 | wxString GetCellValue(int row, int col) const; |
1767 | const wxString GetCellValue(const wxGridCellCoords& coords) const; | |
23324ae1 FM |
1768 | //@} |
1769 | ||
1770 | /** | |
1771 | Returns the column ID of the specified column position. | |
1772 | */ | |
328f5751 | 1773 | int GetColAt(int colPos) const; |
23324ae1 FM |
1774 | |
1775 | /** | |
08dd9b5a VZ |
1776 | Returns the pen used for vertical grid lines. |
1777 | ||
1778 | This virtual function may be overridden in derived classes in order to | |
1779 | change the appearance of individual grid lines for the given column @e | |
1780 | col. | |
1781 | ||
23324ae1 FM |
1782 | See GetRowGridLinePen() for an example. |
1783 | */ | |
adaaa686 | 1784 | virtual wxPen GetColGridLinePen(int col); |
23324ae1 FM |
1785 | |
1786 | /** | |
1787 | Sets the arguments to the current column label alignment values. | |
3c4f71cc | 1788 | |
55f0bf1f VZ |
1789 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1790 | or @c wxALIGN_RIGHT. | |
1791 | ||
1792 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1793 | @c wxALIGN_BOTTOM. | |
23324ae1 | 1794 | */ |
328f5751 | 1795 | void GetColLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
1796 | |
1797 | /** | |
1798 | Returns the current height of the column labels. | |
1799 | */ | |
328f5751 | 1800 | int GetColLabelSize() const; |
23324ae1 FM |
1801 | |
1802 | /** | |
55f0bf1f VZ |
1803 | Returns the specified column label. |
1804 | ||
1805 | The default grid table class provides column labels of the form | |
1806 | A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can | |
1807 | override wxGridTableBase::GetColLabelValue to provide your own labels. | |
23324ae1 | 1808 | */ |
328f5751 | 1809 | wxString GetColLabelValue(int col) const; |
23324ae1 FM |
1810 | |
1811 | /** | |
55f0bf1f | 1812 | Returns the coordinate of the left border specified column. |
23324ae1 | 1813 | */ |
328f5751 | 1814 | int GetColLeft(int col) const; |
23324ae1 FM |
1815 | |
1816 | /** | |
08dd9b5a VZ |
1817 | Returns the minimal width to which a column may be resized. |
1818 | ||
1819 | Use SetColMinimalAcceptableWidth() to change this value globally or | |
1820 | SetColMinimalWidth() to do it for individual columns. | |
23324ae1 | 1821 | */ |
328f5751 | 1822 | int GetColMinimalAcceptableWidth() const; |
23324ae1 FM |
1823 | |
1824 | /** | |
1825 | Get the minimal width of the given column/row. | |
08dd9b5a VZ |
1826 | |
1827 | The value returned by this function may be different than that returned | |
1828 | by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been | |
1829 | called for this column. | |
23324ae1 | 1830 | */ |
328f5751 | 1831 | int GetColMinimalWidth(int col) const; |
23324ae1 FM |
1832 | |
1833 | /** | |
1834 | Returns the position of the specified column. | |
1835 | */ | |
328f5751 | 1836 | int GetColPos(int colID) const; |
23324ae1 FM |
1837 | |
1838 | /** | |
55f0bf1f | 1839 | Returns the coordinate of the right border specified column. |
23324ae1 | 1840 | */ |
328f5751 | 1841 | int GetColRight(int col) const; |
23324ae1 FM |
1842 | |
1843 | /** | |
1844 | Returns the width of the specified column. | |
1845 | */ | |
328f5751 | 1846 | int GetColSize(int col) const; |
23324ae1 FM |
1847 | |
1848 | /** | |
08dd9b5a | 1849 | Returns the default cell alignment. |
3c4f71cc | 1850 | |
08dd9b5a VZ |
1851 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1852 | or @c wxALIGN_RIGHT. | |
1853 | ||
1854 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1855 | @c wxALIGN_BOTTOM. | |
1856 | ||
1857 | @see SetDefaultCellAlignment() | |
23324ae1 | 1858 | */ |
328f5751 | 1859 | void GetDefaultCellAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
1860 | |
1861 | /** | |
1862 | Returns the current default background colour for grid cells. | |
1863 | */ | |
328f5751 | 1864 | wxColour GetDefaultCellBackgroundColour() const; |
23324ae1 FM |
1865 | |
1866 | /** | |
1867 | Returns the current default font for grid cell text. | |
1868 | */ | |
328f5751 | 1869 | wxFont GetDefaultCellFont() const; |
23324ae1 FM |
1870 | |
1871 | /** | |
1872 | Returns the current default colour for grid cell text. | |
1873 | */ | |
328f5751 | 1874 | wxColour GetDefaultCellTextColour() const; |
23324ae1 FM |
1875 | |
1876 | /** | |
1877 | Returns the default height for column labels. | |
1878 | */ | |
328f5751 | 1879 | int GetDefaultColLabelSize() const; |
23324ae1 FM |
1880 | |
1881 | /** | |
1882 | Returns the current default width for grid columns. | |
1883 | */ | |
328f5751 | 1884 | int GetDefaultColSize() const; |
23324ae1 FM |
1885 | |
1886 | /** | |
1887 | Returns a pointer to the current default grid cell editor. | |
08dd9b5a | 1888 | |
c7d4ca81 RR |
1889 | See wxGridCellEditor and the @ref overview_grid "wxGrid overview" |
1890 | for more information about cell editors and renderers. | |
23324ae1 | 1891 | */ |
328f5751 | 1892 | wxGridCellEditor* GetDefaultEditor() const; |
23324ae1 FM |
1893 | |
1894 | //@{ | |
1895 | /** | |
08dd9b5a VZ |
1896 | Returns the default editor for the specified cell. |
1897 | ||
1898 | The base class version returns the editor appropriate for the current | |
1899 | cell type but this method may be overridden in the derived classes to | |
1900 | use custom editors for some cells by default. | |
3c4f71cc | 1901 | |
08dd9b5a VZ |
1902 | Notice that the same may be usually achieved in simpler way by |
1903 | associating a custom editor with the given cell or cells. | |
1904 | ||
1905 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1906 | */ |
08dd9b5a VZ |
1907 | virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; |
1908 | wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const; | |
23324ae1 FM |
1909 | //@} |
1910 | ||
1911 | /** | |
08dd9b5a VZ |
1912 | Returns the default editor for the cells containing values of the given |
1913 | type. | |
1914 | ||
1915 | The base class version returns the editor which was associated with the | |
1916 | specified @a typeName when it was registered RegisterDataType() but | |
1917 | this function may be overridden to return something different. This | |
1918 | allows to override an editor used for one of the standard types. | |
3c4f71cc | 1919 | |
08dd9b5a | 1920 | The caller must call DecRef() on the returned pointer. |
23324ae1 | 1921 | */ |
08dd9b5a VZ |
1922 | virtual wxGridCellEditor * |
1923 | GetDefaultEditorForType(const wxString& typeName) const; | |
23324ae1 FM |
1924 | |
1925 | /** | |
08dd9b5a VZ |
1926 | Returns the pen used for grid lines. |
1927 | ||
1928 | This virtual function may be overridden in derived classes in order to | |
1929 | change the appearance of grid lines. Note that currently the pen width | |
1930 | must be 1. | |
3c4f71cc | 1931 | |
4cc4bfaf | 1932 | @see GetColGridLinePen(), GetRowGridLinePen() |
23324ae1 | 1933 | */ |
adaaa686 | 1934 | virtual wxPen GetDefaultGridLinePen(); |
23324ae1 FM |
1935 | |
1936 | /** | |
1937 | Returns a pointer to the current default grid cell renderer. | |
08dd9b5a | 1938 | |
c7d4ca81 RR |
1939 | See wxGridCellRenderer and the @ref overview_grid "wxGrid overview" |
1940 | for more information about cell editors and renderers. | |
08dd9b5a VZ |
1941 | |
1942 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1943 | */ |
328f5751 | 1944 | wxGridCellRenderer* GetDefaultRenderer() const; |
23324ae1 FM |
1945 | |
1946 | /** | |
08dd9b5a | 1947 | Returns the default renderer for the given cell. |
3c4f71cc | 1948 | |
08dd9b5a VZ |
1949 | The base class version returns the renderer appropriate for the current |
1950 | cell type but this method may be overridden in the derived classes to | |
1951 | use custom renderers for some cells by default. | |
1952 | ||
1953 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1954 | */ |
08dd9b5a | 1955 | virtual wxGridCellRenderer *GetDefaultRendererForCell(int row, int col) const; |
23324ae1 FM |
1956 | |
1957 | /** | |
08dd9b5a VZ |
1958 | Returns the default renderer for the cell containing values of the |
1959 | given type. | |
3c4f71cc | 1960 | |
08dd9b5a | 1961 | @see GetDefaultEditorForType() |
23324ae1 | 1962 | */ |
08dd9b5a VZ |
1963 | virtual wxGridCellRenderer * |
1964 | GetDefaultRendererForType(const wxString& typeName) const; | |
23324ae1 FM |
1965 | |
1966 | /** | |
1967 | Returns the default width for the row labels. | |
1968 | */ | |
328f5751 | 1969 | int GetDefaultRowLabelSize() const; |
23324ae1 FM |
1970 | |
1971 | /** | |
1972 | Returns the current default height for grid rows. | |
1973 | */ | |
328f5751 | 1974 | int GetDefaultRowSize() const; |
23324ae1 FM |
1975 | |
1976 | /** | |
1977 | Returns the current grid cell column position. | |
1978 | */ | |
328f5751 | 1979 | int GetGridCursorCol() const; |
23324ae1 FM |
1980 | |
1981 | /** | |
1982 | Returns the current grid cell row position. | |
1983 | */ | |
328f5751 | 1984 | int GetGridCursorRow() const; |
23324ae1 FM |
1985 | |
1986 | /** | |
1987 | Returns the colour used for grid lines. | |
3c4f71cc | 1988 | |
4cc4bfaf | 1989 | @see GetDefaultGridLinePen() |
23324ae1 | 1990 | */ |
328f5751 | 1991 | wxColour GetGridLineColour() const; |
23324ae1 FM |
1992 | |
1993 | /** | |
1994 | Returns the colour used for the background of row and column labels. | |
1995 | */ | |
328f5751 | 1996 | wxColour GetLabelBackgroundColour() const; |
23324ae1 FM |
1997 | |
1998 | /** | |
1999 | Returns the font used for row and column labels. | |
2000 | */ | |
328f5751 | 2001 | wxFont GetLabelFont() const; |
23324ae1 FM |
2002 | |
2003 | /** | |
2004 | Returns the colour used for row and column label text. | |
2005 | */ | |
328f5751 | 2006 | wxColour GetLabelTextColour() const; |
23324ae1 FM |
2007 | |
2008 | /** | |
08dd9b5a VZ |
2009 | Returns the total number of grid columns. |
2010 | ||
2011 | This is the same as the number of columns in the underlying grid | |
2012 | table. | |
23324ae1 | 2013 | */ |
328f5751 | 2014 | int GetNumberCols() const; |
23324ae1 FM |
2015 | |
2016 | /** | |
08dd9b5a VZ |
2017 | Returns the total number of grid rows. |
2018 | ||
2019 | This is the same as the number of rows in the underlying grid table. | |
23324ae1 | 2020 | */ |
328f5751 | 2021 | int GetNumberRows() const; |
23324ae1 FM |
2022 | |
2023 | /** | |
08dd9b5a | 2024 | Returns the attribute for the given cell creating one if necessary. |
3c4f71cc | 2025 | |
08dd9b5a VZ |
2026 | If the cell already has an attribute, it is returned. Otherwise a new |
2027 | attribute is created, associated with the cell and returned. In any | |
2028 | case the caller must call DecRef() on the returned pointer. | |
2029 | ||
2030 | This function may only be called if CanHaveAttributes() returns @true. | |
23324ae1 | 2031 | */ |
08dd9b5a | 2032 | wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const; |
23324ae1 FM |
2033 | |
2034 | /** | |
08dd9b5a VZ |
2035 | Returns the pen used for horizontal grid lines. |
2036 | ||
2037 | This virtual function may be overridden in derived classes in order to | |
2038 | change the appearance of individual grid line for the given row @e row. | |
2039 | ||
23324ae1 | 2040 | Example: |
08dd9b5a VZ |
2041 | @code |
2042 | // in a grid displaying music notation, use a solid black pen between | |
2043 | // octaves (C0=row 127, C1=row 115 etc.) | |
2044 | wxPen MidiGrid::GetRowGridLinePen(int row) | |
2045 | { | |
2046 | if ( row % 12 == 7 ) | |
2047 | return wxPen(*wxBLACK, 1, wxSOLID); | |
2048 | else | |
2049 | return GetDefaultGridLinePen(); | |
2050 | } | |
2051 | @endcode | |
23324ae1 | 2052 | */ |
adaaa686 | 2053 | virtual wxPen GetRowGridLinePen(int row); |
23324ae1 FM |
2054 | |
2055 | /** | |
08dd9b5a | 2056 | Returns the alignment used for row labels. |
3c4f71cc | 2057 | |
08dd9b5a VZ |
2058 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
2059 | or @c wxALIGN_RIGHT. | |
2060 | ||
2061 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
2062 | @c wxALIGN_BOTTOM. | |
23324ae1 | 2063 | */ |
328f5751 | 2064 | void GetRowLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
2065 | |
2066 | /** | |
2067 | Returns the current width of the row labels. | |
2068 | */ | |
328f5751 | 2069 | int GetRowLabelSize() const; |
23324ae1 FM |
2070 | |
2071 | /** | |
08dd9b5a VZ |
2072 | Returns the specified row label. |
2073 | ||
2074 | The default grid table class provides numeric row labels. If you are | |
2075 | using a custom grid table you can override | |
2076 | wxGridTableBase::GetRowLabelValue to provide your own labels. | |
23324ae1 | 2077 | */ |
328f5751 | 2078 | wxString GetRowLabelValue(int row) const; |
23324ae1 FM |
2079 | |
2080 | /** | |
08dd9b5a VZ |
2081 | Returns the minimal size to which rows can be resized. |
2082 | ||
2083 | Use SetRowMinimalAcceptableHeight() to change this value globally or | |
2084 | SetRowMinimalHeight() to do it for individual cells. | |
2085 | ||
2086 | @see GetColMinimalAcceptableWidth() | |
23324ae1 | 2087 | */ |
328f5751 | 2088 | int GetRowMinimalAcceptableHeight() const; |
23324ae1 FM |
2089 | |
2090 | /** | |
08dd9b5a | 2091 | Returns the minimal size for the given column. |
3c4f71cc | 2092 | |
08dd9b5a VZ |
2093 | The value returned by this function may be different than that returned |
2094 | by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been | |
2095 | called for this row. | |
23324ae1 | 2096 | */ |
328f5751 | 2097 | int GetRowMinimalHeight(int col) const; |
23324ae1 FM |
2098 | |
2099 | /** | |
2100 | Returns the height of the specified row. | |
2101 | */ | |
328f5751 | 2102 | int GetRowSize(int row) const; |
23324ae1 FM |
2103 | |
2104 | /** | |
08dd9b5a VZ |
2105 | Returns the number of pixels per horizontal scroll increment. |
2106 | ||
2107 | The default is 15. | |
3c4f71cc | 2108 | |
4cc4bfaf | 2109 | @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY() |
23324ae1 | 2110 | */ |
328f5751 | 2111 | int GetScrollLineX() const; |
23324ae1 FM |
2112 | |
2113 | /** | |
08dd9b5a VZ |
2114 | Returns the number of pixels per vertical scroll increment. |
2115 | ||
2116 | The default is 15. | |
3c4f71cc | 2117 | |
4cc4bfaf | 2118 | @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY() |
23324ae1 | 2119 | */ |
328f5751 | 2120 | int GetScrollLineY() const; |
23324ae1 FM |
2121 | |
2122 | /** | |
08dd9b5a VZ |
2123 | Returns an array of individually selected cells. |
2124 | ||
2125 | Notice that this array does @em not contain all the selected cells in | |
2126 | general as it doesn't include the cells selected as part of column, row | |
2127 | or block selection. You must use this method, GetSelectedCols(), | |
2128 | GetSelectedRows() and GetSelectionBlockTopLeft() and | |
2129 | GetSelectionBlockBottomRight() methods to obtain the entire selection | |
2130 | in general. | |
2131 | ||
2132 | Please notice this behaviour is by design and is needed in order to | |
2133 | support grids of arbitrary size (when an entire column is selected in | |
2134 | a grid with a million of columns, we don't want to create an array with | |
2135 | a million of entries in this function, instead it returns an empty | |
2136 | array and GetSelectedCols() returns an array containing one element). | |
23324ae1 | 2137 | */ |
328f5751 | 2138 | wxGridCellCoordsArray GetSelectedCells() const; |
23324ae1 FM |
2139 | |
2140 | /** | |
08dd9b5a | 2141 | Returns an array of selected columns. |
bb778cae VZ |
2142 | |
2143 | Please notice that this method alone is not sufficient to find all the | |
08dd9b5a VZ |
2144 | selected columns as it contains only the columns which were |
2145 | individually selected but not those being part of the block selection | |
2146 | or being selected in virtue of all of their cells being selected | |
2147 | individually, please see GetSelectedCells() for more details. | |
23324ae1 | 2148 | */ |
328f5751 | 2149 | wxArrayInt GetSelectedCols() const; |
23324ae1 FM |
2150 | |
2151 | /** | |
2152 | Returns an array of selected rows. | |
bb778cae | 2153 | |
08dd9b5a VZ |
2154 | Please notice that this method alone is not sufficient to find all the |
2155 | selected rows as it contains only the rows which were individually | |
2156 | selected but not those being part of the block selection or being | |
2157 | selected in virtue of all of their cells being selected individually, | |
2158 | please see GetSelectedCells() for more details. | |
23324ae1 | 2159 | */ |
328f5751 | 2160 | wxArrayInt GetSelectedRows() const; |
23324ae1 FM |
2161 | |
2162 | /** | |
2163 | Access or update the selection fore/back colours | |
2164 | */ | |
328f5751 | 2165 | wxColour GetSelectionBackground() const; |
23324ae1 FM |
2166 | |
2167 | /** | |
08dd9b5a VZ |
2168 | Returns an array of the bottom right corners of blocks of selected |
2169 | cells. | |
2170 | ||
2171 | Please see GetSelectedCells() for more information about the selection | |
2172 | representation in wxGrid. | |
2173 | ||
2174 | @see GetSelectionBlockTopLeft() | |
23324ae1 | 2175 | */ |
328f5751 | 2176 | wxGridCellCoordsArray GetSelectionBlockBottomRight() const; |
23324ae1 FM |
2177 | |
2178 | /** | |
08dd9b5a VZ |
2179 | Returns an array of the top left corners of blocks of selected cells. |
2180 | ||
2181 | Please see GetSelectedCells() for more information about the selection | |
2182 | representation in wxGrid. | |
2183 | ||
2184 | @see GetSelectionBlockBottomRight() | |
23324ae1 | 2185 | */ |
328f5751 | 2186 | wxGridCellCoordsArray GetSelectionBlockTopLeft() const; |
23324ae1 FM |
2187 | |
2188 | /** | |
08dd9b5a | 2189 | Returns the colour used for drawing the selection foreground. |
23324ae1 | 2190 | */ |
328f5751 | 2191 | wxColour GetSelectionForeground() const; |
23324ae1 FM |
2192 | |
2193 | /** | |
08dd9b5a VZ |
2194 | Returns the current selection mode. |
2195 | ||
2196 | @see SetSelectionMode(). | |
23324ae1 | 2197 | */ |
55f0bf1f | 2198 | wxGridSelectionModes GetSelectionMode() const; |
23324ae1 FM |
2199 | |
2200 | /** | |
2201 | Returns a base pointer to the current table object. | |
3c4f71cc | 2202 | |
08dd9b5a | 2203 | The returned pointer is still owned by the grid. |
23324ae1 | 2204 | */ |
08dd9b5a | 2205 | wxGridTableBase *GetTable() const; |
23324ae1 | 2206 | |
8a3e536c VZ |
2207 | //@{ |
2208 | /** | |
2209 | Make the given cell current and ensure it is visible. | |
2210 | ||
2211 | This method is equivalent to calling MakeCellVisible() and | |
2212 | SetGridCursor() and so, as with the latter, a wxEVT_GRID_SELECT_CELL | |
2213 | event is generated by it and the selected cell doesn't change if the | |
2214 | event is vetoed. | |
2215 | */ | |
2216 | void GoToCell(int row, int col); | |
2217 | void GoToCell(const wxGridCellCoords& coords); | |
2218 | //@} | |
2219 | ||
23324ae1 FM |
2220 | /** |
2221 | Returns @true if drawing of grid lines is turned on, @false otherwise. | |
2222 | */ | |
328f5751 | 2223 | bool GridLinesEnabled() const; |
23324ae1 FM |
2224 | |
2225 | /** | |
2226 | Hides the in-place cell edit control. | |
2227 | */ | |
2228 | void HideCellEditControl(); | |
2229 | ||
2230 | /** | |
2231 | Hides the column labels by calling SetColLabelSize() | |
2232 | with a size of 0. Show labels again by calling that method with | |
2233 | a width greater than 0. | |
2234 | */ | |
2235 | void HideColLabels(); | |
2236 | ||
2237 | /** | |
08dd9b5a VZ |
2238 | Hides the row labels by calling SetRowLabelSize() with a size of 0. |
2239 | ||
2240 | The labels can be shown again by calling SetRowLabelSize() with a width | |
2241 | greater than 0. | |
23324ae1 FM |
2242 | */ |
2243 | void HideRowLabels(); | |
2244 | ||
2245 | /** | |
08dd9b5a VZ |
2246 | Inserts one or more new columns into a grid with the first new column |
2247 | at the specified position. | |
23324ae1 | 2248 | |
08dd9b5a VZ |
2249 | Notice that inserting the columns in the grid requires grid table |
2250 | cooperation: when this method is called, grid object begins by | |
2251 | requesting the underlying grid table to insert new columns. If this is | |
2252 | successful the table notifies the grid and the grid updates the | |
2253 | display. For a default grid (one where you have called | |
2254 | wxGrid::CreateGrid) this process is automatic. If you are using a | |
2255 | custom grid table (specified with wxGrid::SetTable) then you must | |
2256 | override wxGridTableBase::InsertCols() in your derived table class. | |
23324ae1 | 2257 | |
08dd9b5a VZ |
2258 | @param pos |
2259 | The position which the first newly inserted column will have. | |
2260 | @param numCols | |
2261 | The number of columns to insert. | |
2262 | @param updateLabels | |
2263 | Currently not used. | |
2264 | @return | |
2265 | @true if the columns were successfully inserted, @false if an error | |
2266 | occurred (most likely the table couldn't be updated). | |
23324ae1 | 2267 | */ |
08dd9b5a | 2268 | bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
2269 | |
2270 | /** | |
08dd9b5a VZ |
2271 | Inserts one or more new rows into a grid with the first new row at the |
2272 | specified position. | |
2273 | ||
2274 | Notice that you must implement wxGridTableBase::InsertRows() if you use | |
2275 | a grid with a custom table, please see InsertCols() for more | |
2276 | information. | |
2277 | ||
2278 | @param pos | |
2279 | The position which the first newly inserted row will have. | |
2280 | @param numRows | |
2281 | The number of rows to insert. | |
2282 | @param updateLabels | |
2283 | Currently not used. | |
2284 | @return | |
2285 | @true if the rows were successfully inserted, @false if an error | |
2286 | occurred (most likely the table couldn't be updated). | |
23324ae1 | 2287 | */ |
08dd9b5a | 2288 | bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true); |
23324ae1 FM |
2289 | |
2290 | /** | |
2291 | Returns @true if the in-place edit control is currently enabled. | |
2292 | */ | |
328f5751 | 2293 | bool IsCellEditControlEnabled() const; |
23324ae1 FM |
2294 | |
2295 | /** | |
08dd9b5a VZ |
2296 | Returns @true if the current cell is read-only. |
2297 | ||
2298 | @see SetReadOnly(), IsReadOnly() | |
23324ae1 | 2299 | */ |
328f5751 | 2300 | bool IsCurrentCellReadOnly() const; |
23324ae1 FM |
2301 | |
2302 | /** | |
08dd9b5a VZ |
2303 | Returns @false if the whole grid has been set as read-only or @true |
2304 | otherwise. | |
2305 | ||
2306 | See EnableEditing() for more information about controlling the editing | |
2307 | status of grid cells. | |
23324ae1 | 2308 | */ |
328f5751 | 2309 | bool IsEditable() const; |
23324ae1 FM |
2310 | |
2311 | //@{ | |
2312 | /** | |
08dd9b5a | 2313 | Is this cell currently selected? |
23324ae1 | 2314 | */ |
328f5751 | 2315 | bool IsInSelection(int row, int col) const; |
08dd9b5a | 2316 | bool IsInSelection(const wxGridCellCoords& coords) const; |
23324ae1 FM |
2317 | //@} |
2318 | ||
2319 | /** | |
2320 | Returns @true if the cell at the specified location can't be edited. | |
08dd9b5a VZ |
2321 | |
2322 | @see SetReadOnly(), IsCurrentCellReadOnly() | |
23324ae1 | 2323 | */ |
328f5751 | 2324 | bool IsReadOnly(int row, int col) const; |
23324ae1 FM |
2325 | |
2326 | /** | |
08dd9b5a VZ |
2327 | Returns @true if there are currently any selected cells, rows, columns |
2328 | or blocks. | |
23324ae1 | 2329 | */ |
328f5751 | 2330 | bool IsSelection() const; |
23324ae1 FM |
2331 | |
2332 | //@{ | |
2333 | /** | |
08dd9b5a VZ |
2334 | Returns @true if a cell is either wholly or at least partially visible |
2335 | in the grid window. | |
2336 | ||
2337 | By default, the cell must be entirely visible for this function to | |
2338 | return true but if @a wholeCellVisible is @false, the function returns | |
2339 | @true even if the cell is only partially visible. | |
23324ae1 | 2340 | */ |
328f5751 FM |
2341 | bool IsVisible(int row, int col, bool wholeCellVisible = true) const; |
2342 | const bool IsVisible(const wxGridCellCoords& coords, | |
2343 | bool wholeCellVisible = true) const; | |
23324ae1 FM |
2344 | //@} |
2345 | ||
2346 | //@{ | |
2347 | /** | |
2348 | Brings the specified cell into the visible grid cell area with minimal | |
08dd9b5a VZ |
2349 | scrolling. |
2350 | ||
2351 | Does nothing if the cell is already visible. | |
23324ae1 FM |
2352 | */ |
2353 | void MakeCellVisible(int row, int col); | |
7c913512 | 2354 | void MakeCellVisible(const wxGridCellCoords& coords); |
23324ae1 FM |
2355 | //@} |
2356 | ||
2357 | /** | |
08dd9b5a VZ |
2358 | Moves the grid cursor down by one row. |
2359 | ||
2360 | If a block of cells was previously selected it will expand if the | |
2361 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2362 | */ |
2363 | bool MoveCursorDown(bool expandSelection); | |
2364 | ||
2365 | /** | |
08dd9b5a VZ |
2366 | Moves the grid cursor down in the current column such that it skips to |
2367 | the beginning or end of a block of non-empty cells. | |
2368 | ||
2369 | If a block of cells was previously selected it will expand if the | |
2370 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2371 | */ |
2372 | bool MoveCursorDownBlock(bool expandSelection); | |
2373 | ||
2374 | /** | |
08dd9b5a VZ |
2375 | Moves the grid cursor left by one column. |
2376 | ||
2377 | If a block of cells was previously selected it will expand if the | |
2378 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2379 | */ |
2380 | bool MoveCursorLeft(bool expandSelection); | |
2381 | ||
2382 | /** | |
2383 | Moves the grid cursor left in the current row such that it skips to the | |
08dd9b5a VZ |
2384 | beginning or end of a block of non-empty cells. |
2385 | ||
2386 | If a block of cells was previously selected it will expand if the | |
2387 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2388 | */ |
2389 | bool MoveCursorLeftBlock(bool expandSelection); | |
2390 | ||
2391 | /** | |
08dd9b5a VZ |
2392 | Moves the grid cursor right by one column. |
2393 | ||
2394 | If a block of cells was previously selected it will expand if the | |
2395 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2396 | */ |
2397 | bool MoveCursorRight(bool expandSelection); | |
2398 | ||
2399 | /** | |
08dd9b5a VZ |
2400 | Moves the grid cursor right in the current row such that it skips to |
2401 | the beginning or end of a block of non-empty cells. | |
2402 | ||
2403 | If a block of cells was previously selected it will expand if the | |
2404 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2405 | */ |
2406 | bool MoveCursorRightBlock(bool expandSelection); | |
2407 | ||
2408 | /** | |
08dd9b5a VZ |
2409 | Moves the grid cursor up by one row. |
2410 | ||
2411 | If a block of cells was previously selected it will expand if the | |
2412 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2413 | */ |
2414 | bool MoveCursorUp(bool expandSelection); | |
2415 | ||
2416 | /** | |
08dd9b5a VZ |
2417 | Moves the grid cursor up in the current column such that it skips to |
2418 | the beginning or end of a block of non-empty cells. | |
2419 | ||
2420 | If a block of cells was previously selected it will expand if the | |
2421 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2422 | */ |
2423 | bool MoveCursorUpBlock(bool expandSelection); | |
2424 | ||
2425 | /** | |
08dd9b5a VZ |
2426 | Moves the grid cursor down by some number of rows so that the previous |
2427 | bottom visible row becomes the top visible row. | |
23324ae1 FM |
2428 | */ |
2429 | bool MovePageDown(); | |
2430 | ||
2431 | /** | |
08dd9b5a VZ |
2432 | Moves the grid cursor up by some number of rows so that the previous |
2433 | top visible row becomes the bottom visible row. | |
23324ae1 FM |
2434 | */ |
2435 | bool MovePageUp(); | |
2436 | ||
2437 | /** | |
08dd9b5a VZ |
2438 | Register a new data type. |
2439 | ||
2440 | The data types allow to naturally associate specific renderers and | |
2441 | editors to the cells containing values of the given type. For example, | |
2442 | the grid automatically registers a data type with the name @c | |
2443 | wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and | |
2444 | wxGridCellTextEditor as its renderer and editor respectively -- this is | |
2445 | the data type used by all the cells of the default wxGridStringTable, | |
2446 | so this renderer and editor are used by default for all grid cells. | |
2447 | ||
2448 | However if a custom table returns @c wxGRID_VALUE_BOOL from its | |
2449 | wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and | |
2450 | wxGridCellBoolEditor are used for it because the grid also registers a | |
2451 | boolean data type with this name. | |
2452 | ||
2453 | And as this mechanism is completely generic, you may register your own | |
2454 | data types using your own custom renderers and editors. Just remember | |
2455 | that the table must identify a cell as being of the given type for them | |
2456 | to be used for this cell. | |
2457 | ||
2458 | @param typeName | |
2459 | Name of the new type. May be any string, but if the type name is | |
2460 | the same as the name of an already registered type, including one | |
2461 | of the standard ones (which are @c wxGRID_VALUE_STRING, @c | |
2462 | wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT | |
2463 | and @c wxGRID_VALUE_CHOICE), then the new registration information | |
2464 | replaces the previously used renderer and editor. | |
2465 | @param renderer | |
2466 | The renderer to use for the cells of this type. Its ownership is | |
2467 | taken by the grid, i.e. it will call DecRef() on this pointer when | |
2468 | it doesn't need it any longer. | |
2469 | @param editor | |
2470 | The editor to use for the cells of this type. Its ownership is also | |
2471 | taken by the grid. | |
23324ae1 FM |
2472 | */ |
2473 | void RegisterDataType(const wxString& typeName, | |
2474 | wxGridCellRenderer* renderer, | |
2475 | wxGridCellEditor* editor); | |
2476 | ||
23324ae1 | 2477 | /** |
08dd9b5a VZ |
2478 | Sets the value of the current grid cell to the current in-place edit |
2479 | control value. | |
2480 | ||
2481 | This is called automatically when the grid cursor moves from the | |
2482 | current cell to a new cell. It is also a good idea to call this | |
2483 | function when closing a grid since any edits to the final cell location | |
2484 | will not be saved otherwise. | |
23324ae1 FM |
2485 | */ |
2486 | void SaveEditControlValue(); | |
2487 | ||
2488 | /** | |
2489 | Selects all cells in the grid. | |
2490 | */ | |
2491 | void SelectAll(); | |
2492 | ||
2493 | //@{ | |
2494 | /** | |
08dd9b5a VZ |
2495 | Selects a rectangular block of cells. |
2496 | ||
2497 | If @a addToSelected is @false then any existing selection will be | |
2498 | deselected; if @true the column will be added to the existing | |
2499 | selection. | |
23324ae1 | 2500 | */ |
08dd9b5a | 2501 | void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, |
4cc4bfaf | 2502 | bool addToSelected = false); |
7c913512 FM |
2503 | void SelectBlock(const wxGridCellCoords& topLeft, |
2504 | const wxGridCellCoords& bottomRight, | |
4cc4bfaf | 2505 | bool addToSelected = false); |
23324ae1 FM |
2506 | //@} |
2507 | ||
2508 | /** | |
08dd9b5a VZ |
2509 | Selects the specified column. |
2510 | ||
2511 | If @a addToSelected is @false then any existing selection will be | |
2512 | deselected; if @true the column will be added to the existing | |
2513 | selection. | |
2514 | ||
2515 | This method won't select anything if the current selection mode is | |
2516 | wxGridSelectRows. | |
23324ae1 | 2517 | */ |
4cc4bfaf | 2518 | void SelectCol(int col, bool addToSelected = false); |
23324ae1 FM |
2519 | |
2520 | /** | |
08dd9b5a VZ |
2521 | Selects the specified row. |
2522 | ||
2523 | If @a addToSelected is @false then any existing selection will be | |
23324ae1 | 2524 | deselected; if @true the row will be added to the existing selection. |
23324ae1 | 2525 | |
08dd9b5a VZ |
2526 | This method won't select anything if the current selection mode is |
2527 | wxGridSelectColumns. | |
23324ae1 | 2528 | */ |
08dd9b5a | 2529 | void SelectRow(int row, bool addToSelected = false); |
23324ae1 FM |
2530 | |
2531 | //@{ | |
2532 | /** | |
08dd9b5a VZ |
2533 | Sets the horizontal and vertical alignment for grid cell text at the |
2534 | specified location. | |
3c4f71cc | 2535 | |
08dd9b5a VZ |
2536 | Horizontal alignment should be one of @c wxALIGN_LEFT, @c |
2537 | wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2538 | ||
2539 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2540 | or @c wxALIGN_BOTTOM. | |
23324ae1 FM |
2541 | */ |
2542 | void SetCellAlignment(int row, int col, int horiz, int vert); | |
7c913512 | 2543 | void SetCellAlignment(int align, int row, int col); |
23324ae1 FM |
2544 | //@} |
2545 | ||
08dd9b5a | 2546 | //@{ |
23324ae1 | 2547 | /** |
08dd9b5a | 2548 | Set the background colour for the given cell or all cells by default. |
23324ae1 | 2549 | */ |
08dd9b5a VZ |
2550 | void SetCellBackgroundColour(int row, int col, const wxColour& colour); |
2551 | //@} | |
23324ae1 FM |
2552 | |
2553 | /** | |
2554 | Sets the editor for the grid cell at the specified location. | |
08dd9b5a | 2555 | |
23324ae1 | 2556 | The grid will take ownership of the pointer. |
08dd9b5a | 2557 | |
c7d4ca81 RR |
2558 | See wxGridCellEditor and the @ref overview_grid "wxGrid overview" |
2559 | for more information about cell editors and renderers. | |
23324ae1 FM |
2560 | */ |
2561 | void SetCellEditor(int row, int col, wxGridCellEditor* editor); | |
2562 | ||
2563 | /** | |
2564 | Sets the font for text in the grid cell at the specified location. | |
2565 | */ | |
2566 | void SetCellFont(int row, int col, const wxFont& font); | |
2567 | ||
2568 | /** | |
2569 | Sets the renderer for the grid cell at the specified location. | |
08dd9b5a | 2570 | |
23324ae1 | 2571 | The grid will take ownership of the pointer. |
08dd9b5a | 2572 | |
c7d4ca81 RR |
2573 | See wxGridCellRenderer and the @ref overview_grid "wxGrid overview" |
2574 | for more information about cell editors and renderers. | |
23324ae1 | 2575 | */ |
08dd9b5a | 2576 | void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer); |
23324ae1 FM |
2577 | |
2578 | //@{ | |
2579 | /** | |
08dd9b5a | 2580 | Sets the text colour for the given cell or all cells by default. |
23324ae1 FM |
2581 | */ |
2582 | void SetCellTextColour(int row, int col, const wxColour& colour); | |
7c913512 FM |
2583 | void SetCellTextColour(const wxColour& val, int row, int col); |
2584 | void SetCellTextColour(const wxColour& colour); | |
23324ae1 FM |
2585 | //@} |
2586 | ||
2587 | //@{ | |
2588 | /** | |
08dd9b5a VZ |
2589 | Sets the string value for the cell at the specified location. |
2590 | ||
2591 | For simple applications where a grid object automatically uses a | |
2592 | default grid table of string values you use this function together with | |
2593 | GetCellValue() to access cell values. For more complex applications | |
2594 | where you have derived your own grid table class that contains various | |
2595 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2596 | you only use this function for those cells that contain string values. | |
23324ae1 | 2597 | The last form is for backward compatibility only. |
08dd9b5a | 2598 | |
c7d4ca81 | 2599 | See wxGridTableBase::CanSetValueAs and the @ref overview_grid |
08dd9b5a | 2600 | "wxGrid overview" for more information. |
23324ae1 FM |
2601 | */ |
2602 | void SetCellValue(int row, int col, const wxString& s); | |
08dd9b5a | 2603 | void SetCellValue(const wxGridCellCoords& coords, const wxString& s); |
7c913512 | 2604 | void SetCellValue(const wxString& val, int row, int col); |
23324ae1 FM |
2605 | //@} |
2606 | ||
2607 | /** | |
2608 | Sets the cell attributes for all cells in the specified column. | |
08dd9b5a | 2609 | |
23324ae1 | 2610 | For more information about controlling grid cell attributes see the |
c7d4ca81 | 2611 | wxGridCellAttr cell attribute class and the @ref overview_grid "wxGrid overview". |
23324ae1 FM |
2612 | */ |
2613 | void SetColAttr(int col, wxGridCellAttr* attr); | |
2614 | ||
2615 | /** | |
08dd9b5a VZ |
2616 | Sets the specified column to display boolean values. |
2617 | ||
2618 | @see SetColFormatCustom() | |
23324ae1 FM |
2619 | */ |
2620 | void SetColFormatBool(int col); | |
2621 | ||
2622 | /** | |
2623 | Sets the specified column to display data in a custom format. | |
08dd9b5a VZ |
2624 | |
2625 | This method provides an alternative to defining a custom grid table | |
2626 | which would return @a typeName from its GetTypeName() method for the | |
2627 | cells in this column: while it doesn't really change the type of the | |
2628 | cells in this column, it does associate the renderer and editor used | |
2629 | for the cells of the specified type with them. | |
2630 | ||
c7d4ca81 | 2631 | See the @ref overview_grid "wxGrid overview" for more |
08dd9b5a | 2632 | information on working with custom data types. |
23324ae1 FM |
2633 | */ |
2634 | void SetColFormatCustom(int col, const wxString& typeName); | |
2635 | ||
2636 | /** | |
08dd9b5a VZ |
2637 | Sets the specified column to display floating point values with the |
2638 | given width and precision. | |
2639 | ||
2640 | @see SetColFormatCustom() | |
23324ae1 | 2641 | */ |
08dd9b5a | 2642 | void SetColFormatFloat(int col, int width = -1, int precision = -1); |
23324ae1 FM |
2643 | |
2644 | /** | |
2645 | Sets the specified column to display integer values. | |
08dd9b5a VZ |
2646 | |
2647 | @see SetColFormatCustom() | |
23324ae1 FM |
2648 | */ |
2649 | void SetColFormatNumber(int col); | |
2650 | ||
2651 | /** | |
2652 | Sets the horizontal and vertical alignment of column label text. | |
08dd9b5a VZ |
2653 | |
2654 | Horizontal alignment should be one of @c wxALIGN_LEFT, @c | |
2655 | wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2656 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2657 | or @c wxALIGN_BOTTOM. | |
23324ae1 FM |
2658 | */ |
2659 | void SetColLabelAlignment(int horiz, int vert); | |
2660 | ||
2661 | /** | |
2662 | Sets the height of the column labels. | |
08dd9b5a | 2663 | |
4cc4bfaf | 2664 | If @a height equals to @c wxGRID_AUTOSIZE then height is calculated |
08dd9b5a VZ |
2665 | automatically so that no label is truncated. Note that this could be |
2666 | slow for a large table. | |
23324ae1 FM |
2667 | */ |
2668 | void SetColLabelSize(int height); | |
2669 | ||
2670 | /** | |
08dd9b5a VZ |
2671 | Set the value for the given column label. |
2672 | ||
2673 | If you are using a custom grid table you must override | |
2674 | wxGridTableBase::SetColLabelValue for this to have any effect. | |
23324ae1 FM |
2675 | */ |
2676 | void SetColLabelValue(int col, const wxString& value); | |
2677 | ||
2678 | /** | |
08dd9b5a VZ |
2679 | Sets the minimal width to which the user can resize columns. |
2680 | ||
2681 | @see GetColMinimalAcceptableWidth() | |
23324ae1 FM |
2682 | */ |
2683 | void SetColMinimalAcceptableWidth(int width); | |
2684 | ||
2685 | /** | |
08dd9b5a VZ |
2686 | Sets the minimal width for the specified column. |
2687 | ||
2688 | It is usually best to call this method during grid creation as calling | |
2689 | it later will not resize the column to the given minimal width even if | |
2690 | it is currently narrower than it. | |
2691 | ||
2692 | @a width must be greater than the minimal acceptable column width as | |
2693 | returned by GetColMinimalAcceptableWidth(). | |
23324ae1 FM |
2694 | */ |
2695 | void SetColMinimalWidth(int col, int width); | |
2696 | ||
2697 | /** | |
2698 | Sets the position of the specified column. | |
2699 | */ | |
2700 | void SetColPos(int colID, int newPos); | |
2701 | ||
2702 | /** | |
2703 | Sets the width of the specified column. | |
08dd9b5a VZ |
2704 | |
2705 | Notice that this function does not refresh the grid, you need to call | |
2706 | ForceRefresh() to make the changes take effect immediately. | |
2707 | ||
2708 | @param col | |
2709 | The column index. | |
2710 | @param width | |
2711 | The new column width in pixels or a negative value to fit the | |
2712 | column width to its label width. | |
23324ae1 FM |
2713 | */ |
2714 | void SetColSize(int col, int width); | |
2715 | ||
2716 | /** | |
2717 | Sets the default horizontal and vertical alignment for grid cell text. | |
08dd9b5a VZ |
2718 | |
2719 | Horizontal alignment should be one of @c wxALIGN_LEFT, @c | |
2720 | wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2721 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2722 | or @c wxALIGN_BOTTOM. | |
23324ae1 FM |
2723 | */ |
2724 | void SetDefaultCellAlignment(int horiz, int vert); | |
2725 | ||
2726 | /** | |
2727 | Sets the default background colour for grid cells. | |
2728 | */ | |
2729 | void SetDefaultCellBackgroundColour(const wxColour& colour); | |
2730 | ||
2731 | /** | |
2732 | Sets the default font to be used for grid cell text. | |
2733 | */ | |
2734 | void SetDefaultCellFont(const wxFont& font); | |
2735 | ||
2736 | /** | |
2737 | Sets the current default colour for grid cell text. | |
2738 | */ | |
2739 | void SetDefaultCellTextColour(const wxColour& colour); | |
2740 | ||
2741 | /** | |
08dd9b5a VZ |
2742 | Sets the default width for columns in the grid. |
2743 | ||
2744 | This will only affect columns subsequently added to the grid unless | |
2745 | @a resizeExistingCols is @true. | |
2746 | ||
2747 | If @a width is less than GetColMinimalAcceptableWidth(), then the | |
2748 | minimal acceptable width is used instead of it. | |
23324ae1 | 2749 | */ |
08dd9b5a | 2750 | void SetDefaultColSize(int width, bool resizeExistingCols = false); |
23324ae1 FM |
2751 | |
2752 | /** | |
08dd9b5a VZ |
2753 | Sets the default editor for grid cells. |
2754 | ||
2755 | The grid will take ownership of the pointer. | |
2756 | ||
c7d4ca81 RR |
2757 | See wxGridCellEditor and the @ref overview_grid "wxGrid overview" |
2758 | for more information about cell editors and renderers. | |
23324ae1 FM |
2759 | */ |
2760 | void SetDefaultEditor(wxGridCellEditor* editor); | |
2761 | ||
2762 | /** | |
08dd9b5a VZ |
2763 | Sets the default renderer for grid cells. |
2764 | ||
2765 | The grid will take ownership of the pointer. | |
2766 | ||
c7d4ca81 RR |
2767 | See wxGridCellRenderer and the @ref overview_grid "wxGrid overview" |
2768 | for more information about cell editors and renderers. | |
23324ae1 FM |
2769 | */ |
2770 | void SetDefaultRenderer(wxGridCellRenderer* renderer); | |
2771 | ||
2772 | /** | |
08dd9b5a VZ |
2773 | Sets the default height for rows in the grid. |
2774 | ||
2775 | This will only affect rows subsequently added to the grid unless | |
2776 | @a resizeExistingRows is @true. | |
2777 | ||
2778 | If @a height is less than GetRowMinimalAcceptableHeight(), then the | |
2779 | minimal acceptable heihgt is used instead of it. | |
23324ae1 | 2780 | */ |
08dd9b5a | 2781 | void SetDefaultRowSize(int height, bool resizeExistingRows = false); |
23324ae1 | 2782 | |
8a3e536c | 2783 | //@{ |
23324ae1 FM |
2784 | /** |
2785 | Set the grid cursor to the specified cell. | |
08dd9b5a | 2786 | |
8a3e536c VZ |
2787 | The grid cursor indicates the current cell and can be moved by the user |
2788 | using the arrow keys or the mouse. | |
2789 | ||
2790 | Calling this function generates a wxEVT_GRID_SELECT_CELL event and if | |
2791 | the event handler vetoes this event, the cursor is not moved. | |
2792 | ||
2793 | This function doesn't make the target call visible, use GoToCell() to | |
2794 | do this. | |
23324ae1 FM |
2795 | */ |
2796 | void SetGridCursor(int row, int col); | |
8a3e536c VZ |
2797 | void SetGridCursor(const wxGridCellCoords& coords); |
2798 | //@} | |
23324ae1 FM |
2799 | |
2800 | /** | |
2801 | Sets the colour used to draw grid lines. | |
2802 | */ | |
2803 | void SetGridLineColour(const wxColour& colour); | |
2804 | ||
2805 | /** | |
2806 | Sets the background colour for row and column labels. | |
2807 | */ | |
2808 | void SetLabelBackgroundColour(const wxColour& colour); | |
2809 | ||
2810 | /** | |
2811 | Sets the font for row and column labels. | |
2812 | */ | |
2813 | void SetLabelFont(const wxFont& font); | |
2814 | ||
2815 | /** | |
2816 | Sets the colour for row and column label text. | |
2817 | */ | |
2818 | void SetLabelTextColour(const wxColour& colour); | |
2819 | ||
2820 | /** | |
08dd9b5a | 2821 | Sets the extra margins used around the grid area. |
23324ae1 | 2822 | |
08dd9b5a VZ |
2823 | A grid may occupy more space than needed for its data display and |
2824 | this function allows to set how big this extra space is | |
23324ae1 | 2825 | */ |
08dd9b5a | 2826 | void SetMargins(int extraWidth, int extraHeight); |
23324ae1 FM |
2827 | |
2828 | /** | |
2829 | Makes the cell at the specified location read-only or editable. | |
08dd9b5a VZ |
2830 | |
2831 | @see IsReadOnly() | |
23324ae1 | 2832 | */ |
4cc4bfaf | 2833 | void SetReadOnly(int row, int col, bool isReadOnly = true); |
23324ae1 FM |
2834 | |
2835 | /** | |
2836 | Sets the cell attributes for all cells in the specified row. | |
08dd9b5a VZ |
2837 | |
2838 | The grid takes ownership of the attribute pointer. | |
2839 | ||
2840 | See the wxGridCellAttr class for more information about controlling | |
2841 | cell attributes. | |
23324ae1 FM |
2842 | */ |
2843 | void SetRowAttr(int row, wxGridCellAttr* attr); | |
2844 | ||
2845 | /** | |
2846 | Sets the horizontal and vertical alignment of row label text. | |
08dd9b5a VZ |
2847 | |
2848 | Horizontal alignment should be one of @c wxALIGN_LEFT, @c | |
2849 | wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2850 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2851 | or @c wxALIGN_BOTTOM. | |
23324ae1 FM |
2852 | */ |
2853 | void SetRowLabelAlignment(int horiz, int vert); | |
2854 | ||
2855 | /** | |
2856 | Sets the width of the row labels. | |
08dd9b5a VZ |
2857 | |
2858 | If @a width equals @c wxGRID_AUTOSIZE then width is calculated | |
2859 | automatically so that no label is truncated. Note that this could be | |
2860 | slow for a large table. | |
23324ae1 FM |
2861 | */ |
2862 | void SetRowLabelSize(int width); | |
2863 | ||
2864 | /** | |
08dd9b5a VZ |
2865 | Sets the value for the given row label. |
2866 | ||
2867 | If you are using a derived grid table you must override | |
2868 | wxGridTableBase::SetRowLabelValue for this to have any effect. | |
23324ae1 FM |
2869 | */ |
2870 | void SetRowLabelValue(int row, const wxString& value); | |
2871 | ||
2872 | /** | |
08dd9b5a VZ |
2873 | Sets the minimal row height used by default. |
2874 | ||
2875 | See SetColMinimalAcceptableWidth() for more information. | |
23324ae1 FM |
2876 | */ |
2877 | void SetRowMinimalAcceptableHeight(int height); | |
2878 | ||
2879 | /** | |
08dd9b5a VZ |
2880 | Sets the minimal height for the specified row. |
2881 | ||
2882 | See SetColMinimalWidth() for more information. | |
23324ae1 FM |
2883 | */ |
2884 | void SetRowMinimalHeight(int row, int height); | |
2885 | ||
2886 | /** | |
2887 | Sets the height of the specified row. | |
08dd9b5a VZ |
2888 | |
2889 | See SetColSize() for more information. | |
23324ae1 FM |
2890 | */ |
2891 | void SetRowSize(int row, int height); | |
2892 | ||
2893 | /** | |
08dd9b5a VZ |
2894 | Sets the number of pixels per horizontal scroll increment. |
2895 | ||
2896 | The default is 15. | |
3c4f71cc | 2897 | |
4cc4bfaf | 2898 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY() |
23324ae1 FM |
2899 | */ |
2900 | void SetScrollLineX(int x); | |
2901 | ||
2902 | /** | |
08dd9b5a VZ |
2903 | Sets the number of pixels per vertical scroll increment. |
2904 | ||
2905 | The default is 15. | |
3c4f71cc | 2906 | |
4cc4bfaf | 2907 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX() |
23324ae1 FM |
2908 | */ |
2909 | void SetScrollLineY(int y); | |
2910 | ||
2911 | /** | |
08dd9b5a | 2912 | Set the colour to be used for drawing the selection background. |
23324ae1 FM |
2913 | */ |
2914 | void SetSelectionBackground(const wxColour& c); | |
2915 | ||
2916 | /** | |
08dd9b5a | 2917 | Set the colour to be used for drawing the selection foreground. |
23324ae1 FM |
2918 | */ |
2919 | void SetSelectionForeground(const wxColour& c); | |
2920 | ||
2921 | /** | |
2922 | Set the selection behaviour of the grid. | |
3c4f71cc | 2923 | |
55f0bf1f VZ |
2924 | The existing selection is converted to conform to the new mode if |
2925 | possible and discarded otherwise (e.g. any individual selected cells | |
2926 | are deselected if the new mode allows only the selection of the entire | |
2927 | rows or columns). | |
23324ae1 | 2928 | */ |
55f0bf1f | 2929 | void SetSelectionMode(wxGridSelectionModes selmode); |
23324ae1 FM |
2930 | |
2931 | /** | |
08dd9b5a VZ |
2932 | Passes a pointer to a custom grid table to be used by the grid. |
2933 | ||
2934 | This should be called after the grid constructor and before using the | |
2935 | grid object. If @a takeOwnership is set to @true then the table will be | |
2936 | deleted by the wxGrid destructor. | |
2937 | ||
2938 | Use this function instead of CreateGrid() when your application | |
2939 | involves complex or non-string data or data sets that are too large to | |
2940 | fit wholly in memory. | |
23324ae1 | 2941 | */ |
55f0bf1f VZ |
2942 | bool SetTable(wxGridTableBase* table, |
2943 | bool takeOwnership = false, | |
2944 | wxGridSelectionModes selmode = wxGridSelectCells); | |
23324ae1 FM |
2945 | |
2946 | /** | |
2947 | Call this in order to make the column labels use a native look by using | |
55f0bf1f VZ |
2948 | wxRenderer::DrawHeaderButton internally. |
2949 | ||
2950 | There is no equivalent method for drawing row columns as there is not | |
2951 | native look for that. This option is useful when using wxGrid for | |
2952 | displaying tables and not as a spread-sheet. | |
23324ae1 | 2953 | */ |
4cc4bfaf | 2954 | void SetUseNativeColLabels(bool native = true); |
23324ae1 FM |
2955 | |
2956 | /** | |
2957 | Displays the in-place cell edit control for the current cell. | |
2958 | */ | |
2959 | void ShowCellEditControl(); | |
2960 | ||
2961 | /** | |
08dd9b5a VZ |
2962 | Returns the column at the given pixel position. |
2963 | ||
7c913512 | 2964 | @param x |
4cc4bfaf | 2965 | The x position to evaluate. |
7c913512 | 2966 | @param clipToMinMax |
08dd9b5a VZ |
2967 | If @true, rather than returning wxNOT_FOUND, it returns either the |
2968 | first or last column depending on whether x is too far to the left | |
2969 | or right respectively. | |
2970 | @return | |
2971 | The column index or wxNOT_FOUND. | |
23324ae1 | 2972 | */ |
328f5751 | 2973 | int XToCol(int x, bool clipToMinMax = false) const; |
23324ae1 FM |
2974 | |
2975 | /** | |
08dd9b5a VZ |
2976 | Returns the column whose right hand edge is close to the given logical |
2977 | x position. | |
2978 | ||
23324ae1 FM |
2979 | If no column edge is near to this position @c wxNOT_FOUND is returned. |
2980 | */ | |
328f5751 | 2981 | int XToEdgeOfCol(int x) const; |
23324ae1 | 2982 | |
8a3e536c VZ |
2983 | //@{ |
2984 | /** | |
2985 | Translates logical pixel coordinates to the grid cell coordinates. | |
2986 | ||
2987 | Notice that this function expects logical coordinates on input so if | |
2988 | you use this function in a mouse event handler you need to translate | |
2989 | the mouse position, which is expressed in device coordinates, to | |
2990 | logical ones. | |
2991 | ||
2992 | @see XToCol(), YToRow() | |
2993 | */ | |
2994 | ||
2995 | // XYToCell(int, int, wxGridCellCoords&) overload is intentionally | |
2996 | // undocumented, using it is ugly and non-const reference parameters are | |
2997 | // not used in wxWidgets API | |
2998 | ||
2999 | wxGridCellCoords XYToCell(int x, int y) const; | |
3000 | wxGridCellCoords XYToCell(const wxPoint& pos) const; | |
3001 | ||
3002 | //@} | |
3003 | ||
23324ae1 | 3004 | /** |
08dd9b5a VZ |
3005 | Returns the row whose bottom edge is close to the given logical y |
3006 | position. | |
3007 | ||
23324ae1 FM |
3008 | If no row edge is near to this position @c wxNOT_FOUND is returned. |
3009 | */ | |
328f5751 | 3010 | int YToEdgeOfRow(int y) const; |
23324ae1 FM |
3011 | |
3012 | /** | |
08dd9b5a VZ |
3013 | Returns the grid row that corresponds to the logical y coordinate. |
3014 | ||
3015 | Returns @c wxNOT_FOUND if there is no row at the y position. | |
23324ae1 | 3016 | */ |
328f5751 | 3017 | int YToRow(int y) const; |
23324ae1 FM |
3018 | }; |
3019 | ||
3020 | ||
e54c96f1 | 3021 | |
23324ae1 FM |
3022 | /** |
3023 | @class wxGridCellBoolEditor | |
7c913512 | 3024 | |
23324ae1 | 3025 | The editor for boolean data. |
7c913512 | 3026 | |
23324ae1 | 3027 | @library{wxadv} |
42b5841f | 3028 | @category{grid} |
7c913512 | 3029 | |
e54c96f1 | 3030 | @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellNumberEditor, |
23324ae1 FM |
3031 | wxGridCellTextEditor, wxGridCellChoiceEditor |
3032 | */ | |
3033 | class wxGridCellBoolEditor : public wxGridCellEditor | |
3034 | { | |
3035 | public: | |
3036 | /** | |
3037 | Default constructor. | |
3038 | */ | |
3039 | wxGridCellBoolEditor(); | |
3040 | ||
3041 | /** | |
4cc4bfaf | 3042 | Returns @true if the given @a value is equal to the string representation of |
7c913512 | 3043 | the truth value we currently use (see |
23324ae1 FM |
3044 | wxGridCellBoolEditor::UseStringValues). |
3045 | */ | |
3046 | static bool IsTrueValue(const wxString& value); | |
3047 | ||
3048 | /** | |
328f5751 | 3049 | , wxString&@e valueFalse = _T("")) |
23324ae1 FM |
3050 | This method allows to customize the values returned by GetValue() method for |
3051 | the cell using this editor. By default, the default values of the arguments are | |
3052 | used, i.e. @c "1" is returned if the cell is checked and an empty string | |
3053 | otherwise, using this method allows to change this. | |
3054 | */ | |
328f5751 | 3055 | static void UseStringValues() const; |
23324ae1 FM |
3056 | }; |
3057 | ||
3058 | ||
e54c96f1 | 3059 | |
23324ae1 FM |
3060 | /** |
3061 | @class wxGridUpdateLocker | |
7c913512 | 3062 | |
23324ae1 FM |
3063 | This small class can be used to prevent wxGrid from redrawing |
3064 | during its lifetime by calling wxGrid::BeginBatch | |
3065 | in its constructor and wxGrid::EndBatch in its | |
3066 | destructor. It is typically used in a function performing several operations | |
3067 | with a grid which would otherwise result in flicker. For example: | |
7c913512 | 3068 | |
23324ae1 FM |
3069 | @code |
3070 | void MyFrame::Foo() | |
3071 | { | |
3072 | m_grid = new wxGrid(this, ...); | |
7c913512 | 3073 | |
23324ae1 FM |
3074 | wxGridUpdateLocker noUpdates(m_grid); |
3075 | m_grid-AppendColumn(); | |
3076 | ... many other operations with m_grid... | |
3077 | m_grid-AppendRow(); | |
7c913512 | 3078 | |
23324ae1 FM |
3079 | // destructor called, grid refreshed |
3080 | } | |
3081 | @endcode | |
7c913512 FM |
3082 | |
3083 | Using this class is easier and safer than calling | |
23324ae1 FM |
3084 | wxGrid::BeginBatch and wxGrid::EndBatch |
3085 | because you don't risk not to call the latter (due to an exception for example). | |
7c913512 | 3086 | |
23324ae1 | 3087 | @library{wxadv} |
42b5841f | 3088 | @category{grid} |
23324ae1 | 3089 | */ |
7c913512 | 3090 | class wxGridUpdateLocker |
23324ae1 FM |
3091 | { |
3092 | public: | |
3093 | /** | |
3094 | Creates an object preventing the updates of the specified @e grid. The | |
4cc4bfaf | 3095 | parameter could be @NULL in which case nothing is done. If @a grid is |
23324ae1 FM |
3096 | non-@NULL then the grid must exist for longer than wxGridUpdateLocker object |
3097 | itself. | |
7c913512 | 3098 | The default constructor could be followed by a call to |
23324ae1 FM |
3099 | Create() to set the |
3100 | grid object later. | |
3101 | */ | |
4cc4bfaf | 3102 | wxGridUpdateLocker(wxGrid* grid = NULL); |
23324ae1 FM |
3103 | |
3104 | /** | |
3105 | Destructor reenables updates for the grid this object is associated with. | |
3106 | */ | |
3107 | ~wxGridUpdateLocker(); | |
3108 | ||
3109 | /** | |
3110 | This method can be called if the object had been constructed using the default | |
3111 | constructor. It must not be called more than once. | |
3112 | */ | |
3113 | void Create(wxGrid* grid); | |
3114 | }; | |
e54c96f1 | 3115 |