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