]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/propgrid/property.h | |
3 | // Purpose: wxPGProperty and related support classes | |
4 | // Author: Jaakko Salli | |
5 | // Modified by: | |
6 | // Created: 2008-08-23 | |
ea5af9c5 | 7 | // RCS-ID: $Id$ |
1c4293cb VZ |
8 | // Copyright: (c) Jaakko Salli |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PROPGRID_PROPERTY_H_ | |
13 | #define _WX_PROPGRID_PROPERTY_H_ | |
14 | ||
f4bc1aa2 JS |
15 | #if wxUSE_PROPGRID |
16 | ||
1c4293cb VZ |
17 | #include "wx/propgrid/propgriddefs.h" |
18 | ||
19 | // ----------------------------------------------------------------------- | |
20 | ||
21 | #define wxNullProperty ((wxPGProperty*)NULL) | |
22 | ||
23 | ||
24 | /** @class wxPGPaintData | |
25 | ||
26 | Contains information relayed to property's OnCustomPaint. | |
27 | */ | |
28 | struct wxPGPaintData | |
29 | { | |
30 | /** wxPropertyGrid. */ | |
31 | const wxPropertyGrid* m_parent; | |
32 | ||
33 | /** | |
34 | Normally -1, otherwise index to drop-down list item that has to be | |
35 | drawn. | |
36 | */ | |
37 | int m_choiceItem; | |
38 | ||
39 | /** Set to drawn width in OnCustomPaint (optional). */ | |
40 | int m_drawnWidth; | |
41 | ||
42 | /** | |
43 | In a measure item call, set this to the height of item at m_choiceItem | |
44 | index. | |
45 | */ | |
46 | int m_drawnHeight; | |
47 | }; | |
48 | ||
49 | ||
1c4293cb VZ |
50 | #ifndef SWIG |
51 | ||
52 | ||
53 | // space between vertical sides of a custom image | |
54 | #define wxPG_CUSTOM_IMAGE_SPACINGY 1 | |
55 | ||
56 | // space between caption and selection rectangle, | |
57 | #define wxPG_CAPRECTXMARGIN 2 | |
58 | ||
59 | // horizontally and vertically | |
60 | #define wxPG_CAPRECTYMARGIN 1 | |
61 | ||
62 | ||
63 | /** @class wxPGCellRenderer | |
64 | ||
65 | Base class for wxPropertyGrid cell renderers. | |
66 | */ | |
92ffc98a | 67 | class WXDLLIMPEXP_PROPGRID wxPGCellRenderer : public wxObjectRefData |
1c4293cb VZ |
68 | { |
69 | public: | |
70 | ||
bd035313 JS |
71 | wxPGCellRenderer() |
72 | : wxObjectRefData() { } | |
1c4293cb VZ |
73 | virtual ~wxPGCellRenderer() { } |
74 | ||
75 | // Render flags | |
76 | enum | |
77 | { | |
d7e2b522 | 78 | // We are painting selected item |
1c4293cb | 79 | Selected = 0x00010000, |
d7e2b522 JS |
80 | |
81 | // We are painting item in choice popup | |
82 | ChoicePopup = 0x00020000, | |
83 | ||
84 | // We are rendering wxOwnerDrawnComboBox control | |
85 | // (or other owner drawn control, but that is only | |
86 | // officially supported one ATM). | |
87 | Control = 0x00040000, | |
88 | ||
89 | // We are painting a disable property | |
90 | Disabled = 0x00080000, | |
91 | ||
92 | // We are painting selected, disabled, or similar | |
93 | // item that dictates fore- and background colours, | |
94 | // overriding any cell values. | |
95 | DontUseCellFgCol = 0x00100000, | |
96 | DontUseCellBgCol = 0x00200000, | |
97 | DontUseCellColours = DontUseCellFgCol | | |
98 | DontUseCellBgCol | |
1c4293cb VZ |
99 | }; |
100 | ||
e16bff8e JS |
101 | /** |
102 | Returns @true if rendered something in the foreground (text or | |
103 | bitmap. | |
104 | */ | |
105 | virtual bool Render( wxDC& dc, | |
1c4293cb VZ |
106 | const wxRect& rect, |
107 | const wxPropertyGrid* propertyGrid, | |
108 | wxPGProperty* property, | |
109 | int column, | |
110 | int item, | |
111 | int flags ) const = 0; | |
112 | ||
113 | /** Returns size of the image in front of the editable area. | |
114 | @remarks | |
115 | If property is NULL, then this call is for a custom value. In that case | |
116 | the item is index to wxPropertyGrid's custom values. | |
117 | */ | |
118 | virtual wxSize GetImageSize( const wxPGProperty* property, | |
119 | int column, | |
120 | int item ) const; | |
121 | ||
122 | /** Paints property category selection rectangle. | |
123 | */ | |
124 | virtual void DrawCaptionSelectionRect( wxDC& dc, | |
125 | int x, int y, | |
126 | int w, int h ) const; | |
127 | ||
128 | /** Utility to draw vertically centered text. | |
129 | */ | |
130 | void DrawText( wxDC& dc, | |
131 | const wxRect& rect, | |
132 | int imageWidth, | |
133 | const wxString& text ) const; | |
134 | ||
135 | /** | |
136 | Utility to draw editor's value, or vertically aligned text if editor is | |
137 | NULL. | |
138 | */ | |
139 | void DrawEditorValue( wxDC& dc, const wxRect& rect, | |
140 | int xOffset, const wxString& text, | |
141 | wxPGProperty* property, | |
142 | const wxPGEditor* editor ) const; | |
143 | ||
aaf5f986 JS |
144 | /** Utility to render cell bitmap and set text colour plus bg brush |
145 | colour. | |
1c4293cb | 146 | |
aaf5f986 JS |
147 | @return Returns image width, which, for instance, can be passed to |
148 | DrawText. | |
1c4293cb VZ |
149 | */ |
150 | int PreDrawCell( wxDC& dc, | |
151 | const wxRect& rect, | |
152 | const wxPGCell& cell, | |
153 | int flags ) const; | |
aaf5f986 JS |
154 | |
155 | /** | |
156 | Utility to be called after drawing is done, to revert whatever | |
157 | changes PreDrawCell() did. | |
158 | ||
159 | @param flags | |
160 | Same as those passed to PreDrawCell(). | |
161 | */ | |
162 | void PostDrawCell( wxDC& dc, | |
163 | const wxPropertyGrid* propGrid, | |
164 | const wxPGCell& cell, | |
165 | int flags ) const; | |
1c4293cb VZ |
166 | }; |
167 | ||
168 | ||
b4a72504 JS |
169 | /** |
170 | @class wxPGDefaultRenderer | |
171 | ||
172 | Default cell renderer, that can handles the common | |
173 | scenarios. | |
174 | */ | |
175 | class WXDLLIMPEXP_PROPGRID wxPGDefaultRenderer : public wxPGCellRenderer | |
176 | { | |
177 | public: | |
e16bff8e | 178 | virtual bool Render( wxDC& dc, |
b4a72504 JS |
179 | const wxRect& rect, |
180 | const wxPropertyGrid* propertyGrid, | |
181 | wxPGProperty* property, | |
182 | int column, | |
183 | int item, | |
184 | int flags ) const; | |
185 | ||
186 | virtual wxSize GetImageSize( const wxPGProperty* property, | |
187 | int column, | |
188 | int item ) const; | |
189 | ||
190 | protected: | |
191 | }; | |
192 | ||
193 | ||
d7e2b522 JS |
194 | class WXDLLIMPEXP_PROPGRID wxPGCellData : public wxObjectRefData |
195 | { | |
196 | friend class wxPGCell; | |
197 | public: | |
198 | wxPGCellData(); | |
199 | ||
200 | void SetText( const wxString& text ) | |
201 | { | |
202 | m_text = text; | |
203 | m_hasValidText = true; | |
204 | } | |
205 | void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; } | |
206 | void SetFgCol( const wxColour& col ) { m_fgCol = col; } | |
207 | void SetBgCol( const wxColour& col ) { m_bgCol = col; } | |
aaf5f986 | 208 | void SetFont( const wxFont& font ) { m_font = font; } |
d7e2b522 JS |
209 | |
210 | protected: | |
211 | virtual ~wxPGCellData() { } | |
212 | ||
213 | wxString m_text; | |
214 | wxBitmap m_bitmap; | |
215 | wxColour m_fgCol; | |
216 | wxColour m_bgCol; | |
aaf5f986 | 217 | wxFont m_font; |
d7e2b522 JS |
218 | |
219 | // True if m_text is valid and specified | |
220 | bool m_hasValidText; | |
221 | }; | |
222 | ||
b4a72504 JS |
223 | #endif // !SWIG |
224 | ||
aaf5f986 JS |
225 | /** |
226 | @class wxPGCell | |
1c4293cb | 227 | |
aaf5f986 | 228 | Base class for wxPropertyGrid cell information. |
1c4293cb | 229 | */ |
d7e2b522 | 230 | class WXDLLIMPEXP_PROPGRID wxPGCell : public wxObject |
1c4293cb VZ |
231 | { |
232 | public: | |
233 | wxPGCell(); | |
18415eb5 VZ |
234 | wxPGCell(const wxPGCell& other) |
235 | : wxObject(other) | |
d7e2b522 | 236 | { |
d7e2b522 JS |
237 | } |
238 | ||
1c4293cb VZ |
239 | wxPGCell( const wxString& text, |
240 | const wxBitmap& bitmap = wxNullBitmap, | |
241 | const wxColour& fgCol = wxNullColour, | |
242 | const wxColour& bgCol = wxNullColour ); | |
243 | ||
244 | virtual ~wxPGCell() { } | |
245 | ||
d7e2b522 JS |
246 | wxPGCellData* GetData() |
247 | { | |
248 | return (wxPGCellData*) m_refData; | |
249 | } | |
250 | ||
251 | const wxPGCellData* GetData() const | |
252 | { | |
253 | return (const wxPGCellData*) m_refData; | |
254 | } | |
255 | ||
256 | bool HasText() const | |
257 | { | |
258 | return (m_refData && GetData()->m_hasValidText); | |
259 | } | |
1c4293cb | 260 | |
3e6d8c31 JS |
261 | /** |
262 | Sets empty but valid data to this cell object. | |
263 | */ | |
264 | void SetEmptyData(); | |
265 | ||
d7e2b522 JS |
266 | /** |
267 | Merges valid data from srcCell into this. | |
268 | */ | |
269 | void MergeFrom( const wxPGCell& srcCell ); | |
270 | ||
271 | void SetText( const wxString& text ); | |
272 | void SetBitmap( const wxBitmap& bitmap ); | |
273 | void SetFgCol( const wxColour& col ); | |
aaf5f986 JS |
274 | |
275 | /** | |
276 | Sets font of the cell. | |
277 | ||
278 | @remarks Because wxPropertyGrid does not support rows of | |
279 | different height, it makes little sense to change | |
280 | size of the font. Therefore it is recommended | |
281 | to use return value of wxPropertyGrid::GetFont() | |
282 | or wxPropertyGrid::GetCaptionFont() as a basis | |
283 | for the font that, after modifications, is passed | |
284 | to this member function. | |
285 | */ | |
286 | void SetFont( const wxFont& font ); | |
287 | ||
d7e2b522 JS |
288 | void SetBgCol( const wxColour& col ); |
289 | ||
290 | const wxString& GetText() const { return GetData()->m_text; } | |
291 | const wxBitmap& GetBitmap() const { return GetData()->m_bitmap; } | |
292 | const wxColour& GetFgCol() const { return GetData()->m_fgCol; } | |
aaf5f986 JS |
293 | |
294 | /** | |
295 | Returns font of the cell. If no specific font is set for this | |
296 | cell, then the font will be invalid. | |
297 | */ | |
298 | const wxFont& GetFont() const { return GetData()->m_font; } | |
299 | ||
d7e2b522 JS |
300 | const wxColour& GetBgCol() const { return GetData()->m_bgCol; } |
301 | ||
302 | wxPGCell& operator=( const wxPGCell& other ) | |
303 | { | |
304 | if ( this != &other ) | |
305 | { | |
306 | Ref(other); | |
307 | } | |
308 | return *this; | |
309 | } | |
1c4293cb | 310 | |
b4a72504 | 311 | private: |
d7e2b522 JS |
312 | virtual wxObjectRefData *CreateRefData() const |
313 | { return new wxPGCellData(); } | |
314 | ||
315 | virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; | |
1c4293cb VZ |
316 | }; |
317 | ||
1c4293cb VZ |
318 | // ----------------------------------------------------------------------- |
319 | ||
b4a72504 JS |
320 | #ifndef SWIG |
321 | ||
1c4293cb VZ |
322 | /** @class wxPGAttributeStorage |
323 | ||
324 | wxPGAttributeStorage is somewhat optimized storage for | |
325 | key=variant pairs (ie. a map). | |
326 | */ | |
327 | class WXDLLIMPEXP_PROPGRID wxPGAttributeStorage | |
328 | { | |
329 | public: | |
330 | wxPGAttributeStorage(); | |
331 | ~wxPGAttributeStorage(); | |
332 | ||
333 | void Set( const wxString& name, const wxVariant& value ); | |
68bcfd2c | 334 | unsigned int GetCount() const { return (unsigned int) m_map.size(); } |
1c4293cb VZ |
335 | wxVariant FindValue( const wxString& name ) const |
336 | { | |
337 | wxPGHashMapS2P::const_iterator it = m_map.find(name); | |
338 | if ( it != m_map.end() ) | |
339 | { | |
340 | wxVariantData* data = (wxVariantData*) it->second; | |
341 | data->IncRef(); | |
342 | return wxVariant(data, it->first); | |
343 | } | |
344 | return wxVariant(); | |
345 | } | |
346 | ||
347 | typedef wxPGHashMapS2P::const_iterator const_iterator; | |
348 | const_iterator StartIteration() const | |
349 | { | |
350 | return m_map.begin(); | |
351 | } | |
352 | bool GetNext( const_iterator& it, wxVariant& variant ) const | |
353 | { | |
354 | if ( it == m_map.end() ) | |
355 | return false; | |
356 | ||
357 | wxVariantData* data = (wxVariantData*) it->second; | |
358 | data->IncRef(); | |
359 | variant.SetData(data); | |
360 | variant.SetName(it->first); | |
a09307ab | 361 | ++it; |
1c4293cb VZ |
362 | return true; |
363 | } | |
364 | ||
365 | protected: | |
366 | wxPGHashMapS2P m_map; | |
367 | }; | |
368 | ||
369 | #endif // !SWIG | |
370 | ||
371 | // ----------------------------------------------------------------------- | |
372 | ||
373 | /** @section propgrid_propflags wxPGProperty Flags | |
374 | @{ | |
375 | */ | |
376 | ||
377 | enum wxPG_PROPERTY_FLAGS | |
378 | { | |
379 | ||
380 | /** Indicates bold font. | |
381 | */ | |
382 | wxPG_PROP_MODIFIED = 0x0001, | |
383 | ||
384 | /** Disables ('greyed' text and editor does not activate) property. | |
385 | */ | |
386 | wxPG_PROP_DISABLED = 0x0002, | |
387 | ||
388 | /** Hider button will hide this property. | |
389 | */ | |
390 | wxPG_PROP_HIDDEN = 0x0004, | |
391 | ||
392 | /** This property has custom paint image just in front of its value. | |
393 | If property only draws custom images into a popup list, then this | |
394 | flag should not be set. | |
395 | */ | |
396 | wxPG_PROP_CUSTOMIMAGE = 0x0008, | |
397 | ||
398 | /** Do not create text based editor for this property (but button-triggered | |
399 | dialog and choice are ok). | |
400 | */ | |
401 | wxPG_PROP_NOEDITOR = 0x0010, | |
402 | ||
403 | /** Property is collapsed, ie. it's children are hidden. | |
404 | */ | |
405 | wxPG_PROP_COLLAPSED = 0x0020, | |
406 | ||
407 | /** | |
408 | If property is selected, then indicates that validation failed for pending | |
409 | value. | |
410 | ||
411 | If property is not selected, then indicates that the the actual property | |
412 | value has failed validation (NB: this behavior is not currently supported, | |
413 | but may be used in future). | |
414 | */ | |
415 | wxPG_PROP_INVALID_VALUE = 0x0040, | |
416 | ||
417 | // 0x0080, | |
418 | ||
419 | /** Switched via SetWasModified(). Temporary flag - only used when | |
420 | setting/changing property value. | |
421 | */ | |
422 | wxPG_PROP_WAS_MODIFIED = 0x0200, | |
423 | ||
424 | /** | |
425 | If set, then child properties (if any) are private, and should be | |
426 | "invisible" to the application. | |
427 | */ | |
428 | wxPG_PROP_AGGREGATE = 0x0400, | |
429 | ||
430 | /** If set, then child properties (if any) are copies and should not | |
431 | be deleted in dtor. | |
432 | */ | |
433 | wxPG_PROP_CHILDREN_ARE_COPIES = 0x0800, | |
434 | ||
435 | /** | |
436 | Classifies this item as a non-category. | |
437 | ||
438 | Used for faster item type identification. | |
439 | */ | |
440 | wxPG_PROP_PROPERTY = 0x1000, | |
441 | ||
442 | /** | |
443 | Classifies this item as a category. | |
444 | ||
445 | Used for faster item type identification. | |
446 | */ | |
447 | wxPG_PROP_CATEGORY = 0x2000, | |
448 | ||
449 | /** Classifies this item as a property that has children, but is not aggregate | |
450 | (ie children are not private). | |
451 | */ | |
452 | wxPG_PROP_MISC_PARENT = 0x4000, | |
453 | ||
c05fe841 JS |
454 | /** Property is read-only. Editor is still created for wxTextCtrl-based |
455 | property editors. For others, editor is not usually created because | |
456 | they do implement wxTE_READONLY style or equivalent. | |
1c4293cb VZ |
457 | */ |
458 | wxPG_PROP_READONLY = 0x8000, | |
459 | ||
460 | // | |
461 | // NB: FLAGS ABOVE 0x8000 CANNOT BE USED WITH PROPERTY ITERATORS | |
462 | // | |
463 | ||
464 | /** Property's value is composed from values of child properties. | |
465 | @remarks | |
466 | This flag cannot be used with property iterators. | |
467 | */ | |
468 | wxPG_PROP_COMPOSED_VALUE = 0x00010000, | |
469 | ||
470 | /** Common value of property is selectable in editor. | |
471 | @remarks | |
472 | This flag cannot be used with property iterators. | |
473 | */ | |
474 | wxPG_PROP_USES_COMMON_VALUE = 0x00020000, | |
475 | ||
476 | /** Property can be set to unspecified value via editor. | |
477 | Currently, this applies to following properties: | |
478 | - wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty: | |
479 | Clear the text field | |
480 | ||
481 | @remarks | |
482 | This flag cannot be used with property iterators. | |
483 | */ | |
484 | wxPG_PROP_AUTO_UNSPECIFIED = 0x00040000, | |
485 | ||
486 | /** Indicates the bit useable by derived properties. | |
487 | */ | |
488 | wxPG_PROP_CLASS_SPECIFIC_1 = 0x00080000, | |
489 | ||
490 | /** Indicates the bit useable by derived properties. | |
491 | */ | |
fc72fab6 JS |
492 | wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000, |
493 | ||
494 | /** Indicates that the property is being deleted and should be ignored. | |
495 | */ | |
496 | wxPG_PROP_BEING_DELETED = 0x00200000 | |
1c4293cb VZ |
497 | |
498 | }; | |
499 | ||
500 | /** Topmost flag. | |
501 | */ | |
502 | #define wxPG_PROP_MAX wxPG_PROP_AUTO_UNSPECIFIED | |
503 | ||
504 | /** Property with children must have one of these set, otherwise iterators | |
505 | will not work correctly. | |
506 | Code should automatically take care of this, however. | |
507 | */ | |
508 | #define wxPG_PROP_PARENTAL_FLAGS \ | |
509 | (wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY|wxPG_PROP_MISC_PARENT) | |
510 | ||
511 | /** @} | |
512 | */ | |
513 | ||
1c4293cb VZ |
514 | // Combination of flags that can be stored by GetFlagsAsString |
515 | #define wxPG_STRING_STORED_FLAGS \ | |
516 | (wxPG_PROP_DISABLED|wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR|wxPG_PROP_COLLAPSED) | |
517 | ||
518 | // ----------------------------------------------------------------------- | |
519 | ||
520 | #ifndef SWIG | |
521 | ||
522 | /** | |
523 | @section propgrid_property_attributes wxPropertyGrid Property Attribute | |
524 | Identifiers. | |
525 | ||
526 | wxPGProperty::SetAttribute() and | |
15cbcd00 | 527 | wxPropertyGridInterface::SetPropertyAttribute() accept one of these as |
1c4293cb VZ |
528 | attribute name argument. |
529 | ||
530 | You can use strings instead of constants. However, some of these | |
531 | constants are redefined to use cached strings which may reduce | |
532 | your binary size by some amount. | |
533 | ||
534 | @{ | |
535 | */ | |
536 | ||
537 | /** Set default value for property. | |
538 | */ | |
539 | #define wxPG_ATTR_DEFAULT_VALUE wxS("DefaultValue") | |
540 | ||
541 | /** Universal, int or double. Minimum value for numeric properties. | |
542 | */ | |
543 | #define wxPG_ATTR_MIN wxS("Min") | |
544 | ||
545 | /** Universal, int or double. Maximum value for numeric properties. | |
546 | */ | |
547 | #define wxPG_ATTR_MAX wxS("Max") | |
548 | ||
549 | /** Universal, string. When set, will be shown as text after the displayed | |
550 | text value. Alternatively, if third column is enabled, text will be shown | |
551 | there (for any type of property). | |
552 | */ | |
553 | #define wxPG_ATTR_UNITS wxS("Units") | |
554 | ||
534090e3 JS |
555 | /** When set, will be shown as 'greyed' text in property's value cell when |
556 | the actual displayed value is blank. | |
557 | */ | |
558 | #define wxPG_ATTR_HINT wxS("Hint") | |
559 | ||
560 | #if wxPG_COMPATIBILITY_1_4 | |
561 | /** | |
4fe6eca4 | 562 | @deprecated Use "Hint" (wxPG_ATTR_HINT) instead. |
1c4293cb VZ |
563 | */ |
564 | #define wxPG_ATTR_INLINE_HELP wxS("InlineHelp") | |
534090e3 | 565 | #endif |
1c4293cb | 566 | |
66fb9e12 JS |
567 | /** Universal, wxArrayString. Set to enable auto-completion in any |
568 | wxTextCtrl-based property editor. | |
569 | */ | |
570 | #define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete") | |
571 | ||
16372f0d JS |
572 | /** wxBoolProperty and wxFlagsProperty specific. Value type is bool. |
573 | Default value is False. | |
574 | ||
575 | When set to True, bool property will use check box instead of a | |
576 | combo box as its editor control. If you set this attribute | |
577 | for a wxFlagsProperty, it is automatically applied to child | |
578 | bool properties. | |
1c4293cb VZ |
579 | */ |
580 | #define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox") | |
581 | ||
16372f0d JS |
582 | /** wxBoolProperty and wxFlagsProperty specific. Value type is bool. |
583 | Default value is False. | |
584 | ||
585 | Set to True for the bool property to cycle value on double click | |
586 | (instead of showing the popup listbox). If you set this attribute | |
587 | for a wxFlagsProperty, it is automatically applied to child | |
588 | bool properties. | |
1c4293cb VZ |
589 | */ |
590 | #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling") | |
591 | ||
592 | /** | |
593 | wxFloatProperty (and similar) specific, int, default -1. | |
594 | ||
595 | Sets the (max) precision used when floating point value is rendered as | |
596 | text. The default -1 means infinite precision. | |
597 | */ | |
598 | #define wxPG_FLOAT_PRECISION wxS("Precision") | |
599 | ||
600 | /** | |
601 | The text will be echoed as asterisks (wxTE_PASSWORD will be passed to | |
602 | textctrl etc). | |
603 | */ | |
604 | #define wxPG_STRING_PASSWORD wxS("Password") | |
605 | ||
606 | /** Define base used by a wxUIntProperty. Valid constants are | |
607 | wxPG_BASE_OCT, wxPG_BASE_DEC, wxPG_BASE_HEX and wxPG_BASE_HEXL | |
608 | (lowercase characters). | |
609 | */ | |
610 | #define wxPG_UINT_BASE wxS("Base") | |
611 | ||
612 | /** Define prefix rendered to wxUIntProperty. Accepted constants | |
613 | wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and wxPG_PREFIX_DOLLAR_SIGN. | |
614 | <b>Note:</b> Only wxPG_PREFIX_NONE works with Decimal and Octal | |
615 | numbers. | |
616 | */ | |
617 | #define wxPG_UINT_PREFIX wxS("Prefix") | |
618 | ||
619 | /** | |
620 | wxFileProperty/wxImageFileProperty specific, wxChar*, default is | |
621 | detected/varies. | |
622 | Sets the wildcard used in the triggered wxFileDialog. Format is the same. | |
623 | */ | |
624 | #define wxPG_FILE_WILDCARD wxS("Wildcard") | |
625 | ||
626 | /** wxFileProperty/wxImageFileProperty specific, int, default 1. | |
627 | When 0, only the file name is shown (i.e. drive and directory are hidden). | |
628 | */ | |
629 | #define wxPG_FILE_SHOW_FULL_PATH wxS("ShowFullPath") | |
630 | ||
631 | /** Specific to wxFileProperty and derived properties, wxString, default empty. | |
632 | If set, then the filename is shown relative to the given path string. | |
633 | */ | |
634 | #define wxPG_FILE_SHOW_RELATIVE_PATH wxS("ShowRelativePath") | |
635 | ||
636 | /** | |
637 | Specific to wxFileProperty and derived properties, wxString, default is | |
638 | empty. | |
639 | ||
640 | Sets the initial path of where to look for files. | |
641 | */ | |
642 | #define wxPG_FILE_INITIAL_PATH wxS("InitialPath") | |
643 | ||
644 | /** Specific to wxFileProperty and derivatives, wxString, default is empty. | |
645 | Sets a specific title for the dir dialog. | |
646 | */ | |
647 | #define wxPG_FILE_DIALOG_TITLE wxS("DialogTitle") | |
648 | ||
649 | /** Specific to wxDirProperty, wxString, default is empty. | |
650 | Sets a specific message for the dir dialog. | |
651 | */ | |
652 | #define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage") | |
653 | ||
654 | /** Sets displayed date format for wxDateProperty. | |
655 | */ | |
656 | #define wxPG_DATE_FORMAT wxS("DateFormat") | |
657 | ||
658 | /** Sets wxDatePickerCtrl window style used with wxDateProperty. Default | |
659 | is wxDP_DEFAULT | wxDP_SHOWCENTURY. | |
660 | */ | |
661 | #define wxPG_DATE_PICKER_STYLE wxS("PickerStyle") | |
662 | ||
663 | /** SpinCtrl editor, int or double. How much number changes when button is | |
664 | pressed (or up/down on keybard). | |
665 | */ | |
666 | #define wxPG_ATTR_SPINCTRL_STEP wxS("Step") | |
667 | ||
668 | /** SpinCtrl editor, bool. If true, value wraps at Min/Max. | |
669 | */ | |
670 | #define wxPG_ATTR_SPINCTRL_WRAP wxS("Wrap") | |
671 | ||
672 | /** | |
673 | wxMultiChoiceProperty, int. | |
674 | If 0, no user strings allowed. If 1, user strings appear before list | |
675 | strings. If 2, user strings appear after list string. | |
676 | */ | |
677 | #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode") | |
678 | ||
679 | /** | |
680 | wxColourProperty and its kind, int, default 1. | |
681 | ||
682 | Setting this attribute to 0 hides custom colour from property's list of | |
683 | choices. | |
684 | */ | |
685 | #define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom") | |
686 | ||
1c4293cb VZ |
687 | /** @} |
688 | */ | |
689 | ||
1c4293cb | 690 | // Redefine attribute macros to use cached strings |
0ce8e27f JS |
691 | #undef wxPG_ATTR_DEFAULT_VALUE |
692 | #define wxPG_ATTR_DEFAULT_VALUE wxPGGlobalVars->m_strDefaultValue | |
1c4293cb VZ |
693 | #undef wxPG_ATTR_MIN |
694 | #define wxPG_ATTR_MIN wxPGGlobalVars->m_strMin | |
695 | #undef wxPG_ATTR_MAX | |
696 | #define wxPG_ATTR_MAX wxPGGlobalVars->m_strMax | |
697 | #undef wxPG_ATTR_UNITS | |
698 | #define wxPG_ATTR_UNITS wxPGGlobalVars->m_strUnits | |
534090e3 JS |
699 | #undef wxPG_ATTR_HINT |
700 | #define wxPG_ATTR_HINT wxPGGlobalVars->m_strHint | |
701 | #if wxPG_COMPATIBILITY_1_4 | |
1c4293cb VZ |
702 | #undef wxPG_ATTR_INLINE_HELP |
703 | #define wxPG_ATTR_INLINE_HELP wxPGGlobalVars->m_strInlineHelp | |
534090e3 | 704 | #endif |
1c4293cb | 705 | |
1c4293cb VZ |
706 | #endif // !SWIG |
707 | ||
708 | // ----------------------------------------------------------------------- | |
709 | ||
939d9364 | 710 | #ifndef SWIG |
1c4293cb | 711 | |
939d9364 JS |
712 | /** @class wxPGChoiceEntry |
713 | Data of a single wxPGChoices choice. | |
1c4293cb | 714 | */ |
939d9364 | 715 | class WXDLLIMPEXP_PROPGRID wxPGChoiceEntry : public wxPGCell |
1c4293cb | 716 | { |
1c4293cb | 717 | public: |
939d9364 | 718 | wxPGChoiceEntry(); |
d7e2b522 | 719 | wxPGChoiceEntry(const wxPGChoiceEntry& other) |
18415eb5 | 720 | : wxPGCell(other) |
d7e2b522 | 721 | { |
d7e2b522 JS |
722 | m_value = other.m_value; |
723 | } | |
939d9364 JS |
724 | wxPGChoiceEntry( const wxString& label, |
725 | int value = wxPG_INVALID_VALUE ) | |
726 | : wxPGCell(), m_value(value) | |
727 | { | |
d7e2b522 | 728 | SetText(label); |
939d9364 | 729 | } |
1c4293cb | 730 | |
d7e2b522 | 731 | virtual ~wxPGChoiceEntry() { } |
1c4293cb | 732 | |
939d9364 | 733 | void SetValue( int value ) { m_value = value; } |
939d9364 | 734 | int GetValue() const { return m_value; } |
1c4293cb | 735 | |
d7e2b522 JS |
736 | wxPGChoiceEntry& operator=( const wxPGChoiceEntry& other ) |
737 | { | |
738 | if ( this != &other ) | |
739 | { | |
740 | Ref(other); | |
741 | } | |
742 | m_value = other.m_value; | |
743 | return *this; | |
744 | } | |
745 | ||
939d9364 JS |
746 | protected: |
747 | int m_value; | |
748 | }; | |
1c4293cb | 749 | |
1c4293cb | 750 | |
939d9364 | 751 | typedef void* wxPGChoicesId; |
1c4293cb | 752 | |
92ffc98a | 753 | class WXDLLIMPEXP_PROPGRID wxPGChoicesData : public wxObjectRefData |
939d9364 JS |
754 | { |
755 | friend class wxPGChoices; | |
756 | public: | |
757 | // Constructor sets m_refCount to 1. | |
758 | wxPGChoicesData(); | |
1c4293cb | 759 | |
939d9364 | 760 | void CopyDataFrom( wxPGChoicesData* data ); |
1c4293cb | 761 | |
d7e2b522 | 762 | wxPGChoiceEntry& Insert( int index, const wxPGChoiceEntry& item ); |
1c4293cb | 763 | |
939d9364 JS |
764 | // Delete all entries |
765 | void Clear(); | |
1c4293cb | 766 | |
68bcfd2c JS |
767 | unsigned int GetCount() const |
768 | { | |
769 | return (unsigned int) m_items.size(); | |
770 | } | |
1c4293cb | 771 | |
d7e2b522 | 772 | const wxPGChoiceEntry& Item( unsigned int i ) const |
939d9364 | 773 | { |
d7e2b522 JS |
774 | wxASSERT_MSG( i < GetCount(), "invalid index" ); |
775 | return m_items[i]; | |
776 | } | |
1c4293cb | 777 | |
d7e2b522 JS |
778 | wxPGChoiceEntry& Item( unsigned int i ) |
779 | { | |
780 | wxASSERT_MSG( i < GetCount(), "invalid index" ); | |
f7a094e1 | 781 | return m_items[i]; |
939d9364 | 782 | } |
1c4293cb | 783 | |
939d9364 | 784 | private: |
d7e2b522 | 785 | wxVector<wxPGChoiceEntry> m_items; |
1c4293cb | 786 | |
939d9364 JS |
787 | virtual ~wxPGChoicesData(); |
788 | }; | |
1c4293cb | 789 | |
939d9364 | 790 | #define wxPGChoicesEmptyData ((wxPGChoicesData*)NULL) |
1c4293cb | 791 | |
939d9364 | 792 | #endif // SWIG |
1c4293cb | 793 | |
939d9364 | 794 | /** @class wxPGChoices |
1c4293cb | 795 | |
939d9364 JS |
796 | Helper class for managing choices of wxPropertyGrid properties. |
797 | Each entry can have label, value, bitmap, text colour, and background | |
798 | colour. | |
03647350 | 799 | |
e1ef506e JS |
800 | wxPGChoices uses reference counting, similar to other wxWidgets classes. |
801 | This means that assignment operator and copy constructor only copy the | |
802 | reference and not the actual data. Use Copy() member function to create a | |
803 | real copy. | |
1c4293cb | 804 | |
98c04633 JS |
805 | @remarks If you do not specify value for entry, index is used. |
806 | ||
939d9364 JS |
807 | @library{wxpropgrid} |
808 | @category{propgrid} | |
809 | */ | |
810 | class WXDLLIMPEXP_PROPGRID wxPGChoices | |
811 | { | |
812 | public: | |
813 | typedef long ValArrItem; | |
1c4293cb | 814 | |
939d9364 JS |
815 | /** Default constructor. */ |
816 | wxPGChoices() | |
817 | { | |
818 | Init(); | |
819 | } | |
1c4293cb | 820 | |
e1ef506e JS |
821 | /** |
822 | Copy constructor, uses reference counting. To create a real copy, | |
823 | use Copy() member function instead. | |
824 | */ | |
939d9364 JS |
825 | wxPGChoices( const wxPGChoices& a ) |
826 | { | |
827 | if ( a.m_data != wxPGChoicesEmptyData ) | |
828 | { | |
829 | m_data = a.m_data; | |
92ffc98a | 830 | m_data->IncRef(); |
939d9364 JS |
831 | } |
832 | } | |
1c4293cb | 833 | |
98c04633 JS |
834 | /** |
835 | Constructor. | |
836 | ||
837 | @param labels | |
838 | Labels for choices | |
839 | ||
840 | @param values | |
841 | Values for choices. If NULL, indexes are used. | |
842 | */ | |
a243da29 | 843 | wxPGChoices( const wxChar* const* labels, const long* values = NULL ) |
939d9364 JS |
844 | { |
845 | Init(); | |
846 | Set(labels,values); | |
847 | } | |
1c4293cb | 848 | |
98c04633 JS |
849 | /** |
850 | Constructor. | |
851 | ||
852 | @param labels | |
853 | Labels for choices | |
854 | ||
855 | @param values | |
856 | Values for choices. If empty, indexes are used. | |
857 | */ | |
939d9364 JS |
858 | wxPGChoices( const wxArrayString& labels, |
859 | const wxArrayInt& values = wxArrayInt() ) | |
860 | { | |
861 | Init(); | |
862 | Set(labels,values); | |
863 | } | |
1c4293cb | 864 | |
939d9364 JS |
865 | /** Simple interface constructor. */ |
866 | wxPGChoices( wxPGChoicesData* data ) | |
867 | { | |
868 | wxASSERT(data); | |
869 | m_data = data; | |
92ffc98a | 870 | data->IncRef(); |
939d9364 | 871 | } |
1c4293cb | 872 | |
939d9364 JS |
873 | /** Destructor. */ |
874 | ~wxPGChoices() | |
875 | { | |
876 | Free(); | |
877 | } | |
1c4293cb | 878 | |
939d9364 JS |
879 | /** |
880 | Adds to current. | |
1c4293cb | 881 | |
939d9364 JS |
882 | If did not have own copies, creates them now. If was empty, identical |
883 | to set except that creates copies. | |
98c04633 JS |
884 | |
885 | @param labels | |
886 | Labels for added choices. | |
887 | ||
888 | @param values | |
889 | Values for added choices. If empty, relevant entry indexes are used. | |
1c4293cb | 890 | */ |
a243da29 | 891 | void Add( const wxChar* const* labels, const ValArrItem* values = NULL ); |
1c4293cb | 892 | |
939d9364 | 893 | /** Version that works with wxArrayString and wxArrayInt. */ |
d7e2b522 | 894 | void Add( const wxArrayString& arr, const wxArrayInt& arrint = wxArrayInt() ); |
1c4293cb | 895 | |
98c04633 JS |
896 | /** |
897 | Adds a single choice. | |
898 | ||
899 | @param label | |
900 | Label for added choice. | |
901 | ||
902 | @param value | |
903 | Value for added choice. If unspecified, index is used. | |
904 | */ | |
939d9364 JS |
905 | wxPGChoiceEntry& Add( const wxString& label, |
906 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb | 907 | |
939d9364 JS |
908 | /** Adds a single item, with bitmap. */ |
909 | wxPGChoiceEntry& Add( const wxString& label, | |
910 | const wxBitmap& bitmap, | |
911 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb | 912 | |
939d9364 JS |
913 | /** Adds a single item with full entry information. */ |
914 | wxPGChoiceEntry& Add( const wxPGChoiceEntry& entry ) | |
915 | { | |
916 | return Insert(entry, -1); | |
917 | } | |
1c4293cb | 918 | |
939d9364 JS |
919 | /** Adds single item. */ |
920 | wxPGChoiceEntry& AddAsSorted( const wxString& label, | |
921 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb | 922 | |
e1ef506e JS |
923 | /** |
924 | Assigns choices data, using reference counting. To create a real copy, | |
925 | use Copy() member function instead. | |
926 | */ | |
939d9364 JS |
927 | void Assign( const wxPGChoices& a ) |
928 | { | |
929 | AssignData(a.m_data); | |
930 | } | |
1c4293cb | 931 | |
939d9364 | 932 | void AssignData( wxPGChoicesData* data ); |
1c4293cb | 933 | |
939d9364 | 934 | /** Delete all choices. */ |
2728c3bf | 935 | void Clear(); |
1c4293cb | 936 | |
e1ef506e JS |
937 | /** |
938 | Returns a real copy of the choices. | |
939 | */ | |
940 | wxPGChoices Copy() const | |
941 | { | |
942 | wxPGChoices dst; | |
943 | dst.EnsureData(); | |
944 | dst.m_data->CopyDataFrom(m_data); | |
945 | return dst; | |
946 | } | |
947 | ||
939d9364 JS |
948 | void EnsureData() |
949 | { | |
950 | if ( m_data == wxPGChoicesEmptyData ) | |
951 | m_data = new wxPGChoicesData(); | |
952 | } | |
1c4293cb | 953 | |
939d9364 JS |
954 | /** Gets a unsigned number identifying this list. */ |
955 | wxPGChoicesId GetId() const { return (wxPGChoicesId) m_data; }; | |
1c4293cb | 956 | |
68bcfd2c | 957 | const wxString& GetLabel( unsigned int ind ) const |
939d9364 JS |
958 | { |
959 | return Item(ind).GetText(); | |
960 | } | |
1c4293cb | 961 | |
68bcfd2c | 962 | unsigned int GetCount () const |
939d9364 JS |
963 | { |
964 | if ( !m_data ) | |
965 | return 0; | |
1c4293cb | 966 | |
939d9364 JS |
967 | return m_data->GetCount(); |
968 | } | |
1c4293cb | 969 | |
68bcfd2c | 970 | int GetValue( unsigned int ind ) const { return Item(ind).GetValue(); } |
1c4293cb | 971 | |
939d9364 JS |
972 | /** Returns array of values matching the given strings. Unmatching strings |
973 | result in wxPG_INVALID_VALUE entry in array. | |
1c4293cb | 974 | */ |
939d9364 | 975 | wxArrayInt GetValuesForStrings( const wxArrayString& strings ) const; |
1c4293cb | 976 | |
939d9364 JS |
977 | /** Returns array of indices matching given strings. Unmatching strings |
978 | are added to 'unmatched', if not NULL. | |
979 | */ | |
980 | wxArrayInt GetIndicesForStrings( const wxArrayString& strings, | |
981 | wxArrayString* unmatched = NULL ) const; | |
1c4293cb | 982 | |
939d9364 JS |
983 | int Index( const wxString& str ) const; |
984 | int Index( int val ) const; | |
1c4293cb | 985 | |
939d9364 JS |
986 | /** Inserts single item. */ |
987 | wxPGChoiceEntry& Insert( const wxString& label, | |
988 | int index, | |
989 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb | 990 | |
939d9364 JS |
991 | /** Inserts a single item with full entry information. */ |
992 | wxPGChoiceEntry& Insert( const wxPGChoiceEntry& entry, int index ); | |
1c4293cb | 993 | |
939d9364 JS |
994 | /** Returns false if this is a constant empty set of choices, |
995 | which should not be modified. | |
1c4293cb | 996 | */ |
939d9364 JS |
997 | bool IsOk() const |
998 | { | |
999 | return ( m_data != wxPGChoicesEmptyData ); | |
1000 | } | |
1c4293cb | 1001 | |
939d9364 JS |
1002 | const wxPGChoiceEntry& Item( unsigned int i ) const |
1003 | { | |
1004 | wxASSERT( IsOk() ); | |
d7e2b522 | 1005 | return m_data->Item(i); |
939d9364 | 1006 | } |
1c4293cb | 1007 | |
939d9364 JS |
1008 | wxPGChoiceEntry& Item( unsigned int i ) |
1009 | { | |
1010 | wxASSERT( IsOk() ); | |
d7e2b522 | 1011 | return m_data->Item(i); |
939d9364 | 1012 | } |
1c4293cb | 1013 | |
939d9364 JS |
1014 | /** Removes count items starting at position nIndex. */ |
1015 | void RemoveAt(size_t nIndex, size_t count = 1); | |
1c4293cb | 1016 | |
939d9364 JS |
1017 | #ifndef SWIG |
1018 | /** Does not create copies for itself. */ | |
a243da29 | 1019 | void Set( const wxChar* const* labels, const long* values = NULL ) |
939d9364 JS |
1020 | { |
1021 | Free(); | |
1022 | Add(labels,values); | |
1023 | } | |
939d9364 JS |
1024 | #endif // SWIG |
1025 | ||
1026 | /** Version that works with wxArrayString and wxArrayInt. */ | |
1027 | void Set( const wxArrayString& labels, | |
1028 | const wxArrayInt& values = wxArrayInt() ) | |
1029 | { | |
1030 | Free(); | |
1031 | if ( &values ) | |
1032 | Add(labels,values); | |
1033 | else | |
1034 | Add(labels); | |
1035 | } | |
1036 | ||
1037 | // Creates exclusive copy of current choices | |
2728c3bf | 1038 | void AllocExclusive(); |
939d9364 JS |
1039 | |
1040 | // Returns data, increases refcount. | |
1041 | wxPGChoicesData* GetData() | |
1042 | { | |
92ffc98a VZ |
1043 | wxASSERT( m_data->GetRefCount() != -1 ); |
1044 | m_data->IncRef(); | |
939d9364 JS |
1045 | return m_data; |
1046 | } | |
1c4293cb | 1047 | |
939d9364 JS |
1048 | // Returns plain data ptr - no refcounting stuff is done. |
1049 | wxPGChoicesData* GetDataPtr() const { return m_data; } | |
1c4293cb | 1050 | |
939d9364 JS |
1051 | // Changes ownership of data to you. |
1052 | wxPGChoicesData* ExtractData() | |
1c4293cb | 1053 | { |
939d9364 JS |
1054 | wxPGChoicesData* data = m_data; |
1055 | m_data = wxPGChoicesEmptyData; | |
1056 | return data; | |
1c4293cb VZ |
1057 | } |
1058 | ||
939d9364 | 1059 | wxArrayString GetLabels() const; |
1c4293cb | 1060 | |
939d9364 JS |
1061 | #ifndef SWIG |
1062 | void operator= (const wxPGChoices& a) | |
1063 | { | |
a09307ab PC |
1064 | if (this != &a) |
1065 | AssignData(a.m_data); | |
1c4293cb VZ |
1066 | } |
1067 | ||
939d9364 | 1068 | wxPGChoiceEntry& operator[](unsigned int i) |
1c4293cb | 1069 | { |
939d9364 | 1070 | return Item(i); |
1c4293cb VZ |
1071 | } |
1072 | ||
939d9364 | 1073 | const wxPGChoiceEntry& operator[](unsigned int i) const |
1c4293cb | 1074 | { |
939d9364 | 1075 | return Item(i); |
1c4293cb VZ |
1076 | } |
1077 | ||
939d9364 JS |
1078 | protected: |
1079 | wxPGChoicesData* m_data; | |
1c4293cb | 1080 | |
939d9364 JS |
1081 | void Init(); |
1082 | void Free(); | |
1083 | #endif // !SWIG | |
1084 | }; | |
1c4293cb | 1085 | |
939d9364 | 1086 | // ----------------------------------------------------------------------- |
1c4293cb | 1087 | |
939d9364 | 1088 | /** @class wxPGProperty |
1c4293cb | 1089 | |
939d9364 | 1090 | wxPGProperty is base class for all wxPropertyGrid properties. |
1c4293cb | 1091 | |
939d9364 JS |
1092 | NB: Full class overview is now only present in |
1093 | interface/wx/propgrid/property.h. | |
1c4293cb | 1094 | |
939d9364 JS |
1095 | @library{wxpropgrid} |
1096 | @category{propgrid} | |
1097 | */ | |
1098 | class WXDLLIMPEXP_PROPGRID wxPGProperty : public wxObject | |
1099 | { | |
1100 | friend class wxPropertyGrid; | |
1101 | friend class wxPropertyGridInterface; | |
1102 | friend class wxPropertyGridPageState; | |
1103 | friend class wxPropertyGridPopulator; | |
1104 | friend class wxStringProperty; // Proper "<composed>" support requires this | |
14bac4b5 | 1105 | |
939d9364 | 1106 | DECLARE_ABSTRACT_CLASS(wxPGProperty) |
939d9364 JS |
1107 | public: |
1108 | typedef wxUint32 FlagType; | |
1c4293cb | 1109 | |
a6ca568c JS |
1110 | /** |
1111 | Default constructor. | |
1c4293cb | 1112 | */ |
939d9364 | 1113 | wxPGProperty(); |
1c4293cb | 1114 | |
a6ca568c JS |
1115 | /** |
1116 | Constructor. | |
1c4293cb | 1117 | |
a6ca568c JS |
1118 | All non-abstract property classes should have a constructor with |
1119 | the same first two arguments as this one. | |
939d9364 JS |
1120 | */ |
1121 | wxPGProperty( const wxString& label, const wxString& name ); | |
1c4293cb | 1122 | |
939d9364 JS |
1123 | /** |
1124 | Virtual destructor. | |
1125 | It is customary for derived properties to implement this. | |
1c4293cb | 1126 | */ |
939d9364 | 1127 | virtual ~wxPGProperty(); |
1c4293cb | 1128 | |
939d9364 | 1129 | /** This virtual function is called after m_value has been set. |
1c4293cb | 1130 | |
939d9364 JS |
1131 | @remarks |
1132 | - If m_value was set to Null variant (ie. unspecified value), | |
1133 | OnSetValue() will not be called. | |
1134 | - m_value may be of any variant type. Typically properties internally | |
1135 | support only one variant type, and as such OnSetValue() provides a | |
1136 | good opportunity to convert | |
1137 | supported values into internal type. | |
1138 | - Default implementation does nothing. | |
1139 | */ | |
1140 | virtual void OnSetValue(); | |
1c4293cb | 1141 | |
939d9364 JS |
1142 | /** Override this to return something else than m_value as the value. |
1143 | */ | |
1144 | virtual wxVariant DoGetValue() const { return m_value; } | |
1145 | ||
1146 | #if !defined(SWIG) || defined(CREATE_VCW) | |
1147 | /** Implement this function in derived class to check the value. | |
1148 | Return true if it is ok. Returning false prevents property change events | |
1149 | from occurring. | |
1c4293cb | 1150 | |
1c4293cb | 1151 | @remarks |
939d9364 | 1152 | - Default implementation always returns true. |
1c4293cb | 1153 | */ |
939d9364 JS |
1154 | virtual bool ValidateValue( wxVariant& value, |
1155 | wxPGValidationInfo& validationInfo ) const; | |
1c4293cb | 1156 | |
939d9364 | 1157 | /** |
9e6bebdc JS |
1158 | Converts text into wxVariant value appropriate for this property. |
1159 | ||
1160 | @param variant | |
1161 | On function entry this is the old value (should not be wxNullVariant | |
1162 | in normal cases). Translated value must be assigned back to it. | |
1163 | ||
1164 | @param text | |
1165 | Text to be translated into variant. | |
1166 | ||
939d9364 JS |
1167 | @param argFlags |
1168 | If wxPG_FULL_VALUE is set, returns complete, storable value instead | |
1169 | of displayable one (they may be different). | |
1170 | If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of | |
1425eca5 | 1171 | composite property string value (as generated by ValueToString() |
939d9364 | 1172 | called with this same flag). |
1c4293cb | 1173 | |
9e6bebdc JS |
1174 | @return Returns @true if resulting wxVariant value was different. |
1175 | ||
1176 | @remarks Default implementation converts semicolon delimited tokens into | |
1177 | child values. Only works for properties with children. | |
1178 | ||
1179 | You might want to take into account that m_value is Null variant | |
1180 | if property value is unspecified (which is usually only case if | |
1181 | you explicitly enabled that sort behavior). | |
1c4293cb | 1182 | */ |
939d9364 JS |
1183 | virtual bool StringToValue( wxVariant& variant, |
1184 | const wxString& text, | |
1185 | int argFlags = 0 ) const; | |
1c4293cb | 1186 | |
939d9364 | 1187 | /** |
9e6bebdc JS |
1188 | Converts integer (possibly a choice selection) into wxVariant value |
1189 | appropriate for this property. | |
1c4293cb | 1190 | |
9e6bebdc JS |
1191 | @param variant |
1192 | On function entry this is the old value (should not be wxNullVariant | |
1193 | in normal cases). Translated value must be assigned back to it. | |
1194 | ||
1195 | @param number | |
1196 | Integer to be translated into variant. | |
1c4293cb | 1197 | |
939d9364 JS |
1198 | @param argFlags |
1199 | If wxPG_FULL_VALUE is set, returns complete, storable value instead | |
1200 | of displayable one. | |
1c4293cb | 1201 | |
9e6bebdc JS |
1202 | @return Returns @true if resulting wxVariant value was different. |
1203 | ||
939d9364 JS |
1204 | @remarks |
1205 | - If property is not supposed to use choice or spinctrl or other editor | |
1206 | with int-based value, it is not necessary to implement this method. | |
1207 | - Default implementation simply assign given int to m_value. | |
1208 | - If property uses choice control, and displays a dialog on some choice | |
1209 | items, then it is preferred to display that dialog in IntToValue | |
1210 | instead of OnEvent. | |
9e6bebdc JS |
1211 | - You might want to take into account that m_value is Null variant if |
1212 | property value is unspecified (which is usually only case if you | |
1213 | explicitly enabled that sort behavior). | |
1c4293cb | 1214 | */ |
939d9364 JS |
1215 | virtual bool IntToValue( wxVariant& value, |
1216 | int number, | |
1217 | int argFlags = 0 ) const; | |
1218 | #endif // !defined(SWIG) || defined(CREATE_VCW) | |
1425eca5 JS |
1219 | /** |
1220 | Converts property value into a text representation. | |
1c4293cb | 1221 | |
1425eca5 JS |
1222 | @param value |
1223 | Value to be converted. | |
1c4293cb | 1224 | |
939d9364 | 1225 | @param argFlags |
1425eca5 | 1226 | If 0 (default value), then displayed string is returned. |
939d9364 JS |
1227 | If wxPG_FULL_VALUE is set, returns complete, storable string value |
1228 | instead of displayable. If wxPG_EDITABLE_VALUE is set, returns | |
1229 | string value that must be editable in textctrl. If | |
1230 | wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to | |
1425eca5 JS |
1231 | display as a part of string property's composite text |
1232 | representation. | |
1c4293cb | 1233 | |
1425eca5 | 1234 | @remarks Default implementation calls GenerateComposedValue(). |
1c4293cb | 1235 | */ |
1425eca5 | 1236 | virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const; |
1c4293cb | 1237 | |
939d9364 JS |
1238 | /** Converts string to a value, and if successful, calls SetValue() on it. |
1239 | Default behavior is to do nothing. | |
1240 | @param text | |
1241 | String to get the value from. | |
1242 | @return | |
1243 | true if value was changed. | |
1c4293cb | 1244 | */ |
f275b5db | 1245 | bool SetValueFromString( const wxString& text, int flags = wxPG_PROGRAMMATIC_VALUE ); |
1c4293cb | 1246 | |
939d9364 JS |
1247 | /** Converts integer to a value, and if succesful, calls SetValue() on it. |
1248 | Default behavior is to do nothing. | |
1249 | @param value | |
1250 | Int to get the value from. | |
1251 | @param flags | |
1252 | If has wxPG_FULL_VALUE, then the value given is a actual value and | |
1253 | not an index. | |
1254 | @return | |
1255 | True if value was changed. | |
1c4293cb | 1256 | */ |
939d9364 | 1257 | bool SetValueFromInt( long value, int flags = 0 ); |
1c4293cb VZ |
1258 | |
1259 | /** | |
939d9364 | 1260 | Returns size of the custom painted image in front of property. |
1c4293cb | 1261 | |
939d9364 JS |
1262 | This method must be overridden to return non-default value if |
1263 | OnCustomPaint is to be called. | |
1264 | @param item | |
1265 | Normally -1, but can be an index to the property's list of items. | |
1266 | @remarks | |
1267 | - Default behavior is to return wxSize(0,0), which means no image. | |
1268 | - Default image width or height is indicated with dimension -1. | |
1269 | - You can also return wxPG_DEFAULT_IMAGE_SIZE, i.e. wxSize(-1, -1). | |
1c4293cb | 1270 | */ |
939d9364 | 1271 | virtual wxSize OnMeasureImage( int item = -1 ) const; |
1c4293cb VZ |
1272 | |
1273 | /** | |
939d9364 | 1274 | Events received by editor widgets are processed here. |
1c4293cb | 1275 | |
939d9364 JS |
1276 | Note that editor class usually processes most events. Some, such as |
1277 | button press events of TextCtrlAndButton class, can be handled here. | |
1278 | Also, if custom handling for regular events is desired, then that can | |
1279 | also be done (for example, wxSystemColourProperty custom handles | |
1280 | wxEVT_COMMAND_CHOICE_SELECTED to display colour picker dialog when | |
1281 | 'custom' selection is made). | |
1c4293cb | 1282 | |
939d9364 JS |
1283 | If the event causes value to be changed, SetValueInEvent() |
1284 | should be called to set the new value. | |
1c4293cb | 1285 | |
939d9364 JS |
1286 | @param event |
1287 | Associated wxEvent. | |
1288 | @return | |
1289 | Should return true if any changes in value should be reported. | |
1290 | @remarks | |
1291 | If property uses choice control, and displays a dialog on some choice | |
1292 | items, then it is preferred to display that dialog in IntToValue | |
1293 | instead of OnEvent. | |
1c4293cb | 1294 | */ |
939d9364 JS |
1295 | virtual bool OnEvent( wxPropertyGrid* propgrid, |
1296 | wxWindow* wnd_primary, | |
1297 | wxEvent& event ); | |
1c4293cb | 1298 | |
939d9364 | 1299 | /** |
b8b1ff48 JS |
1300 | Called after value of a child property has been altered. Must return |
1301 | new value of the whole property (after any alterations warrented by | |
1302 | child's new value). | |
1c4293cb | 1303 | |
939d9364 | 1304 | Note that this function is usually called at the time that value of |
b8b1ff48 JS |
1305 | this property, or given child property, is still pending for change, |
1306 | and as such, result of GetValue() or m_value should not be relied | |
1307 | on. | |
1c4293cb | 1308 | |
939d9364 | 1309 | Sample pseudo-code implementation: |
1c4293cb | 1310 | |
939d9364 | 1311 | @code |
b8b1ff48 JS |
1312 | wxVariant MyProperty::ChildChanged( wxVariant& thisValue, |
1313 | int childIndex, | |
1314 | wxVariant& childValue ) const | |
939d9364 JS |
1315 | { |
1316 | // Acquire reference to actual type of data stored in variant | |
1317 | // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros | |
1318 | // were used to create the variant class). | |
1319 | T& data = TFromVariant(thisValue); | |
1c4293cb | 1320 | |
939d9364 JS |
1321 | // Copy childValue into data. |
1322 | switch ( childIndex ) | |
1323 | { | |
1324 | case 0: | |
1325 | data.SetSubProp1( childvalue.GetLong() ); | |
1326 | break; | |
1327 | case 1: | |
1328 | data.SetSubProp2( childvalue.GetString() ); | |
1329 | break; | |
1330 | ... | |
1331 | } | |
b8b1ff48 JS |
1332 | |
1333 | // Return altered data | |
1334 | return data; | |
939d9364 JS |
1335 | } |
1336 | @endcode | |
1c4293cb | 1337 | |
939d9364 | 1338 | @param thisValue |
b8b1ff48 JS |
1339 | Value of this property. Changed value should be returned (in |
1340 | previous versions of wxPropertyGrid it was only necessary to | |
1341 | write value back to this argument). | |
939d9364 | 1342 | @param childIndex |
b8b1ff48 JS |
1343 | Index of child changed (you can use Item(childIndex) to get |
1344 | child property). | |
939d9364 | 1345 | @param childValue |
b8b1ff48 JS |
1346 | (Pending) value of the child property. |
1347 | ||
1348 | @return | |
1349 | Modified value of the whole property. | |
1c4293cb | 1350 | */ |
b8b1ff48 JS |
1351 | virtual wxVariant ChildChanged( wxVariant& thisValue, |
1352 | int childIndex, | |
1353 | wxVariant& childValue ) const; | |
1c4293cb | 1354 | |
939d9364 | 1355 | /** Returns pointer to an instance of used editor. |
1c4293cb | 1356 | */ |
939d9364 | 1357 | virtual const wxPGEditor* DoGetEditorClass() const; |
1c4293cb | 1358 | |
939d9364 JS |
1359 | /** Returns pointer to the wxValidator that should be used |
1360 | with the editor of this property (NULL for no validator). | |
1361 | Setting validator explicitly via SetPropertyValidator | |
1362 | will override this. | |
1c4293cb | 1363 | |
939d9364 JS |
1364 | In most situations, code like this should work well |
1365 | (macros are used to maintain one actual validator instance, | |
1366 | so on the second call the function exits within the first | |
1367 | macro): | |
1c4293cb | 1368 | |
939d9364 | 1369 | @code |
1c4293cb | 1370 | |
939d9364 JS |
1371 | wxValidator* wxMyPropertyClass::DoGetValidator () const |
1372 | { | |
1373 | WX_PG_DOGETVALIDATOR_ENTRY() | |
1c4293cb | 1374 | |
939d9364 | 1375 | wxMyValidator* validator = new wxMyValidator(...); |
1c4293cb | 1376 | |
939d9364 | 1377 | ... prepare validator... |
1c4293cb | 1378 | |
939d9364 JS |
1379 | WX_PG_DOGETVALIDATOR_EXIT(validator) |
1380 | } | |
1c4293cb | 1381 | |
939d9364 JS |
1382 | @endcode |
1383 | ||
1384 | @remarks | |
1385 | You can get common filename validator by returning | |
1386 | wxFileProperty::GetClassValidator(). wxDirProperty, | |
1387 | for example, uses it. | |
1c4293cb | 1388 | */ |
939d9364 | 1389 | virtual wxValidator* DoGetValidator () const; |
1c4293cb | 1390 | |
939d9364 JS |
1391 | /** |
1392 | Override to paint an image in front of the property value text or | |
1393 | drop-down list item (but only if wxPGProperty::OnMeasureImage is | |
1394 | overridden as well). | |
1c4293cb | 1395 | |
939d9364 JS |
1396 | If property's OnMeasureImage() returns size that has height != 0 but |
1397 | less than row height ( < 0 has special meanings), wxPropertyGrid calls | |
1398 | this method to draw a custom image in a limited area in front of the | |
1399 | editor control or value text/graphics, and if control has drop-down | |
1400 | list, then the image is drawn there as well (even in the case | |
1401 | OnMeasureImage() returned higher height than row height). | |
1c4293cb | 1402 | |
939d9364 JS |
1403 | NOTE: Following applies when OnMeasureImage() returns a "flexible" |
1404 | height ( using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable | |
1405 | height items: If rect.x is < 0, then this is a measure item call, which | |
1406 | means that dc is invalid and only thing that should be done is to set | |
1407 | paintdata.m_drawnHeight to the height of the image of item at index | |
1408 | paintdata.m_choiceItem. This call may be done even as often as once | |
1409 | every drop-down popup show. | |
1c4293cb | 1410 | |
939d9364 JS |
1411 | @param dc |
1412 | wxDC to paint on. | |
1413 | @param rect | |
1414 | Box reserved for custom graphics. Includes surrounding rectangle, | |
1415 | if any. If x is < 0, then this is a measure item call (see above). | |
1416 | @param paintdata | |
1417 | wxPGPaintData structure with much useful data. | |
1c4293cb | 1418 | |
939d9364 JS |
1419 | @remarks |
1420 | - You can actually exceed rect width, but if you do so then | |
1421 | paintdata.m_drawnWidth must be set to the full width drawn in | |
1422 | pixels. | |
1423 | - Due to technical reasons, rect's height will be default even if | |
1424 | custom height was reported during measure call. | |
1425 | - Brush is guaranteed to be default background colour. It has been | |
1426 | already used to clear the background of area being painted. It | |
1427 | can be modified. | |
1428 | - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper | |
1429 | colour) pen for drawing framing rectangle. It can be changed as | |
1430 | well. | |
1431 | ||
1425eca5 | 1432 | @see ValueToString() |
1c4293cb | 1433 | */ |
939d9364 JS |
1434 | virtual void OnCustomPaint( wxDC& dc, |
1435 | const wxRect& rect, | |
1436 | wxPGPaintData& paintdata ); | |
1c4293cb | 1437 | |
939d9364 JS |
1438 | /** |
1439 | Returns used wxPGCellRenderer instance for given property column | |
1440 | (label=0, value=1). | |
1c4293cb | 1441 | |
939d9364 | 1442 | Default implementation returns editor's renderer for all columns. |
1c4293cb | 1443 | */ |
939d9364 | 1444 | virtual wxPGCellRenderer* GetCellRenderer( int column ) const; |
1c4293cb | 1445 | |
939d9364 JS |
1446 | /** Returns which choice is currently selected. Only applies to properties |
1447 | which have choices. | |
1c4293cb | 1448 | |
939d9364 JS |
1449 | Needs to reimplemented in derived class if property value does not |
1450 | map directly to a choice. Integer as index, bool, and string usually do. | |
1c4293cb | 1451 | */ |
939d9364 | 1452 | virtual int GetChoiceSelection() const; |
1c4293cb | 1453 | |
939d9364 JS |
1454 | /** |
1455 | Refresh values of child properties. | |
1c4293cb | 1456 | |
939d9364 | 1457 | Automatically called after value is set. |
1c4293cb | 1458 | */ |
939d9364 | 1459 | virtual void RefreshChildren(); |
1c4293cb | 1460 | |
14946ce1 JS |
1461 | /** |
1462 | Reimplement this member function to add special handling for | |
1463 | attributes of this property. | |
1c4293cb | 1464 | |
14946ce1 JS |
1465 | @return Return @false to have the attribute automatically stored in |
1466 | m_attributes. Default implementation simply does that and | |
1467 | nothing else. | |
1c4293cb | 1468 | |
14946ce1 JS |
1469 | @remarks To actually set property attribute values from the |
1470 | application, use wxPGProperty::SetAttribute() instead. | |
1c4293cb | 1471 | */ |
939d9364 | 1472 | virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); |
1c4293cb | 1473 | |
939d9364 | 1474 | /** Returns value of an attribute. |
1c4293cb | 1475 | |
939d9364 | 1476 | Override if custom handling of attributes is needed. |
1c4293cb | 1477 | |
939d9364 | 1478 | Default implementation simply return NULL variant. |
1c4293cb | 1479 | */ |
939d9364 | 1480 | virtual wxVariant DoGetAttribute( const wxString& name ) const; |
1c4293cb | 1481 | |
939d9364 JS |
1482 | /** Returns instance of a new wxPGEditorDialogAdapter instance, which is |
1483 | used when user presses the (optional) button next to the editor control; | |
1c4293cb | 1484 | |
939d9364 JS |
1485 | Default implementation returns NULL (ie. no action is generated when |
1486 | button is pressed). | |
1c4293cb | 1487 | */ |
939d9364 JS |
1488 | virtual wxPGEditorDialogAdapter* GetEditorDialog() const; |
1489 | ||
d8812c6e JS |
1490 | /** |
1491 | Called whenever validation has failed with given pending value. | |
1492 | ||
1493 | @remarks If you implement this in your custom property class, please | |
1494 | remember to call the baser implementation as well, since they | |
1495 | may use it to revert property into pre-change state. | |
1496 | */ | |
1497 | virtual void OnValidationFailure( wxVariant& pendingValue ); | |
1498 | ||
939d9364 | 1499 | /** Append a new choice to property's list of choices. |
1c4293cb | 1500 | */ |
939d9364 JS |
1501 | int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE ) |
1502 | { | |
1503 | return InsertChoice(label, wxNOT_FOUND, value); | |
1504 | } | |
1c4293cb | 1505 | |
939d9364 JS |
1506 | /** |
1507 | Returns true if children of this property are component values (for | |
1508 | instance, points size, face name, and is_underlined are component | |
1509 | values of a font). | |
1c4293cb | 1510 | */ |
939d9364 | 1511 | bool AreChildrenComponents() const |
1c4293cb | 1512 | { |
939d9364 JS |
1513 | if ( m_flags & (wxPG_PROP_COMPOSED_VALUE|wxPG_PROP_AGGREGATE) ) |
1514 | return true; | |
1515 | ||
1516 | return false; | |
1c4293cb VZ |
1517 | } |
1518 | ||
91c818f8 JS |
1519 | /** |
1520 | Deletes children of the property. | |
1521 | */ | |
1522 | void DeleteChildren(); | |
1523 | ||
939d9364 JS |
1524 | /** |
1525 | Removes entry from property's wxPGChoices and editor control (if it is | |
1526 | active). | |
1c4293cb | 1527 | |
939d9364 | 1528 | If selected item is deleted, then the value is set to unspecified. |
1c4293cb | 1529 | */ |
939d9364 | 1530 | void DeleteChoice( int index ); |
1c4293cb VZ |
1531 | |
1532 | /** | |
939d9364 JS |
1533 | Call to enable or disable usage of common value (integer value that can |
1534 | be selected for properties instead of their normal values) for this | |
1535 | property. | |
1c4293cb | 1536 | |
939d9364 JS |
1537 | Common values are disabled by the default for all properties. |
1538 | */ | |
1539 | void EnableCommonValue( bool enable = true ) | |
1540 | { | |
1541 | if ( enable ) SetFlag( wxPG_PROP_USES_COMMON_VALUE ); | |
1542 | else ClearFlag( wxPG_PROP_USES_COMMON_VALUE ); | |
1543 | } | |
1c4293cb | 1544 | |
1425eca5 | 1545 | /** |
c82a80e8 | 1546 | Composes text from values of child properties. |
1425eca5 | 1547 | */ |
c82a80e8 JS |
1548 | wxString GenerateComposedValue() const |
1549 | { | |
1550 | wxString s; | |
1551 | DoGenerateComposedValue(s); | |
1552 | return s; | |
1553 | } | |
1c4293cb | 1554 | |
939d9364 JS |
1555 | /** Returns property's label. */ |
1556 | const wxString& GetLabel() const { return m_label; } | |
1c4293cb | 1557 | |
939d9364 JS |
1558 | /** Returns property's name with all (non-category, non-root) parents. */ |
1559 | wxString GetName() const; | |
1c4293cb | 1560 | |
939d9364 JS |
1561 | /** |
1562 | Returns property's base name (ie parent's name is not added in any | |
1563 | case) | |
1564 | */ | |
1565 | const wxString& GetBaseName() const { return m_name; } | |
1566 | ||
1567 | /** Returns read-only reference to property's list of choices. | |
1c4293cb | 1568 | */ |
939d9364 JS |
1569 | const wxPGChoices& GetChoices() const |
1570 | { | |
1571 | return m_choices; | |
1572 | } | |
1c4293cb | 1573 | |
939d9364 JS |
1574 | /** Returns coordinate to the top y of the property. Note that the |
1575 | position of scrollbars is not taken into account. | |
1c4293cb | 1576 | */ |
939d9364 | 1577 | int GetY() const; |
1c4293cb | 1578 | |
939d9364 | 1579 | wxVariant GetValue() const |
1c4293cb | 1580 | { |
939d9364 | 1581 | return DoGetValue(); |
1c4293cb VZ |
1582 | } |
1583 | ||
939d9364 JS |
1584 | /** Returns reference to the internal stored value. GetValue is preferred |
1585 | way to get the actual value, since GetValueRef ignores DoGetValue, | |
1586 | which may override stored value. | |
1587 | */ | |
1588 | wxVariant& GetValueRef() | |
1589 | { | |
1590 | return m_value; | |
1591 | } | |
1c4293cb | 1592 | |
939d9364 | 1593 | const wxVariant& GetValueRef() const |
1c4293cb | 1594 | { |
939d9364 | 1595 | return m_value; |
1c4293cb | 1596 | } |
ac1013c0 JS |
1597 | |
1598 | // Helper function (for wxPython bindings and such) for settings protected | |
1599 | // m_value. | |
1600 | wxVariant GetValuePlain() const | |
1601 | { | |
1602 | return m_value; | |
1603 | } | |
1c4293cb | 1604 | |
1425eca5 JS |
1605 | /** Returns text representation of property's value. |
1606 | ||
1607 | @param argFlags | |
1608 | If 0 (default value), then displayed string is returned. | |
1609 | If wxPG_FULL_VALUE is set, returns complete, storable string value | |
1610 | instead of displayable. If wxPG_EDITABLE_VALUE is set, returns | |
1611 | string value that must be editable in textctrl. If | |
1612 | wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to | |
1613 | display as a part of string property's composite text | |
1614 | representation. | |
1615 | ||
1616 | @remarks In older versions, this function used to be overridden to convert | |
1617 | property's value into a string representation. This function is | |
1618 | now handled by ValueToString(), and overriding this function now | |
1619 | will result in run-time assertion failure. | |
1620 | */ | |
1621 | virtual wxString GetValueAsString( int argFlags = 0 ) const; | |
1622 | ||
1623 | /** Synonymous to GetValueAsString(). | |
1624 | ||
1625 | @deprecated Use GetValueAsString() instead. | |
1626 | ||
1627 | @see GetValueAsString() | |
939d9364 | 1628 | */ |
1425eca5 | 1629 | wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const ); |
1c4293cb | 1630 | |
d7e2b522 JS |
1631 | /** |
1632 | Returns wxPGCell of given column. | |
58935d4a JS |
1633 | |
1634 | @remarks const version of this member function returns 'default' | |
1635 | wxPGCell object if the property itself didn't hold | |
1636 | cell data. | |
939d9364 | 1637 | */ |
d7e2b522 | 1638 | const wxPGCell& GetCell( unsigned int column ) const; |
1c4293cb | 1639 | |
58935d4a JS |
1640 | /** |
1641 | Returns wxPGCell of given column, creating one if necessary. | |
1642 | */ | |
1643 | wxPGCell& GetCell( unsigned int column ) | |
1644 | { | |
1645 | return GetOrCreateCell(column); | |
1646 | } | |
1647 | ||
1648 | /** | |
1649 | Returns wxPGCell of given column, creating one if necessary. | |
1650 | */ | |
1651 | wxPGCell& GetOrCreateCell( unsigned int column ); | |
1c4293cb | 1652 | |
939d9364 JS |
1653 | /** Return number of displayed common values for this property. |
1654 | */ | |
1655 | int GetDisplayedCommonValueCount() const; | |
1656 | ||
1657 | wxString GetDisplayedString() const | |
1c4293cb | 1658 | { |
1425eca5 | 1659 | return GetValueAsString(0); |
1c4293cb | 1660 | } |
1c4293cb | 1661 | |
534090e3 JS |
1662 | /** |
1663 | Returns property's hint text (shown in empty value cell). | |
1664 | */ | |
1665 | inline wxString GetHintText() const; | |
1666 | ||
939d9364 JS |
1667 | /** Returns property grid where property lies. */ |
1668 | wxPropertyGrid* GetGrid() const; | |
1669 | ||
1670 | /** Returns owner wxPropertyGrid, but only if one is currently on a page | |
1671 | displaying this property. */ | |
1672 | wxPropertyGrid* GetGridIfDisplayed() const; | |
1673 | ||
1674 | /** Returns highest level non-category, non-root parent. Useful when you | |
1675 | have nested wxCustomProperties/wxParentProperties. | |
1c4293cb | 1676 | @remarks |
939d9364 JS |
1677 | Thus, if immediate parent is root or category, this will return the |
1678 | property itself. | |
1c4293cb | 1679 | */ |
939d9364 | 1680 | wxPGProperty* GetMainParent() const; |
1c4293cb | 1681 | |
939d9364 JS |
1682 | /** Return parent of property */ |
1683 | wxPGProperty* GetParent() const { return m_parent; } | |
1684 | ||
1685 | /** Returns true if property has editable wxTextCtrl when selected. | |
1686 | ||
1687 | @remarks | |
1688 | Altough disabled properties do not displayed editor, they still | |
1689 | return True here as being disabled is considered a temporary | |
1690 | condition (unlike being read-only or having limited editing enabled). | |
1c4293cb | 1691 | */ |
939d9364 JS |
1692 | bool IsTextEditable() const; |
1693 | ||
1694 | bool IsValueUnspecified() const | |
1c4293cb | 1695 | { |
939d9364 | 1696 | return m_value.IsNull(); |
1c4293cb VZ |
1697 | } |
1698 | ||
939d9364 | 1699 | FlagType HasFlag( FlagType flag ) const |
1c4293cb | 1700 | { |
939d9364 | 1701 | return ( m_flags & flag ); |
1c4293cb VZ |
1702 | } |
1703 | ||
939d9364 | 1704 | /** Returns comma-delimited string of property attributes. |
1c4293cb | 1705 | */ |
939d9364 | 1706 | const wxPGAttributeStorage& GetAttributes() const |
1c4293cb | 1707 | { |
939d9364 | 1708 | return m_attributes; |
1c4293cb VZ |
1709 | } |
1710 | ||
939d9364 | 1711 | /** Returns m_attributes as list wxVariant. |
1c4293cb | 1712 | */ |
939d9364 | 1713 | wxVariant GetAttributesAsList() const; |
1c4293cb | 1714 | |
939d9364 JS |
1715 | FlagType GetFlags() const |
1716 | { | |
1717 | return m_flags; | |
1718 | } | |
1c4293cb | 1719 | |
939d9364 | 1720 | const wxPGEditor* GetEditorClass() const; |
1c4293cb | 1721 | |
939d9364 JS |
1722 | wxString GetValueType() const |
1723 | { | |
1724 | return m_value.GetType(); | |
1725 | } | |
1c4293cb | 1726 | |
939d9364 | 1727 | /** Returns editor used for given column. NULL for no editor. |
1c4293cb | 1728 | */ |
939d9364 | 1729 | const wxPGEditor* GetColumnEditor( int column ) const |
1c4293cb | 1730 | { |
939d9364 JS |
1731 | if ( column == 1 ) |
1732 | return GetEditorClass(); | |
1733 | ||
1734 | return NULL; | |
1c4293cb VZ |
1735 | } |
1736 | ||
939d9364 JS |
1737 | /** Returns common value selected for this property. -1 for none. |
1738 | */ | |
1739 | int GetCommonValue() const | |
1c4293cb | 1740 | { |
939d9364 | 1741 | return m_commonValue; |
1c4293cb VZ |
1742 | } |
1743 | ||
939d9364 JS |
1744 | /** Returns true if property has even one visible child. |
1745 | */ | |
1746 | bool HasVisibleChildren() const; | |
1c4293cb | 1747 | |
48a32cf6 JS |
1748 | /** |
1749 | Use this member function to add independent (ie. regular) children to | |
1750 | a property. | |
1751 | ||
1752 | @return Inserted childProperty. | |
1753 | ||
1754 | @remarks wxPropertyGrid is not automatically refreshed by this | |
1755 | function. | |
1756 | ||
1757 | @see AddPrivateChild() | |
1758 | */ | |
1759 | wxPGProperty* InsertChild( int index, wxPGProperty* childProperty ); | |
1760 | ||
939d9364 JS |
1761 | /** Inserts a new choice to property's list of choices. |
1762 | */ | |
1763 | int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE ); | |
1c4293cb VZ |
1764 | |
1765 | /** | |
939d9364 | 1766 | Returns true if this property is actually a wxPropertyCategory. |
1c4293cb | 1767 | */ |
939d9364 | 1768 | bool IsCategory() const { return HasFlag(wxPG_PROP_CATEGORY)?true:false; } |
1c4293cb | 1769 | |
939d9364 | 1770 | /** Returns true if this property is actually a wxRootProperty. |
1c4293cb | 1771 | */ |
939d9364 | 1772 | bool IsRoot() const { return (m_parent == NULL); } |
1c4293cb | 1773 | |
939d9364 JS |
1774 | /** Returns true if this is a sub-property. */ |
1775 | bool IsSubProperty() const | |
1776 | { | |
1777 | wxPGProperty* parent = (wxPGProperty*)m_parent; | |
1778 | if ( parent && !parent->IsCategory() ) | |
1779 | return true; | |
1780 | return false; | |
1781 | } | |
1c4293cb | 1782 | |
939d9364 | 1783 | /** Returns last visible sub-property, recursively. |
1c4293cb | 1784 | */ |
939d9364 | 1785 | const wxPGProperty* GetLastVisibleSubItem() const; |
1c4293cb | 1786 | |
939d9364 | 1787 | wxVariant GetDefaultValue() const; |
1c4293cb | 1788 | |
939d9364 JS |
1789 | int GetMaxLength() const |
1790 | { | |
1791 | return (int) m_maxLen; | |
1792 | } | |
1c4293cb | 1793 | |
939d9364 JS |
1794 | /** |
1795 | Determines, recursively, if all children are not unspecified. | |
1c4293cb | 1796 | |
bb6720bb JS |
1797 | @param pendingList |
1798 | Assumes members in this wxVariant list as pending | |
1799 | replacement values. | |
939d9364 JS |
1800 | */ |
1801 | bool AreAllChildrenSpecified( wxVariant* pendingList = NULL ) const; | |
1c4293cb | 1802 | |
939d9364 JS |
1803 | /** Updates composed values of parent non-category properties, recursively. |
1804 | Returns topmost property updated. | |
1c4293cb | 1805 | |
939d9364 JS |
1806 | @remarks |
1807 | - Must not call SetValue() (as can be called in it). | |
1c4293cb | 1808 | */ |
939d9364 | 1809 | wxPGProperty* UpdateParentValues(); |
1c4293cb | 1810 | |
939d9364 JS |
1811 | /** Returns true if containing grid uses wxPG_EX_AUTO_UNSPECIFIED_VALUES. |
1812 | */ | |
bb6720bb | 1813 | bool UsesAutoUnspecified() const |
939d9364 | 1814 | { |
bb6720bb | 1815 | return HasFlag(wxPG_PROP_AUTO_UNSPECIFIED)?true:false; |
1c4293cb | 1816 | } |
939d9364 JS |
1817 | |
1818 | wxBitmap* GetValueImage() const | |
1819 | { | |
1820 | return m_valueBitmap; | |
1c4293cb | 1821 | } |
1c4293cb | 1822 | |
939d9364 | 1823 | wxVariant GetAttribute( const wxString& name ) const; |
1c4293cb | 1824 | |
939d9364 JS |
1825 | /** |
1826 | Returns named attribute, as string, if found. | |
1c4293cb | 1827 | |
939d9364 | 1828 | Otherwise defVal is returned. |
1c4293cb | 1829 | */ |
939d9364 | 1830 | wxString GetAttribute( const wxString& name, const wxString& defVal ) const; |
1c4293cb | 1831 | |
939d9364 JS |
1832 | /** |
1833 | Returns named attribute, as long, if found. | |
1c4293cb | 1834 | |
939d9364 JS |
1835 | Otherwise defVal is returned. |
1836 | */ | |
1837 | long GetAttributeAsLong( const wxString& name, long defVal ) const; | |
1c4293cb | 1838 | |
939d9364 JS |
1839 | /** |
1840 | Returns named attribute, as double, if found. | |
1c4293cb | 1841 | |
939d9364 | 1842 | Otherwise defVal is returned. |
1c4293cb | 1843 | */ |
939d9364 | 1844 | double GetAttributeAsDouble( const wxString& name, double defVal ) const; |
1c4293cb | 1845 | |
939d9364 | 1846 | unsigned int GetDepth() const { return (unsigned int)m_depth; } |
1c4293cb | 1847 | |
939d9364 JS |
1848 | /** Gets flags as a'|' delimited string. Note that flag names are not |
1849 | prepended with 'wxPG_PROP_'. | |
1850 | @param flagsMask | |
1851 | String will only be made to include flags combined by this parameter. | |
1852 | */ | |
1853 | wxString GetFlagsAsString( FlagType flagsMask ) const; | |
1c4293cb | 1854 | |
939d9364 JS |
1855 | /** Returns position in parent's array. */ |
1856 | unsigned int GetIndexInParent() const | |
1c4293cb | 1857 | { |
939d9364 | 1858 | return (unsigned int)m_arrIndex; |
1c4293cb VZ |
1859 | } |
1860 | ||
939d9364 JS |
1861 | /** Hides or reveals the property. |
1862 | @param hide | |
1863 | true for hide, false for reveal. | |
1864 | @param flags | |
1865 | By default changes are applied recursively. Set this paramter | |
1866 | wxPG_DONT_RECURSE to prevent this. | |
1867 | */ | |
1868 | inline bool Hide( bool hide, int flags = wxPG_RECURSE ); | |
1c4293cb | 1869 | |
939d9364 JS |
1870 | bool IsExpanded() const |
1871 | { return (!(m_flags & wxPG_PROP_COLLAPSED) && GetChildCount()); } | |
1c4293cb | 1872 | |
939d9364 JS |
1873 | /** Returns true if all parents expanded. |
1874 | */ | |
1875 | bool IsVisible() const; | |
1c4293cb | 1876 | |
939d9364 | 1877 | bool IsEnabled() const { return !(m_flags & wxPG_PROP_DISABLED); } |
1c4293cb | 1878 | |
939d9364 JS |
1879 | /** If property's editor is created this forces its recreation. |
1880 | Useful in SetAttribute etc. Returns true if actually did anything. | |
1881 | */ | |
1882 | bool RecreateEditor(); | |
1c4293cb | 1883 | |
939d9364 JS |
1884 | /** If property's editor is active, then update it's value. |
1885 | */ | |
1886 | void RefreshEditor(); | |
1c4293cb | 1887 | |
939d9364 JS |
1888 | /** Sets an attribute for this property. |
1889 | @param name | |
1890 | Text identifier of attribute. See @ref propgrid_property_attributes. | |
1891 | @param value | |
1892 | Value of attribute. | |
1893 | */ | |
1894 | void SetAttribute( const wxString& name, wxVariant value ); | |
1c4293cb | 1895 | |
939d9364 | 1896 | void SetAttributes( const wxPGAttributeStorage& attributes ); |
1c4293cb | 1897 | |
d7e2b522 JS |
1898 | /** |
1899 | Sets property's background colour. | |
1900 | ||
1901 | @param colour | |
1902 | Background colour to use. | |
1903 | ||
e607eac2 JS |
1904 | @param flags |
1905 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
1906 | Omit this flag to only set colour for the property in question | |
1907 | and not any of its children. | |
d7e2b522 JS |
1908 | */ |
1909 | void SetBackgroundColour( const wxColour& colour, | |
e607eac2 | 1910 | int flags = wxPG_RECURSE ); |
d7e2b522 JS |
1911 | |
1912 | /** | |
1913 | Sets property's text colour. | |
1914 | ||
1915 | @param colour | |
1916 | Text colour to use. | |
1917 | ||
e607eac2 JS |
1918 | @param flags |
1919 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
1920 | Omit this flag to only set colour for the property in question | |
1921 | and not any of its children. | |
d7e2b522 JS |
1922 | */ |
1923 | void SetTextColour( const wxColour& colour, | |
e607eac2 | 1924 | int flags = wxPG_RECURSE ); |
d7e2b522 | 1925 | |
0ce8e27f JS |
1926 | /** Set default value of a property. Synonymous to |
1927 | ||
1928 | @code | |
1929 | SetAttribute("DefaultValue", value); | |
1930 | @endcode | |
1931 | */ | |
1932 | void SetDefaultValue( wxVariant& value ); | |
1933 | ||
939d9364 JS |
1934 | #ifndef SWIG |
1935 | /** Sets editor for a property. | |
1c4293cb | 1936 | |
939d9364 JS |
1937 | @param editor |
1938 | For builtin editors, use wxPGEditor_X, where X is builtin editor's | |
1939 | name (TextCtrl, Choice, etc. see wxPGEditor documentation for full | |
1940 | list). | |
1c4293cb | 1941 | |
939d9364 JS |
1942 | For custom editors, use pointer you received from |
1943 | wxPropertyGrid::RegisterEditorClass(). | |
1944 | */ | |
1945 | void SetEditor( const wxPGEditor* editor ) | |
1946 | { | |
1947 | m_customEditor = editor; | |
1948 | } | |
1949 | #endif | |
1c4293cb | 1950 | |
939d9364 JS |
1951 | /** Sets editor for a property. |
1952 | */ | |
1953 | inline void SetEditor( const wxString& editorName ); | |
1c4293cb | 1954 | |
d7e2b522 JS |
1955 | /** |
1956 | Sets cell information for given column. | |
939d9364 | 1957 | */ |
d7e2b522 | 1958 | void SetCell( int column, const wxPGCell& cell ); |
1c4293cb | 1959 | |
939d9364 JS |
1960 | /** Sets common value selected for this property. -1 for none. |
1961 | */ | |
1962 | void SetCommonValue( int commonValue ) | |
1963 | { | |
1964 | m_commonValue = commonValue; | |
1965 | } | |
1c4293cb | 1966 | |
939d9364 JS |
1967 | /** Sets flags from a '|' delimited string. Note that flag names are not |
1968 | prepended with 'wxPG_PROP_'. | |
1969 | */ | |
1970 | void SetFlagsFromString( const wxString& str ); | |
1c4293cb | 1971 | |
939d9364 JS |
1972 | /** Sets property's "is it modified?" flag. Affects children recursively. |
1973 | */ | |
1974 | void SetModifiedStatus( bool modified ) | |
1975 | { | |
1976 | SetFlagRecursively(wxPG_PROP_MODIFIED, modified); | |
1977 | } | |
1c4293cb | 1978 | |
939d9364 JS |
1979 | /** Call in OnEvent(), OnButtonClick() etc. to change the property value |
1980 | based on user input. | |
1c4293cb | 1981 | |
939d9364 JS |
1982 | @remarks |
1983 | This method is const since it doesn't actually modify value, but posts | |
1984 | given variant as pending value, stored in wxPropertyGrid. | |
1985 | */ | |
1986 | void SetValueInEvent( wxVariant value ) const; | |
1c4293cb | 1987 | |
939d9364 JS |
1988 | /** |
1989 | Call this to set value of the property. | |
1c4293cb | 1990 | |
939d9364 JS |
1991 | Unlike methods in wxPropertyGrid, this does not automatically update |
1992 | the display. | |
1c4293cb | 1993 | |
939d9364 JS |
1994 | @remarks |
1995 | Use wxPropertyGrid::ChangePropertyValue() instead if you need to run | |
1996 | through validation process and send property change event. | |
1c4293cb | 1997 | |
939d9364 JS |
1998 | If you need to change property value in event, based on user input, use |
1999 | SetValueInEvent() instead. | |
1c4293cb | 2000 | |
939d9364 | 2001 | @param pList |
e777bd14 JS |
2002 | Pointer to list variant that contains child values. Used to |
2003 | indicate which children should be marked as modified. | |
2004 | ||
939d9364 | 2005 | @param flags |
e777bd14 JS |
2006 | Various flags (for instance, wxPG_SETVAL_REFRESH_EDITOR, which is |
2007 | enabled by default). | |
939d9364 | 2008 | */ |
e777bd14 JS |
2009 | void SetValue( wxVariant value, wxVariant* pList = NULL, |
2010 | int flags = wxPG_SETVAL_REFRESH_EDITOR ); | |
1c4293cb | 2011 | |
939d9364 JS |
2012 | /** Set wxBitmap in front of the value. This bitmap may be ignored |
2013 | by custom cell renderers. | |
2014 | */ | |
2015 | void SetValueImage( wxBitmap& bmp ); | |
1c4293cb | 2016 | |
939d9364 | 2017 | /** Sets selected choice and changes property value. |
1c4293cb | 2018 | |
939d9364 JS |
2019 | Tries to retain value type, although currently if it is not string, |
2020 | then it is forced to integer. | |
2021 | */ | |
2022 | void SetChoiceSelection( int newValue ); | |
1c4293cb | 2023 | |
939d9364 JS |
2024 | void SetExpanded( bool expanded ) |
2025 | { | |
2026 | if ( !expanded ) m_flags |= wxPG_PROP_COLLAPSED; | |
2027 | else m_flags &= ~wxPG_PROP_COLLAPSED; | |
2028 | } | |
1c4293cb | 2029 | |
d58526d5 JS |
2030 | /** |
2031 | Sets given property flag(s). | |
2032 | */ | |
939d9364 | 2033 | void SetFlag( FlagType flag ) { m_flags |= flag; } |
1c4293cb | 2034 | |
d58526d5 JS |
2035 | /** |
2036 | Sets or clears given property flag(s). | |
2037 | */ | |
2038 | void ChangeFlag( FlagType flag, bool set ) | |
2039 | { | |
2040 | if ( set ) | |
2041 | m_flags |= flag; | |
2042 | else | |
2043 | m_flags &= ~flag; | |
2044 | } | |
2045 | ||
939d9364 | 2046 | void SetFlagRecursively( FlagType flag, bool set ); |
1c4293cb | 2047 | |
939d9364 JS |
2048 | void SetHelpString( const wxString& helpString ) |
2049 | { | |
2050 | m_helpString = helpString; | |
2051 | } | |
1c4293cb | 2052 | |
939d9364 | 2053 | void SetLabel( const wxString& label ) { m_label = label; } |
1c4293cb | 2054 | |
5fdb6350 | 2055 | void SetName( const wxString& newName ); |
1c4293cb | 2056 | |
2fd4a524 JS |
2057 | /** |
2058 | Changes what sort of parent this property is for its children. | |
2059 | ||
2060 | @param flag | |
48a32cf6 JS |
2061 | Use one of the following values: wxPG_PROP_MISC_PARENT (for |
2062 | generic parents), wxPG_PROP_CATEGORY (for categories), or | |
2fd4a524 JS |
2063 | wxPG_PROP_AGGREGATE (for derived property classes with private |
2064 | children). | |
2065 | ||
48a32cf6 | 2066 | @remarks You generally do not need to call this function. |
2fd4a524 JS |
2067 | */ |
2068 | void SetParentalType( int flag ) | |
2069 | { | |
2070 | m_flags &= ~(wxPG_PROP_PROPERTY|wxPG_PROP_PARENTAL_FLAGS); | |
2071 | m_flags |= flag; | |
2072 | } | |
2073 | ||
939d9364 JS |
2074 | void SetValueToUnspecified() |
2075 | { | |
2076 | wxVariant val; // Create NULL variant | |
269619bf | 2077 | SetValue(val, NULL, wxPG_SETVAL_REFRESH_EDITOR); |
939d9364 | 2078 | } |
1c4293cb | 2079 | |
ac1013c0 JS |
2080 | // Helper function (for wxPython bindings and such) for settings protected |
2081 | // m_value. | |
2082 | void SetValuePlain( wxVariant value ) | |
2083 | { | |
2084 | m_value = value; | |
2085 | } | |
2086 | ||
939d9364 JS |
2087 | #if wxUSE_VALIDATORS |
2088 | /** Sets wxValidator for a property*/ | |
2089 | void SetValidator( const wxValidator& validator ) | |
2090 | { | |
2091 | m_validator = wxDynamicCast(validator.Clone(),wxValidator); | |
2092 | } | |
1c4293cb | 2093 | |
939d9364 JS |
2094 | /** Gets assignable version of property's validator. */ |
2095 | wxValidator* GetValidator() const | |
2096 | { | |
2097 | if ( m_validator ) | |
2098 | return m_validator; | |
2099 | return DoGetValidator(); | |
2100 | } | |
a243da29 | 2101 | #endif // wxUSE_VALIDATORS |
1c4293cb | 2102 | |
1c4293cb | 2103 | #ifndef SWIG |
939d9364 JS |
2104 | /** Returns client data (void*) of a property. |
2105 | */ | |
2106 | void* GetClientData() const | |
1c4293cb | 2107 | { |
939d9364 | 2108 | return m_clientData; |
1c4293cb VZ |
2109 | } |
2110 | ||
939d9364 JS |
2111 | /** Sets client data (void*) of a property. |
2112 | @remarks | |
2113 | This untyped client data has to be deleted manually. | |
2114 | */ | |
2115 | void SetClientData( void* clientData ) | |
1c4293cb | 2116 | { |
939d9364 | 2117 | m_clientData = clientData; |
1c4293cb VZ |
2118 | } |
2119 | ||
939d9364 JS |
2120 | /** Returns client object of a property. |
2121 | */ | |
2122 | void SetClientObject(wxClientData* clientObject) | |
1c4293cb | 2123 | { |
939d9364 JS |
2124 | delete m_clientObject; |
2125 | m_clientObject = clientObject; | |
1c4293cb VZ |
2126 | } |
2127 | ||
939d9364 JS |
2128 | /** Sets managed client object of a property. |
2129 | */ | |
2130 | wxClientData *GetClientObject() const { return m_clientObject; } | |
2131 | #endif | |
1c4293cb | 2132 | |
939d9364 | 2133 | /** Sets new set of choices for property. |
1c4293cb | 2134 | |
939d9364 JS |
2135 | @remarks |
2136 | This operation clears the property value. | |
2137 | */ | |
2138 | bool SetChoices( wxPGChoices& choices ); | |
1c4293cb | 2139 | |
939d9364 JS |
2140 | /** Set max length of text in text editor. |
2141 | */ | |
2142 | inline bool SetMaxLength( int maxLen ); | |
1c4293cb | 2143 | |
939d9364 JS |
2144 | /** Call with 'false' in OnSetValue to cancel value changes after all |
2145 | (ie. cancel 'true' returned by StringToValue() or IntToValue()). | |
2146 | */ | |
2147 | void SetWasModified( bool set = true ) | |
1c4293cb | 2148 | { |
939d9364 JS |
2149 | if ( set ) m_flags |= wxPG_PROP_WAS_MODIFIED; |
2150 | else m_flags &= ~wxPG_PROP_WAS_MODIFIED; | |
2151 | } | |
1c4293cb | 2152 | |
939d9364 JS |
2153 | const wxString& GetHelpString() const |
2154 | { | |
2155 | return m_helpString; | |
1c4293cb VZ |
2156 | } |
2157 | ||
939d9364 | 2158 | void ClearFlag( FlagType flag ) { m_flags &= ~(flag); } |
1c4293cb | 2159 | |
939d9364 JS |
2160 | // Use, for example, to detect if item is inside collapsed section. |
2161 | bool IsSomeParent( wxPGProperty* candidate_parent ) const; | |
1c4293cb | 2162 | |
939d9364 JS |
2163 | /** |
2164 | Adapts list variant into proper value using consecutive | |
2165 | ChildChanged-calls. | |
2166 | */ | |
2167 | void AdaptListToValue( wxVariant& list, wxVariant* value ) const; | |
99774d58 | 2168 | |
48a32cf6 JS |
2169 | #if wxPG_COMPATIBILITY_1_4 |
2170 | /** | |
2171 | Adds a private child property. | |
2172 | ||
2173 | @deprecated Use AddPrivateChild() instead. | |
2174 | ||
2175 | @see AddPrivateChild() | |
2176 | */ | |
2177 | wxDEPRECATED( void AddChild( wxPGProperty* prop ) ); | |
2178 | #endif | |
2179 | ||
2fd4a524 | 2180 | /** |
48a32cf6 | 2181 | Adds a private child property. If you use this instead of |
2fd4a524 | 2182 | wxPropertyGridInterface::Insert() or |
48a32cf6 JS |
2183 | wxPropertyGridInterface::AppendIn(), then property's parental |
2184 | type will automatically be set up to wxPG_PROP_AGGREGATE. In other | |
2185 | words, all properties of this property will become private. | |
2186 | */ | |
2187 | void AddPrivateChild( wxPGProperty* prop ); | |
2fd4a524 | 2188 | |
48a32cf6 JS |
2189 | /** |
2190 | Appends a new child property. | |
2fd4a524 | 2191 | */ |
48a32cf6 JS |
2192 | wxPGProperty* AppendChild( wxPGProperty* prop ) |
2193 | { | |
2194 | return InsertChild(-1, prop); | |
2195 | } | |
1c4293cb | 2196 | |
939d9364 JS |
2197 | /** Returns height of children, recursively, and |
2198 | by taking expanded/collapsed status into account. | |
1c4293cb | 2199 | |
939d9364 JS |
2200 | iMax is used when finding property y-positions. |
2201 | */ | |
2202 | int GetChildrenHeight( int lh, int iMax = -1 ) const; | |
1c4293cb | 2203 | |
939d9364 | 2204 | /** Returns number of child properties */ |
68bcfd2c JS |
2205 | unsigned int GetChildCount() const |
2206 | { | |
2207 | return (unsigned int) m_children.size(); | |
2208 | } | |
1c4293cb | 2209 | |
939d9364 | 2210 | /** Returns sub-property at index i. */ |
68bcfd2c | 2211 | wxPGProperty* Item( unsigned int i ) const |
f7a094e1 | 2212 | { return m_children[i]; } |
1c4293cb | 2213 | |
939d9364 JS |
2214 | /** Returns last sub-property. |
2215 | */ | |
f7a094e1 | 2216 | wxPGProperty* Last() const { return m_children.back(); } |
1c4293cb | 2217 | |
f7a094e1 JS |
2218 | /** Returns index of given child property. */ |
2219 | int Index( const wxPGProperty* p ) const; | |
1c4293cb | 2220 | |
939d9364 | 2221 | // Puts correct indexes to children |
1b895132 | 2222 | void FixIndicesOfChildren( unsigned int starthere = 0 ); |
1c4293cb | 2223 | |
4aee8334 JS |
2224 | /** |
2225 | Converts image width into full image offset, with margins. | |
2226 | */ | |
2227 | int GetImageOffset( int imageWidth ) const; | |
2228 | ||
939d9364 JS |
2229 | #ifndef SWIG |
2230 | // Returns wxPropertyGridPageState in which this property resides. | |
2231 | wxPropertyGridPageState* GetParentState() const { return m_parentState; } | |
2232 | #endif | |
1c4293cb | 2233 | |
14bac4b5 | 2234 | #ifndef SWIG |
939d9364 JS |
2235 | wxPGProperty* GetItemAtY( unsigned int y, |
2236 | unsigned int lh, | |
2237 | unsigned int* nextItemY ) const; | |
14bac4b5 JS |
2238 | #endif |
2239 | ||
2240 | /** Returns property at given virtual y coordinate. | |
2241 | */ | |
2242 | wxPGProperty* GetItemAtY( unsigned int y ) const; | |
1c4293cb | 2243 | |
939d9364 JS |
2244 | /** Returns (direct) child property with given name (or NULL if not found). |
2245 | */ | |
2246 | wxPGProperty* GetPropertyByName( const wxString& name ) const; | |
1c4293cb | 2247 | |
939d9364 | 2248 | #ifndef SWIG |
1c4293cb | 2249 | |
d7e2b522 JS |
2250 | // Returns various display-related information for given column |
2251 | void GetDisplayInfo( unsigned int column, | |
2252 | int choiceIndex, | |
2253 | int flags, | |
2254 | wxString* pString, | |
2255 | const wxPGCell** pCell ); | |
2256 | ||
939d9364 | 2257 | static wxString* sm_wxPG_LABEL; |
1c4293cb | 2258 | |
939d9364 JS |
2259 | /** This member is public so scripting language bindings |
2260 | wrapper code can access it freely. | |
2261 | */ | |
2262 | void* m_clientData; | |
1c4293cb | 2263 | |
939d9364 | 2264 | protected: |
d7e2b522 JS |
2265 | |
2266 | /** | |
2267 | Sets property cell in fashion that reduces number of exclusive | |
2268 | copies of cell data. Used when setting, for instance, same | |
2269 | background colour for a number of properties. | |
2270 | ||
2271 | @param firstCol | |
2272 | First column to affect. | |
2273 | ||
2274 | @param lastCol | |
2275 | Last column to affect. | |
2276 | ||
2277 | @param preparedCell | |
2278 | Pre-prepared cell that is used for those which cell data | |
2279 | before this matched unmodCellData. | |
2280 | ||
2281 | @param srcData | |
2282 | If unmodCellData did not match, valid cell data from this | |
2283 | is merged into cell (usually generating new exclusive copy | |
2284 | of cell's data). | |
2285 | ||
2286 | @param unmodCellData | |
2287 | If cell's cell data matches this, its cell is now set to | |
2288 | preparedCell. | |
2289 | ||
2290 | @param ignoreWithFlags | |
2291 | Properties with any one of these flags are skipped. | |
2292 | ||
2293 | @param recursively | |
2294 | If @true, apply this operation recursively in child properties. | |
1c4293cb | 2295 | */ |
d7e2b522 JS |
2296 | void AdaptiveSetCell( unsigned int firstCol, |
2297 | unsigned int lastCol, | |
2298 | const wxPGCell& preparedCell, | |
2299 | const wxPGCell& srcData, | |
2300 | wxPGCellData* unmodCellData, | |
2301 | FlagType ignoreWithFlags, | |
2302 | bool recursively ); | |
2303 | ||
2304 | /** | |
2305 | Makes sure m_cells has size of column+1 (or more). | |
2306 | */ | |
2307 | void EnsureCells( unsigned int column ); | |
1c4293cb | 2308 | |
939d9364 JS |
2309 | /** Returns (direct) child property with given name (or NULL if not found), |
2310 | with hint index. | |
1c4293cb | 2311 | |
939d9364 JS |
2312 | @param hintIndex |
2313 | Start looking for the child at this index. | |
1c4293cb | 2314 | |
939d9364 JS |
2315 | @remarks |
2316 | Does not support scope (ie. Parent.Child notation). | |
2317 | */ | |
2318 | wxPGProperty* GetPropertyByNameWH( const wxString& name, | |
2319 | unsigned int hintIndex ) const; | |
1c4293cb | 2320 | |
939d9364 | 2321 | /** This is used by Insert etc. */ |
48a32cf6 JS |
2322 | void DoAddChild( wxPGProperty* prop, |
2323 | int index = -1, | |
2324 | bool correct_mode = true ); | |
1c4293cb | 2325 | |
c82a80e8 JS |
2326 | void DoGenerateComposedValue( wxString& text, |
2327 | int argFlags = wxPG_VALUE_IS_CURRENT, | |
2328 | const wxVariantList* valueOverrides = NULL, | |
2329 | wxPGHashMapS2S* childResults = NULL ) const; | |
2330 | ||
939d9364 JS |
2331 | void DoSetName(const wxString& str) { m_name = str; } |
2332 | ||
91c818f8 JS |
2333 | /** Deletes all sub-properties. */ |
2334 | void Empty(); | |
2335 | ||
58935d4a JS |
2336 | bool HasCell( unsigned int column ) const |
2337 | { | |
2338 | if ( m_cells.size() > column ) | |
2339 | return true; | |
2340 | return false; | |
2341 | } | |
2342 | ||
2fd4a524 JS |
2343 | void InitAfterAdded( wxPropertyGridPageState* pageState, |
2344 | wxPropertyGrid* propgrid ); | |
939d9364 | 2345 | |
d8c74d04 JS |
2346 | // Removes child property with given pointer. Does not delete it. |
2347 | void RemoveChild( wxPGProperty* p ); | |
2348 | ||
48a32cf6 JS |
2349 | void DoPreAddChild( int index, wxPGProperty* prop ); |
2350 | ||
939d9364 JS |
2351 | void SetParentState( wxPropertyGridPageState* pstate ) |
2352 | { m_parentState = pstate; } | |
2353 | ||
2354 | // Call after fixed sub-properties added/removed after creation. | |
2355 | // if oldSelInd >= 0 and < new max items, then selection is | |
2356 | // moved to it. | |
2357 | void SubPropsChanged( int oldSelInd = -1 ); | |
1c4293cb | 2358 | |
939d9364 | 2359 | int GetY2( int lh ) const; |
1c4293cb | 2360 | |
939d9364 JS |
2361 | wxString m_label; |
2362 | wxString m_name; | |
2363 | wxPGProperty* m_parent; | |
d7e2b522 | 2364 | wxPropertyGridPageState* m_parentState; |
1c4293cb | 2365 | |
939d9364 | 2366 | wxClientData* m_clientObject; |
1c4293cb | 2367 | |
939d9364 JS |
2368 | // Overrides editor returned by property class |
2369 | const wxPGEditor* m_customEditor; | |
2370 | #if wxUSE_VALIDATORS | |
2371 | // Editor is going to get this validator | |
2372 | wxValidator* m_validator; | |
2373 | #endif | |
2374 | // Show this in front of the value | |
2375 | // | |
2376 | // TODO: Can bitmap be implemented with wxPGCell? | |
2377 | wxBitmap* m_valueBitmap; | |
1c4293cb | 2378 | |
939d9364 JS |
2379 | wxVariant m_value; |
2380 | wxPGAttributeStorage m_attributes; | |
f7a094e1 | 2381 | wxArrayPGProperty m_children; |
1c4293cb | 2382 | |
939d9364 | 2383 | // Extended cell information |
d7e2b522 | 2384 | wxVector<wxPGCell> m_cells; |
1c4293cb | 2385 | |
939d9364 JS |
2386 | // Choices shown in drop-down list of editor control. |
2387 | wxPGChoices m_choices; | |
1c4293cb | 2388 | |
939d9364 JS |
2389 | // Help shown in statusbar or help box. |
2390 | wxString m_helpString; | |
1c4293cb | 2391 | |
939d9364 JS |
2392 | // Index in parent's property array. |
2393 | unsigned int m_arrIndex; | |
1c4293cb | 2394 | |
939d9364 JS |
2395 | // If not -1, then overrides m_value |
2396 | int m_commonValue; | |
1c4293cb | 2397 | |
939d9364 | 2398 | FlagType m_flags; |
1c4293cb | 2399 | |
939d9364 JS |
2400 | // Maximum length (mainly for string properties). Could be in some sort of |
2401 | // wxBaseStringProperty, but currently, for maximum flexibility and | |
2402 | // compatibility, we'll stick it here. Anyway, we had 3 excess bytes to use | |
2403 | // so short int will fit in just fine. | |
2404 | short m_maxLen; | |
1c4293cb | 2405 | |
939d9364 JS |
2406 | // Root has 0, categories etc. at that level 1, etc. |
2407 | unsigned char m_depth; | |
1c4293cb | 2408 | |
939d9364 JS |
2409 | // m_depthBgCol indicates width of background colour between margin and item |
2410 | // (essentially this is category's depth, if none then equals m_depth). | |
2411 | unsigned char m_depthBgCol; | |
1c4293cb | 2412 | |
939d9364 JS |
2413 | private: |
2414 | // Called in constructors. | |
2415 | void Init(); | |
2416 | void Init( const wxString& label, const wxString& name ); | |
2417 | #endif // #ifndef SWIG | |
2418 | }; | |
1c4293cb | 2419 | |
939d9364 | 2420 | // ----------------------------------------------------------------------- |
1c4293cb | 2421 | |
939d9364 JS |
2422 | // |
2423 | // Property class declaration helper macros | |
2424 | // (wxPGRootPropertyClass and wxPropertyCategory require this). | |
2425 | // | |
1c4293cb | 2426 | |
939d9364 JS |
2427 | #define WX_PG_DECLARE_DOGETEDITORCLASS \ |
2428 | virtual const wxPGEditor* DoGetEditorClass() const; | |
1c4293cb VZ |
2429 | |
2430 | #ifndef SWIG | |
939d9364 JS |
2431 | #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \ |
2432 | public: \ | |
2433 | DECLARE_DYNAMIC_CLASS(CLASSNAME) \ | |
2434 | WX_PG_DECLARE_DOGETEDITORCLASS \ | |
2435 | private: | |
2436 | #else | |
2437 | #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) | |
2438 | #endif | |
1c4293cb | 2439 | |
939d9364 JS |
2440 | // Implements sans constructor function. Also, first arg is class name, not |
2441 | // property name. | |
2442 | #define WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(PROPNAME,T,EDITOR) \ | |
2443 | const wxPGEditor* PROPNAME::DoGetEditorClass() const \ | |
2444 | { \ | |
2445 | return wxPGEditor_##EDITOR; \ | |
2446 | } | |
1c4293cb | 2447 | |
939d9364 | 2448 | // ----------------------------------------------------------------------- |
1c4293cb | 2449 | |
939d9364 | 2450 | #ifndef SWIG |
1c4293cb | 2451 | |
939d9364 JS |
2452 | /** @class wxPGRootProperty |
2453 | @ingroup classes | |
2454 | Root parent property. | |
2455 | */ | |
2456 | class WXDLLIMPEXP_PROPGRID wxPGRootProperty : public wxPGProperty | |
2457 | { | |
2458 | public: | |
2459 | WX_PG_DECLARE_PROPERTY_CLASS(wxPGRootProperty) | |
2460 | public: | |
1c4293cb | 2461 | |
939d9364 | 2462 | /** Constructor. */ |
94b8ecf1 | 2463 | wxPGRootProperty( const wxString& name = wxS("<Root>") ); |
939d9364 | 2464 | virtual ~wxPGRootProperty(); |
1c4293cb | 2465 | |
939d9364 | 2466 | virtual bool StringToValue( wxVariant&, const wxString&, int ) const |
1c4293cb | 2467 | { |
939d9364 | 2468 | return false; |
1c4293cb VZ |
2469 | } |
2470 | ||
939d9364 JS |
2471 | protected: |
2472 | }; | |
1c4293cb | 2473 | |
939d9364 | 2474 | // ----------------------------------------------------------------------- |
1c4293cb | 2475 | |
939d9364 JS |
2476 | /** @class wxPropertyCategory |
2477 | @ingroup classes | |
2478 | Category (caption) property. | |
2479 | */ | |
2480 | class WXDLLIMPEXP_PROPGRID wxPropertyCategory : public wxPGProperty | |
2481 | { | |
2482 | friend class wxPropertyGrid; | |
2483 | friend class wxPropertyGridPageState; | |
2484 | WX_PG_DECLARE_PROPERTY_CLASS(wxPropertyCategory) | |
2485 | public: | |
1c4293cb | 2486 | |
939d9364 JS |
2487 | /** Default constructor is only used in special cases. */ |
2488 | wxPropertyCategory(); | |
2489 | ||
2490 | wxPropertyCategory( const wxString& label, | |
2491 | const wxString& name = wxPG_LABEL ); | |
2492 | ~wxPropertyCategory(); | |
2493 | ||
2494 | int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const; | |
1c4293cb | 2495 | |
1425eca5 | 2496 | virtual wxString ValueToString( wxVariant& value, int argFlags ) const; |
e16bff8e | 2497 | virtual wxString GetValueAsString( int argFlags = 0 ) const; |
1c4293cb | 2498 | |
a09307ab | 2499 | protected: |
939d9364 JS |
2500 | void SetTextColIndex( unsigned int colInd ) |
2501 | { m_capFgColIndex = (wxByte) colInd; } | |
2502 | unsigned int GetTextColIndex() const | |
2503 | { return (unsigned int) m_capFgColIndex; } | |
2504 | ||
2505 | void CalculateTextExtent( wxWindow* wnd, const wxFont& font ); | |
2506 | ||
2507 | int m_textExtent; // pre-calculated length of text | |
2508 | wxByte m_capFgColIndex; // caption text colour index | |
2509 | ||
2510 | private: | |
1c4293cb | 2511 | void Init(); |
1c4293cb VZ |
2512 | }; |
2513 | ||
939d9364 | 2514 | #endif // !SWIG |
1c4293cb VZ |
2515 | |
2516 | // ----------------------------------------------------------------------- | |
2517 | ||
f4bc1aa2 JS |
2518 | #endif // wxUSE_PROPGRID |
2519 | ||
1c4293cb | 2520 | #endif // _WX_PROPGRID_PROPERTY_H_ |