]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/propgrid/propgridiface.h | |
3 | // Purpose: wxPropertyGridInterface class | |
4 | // Author: Jaakko Salli | |
5 | // Modified by: | |
6 | // Created: 2008-08-24 | |
7 | // Copyright: (c) Jaakko Salli | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef __WX_PROPGRID_PROPGRIDIFACE_H__ | |
12 | #define __WX_PROPGRID_PROPGRIDIFACE_H__ | |
13 | ||
14 | #include "wx/defs.h" | |
15 | ||
16 | #if wxUSE_PROPGRID | |
17 | ||
18 | #include "wx/propgrid/property.h" | |
19 | #include "wx/propgrid/propgridpagestate.h" | |
20 | ||
21 | // ----------------------------------------------------------------------- | |
22 | ||
23 | /** @section wxPGPropArgCls | |
24 | ||
25 | Most property grid functions have this type as their argument, as it can | |
26 | convey a property by either a pointer or name. | |
27 | */ | |
28 | class WXDLLIMPEXP_PROPGRID wxPGPropArgCls | |
29 | { | |
30 | public: | |
31 | wxPGPropArgCls( const wxPGProperty* property ) | |
32 | { | |
33 | m_ptr.property = (wxPGProperty*) property; | |
34 | m_flags = IsProperty; | |
35 | } | |
36 | wxPGPropArgCls( const wxString& str ) | |
37 | { | |
38 | m_ptr.stringName = &str; | |
39 | m_flags = IsWxString; | |
40 | } | |
41 | wxPGPropArgCls( const wxPGPropArgCls& id ) | |
42 | { | |
43 | m_ptr = id.m_ptr; | |
44 | m_flags = id.m_flags; | |
45 | } | |
46 | // This is only needed for wxPython bindings | |
47 | wxPGPropArgCls( wxString* str, bool WXUNUSED(deallocPtr) ) | |
48 | { | |
49 | m_ptr.stringName = str; | |
50 | m_flags = IsWxString | OwnsWxString; | |
51 | } | |
52 | ~wxPGPropArgCls() | |
53 | { | |
54 | if ( m_flags & OwnsWxString ) | |
55 | delete m_ptr.stringName; | |
56 | } | |
57 | wxPGProperty* GetPtr() const | |
58 | { | |
59 | wxCHECK( m_flags == IsProperty, NULL ); | |
60 | return m_ptr.property; | |
61 | } | |
62 | wxPGPropArgCls( const char* str ) | |
63 | { | |
64 | m_ptr.charName = str; | |
65 | m_flags = IsCharPtr; | |
66 | } | |
67 | wxPGPropArgCls( const wchar_t* str ) | |
68 | { | |
69 | m_ptr.wcharName = str; | |
70 | m_flags = IsWCharPtr; | |
71 | } | |
72 | /** This constructor is required for NULL. */ | |
73 | wxPGPropArgCls( int ) | |
74 | { | |
75 | m_ptr.property = NULL; | |
76 | m_flags = IsProperty; | |
77 | } | |
78 | wxPGProperty* GetPtr( wxPropertyGridInterface* iface ) const; | |
79 | wxPGProperty* GetPtr( const wxPropertyGridInterface* iface ) const | |
80 | { | |
81 | return GetPtr((wxPropertyGridInterface*)iface); | |
82 | } | |
83 | wxPGProperty* GetPtr0() const { return m_ptr.property; } | |
84 | bool HasName() const { return (m_flags != IsProperty); } | |
85 | const wxString& GetName() const { return *m_ptr.stringName; } | |
86 | private: | |
87 | ||
88 | enum | |
89 | { | |
90 | IsProperty = 0x00, | |
91 | IsWxString = 0x01, | |
92 | IsCharPtr = 0x02, | |
93 | IsWCharPtr = 0x04, | |
94 | OwnsWxString = 0x10 | |
95 | }; | |
96 | ||
97 | union | |
98 | { | |
99 | wxPGProperty* property; | |
100 | const char* charName; | |
101 | const wchar_t* wcharName; | |
102 | const wxString* stringName; | |
103 | } m_ptr; | |
104 | unsigned char m_flags; | |
105 | }; | |
106 | ||
107 | typedef const wxPGPropArgCls& wxPGPropArg; | |
108 | ||
109 | // ----------------------------------------------------------------------- | |
110 | ||
111 | WXDLLIMPEXP_PROPGRID | |
112 | void wxPGTypeOperationFailed( const wxPGProperty* p, | |
113 | const wxString& typestr, | |
114 | const wxString& op ); | |
115 | WXDLLIMPEXP_PROPGRID | |
116 | void wxPGGetFailed( const wxPGProperty* p, const wxString& typestr ); | |
117 | ||
118 | // ----------------------------------------------------------------------- | |
119 | ||
120 | // Helper macro that does necessary preparations when calling | |
121 | // some wxPGProperty's member function. | |
122 | #define wxPG_PROP_ARG_CALL_PROLOG_0(PROPERTY) \ | |
123 | PROPERTY *p = (PROPERTY*)id.GetPtr(this); \ | |
124 | if ( !p ) return; | |
125 | ||
126 | #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(PROPERTY, RETVAL) \ | |
127 | PROPERTY *p = (PROPERTY*)id.GetPtr(this); \ | |
128 | if ( !p ) return RETVAL; | |
129 | ||
130 | #define wxPG_PROP_ARG_CALL_PROLOG() \ | |
131 | wxPG_PROP_ARG_CALL_PROLOG_0(wxPGProperty) | |
132 | ||
133 | #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL(RVAL) \ | |
134 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(wxPGProperty, RVAL) | |
135 | ||
136 | #define wxPG_PROP_ID_CONST_CALL_PROLOG() \ | |
137 | wxPG_PROP_ARG_CALL_PROLOG_0(const wxPGProperty) | |
138 | ||
139 | #define wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(RVAL) \ | |
140 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(const wxPGProperty, RVAL) | |
141 | ||
142 | // ----------------------------------------------------------------------- | |
143 | ||
144 | ||
145 | /** @class wxPropertyGridInterface | |
146 | ||
147 | Most of the shared property manipulation interface shared by wxPropertyGrid, | |
148 | wxPropertyGridPage, and wxPropertyGridManager is defined in this class. | |
149 | ||
150 | @remarks | |
151 | - In separate wxPropertyGrid component this class was known as | |
152 | wxPropertyContainerMethods. | |
153 | ||
154 | @library{wxpropgrid} | |
155 | @category{propgrid} | |
156 | */ | |
157 | class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface | |
158 | { | |
159 | public: | |
160 | ||
161 | /** Destructor */ | |
162 | virtual ~wxPropertyGridInterface() { } | |
163 | ||
164 | /** | |
165 | Appends property to the list. | |
166 | ||
167 | wxPropertyGrid assumes ownership of the object. | |
168 | Becomes child of most recently added category. | |
169 | @remarks | |
170 | - wxPropertyGrid takes the ownership of the property pointer. | |
171 | - If appending a category with name identical to a category already in | |
172 | the wxPropertyGrid, then newly created category is deleted, and most | |
173 | recently added category (under which properties are appended) is set | |
174 | to the one with same name. This allows easier adding of items to same | |
175 | categories in multiple passes. | |
176 | - Does not automatically redraw the control, so you may need to call | |
177 | Refresh when calling this function after control has been shown for | |
178 | the first time. | |
179 | */ | |
180 | wxPGProperty* Append( wxPGProperty* property ); | |
181 | ||
182 | wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newproperty ); | |
183 | ||
184 | /** | |
185 | In order to add new items into a property with fixed children (for | |
186 | instance, wxFlagsProperty), you need to call this method. After | |
187 | populating has been finished, you need to call EndAddChildren. | |
188 | */ | |
189 | void BeginAddChildren( wxPGPropArg id ); | |
190 | ||
191 | /** Deletes all properties. | |
192 | */ | |
193 | virtual void Clear() = 0; | |
194 | ||
195 | /** | |
196 | Clears current selection, if any. | |
197 | ||
198 | @param validation | |
199 | If set to @false, deselecting the property will always work, | |
200 | even if its editor had invalid value in it. | |
201 | ||
202 | @return Returns @true if successful or if there was no selection. May | |
203 | fail if validation was enabled and active editor had invalid | |
204 | value. | |
205 | ||
206 | @remarks In wxPropertyGrid 1.4, this member function used to send | |
207 | wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer | |
208 | does that. | |
209 | */ | |
210 | bool ClearSelection( bool validation = false ); | |
211 | ||
212 | /** Resets modified status of all properties. | |
213 | */ | |
214 | void ClearModifiedStatus(); | |
215 | ||
216 | /** Collapses given category or property with children. | |
217 | Returns true if actually collapses. | |
218 | */ | |
219 | bool Collapse( wxPGPropArg id ); | |
220 | ||
221 | /** Collapses all items that can be collapsed. | |
222 | ||
223 | @return | |
224 | Return false if failed (may fail if editor value cannot be validated). | |
225 | */ | |
226 | bool CollapseAll() { return ExpandAll(false); } | |
227 | ||
228 | /** | |
229 | Changes value of a property, as if from an editor. | |
230 | Use this instead of SetPropertyValue() if you need the value to run | |
231 | through validation process, and also send the property change event. | |
232 | ||
233 | @return | |
234 | Returns true if value was successfully changed. | |
235 | */ | |
236 | bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue ); | |
237 | ||
238 | /** | |
239 | Removes and deletes a property and any children. | |
240 | ||
241 | @param id | |
242 | Pointer or name of a property. | |
243 | ||
244 | @remarks If you delete a property in a wxPropertyGrid event | |
245 | handler, the actual deletion is postponed until the next | |
246 | idle event. | |
247 | ||
248 | This functions deselects selected property, if any. | |
249 | Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not | |
250 | respected, ie. selection is cleared even if editor had | |
251 | invalid value. | |
252 | */ | |
253 | void DeleteProperty( wxPGPropArg id ); | |
254 | ||
255 | /** | |
256 | Removes a property. Does not delete the property object, but | |
257 | instead returns it. | |
258 | ||
259 | @param id | |
260 | Pointer or name of a property. | |
261 | ||
262 | @remarks Removed property cannot have any children. | |
263 | ||
264 | Also, if you remove property in a wxPropertyGrid event | |
265 | handler, the actual removal is postponed until the next | |
266 | idle event. | |
267 | */ | |
268 | wxPGProperty* RemoveProperty( wxPGPropArg id ); | |
269 | ||
270 | /** | |
271 | Disables a property. | |
272 | ||
273 | @see EnableProperty(), wxPGProperty::Enable() | |
274 | */ | |
275 | bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); } | |
276 | ||
277 | /** | |
278 | Returns true if all property grid data changes have been committed. | |
279 | ||
280 | Usually only returns false if value in active editor has been | |
281 | invalidated by a wxValidator. | |
282 | */ | |
283 | bool EditorValidate(); | |
284 | ||
285 | /** | |
286 | Enables or disables property, depending on whether enable is true or | |
287 | false. Disabled property usually appears as having grey text. | |
288 | ||
289 | @param id | |
290 | Name or pointer to a property. | |
291 | @param enable | |
292 | If @false, property is disabled instead. | |
293 | ||
294 | @see wxPGProperty::Enable() | |
295 | */ | |
296 | bool EnableProperty( wxPGPropArg id, bool enable = true ); | |
297 | ||
298 | /** Called after population of property with fixed children has finished. | |
299 | */ | |
300 | void EndAddChildren( wxPGPropArg id ); | |
301 | ||
302 | /** Expands given category or property with children. | |
303 | Returns true if actually expands. | |
304 | */ | |
305 | bool Expand( wxPGPropArg id ); | |
306 | ||
307 | /** Expands all items that can be expanded. | |
308 | */ | |
309 | bool ExpandAll( bool expand = true ); | |
310 | ||
311 | /** Returns id of first child of given property. | |
312 | @remarks | |
313 | Does not return sub-properties! | |
314 | */ | |
315 | wxPGProperty* GetFirstChild( wxPGPropArg id ) | |
316 | { | |
317 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty) | |
318 | ||
319 | if ( !p->GetChildCount() || p->HasFlag(wxPG_PROP_AGGREGATE) ) | |
320 | return wxNullProperty; | |
321 | ||
322 | return p->Item(0); | |
323 | } | |
324 | ||
325 | //@{ | |
326 | /** Returns iterator class instance. | |
327 | @param flags | |
328 | See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes | |
329 | iteration over everything except private child properties. | |
330 | @param firstProp | |
331 | Property to start iteration from. If NULL, then first child of root | |
332 | is used. | |
333 | @param startPos | |
334 | Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start | |
335 | from the first property from the top, and wxBOTTOM means that the | |
336 | iteration will instead begin from bottommost valid item. | |
337 | */ | |
338 | wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, | |
339 | wxPGProperty* firstProp = NULL ) | |
340 | { | |
341 | return wxPropertyGridIterator( m_pState, flags, firstProp ); | |
342 | } | |
343 | ||
344 | wxPropertyGridConstIterator | |
345 | GetIterator( int flags = wxPG_ITERATE_DEFAULT, | |
346 | wxPGProperty* firstProp = NULL ) const | |
347 | { | |
348 | return wxPropertyGridConstIterator( m_pState, flags, firstProp ); | |
349 | } | |
350 | ||
351 | wxPropertyGridIterator GetIterator( int flags, int startPos ) | |
352 | { | |
353 | return wxPropertyGridIterator( m_pState, flags, startPos ); | |
354 | } | |
355 | ||
356 | wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const | |
357 | { | |
358 | return wxPropertyGridConstIterator( m_pState, flags, startPos ); | |
359 | } | |
360 | //@} | |
361 | ||
362 | /** Returns id of first item, whether it is a category or property. | |
363 | @param flags | |
364 | @link iteratorflags List of iterator flags@endlink | |
365 | */ | |
366 | wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ) | |
367 | { | |
368 | wxPropertyGridIterator it( m_pState, flags, wxNullProperty, 1 ); | |
369 | return *it; | |
370 | } | |
371 | ||
372 | const wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ) const | |
373 | { | |
374 | return ((wxPropertyGridInterface*)this)->GetFirst(flags); | |
375 | } | |
376 | ||
377 | /** | |
378 | Returns pointer to a property with given name (case-sensitive). | |
379 | If there is no property with such name, @NULL pointer is returned. | |
380 | ||
381 | @remarks Properties which have non-category, non-root parent | |
382 | cannot be accessed globally by their name. Instead, use | |
383 | "<property>.<subproperty>" instead of "<subproperty>". | |
384 | */ | |
385 | wxPGProperty* GetProperty( const wxString& name ) const | |
386 | { | |
387 | return GetPropertyByName(name); | |
388 | } | |
389 | ||
390 | /** Returns map-like storage of property's attributes. | |
391 | @remarks | |
392 | Note that if extra style wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES is set, | |
393 | then builtin-attributes are not included in the storage. | |
394 | */ | |
395 | const wxPGAttributeStorage& GetPropertyAttributes( wxPGPropArg id ) const | |
396 | { | |
397 | // If 'id' refers to invalid property, then we will return dummy | |
398 | // attributes (ie. root property's attributes, which contents should | |
399 | // should always be empty and of no consequence). | |
400 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_pState->DoGetRoot()->GetAttributes()); | |
401 | return p->GetAttributes(); | |
402 | } | |
403 | ||
404 | /** Adds to 'targetArr' pointers to properties that have given | |
405 | flags 'flags' set. However, if 'inverse' is set to true, then | |
406 | only properties without given flags are stored. | |
407 | @param flags | |
408 | Property flags to use. | |
409 | @param iterFlags | |
410 | Iterator flags to use. Default is everything expect private children. | |
411 | */ | |
412 | void GetPropertiesWithFlag( wxArrayPGProperty* targetArr, | |
413 | wxPGProperty::FlagType flags, | |
414 | bool inverse = false, | |
415 | int iterFlags = wxPG_ITERATE_PROPERTIES | | |
416 | wxPG_ITERATE_HIDDEN | | |
417 | wxPG_ITERATE_CATEGORIES) const; | |
418 | ||
419 | /** Returns value of given attribute. If none found, returns NULL-variant. | |
420 | */ | |
421 | wxVariant GetPropertyAttribute( wxPGPropArg id, | |
422 | const wxString& attrName ) const | |
423 | { | |
424 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant) | |
425 | return p->GetAttribute(attrName); | |
426 | } | |
427 | ||
428 | /** Returns pointer of property's nearest parent category. If no category | |
429 | found, returns NULL. | |
430 | */ | |
431 | wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const | |
432 | { | |
433 | wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL) | |
434 | return m_pState->GetPropertyCategory(p); | |
435 | } | |
436 | ||
437 | /** Returns client data (void*) of a property. */ | |
438 | void* GetPropertyClientData( wxPGPropArg id ) const | |
439 | { | |
440 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL) | |
441 | return p->GetClientData(); | |
442 | } | |
443 | ||
444 | /** | |
445 | Returns first property which label matches given string. | |
446 | ||
447 | NULL if none found. Note that this operation is extremely slow when | |
448 | compared to GetPropertyByName(). | |
449 | */ | |
450 | wxPGProperty* GetPropertyByLabel( const wxString& label ) const; | |
451 | ||
452 | /** Returns property with given name. NULL if none found. | |
453 | */ | |
454 | wxPGProperty* GetPropertyByName( const wxString& name ) const; | |
455 | ||
456 | /** Returns child property 'subname' of property 'name'. Same as | |
457 | calling GetPropertyByName("name.subname"), albeit slightly faster. | |
458 | */ | |
459 | wxPGProperty* GetPropertyByName( const wxString& name, | |
460 | const wxString& subname ) const; | |
461 | ||
462 | /** Returns property's editor. */ | |
463 | const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const | |
464 | { | |
465 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL) | |
466 | return p->GetEditorClass(); | |
467 | } | |
468 | ||
469 | /** Returns help string associated with a property. */ | |
470 | wxString GetPropertyHelpString( wxPGPropArg id ) const | |
471 | { | |
472 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString) | |
473 | return p->GetHelpString(); | |
474 | } | |
475 | ||
476 | /** Returns property's custom value image (NULL of none). */ | |
477 | wxBitmap* GetPropertyImage( wxPGPropArg id ) const | |
478 | { | |
479 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL) | |
480 | return p->GetValueImage(); | |
481 | } | |
482 | ||
483 | /** Returns label of a property. */ | |
484 | const wxString& GetPropertyLabel( wxPGPropArg id ) | |
485 | { | |
486 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString) | |
487 | return p->GetLabel(); | |
488 | } | |
489 | ||
490 | /** Returns name of a property, by which it is globally accessible. */ | |
491 | wxString GetPropertyName( wxPGProperty* property ) | |
492 | { | |
493 | return property->GetName(); | |
494 | } | |
495 | ||
496 | /** Returns parent item of a property. */ | |
497 | wxPGProperty* GetPropertyParent( wxPGPropArg id ) | |
498 | { | |
499 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty) | |
500 | return p->GetParent(); | |
501 | } | |
502 | ||
503 | #if wxUSE_VALIDATORS | |
504 | /** Returns validator of a property as a reference, which you | |
505 | can pass to any number of SetPropertyValidator. | |
506 | */ | |
507 | wxValidator* GetPropertyValidator( wxPGPropArg id ) | |
508 | { | |
509 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL) | |
510 | return p->GetValidator(); | |
511 | } | |
512 | #endif | |
513 | ||
514 | /** Returns value as wxVariant. To get wxObject pointer from it, | |
515 | you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro. | |
516 | ||
517 | If property value is unspecified, Null variant is returned. | |
518 | */ | |
519 | wxVariant GetPropertyValue( wxPGPropArg id ) | |
520 | { | |
521 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant()) | |
522 | return p->GetValue(); | |
523 | } | |
524 | ||
525 | wxString GetPropertyValueAsString( wxPGPropArg id ) const; | |
526 | long GetPropertyValueAsLong( wxPGPropArg id ) const; | |
527 | unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const | |
528 | { | |
529 | return (unsigned long) GetPropertyValueAsLong(id); | |
530 | } | |
531 | int GetPropertyValueAsInt( wxPGPropArg id ) const | |
532 | { return (int)GetPropertyValueAsLong(id); } | |
533 | bool GetPropertyValueAsBool( wxPGPropArg id ) const; | |
534 | double GetPropertyValueAsDouble( wxPGPropArg id ) const; | |
535 | ||
536 | #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \ | |
537 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \ | |
538 | wxString typeName(wxS(TYPENAME)); \ | |
539 | wxVariant value = p->GetValue(); \ | |
540 | if ( value.GetType() != typeName ) \ | |
541 | { \ | |
542 | wxPGGetFailed(p, typeName); \ | |
543 | return DEFVAL; \ | |
544 | } | |
545 | ||
546 | #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \ | |
547 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \ | |
548 | wxVariant value = p->GetValue(); \ | |
549 | if ( value.GetType() != wxS(TYPENAME) ) \ | |
550 | return DEFVAL; \ | |
551 | ||
552 | wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const | |
553 | { | |
554 | wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("arrstring", | |
555 | wxArrayString()) | |
556 | return value.GetArrayString(); | |
557 | } | |
558 | ||
559 | #ifdef wxLongLong_t | |
560 | wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const | |
561 | { | |
562 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0) | |
563 | return p->GetValue().GetLongLong().GetValue(); | |
564 | } | |
565 | ||
566 | wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const | |
567 | { | |
568 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0) | |
569 | return p->GetValue().GetULongLong().GetValue(); | |
570 | } | |
571 | #endif | |
572 | ||
573 | wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const | |
574 | { | |
575 | wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxArrayInt", | |
576 | wxArrayInt()) | |
577 | wxArrayInt arr; | |
578 | arr << value; | |
579 | return arr; | |
580 | } | |
581 | ||
582 | #if wxUSE_DATETIME | |
583 | wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const | |
584 | { | |
585 | wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("datetime", | |
586 | wxDateTime()) | |
587 | return value.GetDateTime(); | |
588 | } | |
589 | #endif | |
590 | ||
591 | /** Returns a wxVariant list containing wxVariant versions of all | |
592 | property values. Order is not guaranteed. | |
593 | @param flags | |
594 | Use wxPG_KEEP_STRUCTURE to retain category structure; each sub | |
595 | category will be its own wxVariantList of wxVariant. | |
596 | Use wxPG_INC_ATTRIBUTES to include property attributes as well. | |
597 | Each attribute will be stored as list variant named | |
598 | "@@<propname>@@attr." | |
599 | @remarks | |
600 | */ | |
601 | wxVariant GetPropertyValues( const wxString& listname = wxEmptyString, | |
602 | wxPGProperty* baseparent = NULL, long flags = 0 ) const | |
603 | { | |
604 | return m_pState->DoGetPropertyValues(listname, baseparent, flags); | |
605 | } | |
606 | ||
607 | /** | |
608 | Returns currently selected property. NULL if none. | |
609 | ||
610 | @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this | |
611 | member function returns the focused property, that is the | |
612 | one which can have active editor. | |
613 | */ | |
614 | wxPGProperty* GetSelection() const; | |
615 | ||
616 | /** | |
617 | Returns list of currently selected properties. | |
618 | ||
619 | @remarks wxArrayPGProperty should be compatible with std::vector API. | |
620 | */ | |
621 | const wxArrayPGProperty& GetSelectedProperties() const | |
622 | { | |
623 | return m_pState->m_selection; | |
624 | } | |
625 | ||
626 | wxPropertyGridPageState* GetState() const { return m_pState; } | |
627 | ||
628 | /** Similar to GetIterator(), but instead returns wxPGVIterator instance, | |
629 | which can be useful for forward-iterating through arbitrary property | |
630 | containers. | |
631 | ||
632 | @param flags | |
633 | See @ref propgrid_iterator_flags. | |
634 | */ | |
635 | virtual wxPGVIterator GetVIterator( int flags ) const; | |
636 | ||
637 | /** Hides or reveals a property. | |
638 | @param hide | |
639 | If true, hides property, otherwise reveals it. | |
640 | @param flags | |
641 | By default changes are applied recursively. Set this paramter | |
642 | wxPG_DONT_RECURSE to prevent this. | |
643 | */ | |
644 | bool HideProperty( wxPGPropArg id, | |
645 | bool hide = true, | |
646 | int flags = wxPG_RECURSE ); | |
647 | ||
648 | #if wxPG_INCLUDE_ADVPROPS | |
649 | /** Initializes *all* property types. Causes references to most object | |
650 | files in the library, so calling this may cause significant increase | |
651 | in executable size when linking with static library. | |
652 | */ | |
653 | static void InitAllTypeHandlers(); | |
654 | #else | |
655 | static void InitAllTypeHandlers() { } | |
656 | #endif | |
657 | ||
658 | //@{ | |
659 | /** Inserts property to the property container. | |
660 | ||
661 | @param priorThis | |
662 | New property is inserted just prior to this. Available only | |
663 | in the first variant. There are two versions of this function | |
664 | to allow this parameter to be either an id or name to | |
665 | a property. | |
666 | ||
667 | @param newproperty | |
668 | Pointer to the inserted property. wxPropertyGrid will take | |
669 | ownership of this object. | |
670 | ||
671 | @param parent | |
672 | New property is inserted under this category. Available only | |
673 | in the second variant. There are two versions of this function | |
674 | to allow this parameter to be either an id or name to | |
675 | a property. | |
676 | ||
677 | @param index | |
678 | Index under category. Available only in the second variant. | |
679 | If index is < 0, property is appended in category. | |
680 | ||
681 | @return | |
682 | Returns id for the property, | |
683 | ||
684 | @remarks | |
685 | ||
686 | - wxPropertyGrid takes the ownership of the property pointer. | |
687 | ||
688 | - While Append may be faster way to add items, make note that when | |
689 | both types of data storage (categoric and | |
690 | non-categoric) are active, Insert becomes even more slow. This is | |
691 | especially true if current mode is non-categoric. | |
692 | ||
693 | Example of use: | |
694 | ||
695 | @code | |
696 | ||
697 | // append category | |
698 | wxPGProperty* my_cat_id = propertygrid->Append( | |
699 | new wxPropertyCategory("My Category") ); | |
700 | ||
701 | ... | |
702 | ||
703 | // insert into category - using second variant | |
704 | wxPGProperty* my_item_id_1 = propertygrid->Insert( | |
705 | my_cat_id, 0, new wxStringProperty("My String 1") ); | |
706 | ||
707 | // insert before to first item - using first variant | |
708 | wxPGProperty* my_item_id_2 = propertygrid->Insert( | |
709 | my_item_id, new wxStringProperty("My String 2") ); | |
710 | ||
711 | @endcode | |
712 | ||
713 | */ | |
714 | wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newproperty ); | |
715 | wxPGProperty* Insert( wxPGPropArg parent, | |
716 | int index, | |
717 | wxPGProperty* newproperty ); | |
718 | //@} | |
719 | ||
720 | /** Returns true if property is a category. */ | |
721 | bool IsPropertyCategory( wxPGPropArg id ) const | |
722 | { | |
723 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
724 | return p->IsCategory(); | |
725 | } | |
726 | ||
727 | /** Returns true if property is enabled. */ | |
728 | bool IsPropertyEnabled( wxPGPropArg id ) const | |
729 | { | |
730 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
731 | return (!(p->GetFlags() & wxPG_PROP_DISABLED))?true:false; | |
732 | } | |
733 | ||
734 | /** | |
735 | Returns true if given property is expanded. | |
736 | ||
737 | Naturally, always returns false for properties that cannot be expanded. | |
738 | */ | |
739 | bool IsPropertyExpanded( wxPGPropArg id ) const; | |
740 | ||
741 | /** | |
742 | Returns true if property has been modified after value set or modify | |
743 | flag clear by software. | |
744 | */ | |
745 | bool IsPropertyModified( wxPGPropArg id ) const | |
746 | { | |
747 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
748 | return ( (p->GetFlags() & wxPG_PROP_MODIFIED) ? true : false ); | |
749 | } | |
750 | ||
751 | /** | |
752 | Returns true if property is selected. | |
753 | */ | |
754 | bool IsPropertySelected( wxPGPropArg id ) const | |
755 | { | |
756 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
757 | return m_pState->DoIsPropertySelected(p); | |
758 | } | |
759 | ||
760 | /** | |
761 | Returns true if property is shown (ie hideproperty with true not | |
762 | called for it). | |
763 | */ | |
764 | bool IsPropertyShown( wxPGPropArg id ) const | |
765 | { | |
766 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
767 | return (!(p->GetFlags() & wxPG_PROP_HIDDEN))?true:false; | |
768 | } | |
769 | ||
770 | /** Returns true if property value is set to unspecified. | |
771 | */ | |
772 | bool IsPropertyValueUnspecified( wxPGPropArg id ) const | |
773 | { | |
774 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
775 | return p->IsValueUnspecified(); | |
776 | } | |
777 | ||
778 | /** | |
779 | Disables (limit = true) or enables (limit = false) wxTextCtrl editor of | |
780 | a property, if it is not the sole mean to edit the value. | |
781 | */ | |
782 | void LimitPropertyEditing( wxPGPropArg id, bool limit = true ); | |
783 | ||
784 | /** If state is shown in it's grid, refresh it now. | |
785 | */ | |
786 | virtual void RefreshGrid( wxPropertyGridPageState* state = NULL ); | |
787 | ||
788 | #if wxPG_INCLUDE_ADVPROPS | |
789 | /** | |
790 | Initializes additional property editors (SpinCtrl etc.). Causes | |
791 | references to most object files in the library, so calling this may | |
792 | cause significant increase in executable size when linking with static | |
793 | library. | |
794 | */ | |
795 | static void RegisterAdditionalEditors(); | |
796 | #else | |
797 | static void RegisterAdditionalEditors() { } | |
798 | #endif | |
799 | ||
800 | /** Replaces property with id with newly created property. For example, | |
801 | this code replaces existing property named "Flags" with one that | |
802 | will have different set of items: | |
803 | @code | |
804 | pg->ReplaceProperty("Flags", | |
805 | wxFlagsProperty("Flags", wxPG_LABEL, newItems)) | |
806 | @endcode | |
807 | For more info, see wxPropertyGrid::Insert. | |
808 | */ | |
809 | wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property ); | |
810 | ||
811 | /** @anchor propgridinterface_editablestate_flags | |
812 | ||
813 | Flags for wxPropertyGridInterface::SaveEditableState() and | |
814 | wxPropertyGridInterface::RestoreEditableState(). | |
815 | */ | |
816 | enum EditableStateFlags | |
817 | { | |
818 | /** Include selected property. */ | |
819 | SelectionState = 0x01, | |
820 | /** Include expanded/collapsed property information. */ | |
821 | ExpandedState = 0x02, | |
822 | /** Include scrolled position. */ | |
823 | ScrollPosState = 0x04, | |
824 | /** Include selected page information. | |
825 | Only applies to wxPropertyGridManager. */ | |
826 | PageState = 0x08, | |
827 | /** Include splitter position. Stored for each page. */ | |
828 | SplitterPosState = 0x10, | |
829 | /** Include description box size. | |
830 | Only applies to wxPropertyGridManager. */ | |
831 | DescBoxState = 0x20, | |
832 | ||
833 | /** | |
834 | Include all supported user editable state information. | |
835 | This is usually the default value. */ | |
836 | AllStates = SelectionState | | |
837 | ExpandedState | | |
838 | ScrollPosState | | |
839 | PageState | | |
840 | SplitterPosState | | |
841 | DescBoxState | |
842 | }; | |
843 | ||
844 | /** | |
845 | Restores user-editable state. | |
846 | ||
847 | See also wxPropertyGridInterface::SaveEditableState(). | |
848 | ||
849 | @param src | |
850 | String generated by SaveEditableState. | |
851 | ||
852 | @param restoreStates | |
853 | Which parts to restore from source string. See @ref | |
854 | propgridinterface_editablestate_flags "list of editable state | |
855 | flags". | |
856 | ||
857 | @return | |
858 | False if there was problem reading the string. | |
859 | ||
860 | @remarks | |
861 | If some parts of state (such as scrolled or splitter position) fail to | |
862 | restore correctly, please make sure that you call this function after | |
863 | wxPropertyGrid size has been set (this may sometimes be tricky when | |
864 | sizers are used). | |
865 | */ | |
866 | bool RestoreEditableState( const wxString& src, | |
867 | int restoreStates = AllStates ); | |
868 | ||
869 | /** | |
870 | Used to acquire user-editable state (selected property, expanded | |
871 | properties, scrolled position, splitter positions). | |
872 | ||
873 | @param includedStates | |
874 | Which parts of state to include. See @ref | |
875 | propgridinterface_editablestate_flags "list of editable state flags". | |
876 | */ | |
877 | wxString SaveEditableState( int includedStates = AllStates ) const; | |
878 | ||
879 | /** | |
880 | Lets user set the strings listed in the choice dropdown of a | |
881 | wxBoolProperty. Defaults are "True" and "False", so changing them to, | |
882 | say, "Yes" and "No" may be useful in some less technical applications. | |
883 | */ | |
884 | static void SetBoolChoices( const wxString& trueChoice, | |
885 | const wxString& falseChoice ); | |
886 | ||
887 | /** | |
888 | Set proportion of a auto-stretchable column. wxPG_SPLITTER_AUTO_CENTER | |
889 | window style needs to be used to indicate that columns are auto- | |
890 | resizable. | |
891 | ||
892 | @returns Returns @false on failure. | |
893 | ||
894 | @remarks You should call this for individual pages of | |
895 | wxPropertyGridManager (if used). | |
896 | ||
897 | @see GetColumnProportion() | |
898 | */ | |
899 | bool SetColumnProportion( unsigned int column, int proportion ); | |
900 | ||
901 | /** | |
902 | Returns auto-resize proportion of the given column. | |
903 | ||
904 | @see SetColumnProportion() | |
905 | */ | |
906 | int GetColumnProportion( unsigned int column ) const | |
907 | { | |
908 | return m_pState->DoGetColumnProportion(column); | |
909 | } | |
910 | ||
911 | /** Sets an attribute for this property. | |
912 | @param name | |
913 | Text identifier of attribute. See @ref propgrid_property_attributes. | |
914 | @param value | |
915 | Value of attribute. | |
916 | @param argFlags | |
917 | Optional. Use wxPG_RECURSE to set the attribute to child properties | |
918 | recursively. | |
919 | */ | |
920 | void SetPropertyAttribute( wxPGPropArg id, | |
921 | const wxString& attrName, | |
922 | wxVariant value, | |
923 | long argFlags = 0 ) | |
924 | { | |
925 | DoSetPropertyAttribute(id,attrName,value,argFlags); | |
926 | } | |
927 | ||
928 | /** Sets property attribute for all applicapple properties. | |
929 | Be sure to use this method only after all properties have been | |
930 | added to the grid. | |
931 | */ | |
932 | void SetPropertyAttributeAll( const wxString& attrName, wxVariant value ); | |
933 | ||
934 | /** | |
935 | Sets background colour of a property. | |
936 | ||
937 | @param id | |
938 | Property name or pointer. | |
939 | ||
940 | @param colour | |
941 | New background colour. | |
942 | ||
943 | @param flags | |
944 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
945 | Omit this flag to only set colour for the property in question | |
946 | and not any of its children. | |
947 | */ | |
948 | void SetPropertyBackgroundColour( wxPGPropArg id, | |
949 | const wxColour& colour, | |
950 | int flags = wxPG_RECURSE ); | |
951 | ||
952 | /** Resets text and background colours of given property. | |
953 | */ | |
954 | void SetPropertyColoursToDefault( wxPGPropArg id ); | |
955 | ||
956 | /** | |
957 | Sets text colour of a property. | |
958 | ||
959 | @param id | |
960 | Property name or pointer. | |
961 | ||
962 | @param colour | |
963 | New background colour. | |
964 | ||
965 | @param flags | |
966 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
967 | Omit this flag to only set colour for the property in question | |
968 | and not any of its children. | |
969 | */ | |
970 | void SetPropertyTextColour( wxPGPropArg id, | |
971 | const wxColour& col, | |
972 | int flags = wxPG_RECURSE ); | |
973 | ||
974 | /** | |
975 | Returns background colour of first cell of a property. | |
976 | */ | |
977 | wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const | |
978 | { | |
979 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour()) | |
980 | return p->GetCell(0).GetBgCol(); | |
981 | } | |
982 | ||
983 | /** | |
984 | Returns text colour of first cell of a property. | |
985 | */ | |
986 | wxColour GetPropertyTextColour( wxPGPropArg id ) const | |
987 | { | |
988 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour()) | |
989 | return p->GetCell(0).GetFgCol(); | |
990 | } | |
991 | ||
992 | /** Sets text, bitmap, and colours for given column's cell. | |
993 | ||
994 | @remarks | |
995 | - You can set label cell by setting column to 0. | |
996 | - You can use wxPG_LABEL as text to use default text for column. | |
997 | */ | |
998 | void SetPropertyCell( wxPGPropArg id, | |
999 | int column, | |
1000 | const wxString& text = wxEmptyString, | |
1001 | const wxBitmap& bitmap = wxNullBitmap, | |
1002 | const wxColour& fgCol = wxNullColour, | |
1003 | const wxColour& bgCol = wxNullColour ); | |
1004 | ||
1005 | /** Sets client data (void*) of a property. | |
1006 | @remarks | |
1007 | This untyped client data has to be deleted manually. | |
1008 | */ | |
1009 | void SetPropertyClientData( wxPGPropArg id, void* clientData ) | |
1010 | { | |
1011 | wxPG_PROP_ARG_CALL_PROLOG() | |
1012 | p->SetClientData(clientData); | |
1013 | } | |
1014 | ||
1015 | /** Sets editor for a property. | |
1016 | ||
1017 | @param editor | |
1018 | For builtin editors, use wxPGEditor_X, where X is builtin editor's | |
1019 | name (TextCtrl, Choice, etc. see wxPGEditor documentation for full | |
1020 | list). | |
1021 | ||
1022 | For custom editors, use pointer you received from | |
1023 | wxPropertyGrid::RegisterEditorClass(). | |
1024 | */ | |
1025 | void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor ) | |
1026 | { | |
1027 | wxPG_PROP_ARG_CALL_PROLOG() | |
1028 | wxCHECK_RET( editor, wxT("unknown/NULL editor") ); | |
1029 | p->SetEditor(editor); | |
1030 | RefreshProperty(p); | |
1031 | } | |
1032 | ||
1033 | /** Sets editor control of a property. As editor argument, use | |
1034 | editor name string, such as "TextCtrl" or "Choice". | |
1035 | */ | |
1036 | void SetPropertyEditor( wxPGPropArg id, const wxString& editorName ) | |
1037 | { | |
1038 | SetPropertyEditor(id,GetEditorByName(editorName)); | |
1039 | } | |
1040 | ||
1041 | /** Sets label of a property. | |
1042 | */ | |
1043 | void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel ); | |
1044 | ||
1045 | /** | |
1046 | Sets name of a property. | |
1047 | ||
1048 | @param id | |
1049 | Name or pointer of property which name to change. | |
1050 | ||
1051 | @param newName | |
1052 | New name for property. | |
1053 | */ | |
1054 | void SetPropertyName( wxPGPropArg id, const wxString& newName ) | |
1055 | { | |
1056 | wxPG_PROP_ARG_CALL_PROLOG() | |
1057 | m_pState->DoSetPropertyName( p, newName ); | |
1058 | } | |
1059 | ||
1060 | /** | |
1061 | Sets property (and, recursively, its children) to have read-only value. | |
1062 | In other words, user cannot change the value in the editor, but they | |
1063 | can still copy it. | |
1064 | @remarks | |
1065 | This is mainly for use with textctrl editor. Not all other editors fully | |
1066 | support it. | |
1067 | @param flags | |
1068 | By default changes are applied recursively. Set this paramter | |
1069 | wxPG_DONT_RECURSE to prevent this. | |
1070 | */ | |
1071 | void SetPropertyReadOnly( wxPGPropArg id, | |
1072 | bool set = true, | |
1073 | int flags = wxPG_RECURSE ) | |
1074 | { | |
1075 | wxPG_PROP_ARG_CALL_PROLOG() | |
1076 | if ( flags & wxPG_RECURSE ) | |
1077 | p->SetFlagRecursively(wxPG_PROP_READONLY, set); | |
1078 | else | |
1079 | p->ChangeFlag(wxPG_PROP_READONLY, set); | |
1080 | } | |
1081 | ||
1082 | /** Sets property's value to unspecified. | |
1083 | If it has children (it may be category), then the same thing is done to | |
1084 | them. | |
1085 | */ | |
1086 | void SetPropertyValueUnspecified( wxPGPropArg id ) | |
1087 | { | |
1088 | wxPG_PROP_ARG_CALL_PROLOG() | |
1089 | p->SetValueToUnspecified(); | |
1090 | } | |
1091 | ||
1092 | /** | |
1093 | Sets property values from a list of wxVariants. | |
1094 | */ | |
1095 | void SetPropertyValues( const wxVariantList& list, | |
1096 | wxPGPropArg defaultCategory = wxNullProperty ) | |
1097 | { | |
1098 | wxPGProperty *p; | |
1099 | if ( defaultCategory.HasName() ) p = defaultCategory.GetPtr(this); | |
1100 | else p = defaultCategory.GetPtr0(); | |
1101 | m_pState->DoSetPropertyValues(list, p); | |
1102 | } | |
1103 | ||
1104 | /** | |
1105 | Sets property values from a list of wxVariants. | |
1106 | */ | |
1107 | void SetPropertyValues( const wxVariant& list, | |
1108 | wxPGPropArg defaultCategory = wxNullProperty ) | |
1109 | { | |
1110 | SetPropertyValues(list.GetList(),defaultCategory); | |
1111 | } | |
1112 | ||
1113 | /** Associates the help string with property. | |
1114 | @remarks | |
1115 | By default, text is shown either in the manager's "description" | |
1116 | text box or in the status bar. If extra window style | |
1117 | wxPG_EX_HELP_AS_TOOLTIPS is used, then the text will appear as a | |
1118 | tooltip. | |
1119 | */ | |
1120 | void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString ) | |
1121 | { | |
1122 | wxPG_PROP_ARG_CALL_PROLOG() | |
1123 | p->SetHelpString(helpString); | |
1124 | } | |
1125 | ||
1126 | /** Set wxBitmap in front of the value. | |
1127 | @remarks | |
1128 | - Bitmap will be scaled to a size returned by | |
1129 | wxPropertyGrid::GetImageSize(); | |
1130 | */ | |
1131 | void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp ) | |
1132 | { | |
1133 | wxPG_PROP_ARG_CALL_PROLOG() | |
1134 | p->SetValueImage(bmp); | |
1135 | RefreshProperty(p); | |
1136 | } | |
1137 | ||
1138 | /** Sets max length of property's text. | |
1139 | */ | |
1140 | bool SetPropertyMaxLength( wxPGPropArg id, int maxLen ); | |
1141 | ||
1142 | #if wxUSE_VALIDATORS | |
1143 | /** Sets validator of a property. | |
1144 | */ | |
1145 | void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator ) | |
1146 | { | |
1147 | wxPG_PROP_ARG_CALL_PROLOG() | |
1148 | p->SetValidator(validator); | |
1149 | } | |
1150 | #endif | |
1151 | ||
1152 | /** Sets value (long integer) of a property. | |
1153 | */ | |
1154 | void SetPropertyValue( wxPGPropArg id, long value ) | |
1155 | { | |
1156 | wxVariant v(value); | |
1157 | SetPropVal( id, v ); | |
1158 | } | |
1159 | ||
1160 | /** Sets value (integer) of a property. | |
1161 | */ | |
1162 | void SetPropertyValue( wxPGPropArg id, int value ) | |
1163 | { | |
1164 | wxVariant v((long)value); | |
1165 | SetPropVal( id, v ); | |
1166 | } | |
1167 | /** Sets value (floating point) of a property. | |
1168 | */ | |
1169 | void SetPropertyValue( wxPGPropArg id, double value ) | |
1170 | { | |
1171 | wxVariant v(value); | |
1172 | SetPropVal( id, v ); | |
1173 | } | |
1174 | /** Sets value (bool) of a property. | |
1175 | */ | |
1176 | void SetPropertyValue( wxPGPropArg id, bool value ) | |
1177 | { | |
1178 | wxVariant v(value); | |
1179 | SetPropVal( id, v ); | |
1180 | } | |
1181 | void SetPropertyValue( wxPGPropArg id, const wchar_t* value ) | |
1182 | { | |
1183 | SetPropertyValueString( id, wxString(value) ); | |
1184 | } | |
1185 | void SetPropertyValue( wxPGPropArg id, const char* value ) | |
1186 | { | |
1187 | SetPropertyValueString( id, wxString(value) ); | |
1188 | } | |
1189 | void SetPropertyValue( wxPGPropArg id, const wxString& value ) | |
1190 | { | |
1191 | SetPropertyValueString( id, value ); | |
1192 | } | |
1193 | ||
1194 | /** Sets value (wxArrayString) of a property. | |
1195 | */ | |
1196 | void SetPropertyValue( wxPGPropArg id, const wxArrayString& value ) | |
1197 | { | |
1198 | wxVariant v(value); | |
1199 | SetPropVal( id, v ); | |
1200 | } | |
1201 | ||
1202 | #if wxUSE_DATETIME | |
1203 | void SetPropertyValue( wxPGPropArg id, const wxDateTime& value ) | |
1204 | { | |
1205 | wxVariant v(value); | |
1206 | SetPropVal( id, v ); | |
1207 | } | |
1208 | #endif | |
1209 | ||
1210 | /** Sets value (wxObject*) of a property. | |
1211 | */ | |
1212 | void SetPropertyValue( wxPGPropArg id, wxObject* value ) | |
1213 | { | |
1214 | wxVariant v(value); | |
1215 | SetPropVal( id, v ); | |
1216 | } | |
1217 | ||
1218 | void SetPropertyValue( wxPGPropArg id, wxObject& value ) | |
1219 | { | |
1220 | wxVariant v(&value); | |
1221 | SetPropVal( id, v ); | |
1222 | } | |
1223 | ||
1224 | #ifdef wxLongLong_t | |
1225 | /** Sets value (wxLongLong&) of a property. | |
1226 | */ | |
1227 | void SetPropertyValue( wxPGPropArg id, wxLongLong_t value ) | |
1228 | { | |
1229 | wxVariant v = WXVARIANT(wxLongLong(value)); | |
1230 | SetPropVal( id, v ); | |
1231 | } | |
1232 | /** Sets value (wxULongLong&) of a property. | |
1233 | */ | |
1234 | void SetPropertyValue( wxPGPropArg id, wxULongLong_t value ) | |
1235 | { | |
1236 | wxVariant v = WXVARIANT(wxULongLong(value)); | |
1237 | SetPropVal( id, v ); | |
1238 | } | |
1239 | #endif | |
1240 | ||
1241 | /** Sets value (wxArrayInt&) of a property. | |
1242 | */ | |
1243 | void SetPropertyValue( wxPGPropArg id, const wxArrayInt& value ) | |
1244 | { | |
1245 | wxVariant v = WXVARIANT(value); | |
1246 | SetPropVal( id, v ); | |
1247 | } | |
1248 | ||
1249 | /** Sets value (wxString) of a property. | |
1250 | ||
1251 | @remarks | |
1252 | This method uses wxPGProperty::SetValueFromString, which all properties | |
1253 | should implement. This means that there should not be a type error, | |
1254 | and instead the string is converted to property's actual value type. | |
1255 | */ | |
1256 | void SetPropertyValueString( wxPGPropArg id, const wxString& value ); | |
1257 | ||
1258 | /** Sets value (wxVariant&) of a property. | |
1259 | ||
1260 | @remarks | |
1261 | Use wxPropertyGrid::ChangePropertyValue() instead if you need to run | |
1262 | through validation process and send property change event. | |
1263 | */ | |
1264 | void SetPropertyValue( wxPGPropArg id, wxVariant value ) | |
1265 | { | |
1266 | SetPropVal( id, value ); | |
1267 | } | |
1268 | ||
1269 | /** Sets value (wxVariant&) of a property. Same as SetPropertyValue, but | |
1270 | accepts reference. */ | |
1271 | void SetPropVal( wxPGPropArg id, wxVariant& value ); | |
1272 | ||
1273 | /** Adjusts how wxPropertyGrid behaves when invalid value is entered | |
1274 | in a property. | |
1275 | @param vfbFlags | |
1276 | See @link vfbflags list of valid flags values@endlink | |
1277 | */ | |
1278 | void SetValidationFailureBehavior( int vfbFlags ); | |
1279 | ||
1280 | /** | |
1281 | Sorts all properties recursively. | |
1282 | ||
1283 | @param flags | |
1284 | This can contain any of the following options: | |
1285 | wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their | |
1286 | immediate children. Sorting done by wxPG_AUTO_SORT option | |
1287 | uses this. | |
1288 | ||
1289 | @see SortChildren, wxPropertyGrid::SetSortFunction | |
1290 | */ | |
1291 | void Sort( int flags = 0 ); | |
1292 | ||
1293 | /** | |
1294 | Sorts children of a property. | |
1295 | ||
1296 | @param id | |
1297 | Name or pointer to a property. | |
1298 | ||
1299 | @param flags | |
1300 | This can contain any of the following options: | |
1301 | wxPG_RECURSE: Sorts recursively. | |
1302 | ||
1303 | @see Sort, wxPropertyGrid::SetSortFunction | |
1304 | */ | |
1305 | void SortChildren( wxPGPropArg id, int flags = 0 ) | |
1306 | { | |
1307 | wxPG_PROP_ARG_CALL_PROLOG() | |
1308 | m_pState->DoSortChildren(p, flags); | |
1309 | } | |
1310 | ||
1311 | // GetPropertyByName With nice assertion error message. | |
1312 | wxPGProperty* GetPropertyByNameA( const wxString& name ) const; | |
1313 | ||
1314 | static wxPGEditor* GetEditorByName( const wxString& editorName ); | |
1315 | ||
1316 | // NOTE: This function reselects the property and may cause | |
1317 | // excess flicker, so to just call Refresh() on a rect | |
1318 | // of single property, call DrawItem() instead. | |
1319 | virtual void RefreshProperty( wxPGProperty* p ) = 0; | |
1320 | ||
1321 | protected: | |
1322 | ||
1323 | bool DoClearSelection( bool validation = false, | |
1324 | int selFlags = 0 ); | |
1325 | ||
1326 | /** | |
1327 | In derived class, implement to set editable state component with | |
1328 | given name to given value. | |
1329 | */ | |
1330 | virtual bool SetEditableStateItem( const wxString& name, wxVariant value ) | |
1331 | { | |
1332 | wxUnusedVar(name); | |
1333 | wxUnusedVar(value); | |
1334 | return false; | |
1335 | } | |
1336 | ||
1337 | /** | |
1338 | In derived class, implement to return editable state component with | |
1339 | given name. | |
1340 | */ | |
1341 | virtual wxVariant GetEditableStateItem( const wxString& name ) const | |
1342 | { | |
1343 | wxUnusedVar(name); | |
1344 | return wxNullVariant; | |
1345 | } | |
1346 | ||
1347 | // Returns page state data for given (sub) page (-1 means current page). | |
1348 | virtual wxPropertyGridPageState* GetPageState( int pageIndex ) const | |
1349 | { | |
1350 | if ( pageIndex <= 0 ) | |
1351 | return m_pState; | |
1352 | return NULL; | |
1353 | } | |
1354 | ||
1355 | virtual bool DoSelectPage( int WXUNUSED(index) ) { return true; } | |
1356 | ||
1357 | // Default call's m_pState's BaseGetPropertyByName | |
1358 | virtual wxPGProperty* DoGetPropertyByName( const wxString& name ) const; | |
1359 | ||
1360 | // Deriving classes must set this (it must be only or current page). | |
1361 | wxPropertyGridPageState* m_pState; | |
1362 | ||
1363 | // Intermediate version needed due to wxVariant copying inefficiency | |
1364 | void DoSetPropertyAttribute( wxPGPropArg id, | |
1365 | const wxString& name, | |
1366 | wxVariant& value, long argFlags ); | |
1367 | ||
1368 | // Empty string object to return from member functions returning const | |
1369 | // wxString&. | |
1370 | wxString m_emptyString; | |
1371 | ||
1372 | private: | |
1373 | // Cannot be GetGrid() due to ambiguity issues. | |
1374 | wxPropertyGrid* GetPropertyGrid() | |
1375 | { | |
1376 | if ( !m_pState ) | |
1377 | return NULL; | |
1378 | return m_pState->GetGrid(); | |
1379 | } | |
1380 | ||
1381 | // Cannot be GetGrid() due to ambiguity issues. | |
1382 | const wxPropertyGrid* GetPropertyGrid() const | |
1383 | { | |
1384 | if ( !m_pState ) | |
1385 | return NULL; | |
1386 | ||
1387 | return m_pState->GetGrid(); | |
1388 | } | |
1389 | ||
1390 | friend class wxPropertyGrid; | |
1391 | friend class wxPropertyGridManager; | |
1392 | }; | |
1393 | ||
1394 | #endif // wxUSE_PROPGRID | |
1395 | ||
1396 | #endif // __WX_PROPGRID_PROPGRIDIFACE_H__ |