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