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