]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: property.h | |
3 | // Purpose: interface of wxPGProperty | |
4 | // Author: wxWidgets team | |
de003797 | 5 | // RCS-ID: $Id$ |
1c4293cb VZ |
6 | // Licence: wxWindows license |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | // ----------------------------------------------------------------------- | |
10 | ||
effb029c JS |
11 | /** |
12 | @class wxPropertyGridInterface | |
1c4293cb VZ |
13 | |
14 | Most of the shared property manipulation interface shared by wxPropertyGrid, | |
15 | wxPropertyGridPage, and wxPropertyGridManager is defined in this class. | |
16 | ||
17 | @remarks | |
effb029c JS |
18 | - In separate wxPropertyGrid component this class was known as |
19 | wxPropertyContainerMethods. | |
1c4293cb | 20 | |
bba3f9b5 JS |
21 | - wxPropertyGridInterface's property operation member functions all accept |
22 | a special wxPGPropArg id argument, using which you can refer to properties | |
23 | either by their pointer (for performance) or by their name (for conveniency). | |
24 | ||
1c4293cb VZ |
25 | @library{wxpropgrid} |
26 | @category{propgrid} | |
27 | */ | |
28 | class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface | |
29 | { | |
30 | public: | |
31 | ||
32 | /** Destructor */ | |
33 | virtual ~wxPropertyGridInterface() { } | |
34 | ||
effb029c JS |
35 | /** |
36 | Appends property to the list. wxPropertyGrid assumes ownership of the | |
37 | object. Becomes child of most recently added category. | |
38 | ||
1c4293cb VZ |
39 | @remarks |
40 | - wxPropertyGrid takes the ownership of the property pointer. | |
effb029c JS |
41 | - If appending a category with name identical to a category already in |
42 | the wxPropertyGrid, then newly created category is deleted, and most | |
43 | recently added category (under which properties are appended) is set | |
44 | to the one with same name. This allows easier adding of items to same | |
45 | categories in multiple passes. | |
46 | - Does not automatically redraw the control, so you may need to call | |
47 | Refresh() when calling this function after control has been shown for | |
48 | the first time. | |
1621f192 JS |
49 | - This functions deselects selected property, if any. Validation |
50 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
51 | selection is cleared even if editor had invalid value. | |
1c4293cb VZ |
52 | */ |
53 | wxPGProperty* Append( wxPGProperty* property ); | |
54 | ||
effb029c JS |
55 | /** |
56 | Same as Append(), but appends under given parent property. | |
57 | ||
58 | @param id | |
59 | Name or pointer to parent property. | |
60 | ||
61 | @param newProperty | |
62 | Property to be added. | |
63 | */ | |
64 | wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newProperty ); | |
65 | ||
66 | /** | |
67 | In order to add new items into a property with private children (for | |
0ad10f30 FM |
68 | instance, wxFlagsProperty), you need to call this method. |
69 | After populating has been finished, you need to call EndAddChildren(). | |
1c4293cb | 70 | |
effb029c | 71 | @see EndAddChildren() |
1c4293cb VZ |
72 | */ |
73 | void BeginAddChildren( wxPGPropArg id ); | |
74 | ||
effb029c JS |
75 | /** |
76 | Deletes all properties. | |
1621f192 JS |
77 | |
78 | @remarks This functions deselects selected property, if any. Validation | |
79 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
80 | selection is cleared even if editor had invalid value. | |
1c4293cb VZ |
81 | */ |
82 | virtual void Clear() = 0; | |
83 | ||
effb029c | 84 | /** |
1621f192 JS |
85 | Clears current selection, if any. |
86 | ||
87 | @param validation | |
88 | If set to @false, deselecting the property will always work, | |
89 | even if its editor had invalid value in it. | |
effb029c | 90 | |
1621f192 JS |
91 | @return Returns @true if successful or if there was no selection. May |
92 | fail if validation was enabled and active editor had invalid | |
93 | value. | |
01b5ad3b JS |
94 | |
95 | @remarks In wxPropertyGrid 1.4, this member function used to send | |
96 | wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer | |
97 | does that. | |
98 | ||
99 | @see wxPropertyGrid::SelectProperty() | |
effb029c | 100 | */ |
1621f192 | 101 | bool ClearSelection( bool validation = false); |
1c4293cb | 102 | |
effb029c JS |
103 | /** |
104 | Resets modified status of all properties. | |
1c4293cb | 105 | */ |
effb029c JS |
106 | void ClearModifiedStatus(); |
107 | ||
108 | /** | |
109 | Collapses given category or property with children. | |
1c4293cb | 110 | |
effb029c | 111 | @return Returns @true if actually collapsed. |
1621f192 JS |
112 | |
113 | @remarks This function may deselect selected property, if any. Validation | |
114 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
115 | selection is cleared even if editor had invalid value. | |
1c4293cb VZ |
116 | */ |
117 | bool Collapse( wxPGPropArg id ); | |
118 | ||
effb029c JS |
119 | /** |
120 | Collapses all items that can be collapsed. | |
1c4293cb | 121 | |
1621f192 JS |
122 | @remarks This functions clears selection. Validation failure option |
123 | wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. selection | |
124 | is cleared even if editor had invalid value. | |
1c4293cb | 125 | */ |
effb029c | 126 | bool CollapseAll(); |
1c4293cb | 127 | |
effb029c JS |
128 | /** |
129 | Changes value of a property, as if by user. Use this instead of | |
130 | SetPropertyValue() if you need the value to run through validation | |
131 | process, and also send the property change event. | |
1c4293cb | 132 | |
effb029c | 133 | @return Returns @true if value was successfully changed. |
1c4293cb VZ |
134 | */ |
135 | bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue ); | |
136 | ||
effb029c | 137 | /** |
f231df8a | 138 | Removes and deletes a property and any children. |
1621f192 | 139 | |
f231df8a JS |
140 | @param id |
141 | Pointer or name of a property. | |
142 | ||
143 | @remarks If you delete a property in a wxPropertyGrid event | |
144 | handler, the actual deletion is postponed until the next | |
145 | idle event. | |
146 | ||
147 | This functions deselects selected property, if any. | |
148 | Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not | |
149 | respected, ie. selection is cleared even if editor had | |
150 | invalid value. | |
effb029c | 151 | */ |
1c4293cb VZ |
152 | void DeleteProperty( wxPGPropArg id ); |
153 | ||
effb029c JS |
154 | /** |
155 | Disables a property. | |
156 | */ | |
157 | bool DisableProperty( wxPGPropArg id ); | |
1c4293cb | 158 | |
effb029c | 159 | /** |
0ad10f30 FM |
160 | Returns @true if all property grid data changes have been committed. Usually |
161 | only returns @false if value in active editor has been invalidated by a | |
1c4293cb VZ |
162 | wxValidator. |
163 | */ | |
164 | bool EditorValidate(); | |
165 | ||
effb029c JS |
166 | /** |
167 | Enables or disables property. | |
168 | ||
169 | @param id | |
170 | Name or pointer to a property. | |
effb029c JS |
171 | @param enable |
172 | If @false, property is disabled instead. | |
173 | */ | |
1c4293cb VZ |
174 | bool EnableProperty( wxPGPropArg id, bool enable = true ); |
175 | ||
effb029c JS |
176 | /** |
177 | Called after population of property with fixed children has finished. | |
178 | ||
179 | @see BeginAddChildren() | |
1c4293cb VZ |
180 | */ |
181 | void EndAddChildren( wxPGPropArg id ); | |
182 | ||
effb029c JS |
183 | /** |
184 | Expands given category or property with children. | |
185 | ||
186 | @return Returns @true if actually expanded. | |
1621f192 JS |
187 | |
188 | @remarks This function may deselect selected property, if any. Validation | |
189 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
190 | selection is cleared even if editor had invalid value. | |
1c4293cb VZ |
191 | */ |
192 | bool Expand( wxPGPropArg id ); | |
193 | ||
effb029c JS |
194 | /** |
195 | Expands all items that can be expanded. | |
1621f192 JS |
196 | |
197 | @remarks This functions clears selection. Validation failure option | |
198 | wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. selection | |
199 | is cleared even if editor had invalid value. | |
1c4293cb VZ |
200 | */ |
201 | bool ExpandAll( bool expand = true ); | |
202 | ||
4279fdb4 JS |
203 | /** |
204 | Returns auto-resize proportion of the given column. | |
205 | ||
206 | @see SetColumnProportion() | |
207 | */ | |
208 | int GetColumnProportion( unsigned int column ) const; | |
209 | ||
effb029c JS |
210 | /** |
211 | Returns id of first child of given property. | |
1c4293cb | 212 | |
effb029c JS |
213 | @remarks Does not return private children! |
214 | */ | |
215 | wxPGProperty* GetFirstChild( wxPGPropArg id ); | |
1c4293cb VZ |
216 | |
217 | //@{ | |
0ad10f30 FM |
218 | /** |
219 | Returns iterator class instance. | |
bba3f9b5 | 220 | |
1c4293cb | 221 | @param flags |
bba3f9b5 JS |
222 | See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes |
223 | iteration over everything except private child properties. | |
1c4293cb | 224 | @param firstProp |
0ad10f30 | 225 | Property to start iteration from. If @NULL, then first child of root |
effb029c | 226 | is used. |
bba3f9b5 | 227 | |
0ad10f30 FM |
228 | @beginWxPythonOnly |
229 | <b>wxPython Note:</b> Instead of ++ operator, use Next() method, and | |
230 | instead of * operator, use GetProperty() method. | |
231 | @endWxPythonOnly | |
232 | */ | |
233 | wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, | |
234 | wxPGProperty* firstProp = NULL ); | |
235 | wxPropertyGridConstIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, | |
236 | wxPGProperty* firstProp = NULL ) const; | |
237 | //@} | |
238 | ||
239 | //@{ | |
240 | /** | |
241 | Returns iterator class instance. | |
242 | ||
243 | @param flags | |
244 | See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes | |
245 | iteration over everything except private child properties. | |
1c4293cb | 246 | @param startPos |
effb029c JS |
247 | Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start |
248 | from the first property from the top, and wxBOTTOM means that the | |
249 | iteration will instead begin from bottommost valid item. | |
250 | ||
0ad10f30 | 251 | @beginWxPythonOnly |
effb029c JS |
252 | <b>wxPython Note:</b> Instead of ++ operator, use Next() method, and |
253 | instead of * operator, use GetProperty() method. | |
0ad10f30 | 254 | @endWxPythonOnly |
effb029c | 255 | */ |
effb029c JS |
256 | wxPropertyGridIterator GetIterator( int flags, int startPos ); |
257 | wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const; | |
1c4293cb VZ |
258 | //@} |
259 | ||
effb029c JS |
260 | /** |
261 | Returns id of first item that matches given criteria. | |
262 | ||
1c4293cb | 263 | @param flags |
effb029c | 264 | See @ref propgrid_iterator_flags. |
1c4293cb | 265 | */ |
effb029c | 266 | wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ); |
1c4293cb | 267 | |
effb029c | 268 | /** |
d85635c5 JS |
269 | Returns pointer to a property with given name (case-sensitive). |
270 | If there is no property with such name, @NULL pointer is returned. | |
271 | ||
272 | @remarks Properties which have non-category, non-root parent | |
273 | can not be accessed globally by their name. Instead, use | |
274 | "<property>.<subproperty>" instead of "<subproperty>". | |
1c4293cb | 275 | */ |
0ad10f30 | 276 | wxPGProperty* GetProperty( const wxString& name ) const; |
1c4293cb | 277 | |
effb029c | 278 | /** |
0ad10f30 FM |
279 | Adds to 'targetArr' pointers to properties that have given flags 'flags' set. |
280 | However, if @a 'inverse' is set to @true, then only properties without | |
281 | given flags are stored. | |
effb029c | 282 | |
0ad10f30 FM |
283 | @param targetArr |
284 | @todo docme | |
1c4293cb | 285 | @param flags |
effb029c | 286 | Property flags to use. |
0ad10f30 FM |
287 | @param inverse |
288 | @todo docme | |
1c4293cb | 289 | @param iterFlags |
effb029c JS |
290 | Iterator flags to use. Default is everything expect private children. |
291 | See @ref propgrid_iterator_flags. | |
1c4293cb VZ |
292 | */ |
293 | void GetPropertiesWithFlag( wxArrayPGProperty* targetArr, | |
294 | wxPGProperty::FlagType flags, | |
295 | bool inverse = false, | |
296 | int iterFlags = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES) ) const; | |
297 | ||
effb029c JS |
298 | /** |
299 | Returns value of given attribute. If none found, returns wxNullVariant. | |
1c4293cb | 300 | */ |
effb029c | 301 | wxVariant GetPropertyAttribute( wxPGPropArg id, const wxString& attrName ) const; |
1c4293cb | 302 | |
e2ca6599 JS |
303 | /** |
304 | Returns background colour of first cell of a property. | |
305 | */ | |
306 | wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const; | |
307 | ||
effb029c JS |
308 | /** |
309 | Returns pointer of property's nearest parent category. If no category | |
0ad10f30 | 310 | found, returns @NULL. |
1c4293cb | 311 | */ |
effb029c | 312 | wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const; |
1c4293cb VZ |
313 | |
314 | /** Returns client data (void*) of a property. */ | |
effb029c | 315 | void* GetPropertyClientData( wxPGPropArg id ) const; |
1c4293cb | 316 | |
effb029c | 317 | /** |
0ad10f30 | 318 | Returns first property which label matches given string. @NULL if none |
effb029c JS |
319 | found. Note that this operation is very slow when compared to |
320 | GetPropertyByName(). | |
1c4293cb VZ |
321 | */ |
322 | wxPGProperty* GetPropertyByLabel( const wxString& label ) const; | |
323 | ||
effb029c | 324 | /** |
d85635c5 JS |
325 | Returns pointer to a property with given name (case-sensitive). |
326 | If there is no property with such name, @NULL pointer is returned. | |
327 | ||
328 | @remarks Properties which have non-category, non-root parent | |
329 | can not be accessed globally by their name. Instead, use | |
330 | "<property>.<subproperty>" instead of "<subproperty>". | |
1c4293cb VZ |
331 | */ |
332 | wxPGProperty* GetPropertyByName( const wxString& name ) const; | |
333 | ||
effb029c JS |
334 | /** |
335 | Returns child property 'subname' of property 'name'. Same as | |
1c4293cb VZ |
336 | calling GetPropertyByName("name.subname"), albeit slightly faster. |
337 | */ | |
effb029c JS |
338 | wxPGProperty* GetPropertyByName( const wxString& name, |
339 | const wxString& subname ) const; | |
1c4293cb | 340 | |
effb029c JS |
341 | /** |
342 | Returns property's editor. | |
343 | */ | |
344 | const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const; | |
1c4293cb | 345 | |
effb029c JS |
346 | /** |
347 | Returns help string associated with a property. | |
348 | */ | |
349 | wxString GetPropertyHelpString( wxPGPropArg id ) const; | |
1c4293cb | 350 | |
effb029c | 351 | /** |
0ad10f30 | 352 | Returns property's custom value image (@NULL of none). |
effb029c JS |
353 | */ |
354 | wxBitmap* GetPropertyImage( wxPGPropArg id ) const; | |
1c4293cb VZ |
355 | |
356 | /** Returns label of a property. */ | |
effb029c | 357 | const wxString& GetPropertyLabel( wxPGPropArg id ); |
1c4293cb | 358 | |
effb029c JS |
359 | /** Returns property's name, by which it is globally accessible. */ |
360 | wxString GetPropertyName( wxPGProperty* property ); | |
1c4293cb | 361 | |
e2ca6599 JS |
362 | /** |
363 | Returns text colour of first cell of a property. | |
364 | */ | |
365 | wxColour GetPropertyTextColour( wxPGPropArg id ) const; | |
366 | ||
effb029c JS |
367 | /** |
368 | Returns validator of a property as a reference, which you | |
1c4293cb VZ |
369 | can pass to any number of SetPropertyValidator. |
370 | */ | |
effb029c | 371 | wxValidator* GetPropertyValidator( wxPGPropArg id ); |
1c4293cb | 372 | |
effb029c JS |
373 | /** |
374 | Returns property's value as wxVariant. | |
1c4293cb VZ |
375 | |
376 | If property value is unspecified, Null variant is returned. | |
377 | */ | |
effb029c | 378 | wxVariant GetPropertyValue( wxPGPropArg id ); |
1c4293cb | 379 | |
effb029c JS |
380 | /** Return's property's value as wxArrayInt. */ |
381 | wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const; | |
382 | ||
383 | /** Returns property's value as wxArrayString. */ | |
384 | wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const; | |
385 | ||
386 | /** Returns property's value as bool */ | |
1c4293cb | 387 | bool GetPropertyValueAsBool( wxPGPropArg id ) const; |
1c4293cb | 388 | |
effb029c JS |
389 | /** Return's property's value as wxDateTime. */ |
390 | wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const; | |
1c4293cb | 391 | |
effb029c JS |
392 | /** Returns property's value as double-precision floating point number. */ |
393 | double GetPropertyValueAsDouble( wxPGPropArg id ) const; | |
1c4293cb | 394 | |
effb029c JS |
395 | /** Returns property's value as integer */ |
396 | int GetPropertyValueAsInt( wxPGPropArg id ) const; | |
1c4293cb | 397 | |
effb029c JS |
398 | /** Returns property's value as integer */ |
399 | long GetPropertyValueAsLong( wxPGPropArg id ) const; | |
1c4293cb | 400 | |
effb029c JS |
401 | /** Returns property's value as native signed 64-bit integer. */ |
402 | wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const; | |
1c4293cb | 403 | |
effb029c JS |
404 | /** |
405 | Returns property's value as wxString. If property does not | |
406 | use string value type, then its value is converted using | |
407 | wxPGProperty::GetValueAsString(). | |
408 | */ | |
409 | wxString GetPropertyValueAsString( wxPGPropArg id ) const; | |
1c4293cb | 410 | |
effb029c JS |
411 | /** Returns property's value as unsigned integer */ |
412 | unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const; | |
1c4293cb | 413 | |
effb029c JS |
414 | /** Returns property's value as native unsigned 64-bit integer. */ |
415 | wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const; | |
416 | ||
417 | /** | |
418 | Returns a wxVariant list containing wxVariant versions of all | |
1c4293cb | 419 | property values. Order is not guaranteed. |
effb029c | 420 | |
0ad10f30 FM |
421 | @param listname |
422 | @todo docme | |
423 | @param baseparent | |
424 | @todo docme | |
1c4293cb | 425 | @param flags |
effb029c JS |
426 | Use wxPG_KEEP_STRUCTURE to retain category structure; each sub |
427 | category will be its own wxVariantList of wxVariant. | |
428 | ||
429 | Use wxPG_INC_ATTRIBUTES to include property attributes as well. | |
430 | Each attribute will be stored as list variant named | |
431 | "@@<propname>@@attr." | |
1c4293cb VZ |
432 | */ |
433 | wxVariant GetPropertyValues( const wxString& listname = wxEmptyString, | |
0ad10f30 | 434 | wxPGProperty* baseparent = NULL, long flags = 0 ) const; |
1c4293cb | 435 | |
fc72fab6 JS |
436 | /** |
437 | Returns list of currently selected properties. | |
438 | ||
439 | @remarks wxArrayPGProperty should be compatible with std::vector API. | |
440 | */ | |
441 | const wxArrayPGProperty& GetSelectedProperties() const; | |
442 | ||
443 | /** | |
444 | Returns currently selected property. NULL if none. | |
445 | ||
446 | @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this | |
447 | member function returns the focused property, that is the | |
448 | one which can have active editor. | |
449 | */ | |
effb029c | 450 | wxPGProperty* GetSelection() const; |
1c4293cb | 451 | |
effb029c JS |
452 | /** |
453 | Similar to GetIterator(), but instead returns wxPGVIterator instance, | |
1c4293cb VZ |
454 | which can be useful for forward-iterating through arbitrary property |
455 | containers. | |
456 | ||
457 | @param flags | |
bba3f9b5 JS |
458 | See @ref propgrid_iterator_flags. |
459 | ||
effb029c JS |
460 | <b>wxPython Note:</b> Instead of ++ operator, use Next() method, and |
461 | instead of * operator, use GetProperty() method. | |
1c4293cb VZ |
462 | */ |
463 | virtual wxPGVIterator GetVIterator( int flags ) const; | |
464 | ||
effb029c JS |
465 | /** |
466 | Hides or reveals a property. | |
467 | ||
0ad10f30 FM |
468 | @param id |
469 | @todo docme | |
1c4293cb | 470 | @param hide |
effb029c | 471 | If @true, hides property, otherwise reveals it. |
1c4293cb | 472 | @param flags |
effb029c JS |
473 | By default changes are applied recursively. Set this parameter |
474 | wxPG_DONT_RECURSE to prevent this. | |
1c4293cb VZ |
475 | */ |
476 | bool HideProperty( wxPGPropArg id, bool hide = true, int flags = wxPG_RECURSE ); | |
477 | ||
effb029c JS |
478 | /** |
479 | Initializes *all* property types. Causes references to most object | |
1c4293cb VZ |
480 | files in the library, so calling this may cause significant increase |
481 | in executable size when linking with static library. | |
482 | */ | |
483 | static void InitAllTypeHandlers(); | |
484 | ||
0ad10f30 FM |
485 | /** |
486 | Inserts property to the property container. | |
1c4293cb VZ |
487 | |
488 | @param priorThis | |
effb029c JS |
489 | New property is inserted just prior to this. Available only |
490 | in the first variant. There are two versions of this function | |
491 | to allow this parameter to be either an id or name to | |
492 | a property. | |
effb029c JS |
493 | @param newProperty |
494 | Pointer to the inserted property. wxPropertyGrid will take | |
495 | ownership of this object. | |
1c4293cb | 496 | |
effb029c | 497 | @return Returns newProperty. |
1c4293cb VZ |
498 | |
499 | @remarks | |
500 | ||
501 | - wxPropertyGrid takes the ownership of the property pointer. | |
502 | ||
503 | - While Append may be faster way to add items, make note that when | |
504 | both types of data storage (categoric and | |
505 | non-categoric) are active, Insert becomes even more slow. This is | |
506 | especially true if current mode is non-categoric. | |
507 | ||
1621f192 JS |
508 | - This functions deselects selected property, if any. Validation |
509 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
510 | selection is cleared even if editor had invalid value. | |
511 | ||
1c4293cb VZ |
512 | Example of use: |
513 | ||
514 | @code | |
515 | ||
516 | // append category | |
517 | wxPGProperty* my_cat_id = propertygrid->Append( new wxPropertyCategory("My Category") ); | |
518 | ||
519 | ... | |
520 | ||
521 | // insert into category - using second variant | |
522 | wxPGProperty* my_item_id_1 = propertygrid->Insert( my_cat_id, 0, new wxStringProperty("My String 1") ); | |
523 | ||
524 | // insert before to first item - using first variant | |
525 | wxPGProperty* my_item_id_2 = propertygrid->Insert( my_item_id, new wxStringProperty("My String 2") ); | |
526 | ||
527 | @endcode | |
1c4293cb | 528 | */ |
effb029c | 529 | wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newProperty ); |
0ad10f30 FM |
530 | |
531 | /** | |
532 | Inserts property to the property container. | |
533 | See the other overload for more details. | |
534 | ||
535 | @param parent | |
536 | New property is inserted under this category. Available only | |
537 | in the second variant. There are two versions of this function | |
538 | to allow this parameter to be either an id or name to | |
539 | a property. | |
540 | @param index | |
541 | Index under category. Available only in the second variant. | |
542 | If index is < 0, property is appended in category. | |
543 | @param newProperty | |
544 | Pointer to the inserted property. wxPropertyGrid will take | |
545 | ownership of this object. | |
546 | ||
547 | @return Returns newProperty. | |
548 | */ | |
effb029c | 549 | wxPGProperty* Insert( wxPGPropArg parent, int index, wxPGProperty* newProperty ); |
1c4293cb | 550 | |
effb029c JS |
551 | /** Returns @true if property is a category. */ |
552 | bool IsPropertyCategory( wxPGPropArg id ) const; | |
1c4293cb | 553 | |
effb029c JS |
554 | /** Returns @true if property is enabled. */ |
555 | bool IsPropertyEnabled( wxPGPropArg id ) const; | |
1c4293cb | 556 | |
effb029c | 557 | /** |
0ad10f30 | 558 | Returns @true if given property is expanded. Naturally, always returns |
effb029c | 559 | @false for properties that cannot be expanded. |
1c4293cb VZ |
560 | */ |
561 | bool IsPropertyExpanded( wxPGPropArg id ) const; | |
562 | ||
effb029c JS |
563 | /** |
564 | Returns @true if property has been modified after value set or modify | |
565 | flag clear by software. | |
1c4293cb | 566 | */ |
effb029c | 567 | bool IsPropertyModified( wxPGPropArg id ) const; |
1c4293cb | 568 | |
fc72fab6 JS |
569 | /** |
570 | Returns true if property is selected. | |
571 | */ | |
572 | virtual bool IsPropertySelected( wxPGPropArg id ) const; | |
573 | ||
effb029c | 574 | /** |
0ad10f30 | 575 | Returns @true if property is shown (ie. HideProperty() with @true not |
effb029c | 576 | called for it). |
1c4293cb | 577 | */ |
effb029c | 578 | bool IsPropertyShown( wxPGPropArg id ) const; |
1c4293cb | 579 | |
effb029c | 580 | /** |
0ad10f30 | 581 | Returns @true if property value is set to unspecified. |
1c4293cb | 582 | */ |
effb029c | 583 | bool IsPropertyValueUnspecified( wxPGPropArg id ) const; |
1c4293cb | 584 | |
effb029c JS |
585 | /** |
586 | Disables (limit = @true) or enables (limit = @false) wxTextCtrl editor | |
587 | of a property, if it is not the sole mean to edit the value. | |
1c4293cb | 588 | */ |
effb029c | 589 | void LimitPropertyEditing( wxPGPropArg id, bool limit = true ); |
1c4293cb | 590 | |
effb029c JS |
591 | /** |
592 | Initializes additional property editors (SpinCtrl etc.). Causes | |
593 | references to most object files in the library, so calling this may | |
594 | cause significant increase in executable size when linking with static | |
595 | library. | |
1c4293cb VZ |
596 | */ |
597 | static void RegisterAdditionalEditors(); | |
598 | ||
f915d44b | 599 | /** |
f231df8a JS |
600 | Removes a property. Does not delete the property object, but |
601 | instead returns it. | |
f915d44b JS |
602 | |
603 | @param id | |
604 | Pointer or name of a property. | |
605 | ||
606 | @remarks Removed property cannot have any children. | |
f231df8a JS |
607 | |
608 | Also, if you remove property in a wxPropertyGrid event | |
609 | handler, the actual removal is postponed until the next | |
610 | idle event. | |
f915d44b JS |
611 | */ |
612 | wxPGProperty* RemoveProperty( wxPGPropArg id ); | |
613 | ||
effb029c JS |
614 | /** |
615 | Replaces property with id with newly created one. For example, | |
1c4293cb VZ |
616 | this code replaces existing property named "Flags" with one that |
617 | will have different set of items: | |
effb029c | 618 | |
1c4293cb VZ |
619 | @code |
620 | pg->ReplaceProperty("Flags", | |
621 | wxFlagsProperty("Flags", wxPG_LABEL, newItems)) | |
622 | @endcode | |
effb029c JS |
623 | |
624 | @see Insert() | |
1c4293cb VZ |
625 | */ |
626 | wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property ); | |
627 | ||
effb029c JS |
628 | /** |
629 | @anchor propgridinterface_editablestate_flags | |
1c4293cb VZ |
630 | |
631 | Flags for wxPropertyGridInterface::SaveEditableState() and | |
632 | wxPropertyGridInterface::RestoreEditableState(). | |
633 | */ | |
634 | enum EditableStateFlags | |
635 | { | |
636 | /** Include selected property. */ | |
637 | SelectionState = 0x01, | |
638 | /** Include expanded/collapsed property information. */ | |
639 | ExpandedState = 0x02, | |
640 | /** Include scrolled position. */ | |
641 | ScrollPosState = 0x04, | |
effb029c JS |
642 | /** Include selected page information. Only applies to |
643 | wxPropertyGridManager. */ | |
1c4293cb VZ |
644 | PageState = 0x08, |
645 | /** Include splitter position. Stored for each page. */ | |
646 | SplitterPosState = 0x10, | |
62805170 JS |
647 | /** Include description box size. |
648 | Only applies to wxPropertyGridManager. */ | |
649 | DescBoxState = 0x20, | |
650 | ||
651 | /** | |
652 | Include all supported user editable state information. | |
653 | This is usually the default value. */ | |
654 | AllStates = SelectionState | | |
655 | ExpandedState | | |
656 | ScrollPosState | | |
657 | PageState | | |
658 | SplitterPosState | | |
659 | DescBoxState | |
1c4293cb VZ |
660 | }; |
661 | ||
effb029c JS |
662 | /** |
663 | Restores user-editable state. See also wxPropertyGridInterface::SaveEditableState(). | |
1c4293cb VZ |
664 | |
665 | @param src | |
666 | String generated by SaveEditableState. | |
667 | ||
668 | @param restoreStates | |
669 | Which parts to restore from source string. See @ref propgridinterface_editablestate_flags | |
670 | "list of editable state flags". | |
671 | ||
effb029c | 672 | @return Returns @false if there was problem reading the string. |
1c4293cb | 673 | |
effb029c JS |
674 | @remarks If some parts of state (such as scrolled or splitter position) |
675 | fail to restore correctly, please make sure that you call this | |
676 | function after wxPropertyGrid size has been set (this may | |
677 | sometimes be tricky when sizers are used). | |
1c4293cb VZ |
678 | */ |
679 | bool RestoreEditableState( const wxString& src, | |
680 | int restoreStates = AllStates ); | |
681 | ||
effb029c JS |
682 | /** |
683 | Used to acquire user-editable state (selected property, expanded | |
684 | properties, scrolled position, splitter positions). | |
1c4293cb VZ |
685 | |
686 | @param includedStates | |
687 | Which parts of state to include. See @ref propgridinterface_editablestate_flags | |
688 | "list of editable state flags". | |
689 | */ | |
690 | wxString SaveEditableState( int includedStates = AllStates ) const; | |
691 | ||
effb029c JS |
692 | /** |
693 | Sets strings listed in the choice dropdown of a wxBoolProperty. | |
694 | ||
695 | Defaults are "True" and "False", so changing them to, say, "Yes" and | |
696 | "No" may be useful in some less technical applications. | |
1c4293cb | 697 | */ |
effb029c JS |
698 | static void SetBoolChoices( const wxString& trueChoice, |
699 | const wxString& falseChoice ); | |
700 | ||
fe01f16e JS |
701 | /** |
702 | Set proportion of a auto-stretchable column. wxPG_SPLITTER_AUTO_CENTER | |
703 | window style needs to be used to indicate that columns are auto- | |
704 | resizeable. | |
705 | ||
706 | @returns Returns @false on failure. | |
707 | ||
708 | @remarks You should call this for individual pages of | |
709 | wxPropertyGridManager (if used). | |
4279fdb4 JS |
710 | |
711 | @see GetColumnProportion() | |
fe01f16e JS |
712 | */ |
713 | bool SetColumnProportion( unsigned int column, int proportion ); | |
714 | ||
effb029c JS |
715 | /** |
716 | Sets an attribute for this property. | |
717 | ||
0ad10f30 FM |
718 | @param id |
719 | @todo docme | |
720 | @param attrName | |
effb029c | 721 | Text identifier of attribute. See @ref propgrid_property_attributes. |
1c4293cb | 722 | @param value |
effb029c | 723 | Value of attribute. |
1c4293cb | 724 | @param argFlags |
0ad10f30 FM |
725 | Optional. |
726 | Use wxPG_RECURSE to set the attribute to child properties recursively. | |
1802a91d JS |
727 | |
728 | @remarks Setting attribute's value to Null variant will simply remove it | |
0ad10f30 | 729 | from property's set of attributes. |
1c4293cb | 730 | */ |
effb029c JS |
731 | void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName, |
732 | wxVariant value, long argFlags = 0 ); | |
1c4293cb | 733 | |
effb029c JS |
734 | /** |
735 | Sets property attribute for all applicapple properties. | |
3c26d11b JS |
736 | Be sure to use this method only after all properties have been |
737 | added to the grid. | |
738 | */ | |
739 | void SetPropertyAttributeAll( const wxString& attrName, wxVariant value ); | |
740 | ||
e2ca6599 JS |
741 | /** |
742 | Sets background colour of a property. | |
743 | ||
744 | @param id | |
745 | Property name or pointer. | |
746 | ||
747 | @param colour | |
748 | New background colour. | |
749 | ||
e607eac2 JS |
750 | @param flags |
751 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
752 | Omit this flag to only set colour for the property in question | |
753 | and not any of its children. | |
e2ca6599 JS |
754 | */ |
755 | void SetPropertyBackgroundColour( wxPGPropArg id, | |
756 | const wxColour& colour, | |
e607eac2 | 757 | int flags = wxPG_RECURSE ); |
e2ca6599 | 758 | |
effb029c JS |
759 | /** |
760 | Sets text, bitmap, and colours for given column's cell. | |
1c4293cb VZ |
761 | |
762 | @remarks | |
effb029c | 763 | - You can set label cell by using column 0. |
1c4293cb VZ |
764 | - You can use wxPG_LABEL as text to use default text for column. |
765 | */ | |
766 | void SetPropertyCell( wxPGPropArg id, | |
767 | int column, | |
768 | const wxString& text = wxEmptyString, | |
769 | const wxBitmap& bitmap = wxNullBitmap, | |
770 | const wxColour& fgCol = wxNullColour, | |
effb029c JS |
771 | const wxColour& bgCol = wxNullColour ); |
772 | ||
773 | /** | |
774 | Sets client data (void*) of a property. | |
1c4293cb | 775 | |
1c4293cb VZ |
776 | @remarks |
777 | This untyped client data has to be deleted manually. | |
778 | */ | |
effb029c | 779 | void SetPropertyClientData( wxPGPropArg id, void* clientData ); |
1c4293cb | 780 | |
e2ca6599 JS |
781 | /** |
782 | Resets text and background colours of given property. | |
783 | */ | |
784 | void SetPropertyColoursToDefault( wxPGPropArg id ); | |
785 | ||
effb029c JS |
786 | /** |
787 | Sets editor for a property. | |
1c4293cb | 788 | |
0ad10f30 FM |
789 | @param id |
790 | @todo docme | |
1c4293cb | 791 | @param editor |
effb029c JS |
792 | For builtin editors, use wxPGEditor_X, where X is builtin editor's |
793 | name (TextCtrl, Choice, etc. see wxPGEditor documentation for full | |
794 | list). | |
1c4293cb VZ |
795 | |
796 | For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass(). | |
797 | */ | |
effb029c | 798 | void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor ); |
1c4293cb | 799 | |
effb029c JS |
800 | /** |
801 | Sets editor control of a property. As editor argument, use | |
1c4293cb VZ |
802 | editor name string, such as "TextCtrl" or "Choice". |
803 | */ | |
effb029c | 804 | void SetPropertyEditor( wxPGPropArg id, const wxString& editorName ); |
1c4293cb | 805 | |
effb029c JS |
806 | /** |
807 | Sets label of a property. | |
258ccb95 | 808 | |
1c4293cb | 809 | @remarks |
258ccb95 JS |
810 | - Properties under same parent may have same labels. However, |
811 | property names must still remain unique. | |
1c4293cb VZ |
812 | */ |
813 | void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel ); | |
814 | ||
020b0041 JS |
815 | /** |
816 | Sets name of a property. | |
817 | ||
818 | @param id | |
819 | Name or pointer of property which name to change. | |
820 | ||
821 | @param newName | |
822 | New name for property. | |
823 | */ | |
824 | void SetPropertyName( wxPGPropArg id, const wxString& newName ); | |
825 | ||
effb029c JS |
826 | /** |
827 | Sets property (and, recursively, its children) to have read-only value. | |
828 | In other words, user cannot change the value in the editor, but they can | |
829 | still copy it. | |
830 | ||
effb029c JS |
831 | @param id |
832 | Property name or pointer. | |
833 | ||
834 | @param set | |
835 | Use @true to enable read-only, @false to disable it. | |
1c4293cb | 836 | |
1c4293cb | 837 | @param flags |
effb029c JS |
838 | By default changes are applied recursively. Set this parameter |
839 | wxPG_DONT_RECURSE to prevent this. | |
c05fe841 JS |
840 | |
841 | @remarks This is mainly for use with textctrl editor. Only some other | |
842 | editors fully support it. | |
1c4293cb | 843 | */ |
effb029c JS |
844 | void SetPropertyReadOnly( wxPGPropArg id, bool set = true, |
845 | int flags = wxPG_RECURSE ); | |
1c4293cb | 846 | |
effb029c JS |
847 | /** |
848 | Sets property's value to unspecified. If it has children (it may be | |
849 | category), then the same thing is done to them. | |
1c4293cb VZ |
850 | */ |
851 | void SetPropertyValueUnspecified( wxPGPropArg id ); | |
852 | ||
effb029c | 853 | /** |
c9cc9a2f | 854 | Sets property values from a list of wxVariants. |
1c4293cb | 855 | */ |
effb029c JS |
856 | void SetPropertyValues( const wxVariantList& list, |
857 | wxPGPropArg defaultCategory = wxNullProperty ); | |
1c4293cb | 858 | |
c9cc9a2f JS |
859 | /** |
860 | Sets property values from a list of wxVariants. | |
861 | */ | |
effb029c JS |
862 | void SetPropertyValues( const wxVariant& list, |
863 | wxPGPropArg defaultCategory = wxNullProperty ); | |
1c4293cb | 864 | |
effb029c JS |
865 | /** |
866 | Associates the help string with property. | |
867 | ||
868 | @remarks By default, text is shown either in the manager's "description" | |
869 | text box or in the status bar. If extra window style | |
870 | wxPG_EX_HELP_AS_TOOLTIPS is used, then the text will appear as | |
871 | a tooltip. | |
1c4293cb | 872 | */ |
effb029c | 873 | void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString ); |
1c4293cb | 874 | |
effb029c JS |
875 | /** |
876 | Set wxBitmap in front of the value. | |
877 | ||
878 | @remarks Bitmap will be scaled to a size returned by | |
879 | wxPropertyGrid::GetImageSize(); | |
1c4293cb | 880 | */ |
effb029c | 881 | void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp ); |
1c4293cb | 882 | |
effb029c JS |
883 | /** |
884 | Sets max length of property's text. | |
1c4293cb VZ |
885 | */ |
886 | bool SetPropertyMaxLength( wxPGPropArg id, int maxLen ); | |
887 | ||
e2ca6599 JS |
888 | |
889 | /** | |
890 | Sets text colour of a property. | |
891 | ||
892 | @param id | |
893 | Property name or pointer. | |
894 | ||
895 | @param colour | |
896 | New background colour. | |
897 | ||
e607eac2 JS |
898 | @param flags |
899 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
900 | Omit this flag to only set colour for the property in question | |
901 | and not any of its children. | |
e2ca6599 JS |
902 | */ |
903 | void SetPropertyTextColour( wxPGPropArg id, | |
088441b5 | 904 | const wxColour& colour, |
e607eac2 | 905 | int flags = wxPG_RECURSE ); |
e2ca6599 | 906 | |
effb029c JS |
907 | /** |
908 | Sets validator of a property. | |
1c4293cb | 909 | */ |
effb029c | 910 | void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator ); |
1c4293cb | 911 | |
effb029c JS |
912 | /** Sets value (integer) of a property. */ |
913 | void SetPropertyValue( wxPGPropArg id, long value ); | |
1c4293cb | 914 | |
effb029c JS |
915 | /** Sets value (integer) of a property. */ |
916 | void SetPropertyValue( wxPGPropArg id, int value ); | |
1c4293cb | 917 | |
effb029c JS |
918 | /** Sets value (floating point) of a property. */ |
919 | void SetPropertyValue( wxPGPropArg id, double value ); | |
1c4293cb | 920 | |
effb029c JS |
921 | /** Sets value (bool) of a property. */ |
922 | void SetPropertyValue( wxPGPropArg id, bool value ); | |
1c4293cb | 923 | |
effb029c JS |
924 | /** Sets value (string) of a property. */ |
925 | void SetPropertyValue( wxPGPropArg id, const wxString& value ); | |
1c4293cb | 926 | |
effb029c JS |
927 | /** Sets value (wxArrayString) of a property. */ |
928 | void SetPropertyValue( wxPGPropArg id, const wxArrayString& value ); | |
1c4293cb | 929 | |
effb029c JS |
930 | /** Sets value (wxDateTime) of a property. */ |
931 | void SetPropertyValue( wxPGPropArg id, const wxDateTime& value ); | |
1c4293cb | 932 | |
effb029c JS |
933 | /** Sets value (wxObject*) of a property. */ |
934 | void SetPropertyValue( wxPGPropArg id, wxObject* value ); | |
1c4293cb | 935 | |
effb029c JS |
936 | /** Sets value (wxObject&) of a property. */ |
937 | void SetPropertyValue( wxPGPropArg id, wxObject& value ); | |
938 | ||
939 | /** Sets value (native 64-bit int) of a property. */ | |
940 | void SetPropertyValue( wxPGPropArg id, wxLongLong_t value ); | |
941 | ||
942 | /** Sets value (native 64-bit unsigned int) of a property. */ | |
943 | void SetPropertyValue( wxPGPropArg id, wxULongLong_t value ); | |
944 | ||
945 | /** Sets value (wxArrayInt&) of a property. */ | |
946 | void SetPropertyValue( wxPGPropArg id, const wxArrayInt& value ); | |
947 | ||
948 | /** | |
949 | Sets value (wxString) of a property. | |
950 | ||
951 | @remarks This method uses wxPGProperty::SetValueFromString(), which all | |
952 | properties should implement. This means that there should not be | |
953 | a type error, and instead the string is converted to property's | |
954 | actual value type. | |
1c4293cb VZ |
955 | */ |
956 | void SetPropertyValueString( wxPGPropArg id, const wxString& value ); | |
957 | ||
effb029c JS |
958 | /** |
959 | Sets value (wxVariant&) of a property. | |
bba3f9b5 | 960 | |
effb029c JS |
961 | @remarks Use wxPropertyGrid::ChangePropertyValue() instead if you need to |
962 | run through validation process and send property change event. | |
1c4293cb | 963 | */ |
effb029c | 964 | void SetPropertyValue( wxPGPropArg id, wxVariant value ); |
1c4293cb | 965 | |
effb029c JS |
966 | /** |
967 | Adjusts how wxPropertyGrid behaves when invalid value is entered | |
1c4293cb | 968 | in a property. |
effb029c | 969 | |
1c4293cb | 970 | @param vfbFlags |
effb029c | 971 | See @ref propgrid_vfbflags for possible values. |
1c4293cb VZ |
972 | */ |
973 | void SetValidationFailureBehavior( int vfbFlags ); | |
974 | ||
43396981 | 975 | /** |
0eb877f2 JS |
976 | Sorts all properties recursively. |
977 | ||
978 | @param flags | |
979 | This can contain any of the following options: | |
980 | wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their | |
981 | immediate children. Sorting done by wxPG_AUTO_SORT option | |
982 | uses this. | |
43396981 JS |
983 | |
984 | @see SortChildren, wxPropertyGrid::SetSortFunction | |
985 | */ | |
0eb877f2 | 986 | void Sort( int flags = 0 ); |
43396981 JS |
987 | |
988 | /** | |
989 | Sorts children of a property. | |
990 | ||
991 | @param id | |
992 | Name or pointer to a property. | |
993 | ||
0eb877f2 JS |
994 | @param flags |
995 | This can contain any of the following options: | |
996 | wxPG_RECURSE: Sorts recursively. | |
43396981 JS |
997 | |
998 | @see Sort, wxPropertyGrid::SetSortFunction | |
999 | */ | |
0eb877f2 | 1000 | void SortChildren( wxPGPropArg id, int flags = 0 ); |
43396981 | 1001 | |
effb029c JS |
1002 | /** |
1003 | Returns editor pointer of editor with given name; | |
1004 | */ | |
1c4293cb | 1005 | static wxPGEditor* GetEditorByName( const wxString& editorName ); |
1c4293cb VZ |
1006 | }; |
1007 |