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