1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        propgrid.h
3 // Purpose:     wxPropertyGrid
4 // Author:      Jaakko Salli
5 // Modified by:
6 // Created:     Sep-25-2004
7 // RCS-ID:      $Id:
8 // Copyright:   (c) Jaakko Salli
9 // Licence:     wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef __WX_PROPGRID_PROPGRID_H__
13 #define __WX_PROPGRID_PROPGRID_H__
14 
15 #include <wx/dynarray.h>
16 #include <wx/hashmap.h>
17 #include <wx/variant.h>
18 #include <wx/longlong.h>
19 #include <wx/dcclient.h>
20 #include <wx/scrolwin.h>
21 #include <wx/tooltip.h>
22 #include <wx/datetime.h>
23 
24 // NB: Do *NOT * remove this.
25 #if defined(SWIG) || defined(SWIG_TYPE_TABLE)
26     #if !defined(__WXPYTHON__) && !defined(__NOTWXPYTHON__)
27         #define __WXPYTHON__
28     #endif
29 #endif
30 
31 //
32 // In case DOXYGEN was not specified (should be, but just in case)
33 #if !defined(DOXYGEN) && !defined(_WX_WINDOW_H_BASE_) && !defined(SWIG)
34     #define DOXYGEN
35 #endif
36 
37 #if defined(SWIG) || defined(DOXYGEN)
38     #define wxDEPRECATED(A) A
39 #endif
40 
41 
42 // Doxygen special includes
43 #ifdef DOXYGEN
44     #include "pg_dox_mainpage.h"
45     #include "propdev.h"
46 #endif
47 
48 
49 //
50 // Need to define some things for DOXYGEN
51 #ifdef DOXYGEN
52     #define wxUSE_VALIDATORS        1
53     #define wxUSE_DATETIME          1
54     #define wxUSE_TOOLTIPS          1
55     #define wxUSE_SPINBTN           1
56     #define wxUSE_DATEPICKCTRL      1
57     #define wxPG_COMPATIBILITY_1_2_0    0
58 #endif
59 
60 
61 //
62 // Check that some wxUSE_FOOs exist
63 // (we don't care if they are 1 or 0, just that they exist)
64 #ifndef wxUSE_VALIDATORS
65     #error "wxUSE_VALIDATORS not defined"
66 #endif
67 
68 #ifndef wxUSE_DATETIME
69     #error "wxUSE_DATETIME not defined"
70 #endif
71 
72 #ifndef wxUSE_DATEPICKCTRL
73     #error "wxUSE_DATEPICKCTRL not defined"
74 #endif
75 
76 
77 #if defined(__WXPYTHON__)
78     #include <Python.h>
79 #endif
80 
81 // Defines for component version.
82 // The following symbols should be updated for each new component release
83 // since some kind of tests, like those of AM_WXCODE_CHECKFOR_COMPONENT_VERSION()
84 // for "configure" scripts under unix, use them.
85 #define wxPROPGRID_MAJOR          1
86 #define wxPROPGRID_MINOR          4
87 #define wxPROPGRID_RELEASE        16
88 
89 // For non-Unix systems (i.e. when building without a configure script),
90 // users of this component can use the following macro to check if the
91 // current version is at least major.minor.release
92 #define wxCHECK_PROPGRID_VERSION(major,minor,release) \
93     (wxPROPGRID_MAJOR > (major) || \
94     (wxPROPGRID_MAJOR == (major) && wxPROPGRID_MINOR > (minor)) || \
95     (wxPROPGRID_MAJOR == (major) && wxPROPGRID_MINOR == (minor) && wxPROPGRID_RELEASE >= (release)))
96 
97 
98 // -----------------------------------------------------------------------
99 
100 
101 //
102 // Here are some platform dependent defines
103 // NOTE: More in propertygrid.cpp
104 //
105 
106 #ifndef SWIG
107 
108 #if defined(__WXMSW__)
109     // tested
110 
111     #define wxPG_XBEFORETEXT            4 // space between vertical line and value text
112     #define wxPG_XBEFOREWIDGET          1 // space between vertical line and value editor control
113 
114     #define wxPG_TEXTCTRLXADJUST        3 // x position adjustment for wxTextCtrl (and like)
115 
116     #define wxPG_ICON_WIDTH             9 // comment to use bitmap buttons
117     #define wxPG_USE_RENDERER_NATIVE    0 // 1 if wxRendererNative should be employed
118 
119     #define wxPG_DOUBLE_BUFFER          1 // 1 to use double-buffer that guarantees flicker-free painting
120 
121     #define wxPG_SUPPORT_TOOLTIPS       1  // Enable tooltips
122 
123 #elif defined(__WXGTK__)
124     // tested
125 
126     #define wxPG_XBEFORETEXT            5 // space between vertical line and value text
127     #define wxPG_XBEFOREWIDGET          1 // space between vertical line and value editor control
128 
129     #define wxPG_TEXTCTRLXADJUST        3 // x position adjustment for wxTextCtrl (and like)
130 
131     #define wxPG_ICON_WIDTH             9 // comment to use bitmap buttons
132     #define wxPG_USE_RENDERER_NATIVE    0 // 1 if wxRendererNative should be employed
133 
134     #define wxPG_DOUBLE_BUFFER          1 // 1 to use double-buffer that guarantees flicker-free painting
135 
136     #define wxPG_SUPPORT_TOOLTIPS       1  // Enable tooltips
137 
138 #elif defined(__WXMAC__)
139     // *not* tested
140 
141     #define wxPG_XBEFORETEXT            4 // space between vertical line and value text
142     #define wxPG_XBEFOREWIDGET          1 // space between vertical line and value editor widget
143 
144     #define wxPG_TEXTCTRLXADJUST        3 // x position adjustment for wxTextCtrl (and like)
145 
146     #define wxPG_ICON_WIDTH             11  // comment to use bitmap buttons
147     #define wxPG_USE_RENDERER_NATIVE    1 // 1 if wxRendererNative should be employed
148 
149     #define wxPG_DOUBLE_BUFFER          0 // 1 to use double-buffer that guarantees flicker-free painting
150 
151     #define wxPG_SUPPORT_TOOLTIPS       1  // Enable tooltips
152 
153 #else
154     // defaults
155     // tested on: none.
156 
157     #define wxPG_XBEFORETEXT            5 // space between vertical line and value text
158     #define wxPG_XBEFOREWIDGET          1 // space between vertical line and value editor widget
159 
160     #define wxPG_TEXTCTRLXADJUST        3 // x position adjustment for wxTextCtrl (and like)
161 
162     #define wxPG_ICON_WIDTH             9 // comment to use bitmap buttons
163     #define wxPG_USE_RENDERER_NATIVE    0 // 1 if wxRendererNative should be employed
164 
165     #define wxPG_DOUBLE_BUFFER          0 // 1 to use double-buffer that guarantees flicker-free painting
166 
167     #define wxPG_SUPPORT_TOOLTIPS       0  // Enable tooltips
168 
169 #endif // #if defined(__WXMSW__)
170 
171 
172 #define wxPG_CONTROL_MARGIN             0 // space between splitter and control
173 
174 #define wxCC_CUSTOM_IMAGE_MARGIN1            4  // before image
175 #define wxCC_CUSTOM_IMAGE_MARGIN2            5  // after image
176 
177 // Use this macro to generate standard custom image height from
178 #define wxPG_STD_CUST_IMAGE_HEIGHT(LINEHEIGHT)  (LINEHEIGHT-3)
179 
180 
181 #if defined(__WXWINCE__)
182     #define wxPG_SMALL_SCREEN       1
183     #undef wxPG_DOUBLE_BUFFER
184     #define wxPG_DOUBLE_BUFFER      0
185 #else
186     #define wxPG_SMALL_SCREEN       0
187 #endif
188 
189 #endif // #ifndef SWIG
190 
191 // Undefine wxPG_ICON_WIDTH to use supplied xpm bitmaps instead
192 // (for tree buttons)
193 //#undef wxPG_ICON_WIDTH
194 
195 // Need to force disable tooltips?
196 #if !wxUSE_TOOLTIPS
197     #undef wxPG_SUPPORT_TOOLTIPS
198     #define wxPG_SUPPORT_TOOLTIPS       0
199 #endif
200 
201 // Set 1 to include advanced properties (wxFontProperty, wxColourProperty, etc.)
202 #ifndef wxPG_INCLUDE_ADVPROPS
203     #define wxPG_INCLUDE_ADVPROPS           1
204 #endif
205 
206 // Set 1 include wxPropertyGridManager
207 #ifndef wxPG_INCLUDE_MANAGER
208     #define wxPG_INCLUDE_MANAGER            1
209 #endif
210 
211 // Set 1 to include checkbox editor class
212 #define wxPG_INCLUDE_CHECKBOX           1
213 
214 // Set to 1 to use native STL constructs as much as possible
215 #ifndef wxPG_USE_STL
216     #define wxPG_USE_STL    wxUSE_STL
217 #endif
218 
219 #ifndef wxPG_USING_WXOWNERDRAWNCOMBOBOX
220     #define wxPG_USING_WXOWNERDRAWNCOMBOBOX 1
221 #endif
222 
223 #if wxPG_USING_WXOWNERDRAWNCOMBOBOX
224     #define wxPGComboCtrl                   wxComboCtrl
225     #define wxPGOwnerDrawnComboBox          wxOwnerDrawnComboBox
226     #define wxPGCC_DCLICK_CYCLES            wxCC_SPECIAL_DCLICK
227     #define wxPGCC_PAINTING_CONTROL         wxODCB_PAINTING_CONTROL
228     #define wxPGCC_PAINTING_SELECTED        wxODCB_PAINTING_SELECTED
229     #define wxPGCC_PROCESS_ENTER            wxTE_PROCESS_ENTER
230     #define wxPGCC_ALT_KEYS                 0
231 #else
232     #define wxPGComboCtrl                   wxPGComboControl
233 #endif
234 
235 #define wxPGRectContains    Contains
236 
237 #define wxPGIndex           unsigned int
238 
239 #ifdef __WXMSW__
240   #if wxCHECK_VERSION(3, 0, 0)
241     #define wxPG_GetHDCOf(DC) ((HDC)((const wxMSWDCImpl *)DC.GetImpl())->GetHDC())
242   #else
243     #define wxPG_GetHDCOf(DC) ((HDC)DC.GetHDC())
244   #endif
245 #endif
246 
247 #define wxGDI_IS_OK(OBJ) ((OBJ).IsOk())
248 
249 // -----------------------------------------------------------------------
250 
251 #ifndef wxPG_COMPATIBILITY_1_2_0
252     #define wxPG_COMPATIBILITY_1_2_0    0
253 #endif
254 
255 
256 #if wxPG_COMPATIBILITY_1_2_0
257 
258     // Legacy wxPropertyGrid version macro
259     #define wxPG_VERSION            ((wxPROPGRID_MAJOR*1000)+(wxPROPGRID_MINOR*100)+(wxPROPGRID_RELEASE*10))
260 
261 #endif
262 
263 
264 #ifdef wxPG_COMPATIBILITY_1_0_0
265 
266     #define wxRECURSE               wxPG_RECURSE
267     #define wxKEEP_STRUCTURE        wxPG_KEEP_STRUCTURE
268     #define wxPGConstants           wxPGChoices
269     #define wxPG_EX_CLASSIC_SPACING 0
270 
271     #define wxPGCtrlClass           wxWindow
272     #define wxCCustomTextCtrl       wxTextCtrl
273     #define wxCCustomComboBox       wxPGOwnerDrawnComboBox
274     #define wxCCustomButton         wxButton
275 
276 #endif // #ifdef wxPG_COMPATIBILITY_1_0_0
277 
278 #ifdef __WXPYTHON__
279     #define wxPG_VALUETYPE_IS_STRING    0  // 1
280 #else
281     #define wxPG_VALUETYPE_IS_STRING    0
282 #endif
283 
284 #ifndef SWIG
285     #if !wxCHECK_VERSION(3, 0, 0)
286         #if !defined(wxUniChar)
287             #define wxUniChar   wxChar
288         #endif
289         //#define wxPGGetIterChar(str, i)  str[i]
290         #define wxPGGetIterChar(str, i)  *i
291     #else
292         #define wxPGGetIterChar(str, i)  *i
293     #endif
294 #endif
295 
296 #if wxPG_COMPATIBILITY_1_2_0
297     #define wxPGRegisterPropertyClass(A)
298 #endif
299 
300 // -----------------------------------------------------------------------
301 
302 //
303 // wxPython special considerations
304 //
305 // TODO: Using const yields some ugly function
306 //   names, so might as well make those GetPropertyValueAsXXX non-static
307 //   for regular C++ build as well.s
308 //
309 
310 #ifndef __WXPYTHON__
311 
312 // Some Strings are returned as const wxChar* in C++, and as wxString in wxPython
313 // (using just wxString for everything would've been better, but the current scheme
314 // is necessary for better backwards compatibility).
315 #define wxPG_CONST_WXCHAR_PTR       const wxChar*
316 #define wxPG_CONST_WXCHAR_DEFVAL    ((const wxChar*)NULL)
317 #define wxPG_TO_WXCHAR_PTR(A)       A
318 
319 // In C++ we can stick with overloaded methods
320 #define SetPropertyValueLong        SetPropertyValue
321 #define SetPropertyValueDouble      SetPropertyValue
322 #define SetPropertyValueBool        SetPropertyValue
323 #define SetPropertyValueString      SetPropertyValue
324 #define SetPropertyValueWxObjectPtr SetPropertyValue
325 #define SetPropertyValuePoint       SetPropertyValue
326 #define SetPropertyValueSize        SetPropertyValue
327 #define SetPropertyValueArrint2     SetPropertyValue
328 #define SetPropertyValueArrstr2     SetPropertyValue
329 #define SetPropertyValueDatetime    SetPropertyValue
330 #define SetPropertyValueLongLong    SetPropertyValue
331 #define SetPropertyValueULongLong   SetPropertyValue
332 
333 #define WX_PG_NOT_PURE_IN_WXPYTHON  =0
334 
335 #else
336 
337 // Some Strings are returned as const wxChar* in C++, and as wxString in wxPython
338 // (using just wxString for everything would've been better, but the current scheme
339 // is necessary for better backwards compatibility).
340 #define wxPG_CONST_WXCHAR_PTR       wxString
341 #define wxPG_CONST_WXCHAR_DEFVAL    wxEmptyString
342 #define wxPG_TO_WXCHAR_PTR(A)       A  //(A.c_str())
343 
344 // Because SWIG has problems combining overloaded functions and
345 // Python object-to-wxXXX conversion, we need to use Python proxy
346 // functions for these value setters.
347 #define SetPropertyValueArrstr2     _SetPropertyValueArrstr
348 #define SetPropertyValueArrint2     _SetPropertyValueArrint
349 
350 //
351 // wxPGVariantAndBool
352 //
353 // Helper class that wraps wxVariant and bool. Need to use this class
354 // instead of writeback arguments in some virtual methods of custom
355 // property classes.
356 //
357 // WXDLLIMPEXP_PG
358 class wxPGVariantAndBool
359 {
360 public:
361 
wxPGVariantAndBool()362     wxPGVariantAndBool()
363     {
364         m_valueValid = false;
365         m_result = false;
366     }
367 
wxPGVariantAndBool(bool result,const wxVariant & variant)368     wxPGVariantAndBool( bool result, const wxVariant& variant )
369     {
370         m_valueValid = true;
371         m_result = result;
372         m_value = variant;
373     }
374 
wxPGVariantAndBool(const wxVariant & variant)375     wxPGVariantAndBool( const wxVariant& variant )
376     {
377         m_valueValid = true;
378         m_result = true;
379         m_value = variant;
380     }
381 
wxPGVariantAndBool(bool result)382     wxPGVariantAndBool( bool result )
383     {
384         Init(result);
385     }
386 
~wxPGVariantAndBool()387     ~wxPGVariantAndBool() { }
388 
389     void Init( bool result = false )
390     {
391         m_valueValid = false;
392         m_result = result;
393     }
394 
GetValue()395     const wxVariant& GetValue() const
396     {
397         wxASSERT(m_valueValid);
398         return m_value;
399     }
400 
401 public:
402     wxVariant m_value;
403     bool      m_valueValid;
404     bool      m_result;
405 };
406 
407 #define WX_PG_NOT_PURE_IN_WXPYTHON
408 
409 #endif
410 
411 
412 #define wxPG_NO_DECL
413 
414 #ifndef wxEMPTY_PARAMETER_VALUE
415     #define wxEMPTY_PARAMETER_VALUE
416 #endif
417 
418 // -----------------------------------------------------------------------
419 // C::B patch: define DLLIMPORT to be used to define WXDLLIMPEXP_PG later.
420 #if defined(__WXMSW__)
421     #ifndef DLLIMPORT_PG
422         #if EXPORT_LIB
423             #define DLLIMPORT_PG __declspec (dllexport)
424         #else
425             #define DLLIMPORT_PG __declspec (dllimport)
426         #endif // EXPORT_LIB
427     #endif // DLLIMPORT_PG
428 #else
429     #ifndef DLLIMPORT_PG
430         #define DLLIMPORT_PG __attribute__ ((visibility ("default")))
431     #endif // DLLIMPORT_PG
432 #endif
433 
434 #define WXDLLIMPEXP_PG DLLIMPORT_PG
435 // C::B patch: Add define of WXDLLIMPEXP_PG_FWD to reduce warnings
436 #define WXDLLIMPEXP_PG_FWD
437 
438 // C::B patch: Disable the orignal way to define WXDLLIMPEXP_PG
439 /*
440 #ifdef WXMAKINGLIB_PROPGRID
441     #define WXDLLIMPEXP_PG
442 #elif defined(WXMAKINGDLL_PROPGRID)
443     #define WXDLLIMPEXP_PG WXEXPORT
444 #elif defined(WXUSINGDLL)
445     #define WXDLLIMPEXP_PG WXIMPORT
446 #else // not making nor using DLL
447     #define WXDLLIMPEXP_PG wxEMPTY_PARAMETER_VALUE
448 #endif
449 */
450 
451 // -----------------------------------------------------------------------
452 
453 #ifndef SWIG
454 
455 class WXDLLIMPEXP_PG wxPGEditor;
456 class WXDLLIMPEXP_PG wxPGProperty;
457 class WXDLLIMPEXP_PG wxPropertyCategory;
458 class WXDLLIMPEXP_PG wxPGChoices;
459 class WXDLLIMPEXP_PG wxPropertyGridState;
460 class WXDLLIMPEXP_PG wxPGCell;
461 class WXDLLIMPEXP_PG wxPGChoiceEntry;
462 class WXDLLIMPEXP_PG wxPropertyGridInterface;
463 class WXDLLIMPEXP_PG wxPropertyGrid;
464 class WXDLLIMPEXP_PG wxPropertyGridEvent;
465 class WXDLLIMPEXP_PG wxPropertyGridManager;
466 class WXDLLIMPEXP_PG wxPGOwnerDrawnComboBox;
467 class WXDLLIMPEXP_PG wxPGCustomComboControl;
468 class WXDLLIMPEXP_PG wxPGEditorDialogAdapter;
469 
470 class WXDLLIMPEXP_FWD_CORE wxStatusBar;
471 
472 extern WXDLLIMPEXP_PG const wxChar *wxPropertyGridNameStr;
473 
474 struct WXDLLIMPEXP_PG wxPGValidationInfo;
475 
476 #endif // #ifndef SWIG
477 
478 
479 #ifdef __WXPYTHON__
480     class wxPGPyEditor;
481 #endif // #ifndef __WXPYTHON__
482 
483 
484 /** @class wxPGPaintData
485     @ingroup classes
486     @brief Contains information relayed to property's OnCustomPaint.
487 */
488 struct wxPGPaintData
489 {
490     /** wxPropertyGrid. */
491     const wxPropertyGrid*   m_parent;
492 
493     /** Normally -1, otherwise index to drop-down list item that has to be drawn. */
494     int                     m_choiceItem;
495 
496     /** Set to drawn width in OnCustomPaint (optional). */
497     int                     m_drawnWidth;
498 
499     /** In a measure item call, set this to the height of item at m_choiceItem index. */
500     int                     m_drawnHeight;
501 };
502 
503 
504 #ifndef SWIG
505 
506 /** @class wxPGCellRenderer
507     @ingroup classes
508     @brief
509     Base class for wxPropertyGrid cell renderers.
510 */
511 class WXDLLIMPEXP_PG wxPGCellRenderer
512 {
513 public:
514 
515     wxPGCellRenderer( unsigned int refCount = 1 )
m_refCount(refCount)516         : m_refCount(refCount) { }
~wxPGCellRenderer()517     virtual ~wxPGCellRenderer() { }
518 
519     // Render flags
520     enum
521     {
522         Selected        = 0x00010000,
523         Control         = 0x00020000
524     };
525 
526     virtual void Render( wxDC& dc,
527                          const wxRect& rect,
528                          const wxPropertyGrid* propertyGrid,
529                          wxPGProperty* property,
530                          int column,
531                          int item,
532                          int flags ) const = 0;
533 
534     /** Returns size of the image in front of the editable area.
535         @remarks
536         If property is NULL, then this call is for a custom value. In that case
537         the item is index to wxPropertyGrid's custom values.
538     */
539     virtual wxSize GetImageSize( const wxPGProperty* property,
540                                  int column,
541                                  int item ) const;
542 
543     /** Paints property category selection rectangle.
544     */
545     virtual void DrawCaptionSelectionRect( wxDC& dc, int x, int y, int w, int h ) const;
546 
547     /** Utility to draw vertically centered text.
548     */
549     void DrawText( wxDC& dc,
550                    const wxRect& rect,
551                    int imageWidth,
552                    const wxString& text ) const;
553 
554     /** Utility to draw editor's value, or vertically aligned text if editor is NULL.
555     */
556     void DrawEditorValue( wxDC& dc, const wxRect& rect,
557                           int xOffset, const wxString& text,
558                           wxPGProperty* property,
559                           const wxPGEditor* editor ) const;
560 
561     /**
562         Utility to render cell bitmap and set text colour plus bg brush
563         colour.
564 
565         Returns image width that, for instance, can be passed to DrawText.
566     */
567     int PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell& cell,
568                      int flags ) const;
569 
570     /**
571         Utility to be called after drawing is done, to revert whatever
572         changes PreDrawCell() did.
573 
574         @param flags
575             Same as those passed to PreDrawCell().
576     */
577     void PostDrawCell( wxDC& dc,
578                        const wxPropertyGrid* propGrid,
579                        const wxPGCell& cell,
580                        int flags ) const;
581 
IncRef()582     void IncRef()
583     {
584         m_refCount++;
585     }
586 
DecRef()587     void DecRef()
588     {
589         m_refCount--;
590         if ( !m_refCount )
591             delete this;
592     }
593 protected:
594 
595 private:
596     unsigned int    m_refCount;
597 };
598 
599 /** @class wxPGDefaultRenderer
600     @ingroup classes
601     @brief
602     Default cell renderer, that can handles the common
603     scenarios.
604 */
605 class WXDLLIMPEXP_PG wxPGDefaultRenderer : public wxPGCellRenderer
606 {
607 public:
608     void Render( wxDC& dc,
609                          const wxRect& rect,
610                          const wxPropertyGrid* propertyGrid,
611                          wxPGProperty* property,
612                          int column,
613                          int item,
614                          int flags ) const override;
615 
616     wxSize GetImageSize( const wxPGProperty* property,
617                                  int column,
618                                  int item ) const override;
619 
620 protected:
621 };
622 
623 #endif  // !SWIG
624 
625 /** @class wxPGCell
626     @ingroup classes
627     @brief
628     Base class for simple wxPropertyGrid cell information.
629 */
630 class WXDLLIMPEXP_PG wxPGCell
631 {
632 public:
633     wxPGCell();
634     wxPGCell( const wxString& text,
635               const wxBitmap& bitmap = wxNullBitmap,
636               const wxColour& fgCol = wxNullColour,
637               const wxColour& bgCol = wxNullColour );
638 
~wxPGCell()639     virtual ~wxPGCell() { }
640 
641     /**
642         Copies content of one wxPGCell to this.
643     */
644     void Assign(const wxPGCell& cell);
645 
646     /**
647         Returns @true if the cell has valid text.
648     */
649     bool HasText() const;
650 
SetText(const wxString & text)651     void SetText( const wxString& text ) { m_text = text; }
SetBitmap(const wxBitmap & bitmap)652     void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
SetFgCol(const wxColour & col)653     void SetFgCol( const wxColour& col ) { m_fgCol = col; }
SetBgCol(const wxColour & col)654     void SetBgCol( const wxColour& col ) { m_bgCol = col; }
SetFont(const wxFont & font)655     void SetFont( const wxFont& font ) { m_font = font; }
656 
GetText()657     const wxString& GetText() const { return m_text; }
GetBitmap()658     const wxBitmap& GetBitmap() const { return m_bitmap; }
GetFgCol()659     const wxColour& GetFgCol() const { return m_fgCol; }
GetBgCol()660     const wxColour& GetBgCol() const { return m_bgCol; }
GetFont()661     const wxFont& GetFont() const { return m_font; }
662 
663 protected:
664     wxString    m_text;
665     wxBitmap    m_bitmap;
666     wxColour    m_fgCol;
667     wxColour    m_bgCol;
668     wxFont      m_font;
669 };
670 
671 
672 /** @defgroup miscellaneous wxPropertyGrid Miscellanous
673     This section describes some miscellanous values, types and macros.
674     @{
675 */
676 
677 #define wxPG_EMPTY_ARRAYINT     wxArrayInt()
678 #define wxPG_EMPTY_ARRAYSTRING  wxArrayString()
679 
680 #if !defined(SWIG)
681     extern wxString WXDLLIMPEXP_PG wxString_wxPG_LABEL;
682     #define wxPG_LABEL              wxString_wxPG_LABEL
683     #define wxPG_NULL_BITMAP        wxNullBitmap
684     #define wxPG_COLOUR_BLACK       (*wxBLACK)
685 #else
686     #define wxPG_LABEL              wxString_wxPG_LABEL
687     #define wxPG_NULL_BITMAP        wxBitmap_NULL
688     #define wxPG_COLOUR_BLACK       wxColour_BLACK
689 #endif // #ifndef SWIG
690 
691 
692 // Used to indicate wxPGChoices::Add etc that the value is actually not given
693 // by the caller.
694 #define wxPG_INVALID_VALUE      INT_MAX
695 
696 
697 /** Convert Red, Green and Blue to a single 32-bit value.
698 */
699 #define wxPG_COLOUR(R,G,B) ((wxUint32)(R+(G<<8)+(B<<16)))
700 
701 
702 /** If property is supposed to have custom-painted image, then returning
703     this in OnMeasureImage() will usually be enough.
704 */
705 #define wxPG_DEFAULT_IMAGE_SIZE             wxSize(-1, -1)
706 
707 
708 /** This callback function is used by atleast wxCustomProperty
709     to facilitiate easy custom action on button press.
710     @param propGrid
711     related wxPropertyGrid
712     @param property
713     related wxPGProperty
714     @param ctrl
715     If not NULL (for example, not selected), a wxWindow* or equivalent
716     @param data
717     Value depends on the context.
718     @retval
719     True if changed value of the property.
720 */
721 typedef bool (*wxPropertyGridCallback)(wxPropertyGrid* propGrid,
722                                        wxPGProperty* property,
723                                        wxWindow* ctrl,
724                                        int data);
725 
726 /** This callback function is used by atleast wxCustomProperty
727     to facilitiate drawing items in drop down list.
728 
729     Works very much like the old wxPGProperty::OnCustomPaint.
730 */
731 typedef void (*wxPGPaintCallback)(wxPGProperty* property,
732                                   wxDC& dc,
733                                   const wxRect& rect,
734                                   wxPGPaintData& paintdata);
735 
736 /** This callback function is used for sorting properties.
737 
738     Call wxPropertyGrid::SetSortFunction() to set it.
739 
740     This function should return a value greater than 0 if position of p1 is
741     after p2. So, for instance, when comparing property names, you can use
742     following implementation:
743 
744         @code
745             int MyPropertySortFunction(wxPropertyGrid* propGrid,
746                                        wxPGProperty* p1,
747                                        wxPGProperty* p2)
748             {
749                 return p1->GetBaseName().compare( p2->GetBaseName() );
750             }
751         @endcode
752 */
753 typedef int (*wxPGSortCallback)(wxPropertyGrid* propGrid,
754                                 wxPGProperty* p1,
755                                 wxPGProperty* p2);
756 
757 
758 /** Use this with wxPropertyGrid::IsPropertyKindOf. For example, as in
759     @code
760         pg->IsPropertyKindOf(WX_PG_CLASSINFO(wxStringProperty))
761     @endcode
762 */
763 #define WX_PG_CLASSINFO(NAME) (&NAME::ms_classInfo)
764 
765 
766 typedef wxString wxPGCachedString;
767 
768 /** @}
769 */
770 
771 // -----------------------------------------------------------------------
772 
773 /** @defgroup wndflags wxPropertyGrid Window Styles
774     SetWindowStyleFlag method can be used to modify some of these at run-time.
775     @{
776 */
777 enum wxPG_WINDOW_STYLES
778 {
779 
780 /** This will cause Sort() automatically after an item is added.
781     When inserting a lot of items in this mode, it may make sense to
782     use Freeze() before operations and Thaw() afterwards to increase
783     performance.
784 */
785 wxPG_AUTO_SORT                      = 0x00000010,
786 
787 /** Categories are not initially shown (even if added).
788     IMPORTANT NOTE: If you do not plan to use categories, then this
789     style will waste resources.
790     This flag can also be changed using wxPropertyGrid::EnableCategories method.
791 */
792 wxPG_HIDE_CATEGORIES                = 0x00000020,
793 
794 /* This style combines non-categoric mode and automatic sorting.
795 */
796 wxPG_ALPHABETIC_MODE                = (wxPG_HIDE_CATEGORIES|wxPG_AUTO_SORT),
797 
798 /** Modified values are shown in bold font. Changing this requires Refresh()
799     to show changes.
800 */
801 wxPG_BOLD_MODIFIED                  = 0x00000040,
802 
803 /** Using this style, the column splitters move automatically based on column
804     proportions (default is equal proportion for every column). This behavior
805     stops once the user manually moves a splitter, and returns when a
806     splitter is double-clicked.
807 
808     @see wxPropertyGridInterface::SetColumnProportion().
809 */
810 wxPG_SPLITTER_AUTO_CENTER           = 0x00000080,
811 
812 /** Display tooltips for cell text that cannot be shown completely. If
813     wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
814 */
815 wxPG_TOOLTIPS                       = 0x00000100,
816 
817 /** Disables margin and hides all expand/collapse buttons that would appear
818     outside the margin (for sub-properties). Toggling this style automatically
819     expands all collapsed items.
820 */
821 wxPG_HIDE_MARGIN                    = 0x00000200,
822 
823 /** This style prevents user from moving the splitter.
824 */
825 wxPG_STATIC_SPLITTER                = 0x00000400,
826 
827 /** Combination of other styles that make it impossible for user to modify
828     the layout.
829 */
830 wxPG_STATIC_LAYOUT                  = (wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER),
831 
832 /** Disables wxTextCtrl based editors for properties which
833     can be edited in another way. Equals calling wxPropertyGrid::LimitPropertyEditing
834     for all added properties.
835 */
836 wxPG_LIMITED_EDITING                = 0x00000800,
837 
838 #ifdef DOXYGEN
839 
840 /** <b>NOTE:</b> This feature works very poorly and should be avoided.
841 
842     wxTAB_TRAVERSAL allows using Tab/Shift-Tab to travel between properties
843     in grid. Travelling forwards from last property will navigate to the
844     next control, and backwards from first will navigate to the previous one.
845 */
846 wxTAB_TRAVERSAL                     = 0x00080000,
847 
848 #endif
849 
850 /** wxPropertyGridManager only: Show toolbar for mode and page selection. */
851 wxPG_TOOLBAR                        = 0x00001000,
852 
853 /** wxPropertyGridManager only: Show adjustable text box showing description
854     or help text, if available, for currently selected property.
855 */
856 wxPG_DESCRIPTION                    = 0x00002000,
857 
858 /** wxPropertyGridManager only: Use an alternative and usually more better
859     looking thematic border around the embedded property grid.
860 */
861 wxPG_THEME_BORDER                   = 0x00004000,
862 
863 /** wxPropertyGridManager only: Don't show an internal border around the
864     property grid
865 */
866 wxPG_NO_INTERNAL_BORDER             = 0x00008000
867 
868 };
869 
870 enum wxPG_EX_WINDOW_STYLES
871 {
872 
873 /**
874     NOTE: wxPG_EX_xxx are extra window styles and must be set using SetExtraStyle()
875     member function.
876 
877     Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if wxPG_HIDE_CATEGORIES
878     is not defined, the non-categorized data storage is not activated, and switching
879     the mode first time becomes somewhat slower. wxPG_EX_INIT_NOCAT activates the
880     non-categorized data storage right away. IMPORTANT NOTE: If you do plan not
881     switching to non-categoric mode, or if you don't plan to use categories at
882     all, then using this style will result in waste of resources.
883 
884 */
885 wxPG_EX_INIT_NOCAT                  = 0x00001000,
886 
887 /** Extended window style that sets wxPropertyGridManager toolbar to not
888     use flat style.
889 */
890 wxPG_EX_NO_FLAT_TOOLBAR             = 0x00002000,
891 
892 /** Shows alphabetic/categoric mode buttons from toolbar.
893 */
894 wxPG_EX_MODE_BUTTONS                = 0x00008000,
895 
896 /** Show property help strings as tool tips instead as text on the status bar.
897     You can set the help strings using SetPropertyHelpString member function.
898 */
899 wxPG_EX_HELP_AS_TOOLTIPS            = 0x00010000,
900 
901 /** Prevent TAB from focusing to wxButtons. This behavior was default
902     in version 1.2.0 and earlier.
903     NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
904       atleast the button doesn't properly propagate key events (yes, I'm using
905       wxWANTS_CHARS).
906 */
907 //wxPG_EX_NO_TAB_TO_BUTTON            = 0x00020000,
908 
909 #if wxPG_COMPATIBILITY_1_2_0
910 /* No longer used, defined for compatibility.
911 */
912 wxPG_EX_GREY_LABEL_WHEN_DISABLED        = 0x00000000,
913 #endif
914 
915 /** Allows relying on native double-buffering.
916 */
917 wxPG_EX_NATIVE_DOUBLE_BUFFERING         = 0x00080000,
918 
919 #if wxPG_COMPATIBILITY_1_2_0
920 /** Since all events are now automatically processed immediately, this
921     flag is zero and only provided for backwards compatibility.
922 */
923 wxPG_EX_PROCESS_EVENTS_IMMEDIATELY      = 0x00000000,
924 #endif
925 
926 /** Set this style to let user have ability to set values of properties to
927     unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
928     all properties.
929 */
930 wxPG_EX_AUTO_UNSPECIFIED_VALUES         = 0x00200000,
931 
932 /** If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION and wxPG_STRING_PASSWORD)
933     are not stored into property's attribute storage (thus they are not readable).
934 
935     Note that this option is global, and applies to all wxPG property containers.
936 */
937 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES    = 0x00400000,
938 
939 #if wxPG_COMPATIBILITY_1_2_0
940 /** With this tyle Validators on properties will work basicly work just they
941     work in wxWidgets.
942 
943     @deprecated
944     Since version 1.3. This behavior is automatic now.
945 */
946 wxPG_EX_TRADITIONAL_VALIDATORS          = 0x00000000,
947 #endif
948 
949 /** With this style Validators on properties will work same as in wxPropertyGrid 1.2.
950 */
951 wxPG_EX_LEGACY_VALIDATORS               = 0x00800000,
952 
953 /** Hides page selection buttons from toolbar.
954 */
955 wxPG_EX_HIDE_PAGE_BUTTONS               = 0x01000000,
956 
957 /** Unfocuses text editor after enter has been pressed.
958 */
959 wxPG_EX_UNFOCUS_ON_ENTER                = 0x02000000,
960 
961 /** Allows multiple properties to be selected by user (by pressing SHIFT
962     when clicking on a property, or by dragging with left mouse button
963     down).
964 
965     You can get array of selected properties with
966     wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
967     mode wxPropertyGridInterface::GetSelection() returns
968     property which has editor active (usually the first one
969     selected). Other useful member functions are ClearSelection(),
970     AddToSelection() and RemoveFromSelection().
971 */
972 wxPG_EX_MULTIPLE_SELECTION              = 0x04000000,
973 
974 /**
975     This disables top-level window tracking which may cause crashes when
976     wxProperyGrid is used with wxAUI or similar GUI system. Note that
977     this style will be on by default in wxWidgets 2.9.1 and later.
978 
979     Advantage of top-level window tracking is that wxPropertyGrid is
980     able to notify the application of last-minute property value
981     changes by user.
982 */
983 wxPG_EX_DISABLE_TLP_TRACKING            = 0x08000000,
984 
985 /** wxPropertyGridManager only: Don't show divider above toolbar, on Windows
986 */
987 wxPG_EX_NO_TOOLBAR_DIVIDER              = 0x10000000,
988 
989 /** NOTE: This style may be removed in future versions - do not rely on it!
990 
991     wxPropertyGridManager only: Show a separator below the toolbar
992 */
993 wxPG_EX_TOOLBAR_SEPARATOR               = 0x20000000
994 
995 };
996 
997 /**
998     For compatibility with wxWidgets 2.9.
999 */
1000 #define wxPG_EX_ENABLE_TLP_TRACKING     0x00000000
1001 
1002 
1003 /** Combines various styles.
1004 */
1005 #define wxPG_DEFAULT_STYLE	        (0)
1006 
1007 /** Combines various styles.
1008 */
1009 #define wxPGMAN_DEFAULT_STYLE	    (0)
1010 
1011 /** @}
1012 */
1013 
1014 enum wxPG_GETPROPERTYVALUES_FLAGS
1015 {
1016 
1017 /** Flags for wxPropertyGridInterface::GetPropertyValues */
1018 wxPG_KEEP_STRUCTURE               = 0x00000010,
1019 
1020 /** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
1021 wxPG_RECURSE                      = 0x00000020,
1022 
1023 /** Include attributes for GetPropertyValues. */
1024 wxPG_INC_ATTRIBUTES               = 0x00000040,
1025 
1026 /** Used when first starting recursion. */
1027 wxPG_RECURSE_STARTS               = 0x00000080,
1028 
1029 /** Force value change. */
1030 wxPG_FORCE                        = 0x00000100
1031 
1032 };
1033 
1034 /** Flags for wxPropertyGrid::SetPropertyAttribute() etc */
1035 #define wxPG_DONT_RECURSE         0x00000000
1036 
1037 // -----------------------------------------------------------------------
1038 
1039 // Misc argument flags.
1040 enum wxPG_MISC_ARG_FLAGS
1041 {
1042 
1043 wxPG_FULL_VALUE                     = 0x00000001,  // Get/Store full value instead of displayed value.
1044 
1045 wxPG_REPORT_ERROR                   = 0x00000002,
1046 
1047 wxPG_PROPERTY_SPECIFIC              = 0x00000004,
1048 
1049 wxPG_EDITABLE_VALUE                 = 0x00000008,  // Get/Store editable value instead of displayed one
1050                                               // (should only be different in the case of common values)
1051 
1052 wxPG_COMPOSITE_FRAGMENT             = 0x00000010,  // Used when dealing with fragments of composite string value
1053 
1054 wxPG_UNEDITABLE_COMPOSITE_FRAGMENT  = 0x00000020,  // Means property for which final string value is for can not
1055                                                    // really be edited.
1056 
1057 wxPG_PROGRAMMATIC_VALUE             = 0x00000040   // Value is being set programmatically (ie. not by user)
1058 };
1059 
1060 
1061 // -----------------------------------------------------------------------
1062 
1063 // wxPGProperty::SetValue() flags
1064 enum wxPG_SETVALUE_FLAGS
1065 {
1066 wxPG_SETVAL_REFRESH_EDITOR      = 0x0001,
1067 wxPG_SETVAL_AGGREGATED          = 0x0002,
1068 wxPG_SETVAL_FROM_PARENT         = 0x0004,
1069 wxPG_SETVAL_BY_USER             = 0x0008  // Set if value changed by user
1070 };
1071 
1072 // -----------------------------------------------------------------------
1073 
1074 
1075 #define wxNullProperty  ((wxPGProperty*)NULL)
1076 
1077 #if wxPG_COMPATIBILITY_1_2_0
wxPGIdIsOk(wxPGProperty * id)1078 inline bool wxPGIdIsOk(wxPGProperty* id)
1079 {
1080     return (id != NULL) ? true : false;
1081 }
1082 #endif
1083 
1084 typedef wxPGProperty* wxPGId;
1085 
1086 #ifndef SWIG
1087 
1088 /** @class wxPGPropArgCls
1089     @ingroup classes
1090     @brief
1091     Most property grid functions have this type as their argument, as it can
1092     convey a property by either a pointer or name.
1093 */
1094 class WXDLLIMPEXP_PG wxPGPropArgCls
1095 {
1096 public:
wxPGPropArgCls()1097     wxPGPropArgCls() { }
wxPGPropArgCls(const wxPGProperty * property)1098     wxPGPropArgCls( const wxPGProperty* property )
1099     {
1100         m_ptr.property = (wxPGProperty*) property;
1101         m_isName = false;
1102     }
wxPGPropArgCls(const wxString & str)1103     wxPGPropArgCls( const wxString& str )
1104     {
1105         m_ptr.name = &str;
1106         m_isName = 1;
1107     }
wxPGPropArgCls(const wxPGPropArgCls & id)1108     wxPGPropArgCls( const wxPGPropArgCls& id )
1109     {
1110         m_ptr = id.m_ptr;
1111         m_isName = id.m_isName;
1112     }
1113 #ifdef __WXPYTHON__
wxPGPropArgCls(wxString * str,bool WXUNUSED (deallocPtr))1114     wxPGPropArgCls( wxString* str, bool WXUNUSED(deallocPtr) )
1115     {
1116         m_ptr.name = str;
1117         m_isName = 3;
1118     }
~wxPGPropArgCls()1119     ~wxPGPropArgCls()
1120     {
1121         if ( m_isName == 3 )
1122             delete m_ptr.name;
1123     }
1124 #endif
GetPtr()1125     wxPGProperty* GetPtr() const { wxCHECK( !m_isName, NULL ); return m_ptr.property; }
wxPGPropArgCls(const wxChar * str)1126     wxPGPropArgCls( const wxChar* str )
1127     {
1128         m_ptr.rawname = str;
1129         m_isName = 2;
1130     }
1131     /** This constructor is required for NULL. */
wxPGPropArgCls(int)1132     wxPGPropArgCls( int )
1133     {
1134         m_ptr.property = (wxPGProperty*) NULL;
1135         m_isName = false;
1136     }
1137     wxPGProperty* GetPtr( wxPropertyGridInterface* methods ) const;
GetPtr(const wxPropertyGridInterface * methods)1138     wxPGProperty* GetPtr( const wxPropertyGridInterface* methods ) const
1139     {
1140         return GetPtr((wxPropertyGridInterface*)methods);
1141     }
GetPtr0()1142     wxPGProperty* GetPtr0() const { return m_ptr.property; }
HasName()1143     unsigned char HasName() const { return m_isName; }
GetName()1144     const wxString& GetName() const { return *m_ptr.name; }
1145 private:
1146     union
1147     {
1148         wxPGProperty* property;
1149         const wxChar* rawname;
1150         const wxString* name;
1151     } m_ptr;
1152     unsigned char m_isName;
1153 };
1154 
1155 #else
1156 
1157 class WXDLLIMPEXP_PG wxPGPropArgCls;
1158 
1159 #endif
1160 
1161 typedef const wxPGPropArgCls& wxPGPropArg;
1162 
1163 // -----------------------------------------------------------------------
1164 
1165 WXDLLIMPEXP_PG void wxPGTypeOperationFailed( const wxPGProperty* p, const wxChar* typestr, const wxChar* op );
1166 WXDLLIMPEXP_PG void wxPGGetFailed( const wxPGProperty* p, const wxChar* typestr );
1167 
1168 // -----------------------------------------------------------------------
1169 
1170 /** @defgroup propflags wxPGProperty Flags
1171     @{
1172 */
1173 
1174 enum wxPGPropertyFlags
1175 {
1176 
1177 /** Indicates bold font.
1178 */
1179 wxPG_PROP_MODIFIED                  = 0x0001,
1180 
1181 /** Disables ('greyed' text and editor does not activate) property.
1182 */
1183 wxPG_PROP_DISABLED                  = 0x0002,
1184 
1185 /** Hider button will hide this property.
1186 */
1187 wxPG_PROP_HIDDEN                    = 0x0004,
1188 
1189 /** This property has custom paint image just in front of its value.
1190     If property only draws custom images into a popup list, then this
1191     flag should not be set.
1192 */
1193 wxPG_PROP_CUSTOMIMAGE               = 0x0008,
1194 
1195 /** Do not create text based editor for this property (but button-triggered
1196     dialog and choice are ok).
1197 */
1198 wxPG_PROP_NOEDITOR                  = 0x0010,
1199 
1200 /** Property is collapsed, ie. it's children are hidden.
1201 */
1202 wxPG_PROP_COLLAPSED                 = 0x0020,
1203 
1204 /** If property is selected, then indicates that validation failed for pending value.
1205 
1206     If property is not selected, then indicates that the the actual property
1207     value has failed validation (NB: this behavior is not currently supported,
1208     but may be used in future).
1209 */
1210 wxPG_PROP_INVALID_VALUE             = 0x0040,
1211 
1212 // 0x0080,
1213 
1214 /** Switched via SetWasModified(). Temporary flag - only used when
1215     setting/changing property value.
1216 */
1217 wxPG_PROP_WAS_MODIFIED              = 0x0200,
1218 
1219 /** If set, then child properties (if any) are private, and should be "invisible" to the
1220     application.
1221 */
1222 wxPG_PROP_AGGREGATE                 = 0x0400,
1223 
1224 /** If set, then child properties (if any) are copies and should not
1225     be deleted in dtor.
1226 */
1227 wxPG_PROP_CHILDREN_ARE_COPIES       = 0x0800,
1228 
1229 /** Classifies this item as a non-category. Used for faster item type identification.
1230 */
1231 wxPG_PROP_PROPERTY                  = 0x1000,
1232 
1233 /** Classifies this item as a category. Used for faster item type identification.
1234 */
1235 wxPG_PROP_CATEGORY                  = 0x2000,
1236 
1237 /** Classifies this item as a property that has children, but is not aggregate
1238     (ie. children are not private).
1239 */
1240 wxPG_PROP_MISC_PARENT               = 0x4000,
1241 
1242 /** Property is read-only. Editor is still created for wxTextCtrl-based
1243     property editors. For others, editor is not usually created because
1244     they do implement wxTE_READONLY style or equivalent.
1245 */
1246 wxPG_PROP_READONLY                  = 0x8000,
1247 
1248 //
1249 // NB: FLAGS ABOVE 0x8000 CANNOT BE USED WITH PROPERTY ITERATORS
1250 //
1251 
1252 /** Property's value is composed from values of child properties.
1253     @remarks
1254     This flag cannot be used with property iterators.
1255 */
1256 wxPG_PROP_COMPOSED_VALUE            = 0x00010000,
1257 
1258 /** Common value of property is selectable in editor.
1259     @remarks
1260     This flag cannot be used with property iterators.
1261 */
1262 wxPG_PROP_USES_COMMON_VALUE         = 0x00020000,
1263 
1264 /** Property can be set to unspecified value via editor.
1265     Currently, this applies to following properties:
1266     - wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty:
1267       Clear the text field
1268 
1269     @remarks
1270     This flag cannot be used with property iterators.
1271 */
1272 wxPG_PROP_AUTO_UNSPECIFIED          = 0x00040000,
1273 
1274 /** Indicates the bit useable by derived properties.
1275 */
1276 wxPG_PROP_CLASS_SPECIFIC_1          = 0x00080000,
1277 
1278 /** Indicates the bit useable by derived properties.
1279 */
1280 wxPG_PROP_CLASS_SPECIFIC_2          = 0x00100000,
1281 
1282 /** Indicates that the property is being deleted and should be ignored.
1283 */
1284 wxPG_PROP_BEING_DELETED             = 0x00200000
1285 
1286 };
1287 
1288 /** Topmost flag.
1289 */
1290 #define wxPG_PROP_MAX               wxPG_PROP_AUTO_UNSPECIFIED
1291 
1292 /** Property with children *must* have one of these set, otherwise iterators
1293     will not work correctly. Code should automatically take care of this, however.
1294 */
1295 #define wxPG_PROP_PARENTAL_FLAGS        (wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY|wxPG_PROP_MISC_PARENT)
1296 
1297 /** @}
1298 */
1299 
1300 // Amalgam of flags that should be inherited by sub-properties
1301 #define wxPG_INHERITED_PROPFLAGS        (wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR)
1302 
1303 // Combination of flags that can be stored by GetFlagsAsString
1304 #define wxPG_STRING_STORED_FLAGS        (wxPG_PROP_DISABLED|wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR|wxPG_PROP_COLLAPSED)
1305 
1306 // -----------------------------------------------------------------------
1307 
1308 #ifndef SWIG
1309 
1310 /** @defgroup attrids wxPropertyGrid Property Attribute Identifiers
1311     wxPropertyGrid::SetPropertyAttribute() accepts one of these as
1312     attrname argument .
1313     You can use strings instead of constants. However, some of these
1314     constants are redefined to use cached strings which may reduce
1315     your binary size by some amount.
1316 
1317     @{
1318 */
1319 
1320 
1321 /** Universal, int or double. Minimum value for numeric properties.
1322 */
1323 #define wxPG_ATTR_MIN                     wxT("Min")
1324 
1325 /** Universal, int or double. Maximum value for numeric properties.
1326 */
1327 #define wxPG_ATTR_MAX                     wxT("Max")
1328 
1329 /** Universal, string. When set, will be shown as text after the displayed
1330     text value. Alternatively, if third column is enabled, text will be shown
1331     there (for any type of property).
1332 */
1333 #define wxPG_ATTR_UNITS                     wxT("Units")
1334 
1335 /** Universal, string. When set, will be shown in property's value cell
1336     when displayed value string is empty, or value is unspecified.
1337 */
1338 #define wxPG_ATTR_INLINE_HELP               wxT("InlineHelp")
1339 
1340 /** wxBoolProperty specific, int, default 0. When 1 sets bool property to
1341     use checkbox instead of choice.
1342 */
1343 #define wxPG_BOOL_USE_CHECKBOX              wxT("UseCheckbox")
1344 
1345 /** wxBoolProperty specific, int, default 0. When 1 sets bool property value
1346     to cycle on double click (instead of showing the popup listbox).
1347 */
1348 #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING  wxT("UseDClickCycling")
1349 
1350 /** wxFloatProperty (and similar) specific, int, default -1. Sets the (max) precision
1351     used when floating point value is rendered as text. The default -1 means infinite
1352     precision.
1353 */
1354 #define wxPG_FLOAT_PRECISION                wxT("Precision")
1355 
1356 /** The text will be echoed as asterisks (wxTE_PASSWORD will be passed to textctrl etc).
1357 */
1358 #define wxPG_STRING_PASSWORD                wxT("Password")
1359 
1360 /** Define base used by a wxUIntProperty. Valid constants are
1361     wxPG_BASE_OCT, wxPG_BASE_DEC, wxPG_BASE_HEX and wxPG_BASE_HEXL
1362     (lowercase characters).
1363 */
1364 #define wxPG_UINT_BASE                      wxT("Base")
1365 
1366 /** Define prefix rendered to wxUIntProperty. Accepted constants
1367     wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and wxPG_PREFIX_DOLLAR_SIGN.
1368     <b>Note:</b> Only wxPG_PREFIX_NONE works with Decimal and Octal
1369     numbers.
1370 */
1371 #define wxPG_UINT_PREFIX                    wxT("Prefix")
1372 
1373 /** wxFileProperty/wxImageFileProperty specific, wxChar*, default is detected/varies.
1374     Sets the wildcard used in the triggered wxFileDialog. Format is the
1375     same.
1376 */
1377 #define wxPG_FILE_WILDCARD                  wxT("Wildcard")
1378 
1379 /** wxFileProperty/wxImageFileProperty specific, int, default 1.
1380     When 0, only the file name is shown (i.e. drive and directory are hidden).
1381 */
1382 #define wxPG_FILE_SHOW_FULL_PATH            wxT("ShowFullPath")
1383 
1384 /** Specific to wxFileProperty and derived properties, wxString, default empty.
1385     If set, then the filename is shown relative to the given path string.
1386 */
1387 #define wxPG_FILE_SHOW_RELATIVE_PATH        wxT("ShowRelativePath")
1388 
1389 /** Specific to wxFileProperty and derived properties, wxString, default is empty.
1390     Sets the initial path of where to look for files.
1391 */
1392 #define wxPG_FILE_INITIAL_PATH              wxT("InitialPath")
1393 
1394 /** Specific to wxFileProperty and derivatives, wxString, default is empty.
1395     Sets a specific title for the dir dialog.
1396 */
1397 #define wxPG_FILE_DIALOG_TITLE              wxT("DialogTitle")
1398 
1399 /** Specific to wxDirProperty, wxString, default is empty.
1400     Sets a specific message for the dir dialog.
1401 */
1402 #define wxPG_DIR_DIALOG_MESSAGE             wxT("DialogMessage")
1403 
1404 /** Sets displayed date format for wxDateProperty.
1405 */
1406 #define wxPG_DATE_FORMAT                    wxT("DateFormat")
1407 
1408 /** Sets wxDatePickerCtrl window style used with wxDateProperty. Default
1409     is wxDP_DEFAULT | wxDP_SHOWCENTURY.
1410 */
1411 #define wxPG_DATE_PICKER_STYLE              wxT("PickerStyle")
1412 
1413 /** SpinCtrl editor, int or double. How much number changes when button is
1414     pressed (or up/down on keybard).
1415 */
1416 #define wxPG_ATTR_SPINCTRL_STEP             wxT("Step")
1417 
1418 /** SpinCtrl editor, bool. If true, value wraps at Min/Max.
1419 */
1420 #define wxPG_ATTR_SPINCTRL_WRAP             wxT("Wrap")
1421 
1422 /** SpinCtrl editor, bool. If true, spin control value can be changed by
1423     moving the mouse while left mouse button is pressed.
1424 */
1425 #define wxPG_ATTR_SPINCTRL_MOTIONSPIN       wxT("MotionSpin")
1426 
1427 /** wxMultiChoiceProperty, int. If 0, no user strings allowed. If 1, user strings
1428     appear before list strings. If 2, user strings appear after list string.
1429 */
1430 #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE    wxT("UserStringMode")
1431 
1432 #ifdef wxPG_COMPATIBILITY_1_0_0
1433 
1434 /** wxCustomProperty specific, wxPGEditor*. Set editor control. Editor pointer is stored
1435     in variable named wxPGEditor_EDITORNAME. So the basic built-in editors are at
1436     wxPGEditor_TextCtrl, wxPGEditor_Choice, wxPGEditor_ComboBox, wxPGEditor_CheckBox,
1437     wxPGEditor_TextCtrlAndButton, and wxPGEditor_ChoiceAndButton.
1438 */
1439 #define wxPG_CUSTOM_EDITOR                  wxT("128")
1440 
1441 /** wxCustomProperty specific, wxBitmap*. Sets a small bitmap. Value must be given as
1442     pointer and it is then copied. If you give it wxNullBitmap, then the current
1443     image (if any) is deleted.
1444 */
1445 #define wxPG_CUSTOM_IMAGE                   wxT("129")
1446 
1447 /** wxCustomProperty specific, void*. Sets callback function (of type wxPropertyGridCallback)
1448     that is called whenever button is pressed.
1449 */
1450 #define wxPG_CUSTOM_CALLBACK                wxT("130")
1451 
1452 #endif // wxPG_COMPATIBILITY_1_0_0
1453 
1454 /** wxCustomProperty specific, void*. Sets callback function (of type wxPGPaintCallback)
1455     that is called whenever image in front of property needs to be repainted. This attribute
1456     takes precedence over bitmap set with wxPG_CUSTOM_IMAGE, and it is only proper way
1457     to draw images to wxCustomProperty's drop down choices list.
1458     @remarks
1459     Callback must handle measure calls (i.e. when rect.x < 0, set paintdata.m_drawnHeight to
1460     height of item in question).
1461 */
1462 #define wxPG_CUSTOM_PAINT_CALLBACK          wxT("PaintCallback")
1463 
1464 
1465 /** wxCustomProperty specific, int, default 0. Setting to 1 makes children private (ie. sets
1466     wxPG_PROP_AGGREGATE flag), similar to other properties with fixed children.
1467     @remarks
1468     - Children must be added <b>when this attribute has value 0</b>. Otherwise
1469       there will be an assertion failure.
1470     - Changed event occurs on the parent only.
1471 */
1472 #define wxPG_CUSTOM_PRIVATE_CHILDREN        wxT("PrivateChildren")
1473 
1474 
1475 /** wxColourProperty and its kind, int, default 1. Setting this attribute to 0 hides custom
1476     colour from property's list of choices.
1477 */
1478 #define wxPG_COLOUR_ALLOW_CUSTOM            wxT("AllowCustom")
1479 
1480 
1481 /** First attribute id that is guaranteed not to be used built-in
1482     properties.
1483 */
1484 //#define wxPG_USER_ATTRIBUTE                 192
1485 
1486 /** @}
1487 */
1488 
1489 #ifndef DOXYGEN
1490 
1491 // Redefine attribute macros to use cached strings
1492 #undef wxPG_ATTR_DEFAULT_VALUE
1493 #define wxPG_ATTR_DEFAULT_VALUE           wxPGGlobalVars->m_strDefaultValue
1494 #undef wxPG_ATTR_MIN
1495 #define wxPG_ATTR_MIN                     wxPGGlobalVars->m_strMin
1496 #undef wxPG_ATTR_MAX
1497 #define wxPG_ATTR_MAX                     wxPGGlobalVars->m_strMax
1498 #undef wxPG_ATTR_UNITS
1499 #define wxPG_ATTR_UNITS                   wxPGGlobalVars->m_strUnits
1500 #undef wxPG_ATTR_INLINE_HELP
1501 #define wxPG_ATTR_INLINE_HELP             wxPGGlobalVars->m_strInlineHelp
1502 
1503 #endif  // !DOXYGEN
1504 
1505 #endif  // !SWIG
1506 
1507 
1508 //
1509 // Valid constants for wxPG_UINT_BASE attribute
1510 // (long because of wxVariant constructor)
1511 #define wxPG_BASE_OCT                       (long)8
1512 #define wxPG_BASE_DEC                       (long)10
1513 #define wxPG_BASE_HEX                       (long)16
1514 #define wxPG_BASE_HEXL                      (long)32
1515 
1516 //
1517 // Valid constants for wxPG_UINT_PREFIX attribute
1518 #define wxPG_PREFIX_NONE                    (long)0
1519 #define wxPG_PREFIX_0x                      (long)1
1520 #define wxPG_PREFIX_DOLLAR_SIGN             (long)2
1521 
1522 
1523 // -----------------------------------------------------------------------
1524 // Editor class.
1525 
1526 // Editor accessor.
1527 #define wxPG_EDITOR(T)          wxPGEditor_##T
1528 
1529 // Declare editor class, with optional part.
1530 #define WX_PG_DECLARE_EDITOR_WITH_DECL(EDITOR,DECL) \
1531 extern DECL wxPGEditor* wxPGEditor_##EDITOR; \
1532 extern DECL wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
1533 
1534 // Declare editor class.
1535 #define WX_PG_DECLARE_EDITOR(EDITOR) \
1536 extern wxPGEditor* wxPGEditor_##EDITOR; \
1537 extern wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
1538 
1539 // Declare builtin editor classes.
WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrl,WXDLLIMPEXP_PG)1540 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrl,WXDLLIMPEXP_PG)
1541 WX_PG_DECLARE_EDITOR_WITH_DECL(Choice,WXDLLIMPEXP_PG)
1542 WX_PG_DECLARE_EDITOR_WITH_DECL(ComboBox,WXDLLIMPEXP_PG)
1543 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrlAndButton,WXDLLIMPEXP_PG)
1544 #if wxPG_INCLUDE_CHECKBOX
1545 WX_PG_DECLARE_EDITOR_WITH_DECL(CheckBox,WXDLLIMPEXP_PG)
1546 #endif
1547 WX_PG_DECLARE_EDITOR_WITH_DECL(ChoiceAndButton,WXDLLIMPEXP_PG)
1548 
1549 // -----------------------------------------------------------------------
1550 
1551 
1552 #ifdef SWIG
1553     #define wxVARIANT_REFCOUNTED 1
1554 #endif
1555 
1556 //
1557 // For compability with wxWidgets 2.6 patched with refcounted wxVariant
1558 #ifndef wxVARIANT_REFCOUNTED
1559   #define wxVARIANT_REFCOUNTED 1
1560 #endif
1561 
1562 
1563 #if !defined(SWIG)
1564 
1565 /** @class wxPGVariantData
1566 	@ingroup classes
1567     @brief wxVariantData with additional functionality.
1568 
1569     It is usually enough to use supplied to macros to automatically generate
1570     variant data class. Like so:
1571 
1572     @code
1573 
1574     // In header
1575     WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataMyClass,  // Name of the class
1576                                MyClass,  // Name of the data type
1577                                wxEMPTY_PARAMETER_VALUE)  // Declaration
1578 
1579     // In source
1580     WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantDataMyClass, MyClass)
1581 
1582     @endcode
1583 
1584     If your class has operator==() implementation, then it is recommended that
1585     you use WX_PG_IMPLEMENT_VARIANT_DATA_WITH_EQ macro instead, since the
1586     plain WX_PG_IMPLEMENT_VARIANT_DATA macro only implements a simple, shallow
1587     equality testing.
1588 
1589     If your class is derived from wxObject, it is recommended that you use
1590     wxObject-versions of the macros (WX_PG_DECLARE_WXOBJECT_VARIANT_DATA and
1591     WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA).
1592 
1593 */
1594 class WXDLLIMPEXP_PG wxPGVariantData : public wxVariantData
1595 {
1596 #if !wxCHECK_VERSION(3, 0, 0)
1597     DECLARE_ABSTRACT_CLASS(wxPGVariantData)
1598 #endif
1599 public:
1600     virtual void* GetValuePtr() = 0;
1601     virtual wxVariant GetDefaultValue() const = 0;
1602 protected:
1603 };
1604 
1605 
1606 //
1607 // With wxWidgets 2.9 and later we demand native C++ RTTI support
1608 #if wxCHECK_VERSION(3, 0, 0)
1609     #ifdef wxNO_RTTI
1610         #error "You need to enable compiler RTTI support when using wxWidgets 2.9.0 or later"
1611     #endif
1612     #define WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(A)
1613     #define WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(A, B)
1614     typedef const std::type_info* wxPGVariantDataClassInfo;
1615     #define wxPGVariantDataGetClassInfo(A) (&typeid(*A))
1616     #define wxPG_VARIANT_EQ(A, B) ( ((A).GetData() && (B).GetData() && typeid(*(A).GetData()) == typeid(*(B).GetData()) && (A == B)) || (!(A).GetData() && !(B).GetData()) )
1617 #else
1618     #define WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA DECLARE_DYNAMIC_CLASS
1619     #define WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA IMPLEMENT_DYNAMIC_CLASS
1620     typedef wxList wxVariantList;
1621     typedef wxClassInfo* wxPGVariantDataClassInfo;
1622     #define wxPGVariantDataGetClassInfo(A) (A->GetClassInfo())
1623     #define wxPG_VARIANT_EQ(A, B) ( ((A).GetData() && (B).GetData() && (A).GetData()->GetClassInfo() == (B).GetData()->GetClassInfo() && (A == B)) || (!(A).GetData() && !(B).GetData()) )
1624 #endif
1625 
1626 #ifndef wxDynamicCastVariantData
1627     #define wxDynamicCastVariantData wxDynamicCast
1628 #endif
1629 
1630 
wxPGDoesNothing()1631 inline void wxPGDoesNothing() {}
1632 
1633 
1634 #define _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, AS_ARG, AS_ARG_CONST, CTOR_CODE, DEFAULT_VALUE, SET_CODE) \
1635     WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME) \
1636 protected: \
1637     DATATYPE m_value; \
1638 public: \
1639     CLASSNAME() { CTOR_CODE; } \
1640     CLASSNAME(AS_ARG_CONST value) { CTOR_CODE; SET_CODE; m_value = value; } \
1641     DATATYPE GetValue() const { return m_value; } \
1642     AS_ARG_CONST GetValueRef() const { return m_value; } \
1643     AS_ARG GetValueRef() { return m_value; } \
1644     void SetValue(AS_ARG_CONST value) { SET_CODE; m_value = value; } \
1645     virtual wxString GetType() const { return wxT(#DATATYPE); } \
1646     virtual wxVariantData* Clone() { return new CLASSNAME; } \
1647     virtual bool Read(wxString &) { return false; } \
1648     virtual bool Write(wxString &) const { return true; } \
1649     virtual wxVariant GetDefaultValue() const { return DEFAULT_VALUE; }
1650 
1651 
1652 #define _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
1653     virtual bool Eq(wxVariantData& other) const \
1654         { return (this == (const wxVariantData*) &other); }
1655 
1656 #define _WX_PG_IMPLEMENT_VARIANT_DATA_PROPER_EQ(CLASSNAME, DATATYPE) \
1657     virtual bool Eq(wxVariantData& other) const \
1658     { \
1659         if ( other.GetType() != wxT(#DATATYPE) ) \
1660             return false; \
1661         CLASSNAME* pOther = wxStaticCast(&other, CLASSNAME); \
1662         return (m_value == pOther->GetValueRef()); \
1663     }
1664 
1665 //
1666 // Macro WXVARIANT allows creation of wxVariant from any type supported by wxWidgets internally,
1667 // and of all types created using WX_PG_DECLARE_VARIANT_DATA.
1668 template<class T>
WXVARIANT(const T & value)1669 wxVariant WXVARIANT( const T& value )
1670 {
1671     return wxVariant((void*)&value);
1672 }
1673 
WXVARIANT(const int & value)1674 template<> inline wxVariant WXVARIANT( const int& value ) { return wxVariant((long)value); }
WXVARIANT(const long & value)1675 template<> inline wxVariant WXVARIANT( const long& value ) { return wxVariant(value); }
WXVARIANT(const bool & value)1676 template<> inline wxVariant WXVARIANT( const bool& value ) { return wxVariant(value); }
WXVARIANT(const double & value)1677 template<> inline wxVariant WXVARIANT( const double& value ) { return wxVariant(value); }
1678 //template<> inline wxVariant WXVARIANT( const wxChar* value ) { return wxVariant(wxString(value)); }
1679 //#if wxCHECK_VERSION(3, 0, 0)
1680 //    template<> inline wxVariant WXVARIANT( const char* value ) { return wxVariant(wxString(value)); }
1681 //#endif
WXVARIANT(const wxArrayString & value)1682 template<> inline wxVariant WXVARIANT( const wxArrayString& value ) { return wxVariant(value); }
WXVARIANT(const wxString & value)1683 template<> inline wxVariant WXVARIANT( const wxString& value ) { return wxVariant(value); }
1684 #if wxUSE_DATETIME
WXVARIANT(const wxDateTime & value)1685     template<> inline wxVariant WXVARIANT( const wxDateTime& value ) { return wxVariant(value); }
1686 #endif
1687 
1688 #if wxCHECK_VERSION(3, 0, 0)
1689     #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME) \
1690         extern int CLASSNAME##_d_;
1691     #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
1692         int CLASSNAME##_d_;
1693 #else
1694     #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME) \
1695         extern wxPGVariantDataClassInfo CLASSNAME##_ClassInfo
1696     #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
1697         wxPGVariantDataClassInfo CLASSNAME##_ClassInfo = &CLASSNAME::ms_classInfo;
1698 #endif
1699 
1700 #define _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, AS_ARG, AS_CONST_ARG, NULLVAL, BASECLASS) \
1701 _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
1702 WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME, BASECLASS) \
1703 AS_ARG operator <<( AS_ARG value, const wxVariant &variant ) \
1704 { \
1705 	CLASSNAME *data = wxDynamicCastVariantData( variant.GetData(), CLASSNAME ); \
1706     wxASSERT( data ); \
1707     value = data->GetValue(); \
1708     return value; \
1709 } \
1710 wxVariant& operator <<( wxVariant &variant, AS_CONST_ARG value ) \
1711 { \
1712     CLASSNAME *data = new CLASSNAME( value ); \
1713     variant.SetData( data ); \
1714     return variant; \
1715 } \
1716 AS_ARG DATATYPE##FromVariant( const wxVariant& v ) \
1717 { \
1718 	CLASSNAME *data = wxDynamicCastVariantData( v.GetData(), CLASSNAME ); \
1719     if ( !data ) \
1720         return NULLVAL; \
1721     return data->GetValueRef(); \
1722 } \
1723 wxVariant DATATYPE##ToVariant( AS_CONST_ARG value ) \
1724 { \
1725     wxVariant variant( new CLASSNAME( value ) ); \
1726     return variant; \
1727 }
1728 
1729 #define WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE) \
1730 class CLASSNAME : public wxPGVariantData \
1731 { \
1732 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
1733                                     const DATATYPE&, wxPGDoesNothing(), \
1734                                     wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
1735 _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
1736 public: \
1737     virtual void* GetValuePtr() { return (void*)&m_value; } \
1738 }; \
1739 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
1740 
1741 #define WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA(CLASSNAME, DATATYPE) \
1742 class CLASSNAME : public wxPGVariantData \
1743 { \
1744 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
1745                                     const DATATYPE&, wxPGDoesNothing(), \
1746                                     wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
1747 _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
1748 public: \
1749     virtual void* GetValuePtr() { return (void*)&m_value; } \
1750     virtual wxClassInfo* GetValueClassInfo() { return m_value.GetClassInfo(); } \
1751 }; \
1752 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
1753 
1754 
1755 #define WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA_WITH_PROPER_EQ(CLASSNAME, DATATYPE) \
1756 class CLASSNAME : public wxPGVariantData \
1757 { \
1758 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
1759                                     const DATATYPE&, wxPGDoesNothing(), \
1760                                     wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
1761 _WX_PG_IMPLEMENT_VARIANT_DATA_PROPER_EQ(CLASSNAME, DATATYPE) \
1762 public: \
1763     virtual void* GetValuePtr() { return (void*)&m_value; } \
1764     virtual wxClassInfo* GetValueClassInfo() { return m_value.GetClassInfo(); } \
1765 }; \
1766 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
1767 
1768 #define WX_PG_IMPLEMENT_VARIANT_DATA_WITH_EQ(CLASSNAME, DATATYPE) \
1769 class CLASSNAME : public wxPGVariantData \
1770 { \
1771 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
1772                                     const DATATYPE&, wxPGDoesNothing(), \
1773                                     wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
1774 _WX_PG_IMPLEMENT_VARIANT_DATA_PROPER_EQ(CLASSNAME, DATATYPE) \
1775 public: \
1776     virtual void* GetValuePtr() { return (void*)&m_value; } \
1777 }; \
1778 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
1779 
1780 
1781 #define WX_PG_DECLARE_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
1782 DECL DATATYPE& operator <<( DATATYPE& value, const wxVariant &variant ); \
1783 DECL wxVariant& operator <<( wxVariant &variant, const DATATYPE& value ); \
1784 DECL DATATYPE& DATATYPE##FromVariant( const wxVariant& variant ); \
1785 DECL wxVariant DATATYPE##ToVariant( const DATATYPE& value ); \
1786 template<> inline wxVariant WXVARIANT( const DATATYPE& value ) { return DATATYPE##ToVariant(value); } \
1787 DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
1788 
1789 #define WX_PG_DECLARE_WXOBJECT_VARIANT_DATA WX_PG_DECLARE_VARIANT_DATA
1790 
1791 #define WX_PG_DECLARE_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
1792 DECL DATATYPE* operator <<( DATATYPE* value, const wxVariant &variant ); \
1793 DECL wxVariant& operator <<( wxVariant &variant, DATATYPE* value ); \
1794 DECL DATATYPE* DATATYPE##FromVariant( const wxVariant& variant ); \
1795 DECL wxVariant DATATYPE##ToVariant( DATATYPE* value ); \
1796 DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
1797 
1798 
1799 #define WX_PG_IMPLEMENT_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DEFAULT) \
1800 class CLASSNAME : public wxPGVariantData \
1801 { \
1802 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE*, DATATYPE*, \
1803                                     DATATYPE*, m_value = NULL, \
1804                                     DEFAULT, if (m_value) Py_DECREF(m_value); if (!value) value = Py_None; Py_INCREF(value) ) \
1805 _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
1806     ~CLASSNAME() { if (m_value) Py_DECREF(m_value); } \
1807 public: \
1808     virtual void* GetValuePtr() { return (void*)m_value; } \
1809 }; \
1810 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE*, DATATYPE*, NULL, wxPGVariantData)
1811 
1812 
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataPoint,wxPoint,WXDLLIMPEXP_PG)1813 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataPoint, wxPoint, WXDLLIMPEXP_PG)
1814 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataSize, wxSize, WXDLLIMPEXP_PG)
1815 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataArrayInt, wxArrayInt, WXDLLIMPEXP_PG)
1816 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataLongLong, wxLongLong, WXDLLIMPEXP_PG)
1817 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataULongLong, wxULongLong, WXDLLIMPEXP_PG)
1818 #ifdef __WXPYTHON__
1819     WX_PG_DECLARE_PTR_VARIANT_DATA(wxPGVariantDataPyObject, PyObject, WXDLLIMPEXP_PG)
1820 #endif
1821 
1822 WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataFont, wxFont, WXDLLIMPEXP_PG)
1823     template<> inline wxVariant WXVARIANT( const wxColour& value )
1824     {
1825         wxVariant variant;
1826         variant << value;
1827         return variant;
1828     }
1829 
1830 #endif // !SWIG
1831 
1832 #define WX_PG_VARIANT_GETVALUEREF(P, T)   (*((T*)((wxPGVariantData*)(P.GetData()))->GetValuePtr()))
1833 
1834 // Safely converts a wxVariant to (long) int. Supports converting from string and boolean as well.
1835 WXDLLIMPEXP_PG long wxPGVariantToInt( const wxVariant& variant, long defVal = 1 );
1836 
1837 // Safely converts a wxVariant to wxLongLong_t. Returns true on success.
1838 WXDLLIMPEXP_PG bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult );
1839 
1840 // Safely converts a wxVariant to wxULongLong_t. Returns true on success.
1841 WXDLLIMPEXP_PG bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult );
1842 
1843 // Safely converts a wxVariant to double. Supports converting from string and wxLongLong as well.
1844 WXDLLIMPEXP_PG bool wxPGVariantToDouble( const wxVariant& variant, double* pResult );
1845 
1846 // Convert wxVariant from various forms to a wxObject pointer
1847 WXDLLIMPEXP_PG bool wxPGVariantToWxObjectPtr( const wxVariant& value,
1848                                               wxObject** result );
1849 
1850 // -----------------------------------------------------------------------
1851 
1852 // When wxPG is loaded dynamically after the application is already running
1853 // then the built-in module system won't pick this one up.  Add it manually.
1854 WXDLLIMPEXP_PG void wxPGInitResourceModule();
1855 
1856 // -----------------------------------------------------------------------
1857 
1858 
1859 #if !defined(SWIG)
1860 
1861 #if wxPG_USE_STL
1862 typedef std::vector<wxPGProperty*>  wxArrayPGProperty;
1863 #else
1864 WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty*, wxArrayPGProperty,
1865                                   wxBaseArrayPtrVoid, class WXDLLIMPEXP_PG);
1866 #endif
1867 
1868 // Always use wxString based hashmap with unicode, stl, swig and GCC 4.0+
1869 WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
1870                                      wxPGHashMapS2P,
1871                                      class WXDLLIMPEXP_PG);
1872 
1873 #else
1874 
1875 class WXDLLIMPEXP_PG wxArrayPGProperty;
1876 class WXDLLIMPEXP_PG wxPGHashMapS2P;
1877 
1878 #endif
1879 
1880 
1881 // -----------------------------------------------------------------------
1882 
1883 //
1884 // Property class declaration helper macros
1885 // (wxPGRootPropertyClass and wxPropertyCategory require this).
1886 //
1887 
1888 // We don't want to create SWIG interface for DoGetEditorClass (we'll use GetEditor instead)
1889 #ifndef SWIG
1890     #define WX_PG_DECLARE_DOGETEDITORCLASS  virtual const wxPGEditor* DoGetEditorClass() const;
1891 #else
1892     #define WX_PG_DECLARE_DOGETEDITORCLASS
1893 #endif
1894 
1895 #ifndef SWIG
1896     #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
1897         public: \
1898             DECLARE_DYNAMIC_CLASS(CLASSNAME) \
1899             WX_PG_DECLARE_DOGETEDITORCLASS \
1900         private:
1901 #else
1902     #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME)
1903 #endif
1904 
1905 // Implements sans constructor function. Also, first arg is class name, not property name.
1906 #define WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(PROPNAME,T,EDITOR) \
1907 const wxPGEditor* PROPNAME::DoGetEditorClass() const \
1908 { \
1909     return wxPGEditor_##EDITOR; \
1910 }
1911 
1912 
1913 // -----------------------------------------------------------------------
1914 
1915 //
1916 // Ids for sub-controls
1917 // NB: It should not matter what these are.
1918 #define wxPG_SUBID1                     2
1919 #define wxPG_SUBID2                     3
1920 #define wxPG_SUBID_TEMP1                4
1921 
1922 
1923 #ifndef SWIG
1924 
1925 // -----------------------------------------------------------------------
1926 
1927 // Structure for relaying choice/list info.
1928 struct wxPGChoiceInfo
1929 {
1930     wxPGChoices*    m_choices;
1931 };
1932 
1933 // -----------------------------------------------------------------------
1934 
1935 /** @class wxPGAttributeStorage
1936 	@ingroup classes
1937     @brief wxPGAttributeStorage is somewhat optimized storage for
1938       key=variant pairs (ie. a map).
1939 */
1940 class WXDLLIMPEXP_PG wxPGAttributeStorage
1941 {
1942 public:
1943     wxPGAttributeStorage();
1944     ~wxPGAttributeStorage();
1945 
1946     void Set( const wxString& name, const wxVariant& value );
GetCount()1947     unsigned int GetCount() const
1948     {
1949         return (unsigned int) m_map.size();
1950     }
FindValue(const wxString & name)1951     wxVariant FindValue( const wxString& name ) const
1952     {
1953         wxPGHashMapS2P::const_iterator it = m_map.find(name);
1954         if ( it != m_map.end() )
1955         {
1956             wxVariantData* data = (wxVariantData*) it->second;
1957             data->IncRef();
1958             return wxVariant(data, it->first);
1959         }
1960         return wxVariant();
1961     }
1962 
1963     typedef wxPGHashMapS2P::const_iterator const_iterator;
StartIteration()1964     const_iterator StartIteration() const
1965     {
1966         return m_map.begin();
1967     }
GetNext(const_iterator & it,wxVariant & variant)1968     bool GetNext( const_iterator& it, wxVariant& variant ) const
1969     {
1970         if ( it == m_map.end() )
1971             return false;
1972 
1973         wxVariantData* data = (wxVariantData*) it->second;
1974         data->IncRef();
1975         variant.SetData(data);
1976         variant.SetName(it->first);
1977         it++;
1978         return true;
1979     }
1980 
1981 protected:
1982     wxPGHashMapS2P  m_map;
1983 };
1984 
1985 #endif  // !SWIG
1986 
1987 // -----------------------------------------------------------------------
1988 
1989 /** @class wxPGProperty
1990 	@ingroup classes
1991     @brief wxPGProperty is base class for all wxPropertyGrid properties.
1992 */
1993 class WXDLLIMPEXP_PG wxPGProperty : public wxObject
1994 {
1995 #ifndef SWIG
1996     friend class wxPropertyGrid;
1997     friend class wxPropertyGridInterface;
1998     friend class wxPropertyGridState;
1999     friend class wxPropertyGridPopulator;
2000     friend class wxStringProperty;  // Proper "<composed>" support requires this
2001     DECLARE_ABSTRACT_CLASS(wxPGProperty)
2002 #endif
2003 public:
2004     typedef wxUint32 FlagType;
2005 #ifndef __WXPYTHON__
2006     typedef void* ClientDataType;
2007 #else
2008     typedef PyObject* ClientDataType;
2009 #endif
2010 
2011 // PYSWIG is a special symbol used by my custom scripts. Code to remove it
2012 // automatically should be added in future.
2013 #ifndef PYSWIG
2014     /** Basic constructor. Should not be necessary to override.
2015     */
2016     wxPGProperty();
2017 #endif
2018 
2019     /** Constructor.
2020         Real used property classes should have constructor of this style:
2021 
2022         @code
2023 
2024         // If T is a class, then it should be a constant reference
2025         // (e.g. const T& ) instead.
2026         MyProperty( const wxString& label, const wxString& name, T value )
2027             : wxPGProperty(label, name)
2028         {
2029             // Generally recommended way to set the initial value
2030             // (as it should work in pretty much 100% of cases).
2031             wxVariant variant;
2032             variant << value;
2033             SetValue(variant);
2034 
2035             // If has child properties then create them here. For example:
2036             //     AddPrivateChild( new wxStringProperty(wxT("Subprop 1"),
2037             //                                           wxPG_LABEL,
2038             //                                           value.GetSubProp1()));
2039         }
2040 
2041         @endcode
2042 
2043         Of course, in this example, wxPGProperty could actually any other property class.
2044     */
2045     wxPGProperty( const wxString& label, const wxString& name );
2046 
2047     /** Virtual destructor. It is customary for derived properties to implement this. */
2048     ~wxPGProperty() override;
2049 
2050     /** This virtual function is called after m_value has been set.
2051 
2052         @remarks
2053         - If m_value was set to Null variant (ie. unspecified value), OnSetValue()
2054           will not be called.
2055         - m_value may be of any variant type. Typically properties internally support only
2056           one variant type, and as such OnSetValue() provides a good opportunity to convert
2057           supported values into internal type.
2058         - Default implementation does nothing.
2059     */
2060     virtual void OnSetValue();
2061 
2062     /** Override this to return something else than m_value as the value.
2063     */
DoGetValue()2064     virtual wxVariant DoGetValue() const { return m_value; }
2065 
2066 #ifndef DOXYGEN
2067 private:
2068 #else
2069 public:
2070 #endif
2071     // These methods are private. Use ActualXXX versions in code.
2072     //
2073 
2074     /** Implement this function in derived class to check the value.
2075         Return true if it is ok. Returning false prevents property change events
2076         from occurring.
2077 
2078         @remarks
2079         - Default implementation always returns true.
2080     */
2081     virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
2082 
2083     /** Converts 'text' into proper value 'variant'. Returns true if new (different than
2084         m_value) value could be interpreted from the text.
2085         @param argFlags
2086         If wxPG_FULL_VALUE is set, returns complete, storable value instead of displayable
2087         one (they may be different).
2088         If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of composite
2089         property string value (as generated by GetValueAsString() called with this same
2090         flag).
2091 
2092         @remarks
2093         - Default implementation converts semicolon delimited tokens into child values. Only
2094           works for properties with children.
2095         - You might want to take into account that m_value is Null variant if property
2096           value is unspecified (which is usually only case if you explicitly enabled that
2097           sort behavior).
2098     */
2099     virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
2100 
2101     /** Converts 'number' (including choice selection) into proper value 'variant'.
2102         Returns true if new (different than m_value) value could be interpreted from the integer.
2103         @param argFlags
2104         If wxPG_FULL_VALUE is set, returns complete, storable value instead of displayable
2105 
2106         @remarks
2107         - Default implementation may work correctly if used value type is int.
2108         - If property is not supposed to use choice or spinctrl or other editor
2109           with int-based value, it is not necessary to implement this method.
2110         - If property uses choice control, and displays a dialog on some choice items,
2111           then it is preferred to display that dialog in IntToValue instead of OnEvent.
2112         - You might want to take into account that m_value is Null variant if property
2113           value is unspecified (which is usually only case if you explicitly enabled that
2114           sort behavior).
2115     */
2116     virtual bool IntToValue( wxVariant& value, int number, int argFlags = 0 ) const;
2117 public:
2118 
2119     /** Returns text representation of property's value. Generally this function should
2120         not be called from the application code. Instead, call GetValueString().
2121 
2122         @param argFlags
2123         If wxPG_FULL_VALUE is set, returns complete, storable string value instead of displayable.
2124         If wxPG_EDITABLE_VALUE is set, returns string value that must be editable in textctrl.
2125         If wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to display
2126         as a part of composite property string value.
2127 
2128         @remarks
2129         - Default implementation returns string composed from text representations of
2130           child properties.
2131         - Implementations are never called with m_value being null variant (ie. unspecified
2132           value), so you don't need to check for that. Naturally this means that unspecified
2133           value is always displayed as an empty string.
2134 
2135         @see GetValueString()
2136     */
2137     virtual wxString GetValueAsString( int argFlags = 0 ) const;
2138 
2139     /** Converts string to a value, and if succesfull, calls SetValue() on it.
2140         Default behavior is to do nothing.
2141         @param text
2142         String to get the value from.
2143         @retval
2144         true if value was changed.
2145     */
2146 #if wxPG_COMPATIBILITY_1_2_0
2147     virtual
2148 #endif
2149     bool SetValueFromString( const wxString& text, int flags = wxPG_PROGRAMMATIC_VALUE );
2150 
2151     /** Converts integer to a value, and if succesfull, calls SetValue() on it.
2152         Default behavior is to do nothing.
2153         @param value
2154         Int to get the value from.
2155         @param flags
2156         If has wxPG_FULL_VALUE, then the value given is a actual value and not an index.
2157         @retval
2158         true if value was changed.
2159     */
2160 #if wxPG_COMPATIBILITY_1_2_0
2161     virtual
2162 #endif
2163     bool SetValueFromInt( long value, int flags = 0 );
2164 
2165 #if wxPG_COMPATIBILITY_1_2_0
2166     /** @deprecated
2167         Since version 1.3. Overriding this will cause run-time assertion failure.
2168     */
2169     virtual wxSize GetImageSize() const;
2170 #endif
2171 
2172     /** Returns size of the custom painted image in front of property. This method
2173         must be overridden to return non-default value if OnCustomPaint is to be
2174         called.
2175         @param item
2176         Normally -1, but can be an index to the property's list of items.
2177         @remarks
2178         - Default behavior is to return wxSize(0,0), which means no image.
2179         - Default image width or height is indicated with dimension -1.
2180         - You can also return wxPG_DEFAULT_IMAGE_SIZE which equals wxSize(-1, -1).
2181     */
2182     virtual wxSize OnMeasureImage( int item = -1 ) const;
2183 
2184     /** Events received by editor widgets are processed here. Note that editor class
2185         usually processes most events. Some, such as button press events of
2186         TextCtrlAndButton class, should be handled here. Also, if custom handling
2187         for regular events is desired, then that can also be done (for example,
2188         wxSystemColourProperty custom handles wxEVT_COMMAND_CHOICE_SELECTED).
2189 
2190         If the event causes value to be changed, wxPropertyGrid::ValueChangeInEvent(value)
2191         should be used.
2192 
2193         @param event
2194         Associated wxEvent.
2195         @retval
2196         Should return true if any changes in value should be reported.
2197         @remarks
2198         - If property uses choice control, and displays a dialog on some choice items,
2199           then it is preferred to display that dialog in IntToValue instead of OnEvent.
2200     */
2201     virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event );
2202 
2203     /** Called after value of a child property has been altered. Note that this function is
2204         usually called at the time that value of this property, or given child property, is
2205         still pending for change.
2206 
2207         Sample pseudo-code implementation:
2208 
2209         @code
2210         void MyProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
2211         {
2212             // Acquire reference to actual type of data stored in variant
2213             // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros were used to create
2214             // the variant class).
2215             T& data = TFromVariant(thisValue);
2216 
2217             // Copy childValue into data.
2218             switch ( childIndex )
2219             {
2220                 case 0:
2221                     data.SetSubProp1( childvalue.GetLong() );
2222                     break;
2223                 case 1:
2224                     data.SetSubProp2( childvalue.GetString() );
2225                     break;
2226                 ...
2227             }
2228         }
2229         @endcode
2230 
2231         @param thisValue
2232         Value of this property, that should be altered.
2233         @param childIndex
2234         Index of child changed (you can use Item(childIndex) to get).
2235         @param childValue
2236         Value of the child property.
2237     */
2238     virtual void ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const;
2239 
2240 #ifdef __WXPYTHON__
2241     // Because SWIG doesn't generate code well for writeback variables,
2242     // we need to declare custom versions of some functions.
2243     virtual wxPGVariantAndBool PyValidateValue( const wxVariant& value, wxPGValidationInfo& validationInfo ) const;
2244     virtual wxPGVariantAndBool PyStringToValue( const wxString& text, int argFlags = 0 ) const;
2245     virtual wxPGVariantAndBool PyIntToValue( int number, int argFlags = 0 ) const;
2246     virtual wxVariant PyChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const;
2247 #endif
2248 
ActualChildChanged(wxVariant & thisValue,int childIndex,wxVariant & childValue)2249     void ActualChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
2250     {
2251 #ifdef __WXPYTHON__
2252         if ( m_scriptObject )
2253         {
2254             thisValue = PyChildChanged(thisValue, childIndex, childValue);
2255             return;
2256         }
2257 #endif
2258 
2259         ChildChanged(thisValue, childIndex, childValue);
2260     }
2261 
ActualValidateValue(wxVariant & value,wxPGValidationInfo & validationInfo)2262     bool ActualValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const
2263     {
2264 #ifdef __WXPYTHON__
2265         if ( m_scriptObject )
2266         {
2267             wxPGVariantAndBool vab = PyValidateValue(value, validationInfo);
2268             if ( vab.m_valueValid )
2269                 value = vab.m_value;
2270             return vab.m_result;
2271         }
2272 #endif
2273 
2274         return ValidateValue(value, validationInfo);
2275     }
2276 
2277     bool ActualStringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const
2278     {
2279 #ifdef __WXPYTHON__
2280         if ( m_scriptObject )
2281         {
2282             wxPGVariantAndBool vab = PyStringToValue(text, argFlags);
2283             if ( vab.m_valueValid )
2284                 variant = vab.m_value;
2285             return vab.m_result;
2286         }
2287 #endif
2288 
2289         return StringToValue(variant, text, argFlags);
2290     }
2291 
2292     bool ActualIntToValue( wxVariant& variant, int number, int argFlags = 0 ) const
2293     {
2294 #ifdef __WXPYTHON__
2295         if ( m_scriptObject )
2296         {
2297             wxPGVariantAndBool vab = PyIntToValue(number, argFlags);
2298             if ( vab.m_valueValid )
2299                 variant = vab.m_value;
2300             return vab.m_result;
2301         }
2302 #endif
2303 
2304         return IntToValue(variant, number, argFlags);
2305     }
2306 
GetValueType()2307     wxString GetValueType() const
2308     {
2309         return m_value.GetType();
2310     }
2311 
2312 #ifndef SWIG
2313     /** Returns pointer to an instance of editor class.
2314     */
2315     virtual const wxPGEditor* DoGetEditorClass() const;
2316 #endif
2317 
2318 #ifdef __WXPYTHON__
2319     /** Returns name of editor used. Takes precendence in the wxPython bindings.
2320     */
2321     virtual wxString GetEditor() const;
2322 #endif
2323 
2324     /** Returns pointer to the wxValidator that should be used
2325         with the editor of this property (NULL for no validator).
2326         Setting validator explicitly via SetPropertyValidator
2327         will override this.
2328 
2329         In most situations, code like this should work well
2330         (macros are used to maintain one actual validator instance,
2331         so on the second call the function exits within the first
2332         macro):
2333 
2334         @code
2335 
2336         wxValidator* wxMyPropertyClass::DoGetValidator () const
2337         {
2338             WX_PG_DOGETVALIDATOR_ENTRY()
2339 
2340             wxMyValidator* validator = new wxMyValidator(...);
2341 
2342             ... prepare validator...
2343 
2344             WX_PG_DOGETVALIDATOR_EXIT(validator)
2345         }
2346 
2347         @endcode
2348 
2349         @remarks
2350         You can get common filename validator by returning
2351         wxFileProperty::GetClassValidator(). wxDirProperty,
2352         for example, uses it.
2353     */
2354     virtual wxValidator* DoGetValidator () const;
2355 
2356     /** Returns current value's index to the choice control. May also return,
2357         through pointer arguments, strings that should be inserted to that control.
2358         Irrelevant to classes which do not employ wxPG_EDITOR(Choice) or similar.
2359         @remarks
2360         - If returns NULL in choices, then this class must be
2361           derived from wxBaseEnumProperty.
2362         - Must not crash even if property's set of choices is uninitialized
2363           (i.e. it points to wxPGGlobalVars->m_emptyConstants).
2364     */
2365     virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
2366 
2367     /** Override to paint an image in front of the property value text or drop-down
2368         list item (but only if wxPGProperty::OnMeasureImage is overridden as well).
2369 
2370         If property's OnMeasureImage() returns size that has height != 0 but less than
2371         row height ( < 0 has special meanings), wxPropertyGrid calls this method to
2372         draw a custom image in a limited area in front of the editor control or
2373         value text/graphics, and if control has drop-down list, then the image is
2374         drawn there as well (even in the case OnMeasureImage() returned higher height
2375         than row height).
2376 
2377         NOTE: Following applies when OnMeasureImage() returns a "flexible" height (
2378         using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable height items:
2379         If rect.x is < 0, then this is a measure item call, which means that
2380         dc is invalid and only thing that should be done is to set paintdata.m_drawnHeight
2381         to the height of the image of item at index paintdata.m_choiceItem. This call
2382         may be done even as often as once every drop-down popup show.
2383 
2384         @param dc
2385         wxDC to paint on.
2386         @param rect
2387         Box reserved for custom graphics. Includes surrounding rectangle, if any.
2388         If x is < 0, then this is a measure item call (see above).
2389         @param paintdata
2390         wxPGPaintData structure with much useful data.
2391 
2392         @remarks
2393             - You can actually exceed rect width, but if you do so then paintdata.m_drawnWidth
2394               must be set to the full width drawn in pixels.
2395             - Due to technical reasons, rect's height will be default even if custom height
2396               was reported during measure call.
2397             - Brush is guaranteed to be default background colour. It has been already used to
2398               clear the background of area being painted. It can be modified.
2399             - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper colour) pen for
2400               drawing framing rectangle. It can be changed as well.
2401         @sa @link GetValueAsString @endlink
2402     */
2403     virtual void OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& paintdata );
2404 
2405     /** Returns used wxPGCellRenderer instance for given property column (label=0, value=1).
2406 
2407         Default implementation returns editor's renderer for all columns.
2408     */
2409     virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
2410 
2411     /** Refresh values of child properties. Automatically called after value is set.
2412     */
2413     virtual void RefreshChildren();
2414 
2415     /** Special handling for attributes of this property.
2416 
2417         If returns false, then the attribute will be automatically stored in
2418         m_attributes.
2419 
2420         Default implementation simply returns false.
2421     */
2422     virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
2423 
2424     /** Returns value of an attribute.
2425 
2426         Override if custom handling of attributes is needed.
2427 
2428         Default implementation simply return NULL variant.
2429     */
2430     virtual wxVariant DoGetAttribute( const wxString& name ) const;
2431 
2432     /** Returns instance of a new wxPGEditorDialogAdapter instance, which is
2433         used when user presses the (optional) button next to the editor control;
2434 
2435         Default implementation returns NULL (ie. no action is generated when
2436         button is pressed).
2437     */
2438     virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
2439 
2440     /**
2441         Called whenever validation has failed with given pending value.
2442 
2443         @remarks If you implement this in your custom property class, please
2444                  remember to call the baser implementation as well as they
2445                  may use it to revert property into pre-change state.
2446     */
2447     virtual void OnValidationFailure( wxVariant& pendingValue );
2448 
2449     /** Adds entry to property's wxPGChoices and editor control (if it is active).
2450         Returns index of item added.
2451     */
2452     int AppendChoice( const wxString& label, int value = wxPG_INVALID_VALUE )
2453     {
2454         return InsertChoice(label,-1,value);
2455     }
2456 
2457     /** Returns wxPGCell of given column, NULL if none. If valid
2458         object is returned, caller will gain its ownership.
2459     */
AcquireCell(unsigned int column)2460     wxPGCell* AcquireCell( unsigned int column )
2461     {
2462         if ( column >= m_cells.size() )
2463             return NULL;
2464 
2465         wxPGCell* cell = (wxPGCell*) m_cells[column];
2466         m_cells[column] = NULL;
2467         return cell;
2468     }
2469 
2470     /** Returns true if children of this property are component values (for instance,
2471         points size, face name, and is_underlined are component values of a font).
2472     */
AreChildrenComponents()2473     bool AreChildrenComponents() const
2474     {
2475         if ( m_flags & (wxPG_PROP_COMPOSED_VALUE|wxPG_PROP_AGGREGATE) )
2476             return true;
2477 
2478         return false;
2479     }
2480 
2481     /**
2482         Call this to add sub-properties which will become private, fixed
2483         children. To handle value changes to and from these properties,
2484         you must implement RefreshChildren() and ChildChanged() in derived
2485         property class.
2486 
2487         @remarks If you wish to add independent child properties, use
2488                  AppendChild() or InsertChild() instead.
2489 
2490         @see AppendChild(), InsertChild()
2491     */
AddPrivateChild(wxPGProperty * prop)2492     void AddPrivateChild( wxPGProperty* prop )
2493     {
2494         AddChild(prop);
2495     }
2496 
2497     /**
2498         Appends a new child property.
2499 
2500         @see InsertChild(), AddPrivateChild()
2501     */
AppendChild(wxPGProperty * prop)2502     wxPGProperty* AppendChild( wxPGProperty* prop )
2503     {
2504         return InsertChild(-1, prop);
2505     }
2506 
2507     /**
2508         Use this member function to add independent (ie. regular) children to
2509         a property.
2510 
2511         @return Inserted childProperty.
2512 
2513         @remarks wxPropertyGrid is not automatically refreshed by this
2514                  function.
2515 
2516         @see AppendChild(), AddPrivateChild()
2517     */
2518     wxPGProperty* InsertChild( int index, wxPGProperty* childProperty );
2519 
2520     /**
2521         Deletes children of the property.
2522     */
2523     void DeleteChildren();
2524 
2525     /** Removes entry from property's wxPGChoices and editor control (if it is active).
2526 
2527         If selected item is deleted, then the value is set to unspecified.
2528     */
2529     void DeleteChoice( int index );
2530 
2531     /**
2532         Deletes children of the property.
2533     */
Empty()2534     void Empty()
2535     {
2536         DeleteChildren();
2537     }
2538 
2539     /** Call to enable or disable usage of common value (integer value that can be selected for
2540         properties instead of their normal values) for this property.
2541 
2542         Common values are disabled by the default for all properties.
2543     */
2544     void EnableCommonValue( bool enable = true )
2545     {
2546         if ( enable ) SetFlag( wxPG_PROP_USES_COMMON_VALUE );
2547         else ClearFlag( wxPG_PROP_USES_COMMON_VALUE );
2548     }
2549 
2550     /** Composes text from values of child properties. */
2551     void GenerateComposedValue( wxString& text, int argFlags = 0 ) const;
2552 
2553     /** Returns property's label. */
GetLabel()2554     const wxString& GetLabel() const { return m_label; }
2555 
2556     /** Returns property's name with all (non-category, non-root) parents. */
2557     wxString GetName() const;
2558 
2559     /** Returns property's base name (ie. parent's name is not added in any case) */
GetBaseName()2560     const wxString& GetBaseName() const { return m_name; }
2561 
2562     wxPGChoices& GetChoices();
2563 
2564     const wxPGChoices& GetChoices() const;
2565 
2566     const wxPGChoiceEntry* GetCurrentChoice() const;
2567 
2568     /** Returns coordinate to the top y of the property. Note that the
2569         position of scrollbars is not taken into account.
2570     */
2571     int GetY() const;
2572 
GetValue()2573     wxVariant GetValue() const
2574     {
2575     #ifdef __WXPYTHON__
2576         wxVariant val = DoGetValue();
2577         if ( val.IsNull() )
2578             return PyObjectToVariant( Py_None );
2579         return val;
2580     #else
2581         return DoGetValue();
2582     #endif
2583     }
2584 
2585     /** Returns reference to the internal stored value. GetValue is preferred
2586         way to get the actual value, since GetValueRef ignores DoGetValue,
2587         which may override stored value.
2588     */
GetValueRef()2589     wxVariant& GetValueRef()
2590     {
2591         return m_value;
2592     }
2593 
GetValueRef()2594     const wxVariant& GetValueRef() const
2595     {
2596         return m_value;
2597     }
2598 
2599     /** Same as GetValueAsString, except takes common value into account.
2600     */
2601     wxString GetValueString( int argFlags = 0 ) const;
2602 
2603     /**
2604         Returns wxPGCell of given column, NULL if none. wxPGProperty
2605         will retain ownership of the cell object.
2606 
2607         @remarks If cell object does not exist for given column,
2608                  it will not be created. Use GetOrCreateCell()
2609                  instead if you want that behavior.
2610     */
GetCell(unsigned int column)2611     wxPGCell* GetCell( unsigned int column ) const
2612     {
2613         if ( column >= m_cells.size() )
2614             return NULL;
2615 
2616         return (wxPGCell*) m_cells[column];
2617     }
2618 
2619     /**
2620         Returns wxPGCell of given column, creating one if necesasry.
2621         wxPGProperty will retain ownership of the cell object.
2622     */
2623     wxPGCell* GetOrCreateCell( unsigned int column );
2624 
GetClassName()2625     const wxChar* GetClassName() const
2626     {
2627         return GetClassInfo()->GetClassName();
2628     }
2629 
2630     unsigned int GetChoiceCount() const;
2631 
2632     wxString GetChoiceString( unsigned int index );
2633 
2634     /** Return number of displayed common values for this property.
2635     */
2636     int GetDisplayedCommonValueCount() const;
2637 
GetDisplayedString()2638     wxString GetDisplayedString() const
2639     {
2640         return GetValueString(0);
2641     }
2642 
2643 #if wxPG_COMPATIBILITY_1_2_0
2644     /** Returns property id. */
GetId()2645     wxPGId GetId() { return this; }
2646 #endif
2647 
2648     /** Returns property grid where property lies. */
2649     wxPropertyGrid* GetGrid() const;
2650 
2651     /** Returns owner wxPropertyGrid, but only if one is currently on a page
2652         displaying this property. */
2653     wxPropertyGrid* GetGridIfDisplayed() const;
2654 
2655     /** Returns highest level non-category, non-root parent. Useful when you
2656         have nested wxCustomProperties/wxParentProperties.
2657         @remarks
2658         Thus, if immediate parent is root or category, this will return the
2659         property itself.
2660     */
2661     wxPGProperty* GetMainParent() const;
2662 
2663     /** Return parent of property */
GetParent()2664     wxPGProperty* GetParent() const { return m_parent; }
2665 
IsFlagSet(FlagType flag)2666     bool IsFlagSet( FlagType flag ) const
2667     {
2668         return ( m_flags & flag ) ? true : false;
2669     }
2670 
2671     /** Returns true if property has editable wxTextCtrl when selected.
2672 
2673         @remarks
2674         Altough disabled properties do not displayed editor, they still
2675         return True here as being disabled is considered a temporary
2676         condition (unlike being read-only or having limited editing enabled).
2677     */
2678     bool IsTextEditable() const;
2679 
2680     /**
2681         Returns @true if property value is unspecified.
2682     */
IsValueUnspecified()2683     bool IsValueUnspecified() const
2684     {
2685         return m_value.IsNull();
2686     }
2687 
2688     /**
2689         Returns non-zero if given property flag is set.
2690 
2691         For list of supported flags, see
2692         @link propflags List of wxPGProperty Flags@endlink.
2693     */
HasFlag(FlagType flag)2694     FlagType HasFlag( FlagType flag ) const
2695     {
2696         return ( m_flags & flag );
2697     }
2698 
2699     /** Returns true if extra children can be added for this property
2700         (i.e. it is wxPropertyCategory or wxCustomProperty)
2701     */
CanHaveExtraChildren()2702     bool CanHaveExtraChildren() const
2703     {
2704         return !IsFlagSet(wxPG_PROP_AGGREGATE);
2705     }
2706 
2707     /** Returns comma-delimited string of property attributes.
2708     */
GetAttributes()2709     const wxPGAttributeStorage& GetAttributes() const
2710     {
2711         return m_attributes;
2712     }
2713 
2714     /** Returns m_attributes as list wxVariant.
2715     */
2716     wxVariant GetAttributesAsList() const;
2717 
GetFlags()2718     FlagType GetFlags() const
2719     {
2720         return m_flags;
2721     }
2722 
2723     const wxPGEditor* GetEditorClass() const;
2724 
2725     /** Returns editor used for given column. NULL for no editor.
2726     */
GetColumnEditor(int column)2727     const wxPGEditor* GetColumnEditor( int column ) const
2728     {
2729         if ( column == 1 )
2730             return GetEditorClass();
2731 
2732         return NULL;
2733     }
2734 
2735     /** Returns common value selected for this property. -1 for none.
2736     */
GetCommonValue()2737     int GetCommonValue() const
2738     {
2739         return m_commonValue;
2740     }
2741 
2742     /** Returns type name of property that is compatible with CreatePropertyByType.
2743         and wxVariant::GetType.
2744     */
GetType()2745     wxString GetType() const
2746     {
2747         return m_value.GetType();
2748     }
2749 
2750     /** Returns true if property has even one visible child.
2751     */
2752     bool HasVisibleChildren() const;
2753 
2754     /** Adds entry to property's wxPGChoices and editor control (if it is active).
2755         Returns index of item added.
2756     */
2757     int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
2758 
2759     /** Returns true if this property is actually a wxPropertyCategory.
2760     */
IsCategory()2761     bool IsCategory() const { return IsFlagSet(wxPG_PROP_CATEGORY); }
2762 
2763     /** Returns true if this property is actually a wxRootProperty.
2764     */
IsRoot()2765     bool IsRoot() const { return (m_parent == NULL); }
2766 
2767     /** Returns true if this is a sub-property. */
IsSubProperty()2768     bool IsSubProperty() const
2769     {
2770         wxPGProperty* parent = (wxPGProperty*)m_parent;
2771         if ( parent && !parent->IsCategory() )
2772             return true;
2773         return false;
2774     }
2775 
2776     /** Returns last visible sub-property, recursively.
2777     */
2778     const wxPGProperty* GetLastVisibleSubItem() const;
2779 
2780     wxVariant GetDefaultValue() const;
2781 
GetMaxLength()2782     int GetMaxLength() const
2783     {
2784         return (int) m_maxLen;
2785     }
2786 
2787 #ifndef SWIG
2788   #if wxPG_COMPATIBILITY_1_2_0
2789     /** Returns value as wxVariant.
2790         @deprecated
2791         Since wxPropertyGrid 1.3. Use GetValue() instead.
2792     */
GetValueAsVariant()2793     wxVariant GetValueAsVariant() const
2794     {
2795         return GetValue();
2796     }
2797   #endif
2798 #endif
2799 
2800     /** Determines, recursively, if all children are not unspecified. Takes values in given list into account.
2801     */
2802     bool AreAllChildrenSpecified( wxVariant* pendingList = NULL ) const;
2803 
2804     /** Updates composed values of parent non-category properties, recursively.
2805         Returns topmost property updated.
2806 
2807         @remarks
2808         - Must not call SetValue() (as can be called in it).
2809     */
2810     wxPGProperty* UpdateParentValues();
2811 
2812     /** Returns true if containing grid uses wxPG_EX_AUTO_UNSPECIFIED_VALUES.
2813     */
UsesAutoUnspecified()2814     FlagType UsesAutoUnspecified() const
2815     {
2816         return HasFlag(wxPG_PROP_AUTO_UNSPECIFIED);
2817     }
2818 
GetValueImage()2819     wxBitmap* GetValueImage() const
2820     {
2821         return m_valueBitmap;
2822     }
2823 
2824     wxVariant GetAttribute( const wxString& name ) const;
2825 
2826     /** Returns named attribute, as string, if found. Otherwise defVal is returned.
2827     */
2828     wxString GetAttribute( const wxString& name, const wxString& defVal ) const;
2829 
2830     /** Returns named attribute, as long, if found. Otherwise defVal is returned.
2831     */
2832     long GetAttributeAsLong( const wxString& name, long defVal ) const;
2833 
2834     /** Returns named attribute, as double, if found. Otherwise defVal is returned.
2835     */
2836     double GetAttributeAsDouble( const wxString& name, double defVal ) const;
2837 
GetArrIndex()2838     inline unsigned int GetArrIndex() const { return m_arrIndex; }
2839 
GetDepth()2840     inline unsigned int GetDepth() const { return (unsigned int)m_depth; }
2841 
2842     /** Gets flags as a'|' delimited string. Note that flag names are not
2843         prepended with 'wxPG_PROP_'.
2844         @param flagsMask
2845         String will only be made to include flags combined by this parameter.
2846     */
2847     wxString GetFlagsAsString( FlagType flagsMask ) const;
2848 
2849     /** Returns position in parent's array. */
GetIndexInParent()2850     unsigned int GetIndexInParent() const
2851     {
2852         return m_arrIndex;
2853     }
2854 
2855     /** Hides or reveals the property.
2856         @param hide
2857         true for hide, false for reveal.
2858         @param flags
2859         By default changes are applied recursively. Set this paramter wxPG_DONT_RECURSE to prevent this.
2860     */
2861     bool Hide( bool hide, int flags = wxPG_RECURSE );
2862 
IsExpanded()2863     bool IsExpanded() const { return (!(m_flags & wxPG_PROP_COLLAPSED) && GetChildCount()); }
2864 
2865     /** Returns true if all parents expanded.
2866     */
2867     bool IsVisible() const;
2868 
IsEnabled()2869     bool IsEnabled() const
2870     {
2871         return ( m_flags & wxPG_PROP_DISABLED ) ? false : true;
2872     }
2873 
2874     /** If property's editor is created this forces its recreation. Useful
2875         in SetAttribute etc. Returns true if actually did anything.
2876     */
2877     bool RecreateEditor();
2878 
2879     /** If property's editor is active, then update it's value.
2880     */
2881     void RefreshEditor();
2882 
2883     /** Sets an attribute for this property.  There are both common attributes and
2884         property class specific ones. For list of common attributes, see
2885         wxPropertyGridInterface::SetPropertyAttribute().
2886 
2887         @remarks Settings attribute's value to Null variant will simply remove it
2888                  from property's set of attributes.
2889     */
2890     void SetAttribute( const wxString& name, wxVariant value );
2891 
2892     /** Sets attributes from a comma-delimited string.
2893     */
2894     void SetAttributes( const wxPGAttributeStorage& attributes );
2895 
2896     /** Set default value of a property. Synonymous to
2897 
2898         @code
2899             SetAttribute(wxT("DefaultValue"), value);
2900         @endcode
2901     */
SetDefaultValue(wxVariant & value)2902     void SetDefaultValue( wxVariant& value )
2903     {
2904         SetAttribute(wxT("DefaultValue"), value);
2905     }
2906 
2907     /** Sets editor for a property. */
2908 #ifndef SWIG
SetEditor(const wxPGEditor * editor)2909     void SetEditor( const wxPGEditor* editor )
2910     {
2911         m_customEditor = editor;
2912     }
2913 #endif
2914 
2915     /** Sets editor for a property. */
2916     inline void SetEditor( const wxString& editorName );
2917 
2918     /** Sets cell information for given column.
2919 
2920         Note that the property takes ownership of given wxPGCell instance.
2921     */
2922     void SetCell( int column, wxPGCell* cellObj );
2923 
2924     /** Changes value of a property with choices, but only
2925         works if the value type is long or string. */
2926     void SetChoiceSelection( int newValue, const wxPGChoiceInfo& choiceInfo );
2927 
2928     /** Sets common value selected for this property. -1 for none.
2929     */
SetCommonValue(int commonValue)2930     void SetCommonValue( int commonValue )
2931     {
2932         m_commonValue = commonValue;
2933     }
2934 
2935     /** Sets flags from a '|' delimited string. Note that flag names are not
2936         prepended with 'wxPG_PROP_'.
2937     */
2938     void SetFlagsFromString( const wxString& str );
2939 
2940     /** Call in OnEvent(), OnButtonClick() etc. to change the property value
2941         based on user input.
2942 
2943         @remarks
2944         This method is const since it doesn't actually modify value, but posts
2945         given variant as pending value, stored in wxPropertyGrid.
2946     */
2947     void SetValueInEvent( wxVariant value ) const;
2948 
2949     /** Call this to set value of the property. Unlike methods in wxPropertyGrid,
2950         this does not automatically update the display.
2951 
2952         @remarks
2953         Use wxPropertyGrid::ChangePropertyValue() instead if you need to run through
2954         validation process and send property change event.
2955 
2956         If you need to change property value in event, based on user input, use
2957         SetValueInEvent() instead.
2958 
2959         (only if wxPG_PROP_AGGREGATE flag is set).
2960         @param pList
2961         Pointer to list variant that contains child values. Used to indicate
2962         which children should be marked as modified.
2963         @param flags
2964         Various flags (for instance, wxPG_SETVAL_REFRESH_EDITOR), which is on
2965         by default.
2966     */
2967     void SetValue( wxVariant value, wxVariant* pList = NULL,
2968                    int flags = wxPG_SETVAL_REFRESH_EDITOR );
2969 
2970     /** Set wxBitmap in front of the value. This bitmap may be ignored
2971         by custom cell renderers.
2972     */
2973     void SetValueImage( wxBitmap& bmp );
2974 
2975     /** If property has choices and they are not yet exclusive, new such copy
2976         of them will be created.
2977     */
2978     void SetChoicesExclusive();
2979 
SetExpanded(bool expanded)2980     void SetExpanded( bool expanded )
2981     {
2982         if ( !expanded ) m_flags |= wxPG_PROP_COLLAPSED;
2983         else m_flags &= ~wxPG_PROP_COLLAPSED;
2984     }
2985 
2986     /**
2987         Sets given property flag(s).
2988 
2989         For list of allowed flags, see
2990         @link propflags List of wxPGProperty Flags@endlink.
2991     */
SetFlag(FlagType flag)2992     void SetFlag( FlagType flag ) { m_flags |= flag; }
2993 
2994     /**
2995         Sets or clears given property flag(s).
2996 
2997         For list of allowed flags, see
2998         @link propflags List of wxPGProperty Flags@endlink.
2999     */
ChangeFlag(FlagType flag,bool set)3000     void ChangeFlag( FlagType flag, bool set )
3001     {
3002         if ( set )
3003             m_flags |= flag;
3004         else
3005             m_flags &= ~flag;
3006     }
3007 
3008     /**
3009         Sets or clears given property flag(s), recursively in
3010         child properties (if any).
3011 
3012         For list of allowed flags, see
3013         @link propflags List of wxPGProperty Flags@endlink.
3014     */
3015     void SetFlagRecursively( FlagType flag, bool set );
3016 
SetHelpString(const wxString & helpString)3017     void SetHelpString( const wxString& helpString )
3018     {
3019         m_helpString = helpString;
3020     }
3021 
3022     /** Sets property's label.
3023 
3024         @remarks
3025         - Properties under same parent may have same labels. However,
3026         property names must still remain unique.
3027     */
SetLabel(const wxString & label)3028     void SetLabel( const wxString& label ) { m_label = label; }
3029 
3030     void SetName( const wxString& newName );
3031 
3032     /**
3033         Sets property value to unspecified.
3034     */
SetValueToUnspecified()3035     void SetValueToUnspecified()
3036     {
3037         wxVariant val;  // Create NULL variant
3038         SetValue(val, NULL, wxPG_SETVAL_REFRESH_EDITOR);
3039     }
3040 
3041 #if wxUSE_VALIDATORS
3042     /** Sets wxValidator for a property*/
SetValidator(const wxValidator & validator)3043     void SetValidator( const wxValidator& validator )
3044     {
3045         m_validator = wxDynamicCast(validator.Clone(),wxValidator);
3046     }
3047 
3048     /** Gets assignable version of property's validator. */
GetValidator()3049     wxValidator* GetValidator() const
3050     {
3051         if ( m_validator )
3052             return m_validator;
3053         return DoGetValidator();
3054     }
3055 #endif // #if wxUSE_VALIDATORS
3056 
3057     /** Updates property value in case there were last minute
3058         changes. If value was unspecified, it will be set to default.
3059         Use only for properties that have TextCtrl-based editor.
3060         @remarks
3061         If you have code similar to
3062         @code
3063             // Update the value in case of last minute changes
3064             if ( primary && propgrid->IsEditorsValueModified() )
3065                  GetEditorClass()->CopyValueFromControl( this, primary );
3066         @endcode
3067         in wxPGProperty::OnEvent wxEVT_COMMAND_BUTTON_CLICKED handler,
3068         then replace it with call to this method.
3069         @retval
3070         True if value changed.
3071     */
3072     bool PrepareValueForDialogEditing( wxPropertyGrid* propgrid );
3073 
3074     //
3075     // NB: There is something slightly wrong with the Python
3076     //     client data code. What exactly, I have no idea. Increfs
3077     //     and decrefs seemed to be correct, but in certain complex
3078     //     situations (where two separate grids refer to same
3079     //     client data objects are being destroyed?) it causes a hard
3080     //     crash. Current workaround is not to use this "native" client
3081     //     data but use some Python dict system instead. I won't replace
3082     //     current system with such just yet... (but maybe I should
3083     //     or need to).
GetClientData()3084     ClientDataType GetClientData() const
3085     {
3086 #ifdef __WXPYTHON__
3087         if ( m_clientData )
3088             Py_INCREF( m_clientData );
3089         else
3090             Py_RETURN_NONE;
3091 #endif
3092         return m_clientData;
3093     }
3094 
3095     /** Sets client data (void*) of a property.
3096         @remarks
3097         This untyped client data has to be deleted manually.
3098     */
SetClientData(ClientDataType clientData)3099     void SetClientData( ClientDataType clientData )
3100     {
3101 #ifdef __WXPYTHON__
3102         if ( m_clientData )
3103             Py_DECREF( m_clientData );
3104 
3105         if ( clientData == Py_None )
3106         {
3107             m_clientData = NULL;
3108             return;
3109         }
3110 
3111         Py_INCREF( clientData );
3112 #endif
3113         m_clientData = clientData;
3114     }
3115 
3116     /**
3117         Set choices of a property to specified set of labels and values.
3118 
3119         @remarks This operation clears the property value. Also, if you
3120                  try to use this on a property which cannot hold choices,
3121                  a run-time error will be shown.
3122 
3123                  This function will deselect the property, if
3124                  necessary.
3125     */
3126     bool SetChoices( wxPGChoices& choices );
3127 
3128     /** Sets new set of choices for property.
3129     */
3130     inline bool SetChoices( const wxArrayString& labels,
3131                             const wxArrayInt& values = wxPG_EMPTY_ARRAYINT );
3132 
3133     /** Set max length of text editor.
3134     */
3135     inline bool SetMaxLength( int maxLen );
3136 
3137     /** Call with 'false' in OnSetValue to cancel value changes after all
3138         (ie. cancel 'true' returned by StringToValue() or IntToValue()).
3139     */
3140     void SetWasModified( bool set = true )
3141     {
3142         if ( set ) m_flags |= wxPG_PROP_WAS_MODIFIED;
3143         else m_flags &= ~wxPG_PROP_WAS_MODIFIED;
3144     }
3145 
GetHelpString()3146     const wxString& GetHelpString() const
3147     {
3148         return m_helpString;
3149     }
3150 
ClearFlag(FlagType flag)3151     void ClearFlag( FlagType flag ) { m_flags &= ~(flag); }
3152 
3153     // Use, for example, to detect if item is inside collapsed section.
3154     bool IsSomeParent( wxPGProperty* candidate_parent ) const;
3155 
3156 #if defined(__WXPYTHON__) && !defined(SWIG)
3157     // This is the python object that contains and owns the C++ representation.
3158     PyObject*                   m_scriptObject;
3159     wxClientData*               m_OORClientData;
3160 #endif
3161 
3162     /** Adapts list variant into proper value using consequtive ChildChanged-calls.
3163     */
3164     void AdaptListToValue( wxVariant& list, wxVariant* value ) const;
3165 
3166     /** Returns height of children, recursively, and
3167         by taking expanded/collapsed status into account.
3168 
3169         iMax is used when finding property y-positions.
3170     */
3171     int GetChildrenHeight( int lh, int iMax = -1 ) const;
3172 
3173     /** Returns number of child properties */
GetChildCount()3174     unsigned int GetChildCount() const
3175     {
3176         return (unsigned int) m_children.GetCount();
3177     }
3178 
3179     /** Returns number of child properties */
GetCount()3180     unsigned int GetCount() const
3181     {
3182         return GetChildCount();
3183     }
3184 
3185     /** Returns sub-property at index i. */
Item(unsigned int i)3186     wxPGProperty* Item( unsigned int i ) const
3187     {
3188         return (wxPGProperty*)m_children.Item(i);
3189     }
3190 
3191     /** Returns last sub-property.
3192     */
Last()3193     wxPGProperty* Last() const { return (wxPGProperty*)m_children.Last(); }
3194 
3195     /** Returns index of given sub-property. */
Index(const wxPGProperty * p)3196     int Index( const wxPGProperty* p ) const { return m_children.Index((wxPGProperty*)p); }
3197 
3198     // Puts correct indexes to children
3199     void FixIndexesOfChildren( unsigned int starthere = 0 );
3200 
3201 #ifndef SWIG
3202     // Returns wxPropertyGridState in which this property resides.
GetParentState()3203     wxPropertyGridState* GetParentState() const { return m_parentState; }
3204 #endif
3205 
3206     wxPGProperty* GetItemAtY( unsigned int y, unsigned int lh, unsigned int* nextItemY ) const;
3207 
3208     /** Returns (direct) child property with given name (or NULL if not found).
3209     */
3210     wxPGProperty* GetPropertyByName( const wxString& name ) const;
3211 
3212     /**
3213         Converts image width into full image offset, with margins.
3214     */
3215     int GetImageOffset( int imageWidth ) const;
3216 
3217 protected:
3218 
3219     /**
3220         Call this to add sub-properties which will become private, fixed
3221         children. To handle value changes to and from these properties,
3222         you must implement RefreshChildren() and ChildChanged() in derived
3223         property class.
3224 
3225         @remarks If you wish to add independent child properties, use
3226                  InsertChild() instead. If you wish to add private child
3227                  properties outside derived property class, use
3228                  AddPrivateChild().
3229 
3230         @deprecated
3231             Since wxPropertyGrid 1.4.5. Use AddPrivateChild() instead.
3232 
3233         @see AddPrivateChild(), AppendChild(), InsertChild()
3234     */
3235     void AddChild( wxPGProperty* prop );
3236 
3237 #ifndef SWIG
3238 
3239     /** Returns text for given column.
3240     */
3241     wxString GetColumnText( unsigned int col ) const;
3242 
3243     /** Returns (direct) child property with given name (or NULL if not found),
3244         with hint index.
3245 
3246         @param hintIndex
3247         Start looking for the child at this index.
3248 
3249         @remarks
3250         Does not support scope (ie. Parent.Child notation).
3251     */
3252     wxPGProperty* GetPropertyByNameWH( const wxString& name, unsigned int hintIndex ) const;
3253 
3254     /** This is used by Insert etc. */
3255     void AddChild2( wxPGProperty* prop, int index = -1, bool correct_mode = true );
3256 
3257     bool DoHide( bool hide, int flags );
3258 
DoSetName(const wxString & str)3259     void DoSetName(const wxString& str) { m_name = str; }
3260 
3261     /** Deletes all sub-properties. */
3262     void DoEmpty();
3263 
3264     /**
3265         Returns true if child property is selected.
3266         If recursive == true, test sub-childs too (returns true if at least
3267         one sub-child is selected).
3268     */
3269     bool IsChildSelected( const bool recursive = false ) const;
3270 
3271     // Call for after sub-properties added with AddChild
3272     void PrepareSubProperties();
3273 
SetParentalType(int flag)3274     void SetParentalType( int flag )
3275     {
3276         m_flags = (m_flags&(~(wxPG_PROP_PROPERTY|wxPG_PROP_PARENTAL_FLAGS)))|flag;
3277     }
3278 
SetParentState(wxPropertyGridState * pstate)3279     void SetParentState( wxPropertyGridState* pstate ) { m_parentState = pstate; }
3280 
3281     // Call after fixed sub-properties added/removed after creation.
3282     // if oldSelInd >= 0 and < new max items, then selection is
3283     // moved to it.
3284     void SubPropsChanged( int oldSelInd = -1 );
3285 
3286     int GetY2( int lh ) const;
3287 
3288     wxString                    m_label;
3289     wxString                    m_name;
3290     wxPGProperty*               m_parent;
3291     wxPropertyGridState*        m_parentState;
3292     ClientDataType              m_clientData;
3293     const wxPGEditor*           m_customEditor; // Overrides editor returned by property class
3294 #if wxUSE_VALIDATORS
3295     wxValidator*                m_validator; // Editor is going to get this validator
3296 #endif
3297     // TODO: Can bitmap be implemented with wxPGCell?
3298     wxBitmap*                   m_valueBitmap; // Show this in front of the value
3299 
3300     wxVariant                   m_value;
3301     wxPGAttributeStorage        m_attributes;
3302     wxArrayPtrVoid              m_children;
3303     wxArrayPtrVoid              m_cells;  // Extended cell information
3304     wxString                    m_helpString; // Help shown in statusbar or help box.
3305 
3306     unsigned int                m_arrIndex; // Index in parent's property array.
3307     int                         m_commonValue; // If not -1, then overrides m_value
3308 
3309     FlagType                    m_flags;
3310 
3311     short                       m_maxLen; // Maximum length (mainly for string properties).
3312                                           // Could be in some sort of wxBaseStringProperty, but currently,
3313                                           // for maximum flexibility and compatibility, we'll stick it here.
3314                                           // Anyway, we had 3 excess bytes to use so short int will fit in
3315                                           // just fine.
3316 
3317     unsigned char               m_depth; // Root has 0, categories etc. at that level 1, etc.
3318 
3319     // m_depthBgCol indicates width of background colour between margin and item
3320     // (essentially this is category's depth, if none then equals m_depth).
3321     unsigned char               m_depthBgCol;
3322 
3323     unsigned char               m_bgColIndex; // Background brush index.
3324     unsigned char               m_fgColIndex; // Foreground colour index.
3325 
3326 private:
3327     // Called in constructors.
3328     void Init();
3329     void Init( const wxString& label, const wxString& name );
3330 #endif // #ifndef SWIG
3331 };
3332 
3333 
3334 #if wxPG_COMPATIBILITY_1_2_0
3335     typedef wxPGProperty wxPGPropertyWithChildren;
3336 #endif
3337 
3338 #define wxPGPropNameStr            const wxString&
3339 #define wxPGNameConv(STR)      STR
3340 
3341 // -----------------------------------------------------------------------
3342 
3343 
3344 #ifndef SWIG
3345 
3346 WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(void*,
3347                                       wxPGHashMapP2P,
3348                                       class WXDLLIMPEXP_PG);
3349 
3350 #else
3351 class WXDLLIMPEXP_PG wxPGHashMapP2P;
3352 #endif // #ifndef SWIG
3353 
3354 // -----------------------------------------------------------------------
3355 
3356 #ifndef SWIG
3357 
3358 WX_DECLARE_HASH_MAP_WITH_DECL(wxInt32,
3359                               wxInt32,
3360                               wxIntegerHash,
3361                               wxIntegerEqual,
3362                               wxPGHashMapI2I,
3363                               class WXDLLIMPEXP_PG);
3364 
3365 #else
3366 class WXDLLIMPEXP_PG wxPGHashMapI2I;
3367 #endif // #ifndef SWIG
3368 
3369 // -----------------------------------------------------------------------
3370 
3371 #ifndef SWIG
3372 
3373 /** @class wxPGRootProperty
3374     @ingroup classes
3375     @brief Root parent property.
3376 */
3377 class WXDLLIMPEXP_PG wxPGRootProperty : public wxPGProperty
3378 {
3379 public:
3380     WX_PG_DECLARE_PROPERTY_CLASS(wxPGRootProperty)
3381 public:
3382 
3383     /** Constructor. */
3384     wxPGRootProperty();
3385     ~wxPGRootProperty() override;
3386 
StringToValue(wxVariant &,const wxString &,int)3387     bool StringToValue( wxVariant&, const wxString&, int ) const override
3388     {
3389         return false;
3390     }
3391 
ChildChanged(wxVariant &,int,wxVariant &)3392     void ChildChanged( wxVariant&, int, wxVariant& ) const override
3393     {
3394     }
3395 
3396 protected:
3397 };
3398 
3399 // -----------------------------------------------------------------------
3400 
3401 /** @class wxPropertyCategory
3402     @ingroup classes
3403     @brief Category (caption) property.
3404 */
3405 class WXDLLIMPEXP_PG wxPropertyCategory : public wxPGProperty
3406 {
3407     WX_PG_DECLARE_PROPERTY_CLASS(wxPropertyCategory)
3408 public:
3409 
3410     /** Special constructor only used in special cases. */
3411     wxPropertyCategory();
3412 
3413     /** Construct.
3414         @param label
3415         Label for the category.
3416         @remarks
3417         All non-category properties appended will have most recently
3418         added category.
3419     */
3420     wxPropertyCategory( const wxString& label, const wxString& name = wxPG_LABEL );
3421     ~wxPropertyCategory() override;
3422 
3423     /** Must be overridden with function that doesn't do anything. */
3424     wxString GetValueAsString( int argFlags ) const override;
3425 
ChildChanged(wxVariant &,int,wxVariant &)3426     void ChildChanged( wxVariant&, int, wxVariant& ) const override
3427     {
3428     }
3429 
3430     int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const;
3431 
3432     void CalculateTextExtent( wxWindow* wnd, const wxFont& font );
3433 
SetTextColIndex(unsigned int colInd)3434     void SetTextColIndex( unsigned int colInd ) { m_capFgColIndex = (wxByte) colInd; }
GetTextColIndex()3435     unsigned int GetTextColIndex() const { return (unsigned int) m_capFgColIndex; }
3436 
3437 protected:
3438     int     m_textExtent;  // pre-calculated length of text
3439     wxByte  m_capFgColIndex;  // caption text colour index
3440 
3441 private:
3442     void Init();
3443 };
3444 
3445 #endif  // !SWIG
3446 
3447 // -----------------------------------------------------------------------
3448 
3449 /** @class wxPGCommonValue
3450     @ingroup classes
3451     @brief wxPropertyGrid stores information about common values in these
3452     records.
3453 */
3454 class WXDLLIMPEXP_PG wxPGCommonValue
3455 {
3456 public:
3457 
wxPGCommonValue(const wxString & label,wxPGCellRenderer * renderer)3458     wxPGCommonValue( const wxString& label, wxPGCellRenderer* renderer )
3459     {
3460         m_label = label;
3461         m_renderer = renderer;
3462         renderer->IncRef();
3463     }
~wxPGCommonValue()3464     virtual ~wxPGCommonValue()
3465     {
3466         m_renderer->DecRef();
3467     }
3468 
GetEditableText()3469     virtual wxString GetEditableText() const { return m_label; }
GetLabel()3470     const wxString& GetLabel() const { return m_label; }
GetRenderer()3471     wxPGCellRenderer* GetRenderer() const { return m_renderer; }
3472 
3473 protected:
3474     wxString            m_label;
3475     wxPGCellRenderer*   m_renderer;
3476 };
3477 
3478 // -----------------------------------------------------------------------
3479 
3480 
3481 #ifndef SWIG
3482 
3483 /** @class wxPGChoiceEntry
3484     @ingroup classes
3485     @brief Attributes of a single wxPGChoices choice.
3486 */
3487 class WXDLLIMPEXP_PG wxPGChoiceEntry : public wxPGCell
3488 {
3489 public:
3490     wxPGChoiceEntry();
3491     wxPGChoiceEntry( const wxPGChoiceEntry& entry );
3492     wxPGChoiceEntry( const wxString& label,
3493                      int value = wxPG_INVALID_VALUE )
wxPGCell()3494         : wxPGCell(), m_value(value)
3495     {
3496         m_text = label;
3497     }
3498 
3499     wxPGChoiceEntry( const wxString& label,
3500                      int value,
3501                      const wxBitmap& bitmap,
3502                      const wxColour& fgCol = wxNullColour,
3503                      const wxColour& bgCol = wxNullColour )
wxPGCell(label,bitmap,fgCol,bgCol)3504         : wxPGCell(label, bitmap, fgCol, bgCol), m_value(value)
3505     {
3506     }
3507 
~wxPGChoiceEntry()3508     ~wxPGChoiceEntry() override
3509     {
3510     }
3511 
SetValue(int value)3512     void SetValue( int value ) { m_value = value; }
3513 
GetValue()3514     int GetValue() const { return m_value; }
3515 
3516 protected:
3517     int m_value;
3518 };
3519 
3520 
3521 typedef void* wxPGChoicesId;
3522 
3523 class WXDLLIMPEXP_PG wxPGChoicesData
3524 {
3525     friend class wxPGChoices;
3526 public:
3527     // Constructor sets m_refCount to 1.
3528     wxPGChoicesData();
3529 
3530     void CopyDataFrom( wxPGChoicesData* data );
3531 
3532     // Takes ownership of 'item'
Insert(int index,wxPGChoiceEntry * item)3533     void Insert( int index, wxPGChoiceEntry* item )
3534     {
3535         wxArrayPtrVoid::iterator it;
3536         if ( index == -1 )
3537         {
3538             it = m_items.end();
3539             index = (int) m_items.size();
3540         }
3541         else
3542         {
3543             it = m_items.begin() + index;
3544         }
3545 
3546         // Need to fix value?
3547         if ( item->GetValue() == wxPG_INVALID_VALUE )
3548             item->SetValue(index);
3549 
3550         m_items.insert(it, item);
3551     }
3552 
3553     // Delete all entries
3554     void Clear();
3555 
GetCount()3556     unsigned int GetCount() const
3557     {
3558         return (unsigned int) m_items.size();
3559     }
3560 
Item(unsigned int i)3561     wxPGChoiceEntry* Item( unsigned int i ) const
3562     {
3563         return (wxPGChoiceEntry*) m_items[i];
3564     }
3565 
DecRef()3566     void DecRef()
3567     {
3568         m_refCount--;
3569         wxASSERT( m_refCount >= 0 );
3570         if ( m_refCount == 0 )
3571             delete this;
3572     }
3573 
3574 private:
3575     wxArrayPtrVoid  m_items;
3576 
3577     // So that multiple properties can use the same set
3578     int             m_refCount;
3579 
3580     virtual ~wxPGChoicesData();
3581 };
3582 
3583 #define wxPGChoicesEmptyData    ((wxPGChoicesData*)NULL)
3584 
3585 #endif // SWIG
3586 
3587 
3588 /** @class wxPGChoices
3589     @ingroup classes
3590     @brief Helper class for managing choices for properties.
3591 
3592     Each entry can have label, value, bitmap, text colour, and background
3593     colour.
3594 
3595     wxPGChoices uses reference counting, similar to other wxWidgets classes.
3596     This means, that assignment and copy constructor only copy the reference
3597     and not the actual data. Call Copy() member function to create a real
3598     copy.
3599 
3600     @remarks If you do not specify value for entry, index is used.
3601 */
3602 class WXDLLIMPEXP_PG wxPGChoices
3603 {
3604 public:
3605 
3606     /** Default constructor. */
wxPGChoices()3607     wxPGChoices()
3608     {
3609         Init();
3610     }
3611 
3612     /**
3613         Copy constructor, uses reference counting. To create a real copy,
3614         use Copy() member function instead.
3615     */
wxPGChoices(const wxPGChoices & src)3616     wxPGChoices( const wxPGChoices& src )
3617     {
3618         if ( src.m_data != wxPGChoicesEmptyData )
3619         {
3620             m_data = src.m_data;
3621             m_data->m_refCount++;
3622         }
3623     }
3624 
3625     /**
3626         Constructor.
3627 
3628         @param labels
3629             Labels for choices
3630 
3631         @param values
3632             Values for choices. If NULL, indexes are used.
3633     */
3634     wxPGChoices( const wxChar** labels, const long* values = NULL )
3635     {
3636         Init();
3637         Set(labels,values);
3638     }
3639 
3640     /**
3641         Constructor.
3642 
3643         @param labels
3644             Labels for choices
3645 
3646         @param values
3647             Values for choices. If empty, indexes are used.
3648     */
3649     wxPGChoices( const wxArrayString& labels, const wxArrayInt& values = wxPG_EMPTY_ARRAYINT )
3650     {
3651         Init();
3652         Set(labels,values);
3653     }
3654 
3655     /** Simple interface constructor. */
wxPGChoices(wxPGChoicesData * data)3656     wxPGChoices( wxPGChoicesData* data )
3657     {
3658         wxASSERT(data);
3659         m_data = data;
3660         data->m_refCount++;
3661     }
3662 
3663     /** Destructor. */
~wxPGChoices()3664     ~wxPGChoices()
3665     {
3666         Free();
3667     }
3668 
3669     void AssignData( wxPGChoicesData* data );
3670 
3671     /**
3672         Assigns choices data, using reference counting. To create a real copy,
3673         call Copy() member function instead.
3674     */
Assign(const wxPGChoices & src)3675     void Assign( const wxPGChoices& src )
3676     {
3677         AssignData(src.m_data);
3678     }
3679 
3680 #ifndef SWIG
3681     void operator= (const wxPGChoices& a)
3682     {
3683         AssignData(a.m_data);
3684     }
3685 #endif
3686 
3687     typedef long ValArrItem;
3688 
3689     /**
3690         Adds to current. If did not have own copies, creates them now. If was empty,
3691         identical to set except that creates copies.
3692 
3693         @param labels
3694             Labels for added choices.
3695 
3696         @param values
3697             Values for added choices. If empty, relevant entry indexes are used.
3698     */
3699     void Add( const wxChar** labels, const ValArrItem* values = NULL );
3700 
3701     /** Version that works with wxArrayString. */
3702     void Add( const wxArrayString& arr, const ValArrItem* values = NULL );
3703 
3704     /** Version that works with wxArrayString and wxArrayInt. */
3705     void Add( const wxArrayString& arr, const wxArrayInt& arrint );
3706 
3707     /**
3708         Adds a single choice.
3709 
3710         @param label
3711             Label for added choice.
3712 
3713         @param value
3714             Value for added choice. If unspecified, index is used.
3715     */
3716     wxPGChoiceEntry& Add( const wxString& label, int value = wxPG_INVALID_VALUE );
3717 
3718     /** Adds a single item, with bitmap. */
3719     wxPGChoiceEntry& Add( const wxString& label, const wxBitmap& bitmap, int value = wxPG_INVALID_VALUE );
3720 
3721     /** Adds a single item with full entry information. */
Add(const wxPGChoiceEntry & entry)3722     wxPGChoiceEntry& Add( const wxPGChoiceEntry& entry )
3723     {
3724         return Insert(entry, -1);
3725     }
3726 
3727     /** Adds single item. */
3728     wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE );
3729 
3730     /** Delete all choices. */
Clear()3731     void Clear()
3732     {
3733         if ( m_data != wxPGChoicesEmptyData )
3734             m_data->Clear();
3735     }
3736 
3737     /**
3738         Creates a physical copy of the choices.
3739     */
Copy()3740     wxPGChoices Copy() const
3741     {
3742         wxPGChoices dst;
3743         dst.EnsureData();
3744         dst.m_data->CopyDataFrom(m_data);
3745         return dst;
3746     }
3747 
EnsureData()3748     void EnsureData()
3749     {
3750         if ( m_data == wxPGChoicesEmptyData )
3751             m_data = new wxPGChoicesData();
3752     }
3753 
Item(unsigned int i)3754     const wxPGChoiceEntry& Item( unsigned int i ) const
3755     {
3756         wxASSERT( IsOk() );
3757         return *m_data->Item(i);
3758     }
3759 
Item(unsigned int i)3760     wxPGChoiceEntry& Item( unsigned int i )
3761     {
3762         wxASSERT( IsOk() );
3763         return *m_data->Item(i);
3764     }
3765 
3766     wxPGChoiceEntry& operator[](unsigned int i)
3767     {
3768         return Item(i);
3769     }
3770 
3771     const wxPGChoiceEntry& operator[](unsigned int i) const
3772     {
3773         return Item(i);
3774     }
3775 
3776     /** Returns false if this is a constant empty set of choices,
3777         which should not be modified.
3778     */
IsOk()3779     bool IsOk() const
3780     {
3781         return ( m_data != wxPGChoicesEmptyData );
3782     }
3783 
3784     /** Gets a unsigned number identifying this list. */
GetId()3785     wxPGChoicesId GetId() const { return (wxPGChoicesId) m_data; };
3786 
3787     /** Removes count items starting at position nIndex. */
3788     void RemoveAt(size_t nIndex, size_t count = 1);
3789 
3790 #ifndef SWIG
3791     /** Does not create copies for itself. */
3792     void Set( const wxChar** labels, const long* values = NULL )
3793     {
3794         Free();
3795         Add(labels,values);
3796     }
3797 
3798     /** Version that works with wxArrayString.
3799         TODO: Deprecate this.
3800     */
3801     void Set( wxArrayString& arr, const long* values = (const long*) NULL )
3802     {
3803         Free();
3804         Add(arr,values);
3805     }
3806 #endif // SWIG
3807 
3808     /** Version that works with wxArrayString and wxArrayInt. */
3809     void Set( const wxArrayString& labels, const wxArrayInt& values = wxPG_EMPTY_ARRAYINT )
3810     {
3811         Free();
3812         Add(labels,values);
3813     }
3814 
3815     // Creates exclusive copy of current choices
SetExclusive()3816     void SetExclusive()
3817     {
3818         if ( m_data->m_refCount != 1 )
3819         {
3820             wxPGChoicesData* data = new wxPGChoicesData();
3821             data->CopyDataFrom(m_data);
3822             Free();
3823             m_data = data;
3824         }
3825     }
3826 
GetLabel(unsigned int ind)3827     const wxString& GetLabel( unsigned int ind ) const
3828     {
3829         wxASSERT( ind >= 0 && ind < GetCount() );
3830         return Item(ind).GetText();
3831     }
3832 
GetCount()3833     unsigned int GetCount () const
3834     {
3835         if ( m_data )
3836             return m_data->GetCount();
3837         return 0;
3838     }
3839 
3840 #if wxPG_COMPATIBILITY_1_2_0
3841     /**
3842         Used to return true if choices in general were likely to have values.
3843         Now always returns true since if value was not specified for choice,
3844         index is used.
3845 
3846         \deprecated
3847         Since wxPropertyGrid 1.4.0 choice entries always have valid values.
3848     */
3849     wxDEPRECATED( bool HasValues() const );
3850 
3851     /**
3852         Used to return true if given choice has valid value. Now always returns
3853         since if value was not specified for choice, index is used.
3854 
3855         \deprecated
3856         Since wxPropertyGrid 1.4.0 choice entries always have valid values.
3857     */
3858     wxDEPRECATED( bool HasValue( unsigned int i ) const );
3859 #endif
3860 
GetValue(unsigned int ind)3861     int GetValue( unsigned int ind ) const { return Item(ind).GetValue(); }
3862 
3863     /** Returns array of values matching the given strings. Unmatching strings
3864         result in wxPG_INVALID_VALUE entry in array.
3865     */
3866     wxArrayInt GetValuesForStrings( const wxArrayString& strings ) const;
3867 
3868     /** Returns array of indices matching given strings. Unmatching strings
3869         are added to 'unmatched', if not NULL.
3870     */
3871     wxArrayInt GetIndicesForStrings( const wxArrayString& strings, wxArrayString* unmatched = NULL ) const;
3872 
3873     int Index( const wxString& str ) const;
3874     int Index( int val ) const;
3875 
3876     /** Inserts single item. */
3877     wxPGChoiceEntry& Insert( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
3878 
3879     /** Inserts a single item with full entry information. */
3880     wxPGChoiceEntry& Insert( const wxPGChoiceEntry& entry, int index );
3881 
3882     // Returns data, increases refcount.
GetData()3883     wxPGChoicesData* GetData()
3884     {
3885         wxASSERT( m_data->m_refCount != 0xFFFFFFF );
3886         m_data->m_refCount++;
3887         return m_data;
3888     }
3889 
3890     // Returns plain data ptr - no refcounting stuff is done.
GetDataPtr()3891     wxPGChoicesData* GetDataPtr() const { return m_data; }
3892 
3893     // Changes ownership of data to you.
ExtractData()3894     wxPGChoicesData* ExtractData()
3895     {
3896         wxPGChoicesData* data = m_data;
3897         m_data = wxPGChoicesEmptyData;
3898         return data;
3899     }
3900 
3901     wxArrayString GetLabels() const;
3902 
3903 #ifndef SWIG
3904 
3905 protected:
3906     wxPGChoicesData*    m_data;
3907 
3908     void Init();
3909     void Free();
3910 #endif
3911 };
3912 
3913 
3914 // -----------------------------------------------------------------------
3915 
3916 #ifndef SWIG
3917   #if wxMINOR_VERSION < 7 || ( wxMINOR_VERSION == 7 && wxRELEASE_NUMBER < 1 )
3918     // NOTE: Since wxWidgets at this point doesn't have wxArrayDouble, we have
3919     //   to create it ourself, using wxObjArray model.
3920     WX_DECLARE_OBJARRAY_WITH_DECL(double, wxArrayDouble, class WXDLLIMPEXP_PG);
3921   #endif
3922 #endif // !SWIG
3923 
3924 // -----------------------------------------------------------------------
3925 // Property declaration.
3926 
3927 // Doxygen will only generate warnings here
3928 #define wxPG_CONSTFUNC(PROP) PROP##Create
3929 #define wxPG_PROPCLASS(PROP) PROP
3930 
3931 // Macro based constructor.
3932 #define wxPG_NEWPROPERTY(PROP,LABEL,NAME,VALUE) wx##PROP##Property(LABEL,NAME,VALUE)
3933 
3934 
3935 WXDLLIMPEXP_PG wxObject* wxPG_VariantToWxObject( const wxVariant& variant, wxClassInfo* classInfo );
3936 
3937 //
3938 // Redefine wxGetVariantCast to also take propertygrid variantdata
3939 // classes into account.
3940 //
3941 #undef wxGetVariantCast
3942 #define wxGetVariantCast(var,classname) (classname*)wxPG_VariantToWxObject(var,&classname::ms_classInfo)
3943 
3944 // TODO: After a while, remove this.
3945 #define WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) (CLASSNAME*)wxPG_VariantToWxObject(VARIANT,&CLASSNAME::ms_classInfo)
3946 
3947 // -----------------------------------------------------------------------
3948 
3949 #define wxPG_IT_CHILDREN(A)         (A<<16)
3950 
3951 /** @defgroup iteratorflags wxPropertyGridIterator Flags
3952     @{
3953 
3954     NOTES: At lower 16-bits, there are flags to check if item will be included. At higher
3955       16-bits, there are same flags, but to instead check if children will be included.
3956 */
3957 
3958 enum wxPG_ITERATOR_FLAGS
3959 {
3960 
3961 /** Iterate through 'normal' property items (does not include children of aggregate or hidden items by default).
3962 */
3963 wxPG_ITERATE_PROPERTIES             = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
3964                                        wxPG_PROP_COLLAPSED|((wxPG_PROP_MISC_PARENT|wxPG_PROP_CATEGORY)<<16)),
3965 
3966 /** Iterate children of collapsed parents, and individual items that are hidden.
3967 */
3968 wxPG_ITERATE_HIDDEN                 = (wxPG_PROP_HIDDEN|wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED)),
3969 
3970 /** Iterate children of parent that is an aggregate property (ie. has fixed children).
3971 */
3972 wxPG_ITERATE_FIXED_CHILDREN         = (wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)|wxPG_ITERATE_PROPERTIES),
3973 
3974 /** Iterate categories. Note that even without this flag, children of categories
3975     are still iterated through.
3976 */
3977 wxPG_ITERATE_CATEGORIES             = (wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY)|wxPG_PROP_COLLAPSED),
3978 
3979 wxPG_ITERATE_ALL_PARENTS            = (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY),
3980 
3981 wxPG_ITERATE_ALL_PARENTS_RECURSIVELY        = (wxPG_ITERATE_ALL_PARENTS|wxPG_IT_CHILDREN(wxPG_ITERATE_ALL_PARENTS)),
3982 
3983 wxPG_ITERATOR_FLAGS_ALL             = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
3984                                       wxPG_PROP_HIDDEN|wxPG_PROP_CATEGORY|wxPG_PROP_COLLAPSED),
3985 
3986 wxPG_ITERATOR_MASK_OP_ITEM          = wxPG_ITERATOR_FLAGS_ALL,
3987 
3988 wxPG_ITERATOR_MASK_OP_PARENT        = wxPG_ITERATOR_FLAGS_ALL,  // (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY)
3989 
3990 /** Combines all flags needed to iterate through visible properties
3991     (ie. hidden properties and children of collapsed parents are skipped).
3992 */
3993 wxPG_ITERATE_VISIBLE                = (wxPG_ITERATE_PROPERTIES|wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)),
3994 
3995 /** Iterate all items.
3996 */
3997 wxPG_ITERATE_ALL                    = (wxPG_ITERATE_VISIBLE|wxPG_ITERATE_HIDDEN),
3998 
3999 /** Iterate through individual properties (ie. categories and children of
4000     aggregate properties are skipped).
4001 */
4002 wxPG_ITERATE_NORMAL                 = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN),
4003 
4004 /** Default iterator flags.
4005 */
4006 wxPG_ITERATE_DEFAULT                = wxPG_ITERATE_NORMAL
4007 
4008 };
4009 
4010 /** @}
4011 */
4012 
4013 
4014 #define wxPG_ITERATOR_CREATE_MASKS(FLAGS, A, B) \
4015     A = (FLAGS ^ wxPG_ITERATOR_MASK_OP_ITEM) & wxPG_ITERATOR_MASK_OP_ITEM & 0xFFFF; \
4016     B = ((FLAGS>>16) ^ wxPG_ITERATOR_MASK_OP_PARENT) & wxPG_ITERATOR_MASK_OP_PARENT & 0xFFFF;
4017 
4018 
4019 // Macro to test if children of PWC should be iterated through
4020 #define wxPG_ITERATOR_PARENTEXMASK_TEST(PWC, PARENTMASK) \
4021         ( \
4022         !(PWC->GetFlags() & PARENTMASK) && \
4023         PWC->GetChildCount() \
4024         )
4025 
4026 
4027 /** @class wxPropertyGridIteratorBase
4028     @ingroup classes
4029     @brief Base for wxPropertyGridIterator classes.
4030 */
4031 class WXDLLIMPEXP_PG wxPropertyGridIteratorBase
4032 {
4033 public:
wxPropertyGridIteratorBase()4034     wxPropertyGridIteratorBase()
4035     {
4036     }
4037 
4038     void Assign( const wxPropertyGridIteratorBase& it );
4039 
AtEnd()4040     bool AtEnd() const { return m_property == NULL; }
4041 
4042     /** Get current property.
4043     */
GetProperty()4044     wxPGProperty* GetProperty() const { return m_property; }
4045 
4046     void Init( wxPropertyGridState* state, int flags, wxPGProperty* property, int dir = 1 );
4047 
4048     void Init( wxPropertyGridState* state, int flags, int startPos = wxTOP, int dir = 0 );
4049 
4050     /** Iterate to the next property.
4051     */
4052     void Next( bool iterateChildren = true );
4053 
4054     /** Iterate to the previous property.
4055     */
4056     void Prev();
4057 
4058     /** Set base parent, ie. a property when, in which iteration returns, it ends.
4059 
4060         Default base parent is the root of the used wxPropertyGridState.
4061     */
SetBaseParent(wxPGProperty * baseParent)4062     void SetBaseParent( wxPGProperty* baseParent ) { m_baseParent = baseParent; }
4063 
4064 protected:
4065 
4066     wxPGProperty*               m_property;
4067 
4068 private:
4069     wxPropertyGridState*        m_state;
4070     wxPGProperty*               m_baseParent;
4071 
4072     // Masks are used to quickly exclude items
4073     int                         m_itemExMask;
4074     int                         m_parentExMask;
4075 };
4076 
4077 
4078 #define wxPG_IMPLEMENT_ITERATOR(CLASS, PROPERTY, STATE) \
4079     CLASS( STATE* state, int flags = wxPG_ITERATE_DEFAULT, PROPERTY* property = NULL, int dir = 1 ) \
4080         : wxPropertyGridIteratorBase() \
4081         { Init( (wxPropertyGridState*)state, flags, (wxPGProperty*)property, dir ); } \
4082     CLASS( STATE* state, int flags, int startPos, int dir = 0 ) \
4083         : wxPropertyGridIteratorBase() \
4084         { Init( (wxPropertyGridState*)state, flags, startPos, dir ); } \
4085     CLASS() \
4086         : wxPropertyGridIteratorBase() \
4087     { \
4088         m_property = NULL; \
4089     } \
4090     CLASS( const CLASS& it ) \
4091         : wxPropertyGridIteratorBase( ) \
4092     { \
4093         Assign(it); \
4094     } \
4095     ~CLASS() \
4096     { \
4097     } \
4098     const CLASS& operator=( const CLASS& it ) \
4099     { \
4100         Assign(it); \
4101         return *this; \
4102     } \
4103     CLASS& operator++() { Next(); return *this; } \
4104     CLASS operator++(int) { CLASS it=*this;Next();return it; } \
4105     CLASS& operator--() { Prev(); return *this; } \
4106     CLASS operator--(int) { CLASS it=*this;Prev();return it; } \
4107     PROPERTY* operator *() const { return (PROPERTY*)m_property; } \
4108     static PROPERTY* OneStep( STATE* state, int flags = wxPG_ITERATE_DEFAULT, PROPERTY* property = NULL, int dir = 1 ) \
4109     { \
4110         CLASS it( state, flags, property, dir ); \
4111         if ( property ) \
4112         { \
4113             if ( dir == 1 ) it.Next(); \
4114             else it.Prev(); \
4115         } \
4116         return *it; \
4117     }
4118 
4119 
4120 /** @class wxPropertyGridIterator
4121     @ingroup classes
4122     @brief Preferable way to iterate through contents of wxPropertyGrid,
4123     wxPropertyGridManager, and wxPropertyGridPage.
4124 
4125     See wxPropertyGridInterface::GetIterator() for more information about usage.
4126 */
4127 class WXDLLIMPEXP_PG wxPropertyGridIterator : public wxPropertyGridIteratorBase
4128 {
4129 public:
4130 
4131     wxPG_IMPLEMENT_ITERATOR(wxPropertyGridIterator,
4132                             wxPGProperty,
4133                             wxPropertyGridState)
4134 
4135 protected:
4136 };
4137 
4138 
4139 /** @class wxPropertyGridConstIterator
4140     @ingroup classes
4141     @brief Const version of wxPropertyGridIterator.
4142 */
4143 class WXDLLIMPEXP_PG wxPropertyGridConstIterator : public wxPropertyGridIteratorBase
4144 {
4145 public:
wxPG_IMPLEMENT_ITERATOR(wxPropertyGridConstIterator,const wxPGProperty,const wxPropertyGridState)4146     wxPG_IMPLEMENT_ITERATOR(wxPropertyGridConstIterator,
4147                             const wxPGProperty,
4148                             const wxPropertyGridState)
4149 
4150     /**
4151         Additional copy constructor.
4152     */
4153     wxPropertyGridConstIterator( const wxPropertyGridIterator& other )
4154     {
4155         Assign(other);
4156     }
4157 
4158     /**
4159         Additional assignment operator.
4160     */
4161     const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it )
4162     {
4163         Assign(it);
4164         return *this;
4165     }
4166 
4167 protected:
4168 };
4169 
4170 // -----------------------------------------------------------------------
4171 
4172 /** Base class to derive new viterators.
4173 */
4174 class WXDLLIMPEXP_PG wxPGVIteratorBase
4175 {
4176     friend class wxPGVIterator;
4177 public:
wxPGVIteratorBase()4178     wxPGVIteratorBase() { m_refCount = 1; }
4179     virtual void Next() = 0;
IncRef()4180     void IncRef()
4181     {
4182         m_refCount++;
4183     }
DecRef()4184     void DecRef()
4185     {
4186         m_refCount--;
4187         if ( m_refCount <= 0 )
4188             delete this;
4189     }
4190 protected:
~wxPGVIteratorBase()4191     virtual ~wxPGVIteratorBase() { }
4192 
4193     wxPropertyGridIterator  m_it;
4194 private:
4195     int     m_refCount;
4196 };
4197 
4198 /** @class wxPGVIterator
4199     @ingroup classes
4200     @brief Abstract implementation of a simple iterator. Can only be used
4201     to iterate in forward order, and only through the entire container.
4202     Used to have functions dealing with all properties work with both
4203     wxPropertyGrid and wxPropertyGridManager.
4204 */
4205 class WXDLLIMPEXP_PG wxPGVIterator
4206 {
4207 public:
wxPGVIterator()4208     wxPGVIterator() { m_pIt = NULL; }
wxPGVIterator(wxPGVIteratorBase * obj)4209     wxPGVIterator( wxPGVIteratorBase* obj ) { m_pIt = obj; }
~wxPGVIterator()4210     ~wxPGVIterator() { UnRef(); }
UnRef()4211     void UnRef() { if (m_pIt) m_pIt->DecRef(); }
wxPGVIterator(const wxPGVIterator & it)4212     wxPGVIterator( const wxPGVIterator& it )
4213     {
4214         m_pIt = it.m_pIt;
4215         m_pIt->IncRef();
4216     }
4217 #ifndef SWIG
4218     const wxPGVIterator& operator=( const wxPGVIterator& it )
4219     {
4220         UnRef();
4221         m_pIt = it.m_pIt;
4222         m_pIt->IncRef();
4223         return *this;
4224     }
4225 #endif
Next()4226     void Next() { m_pIt->Next(); }
AtEnd()4227     bool AtEnd() const { return m_pIt->m_it.AtEnd(); }
GetProperty()4228     wxPGProperty* GetProperty() const { return m_pIt->m_it.GetProperty(); }
4229 protected:
4230     wxPGVIteratorBase*  m_pIt;
4231 };
4232 
4233 // -----------------------------------------------------------------------
4234 
4235 /** @class wxPropertyGridHitTestResult
4236     @ingroup classes
4237     @brief wxPropertyGridHitTestResult, a return value from wxPropertyGrid::HitTest(),
4238     contains all you need to know about an arbitrary location on the grid.
4239 */
4240 class WXDLLIMPEXP_PG wxPropertyGridHitTestResult
4241 {
4242     friend class wxPropertyGrid;
4243 public:
wxPropertyGridHitTestResult()4244     wxPropertyGridHitTestResult()
4245     {
4246         property = NULL;
4247         column = -1;
4248         splitter = -1;
4249         splitterHitOffset = 0;
4250     }
4251 
~wxPropertyGridHitTestResult()4252     ~wxPropertyGridHitTestResult()
4253     {
4254     }
4255 
4256     /**
4257         Returns column hit. -1 for margin.
4258     */
GetColumn()4259     int GetColumn() const { return column; }
4260 
4261     /**
4262         Returns property hit. NULL if empty space below
4263         properties was hit instead.
4264     */
GetProperty()4265     wxPGProperty* GetProperty() const
4266     {
4267         return property;
4268     }
4269 
4270     /**
4271         Returns index of splitter hit, -1 for none.
4272     */
GetSplitter()4273     int GetSplitter() const { return splitter; }
4274 
4275     /**
4276         If splitter hit, then this member function
4277         returns offset to the exact splitter position.
4278     */
GetSplitterHitOffset()4279     int GetSplitterHitOffset() const { return splitterHitOffset; }
4280 
4281     /** Property. NULL if empty space below properties was hit */
4282     wxPGProperty*   property;
4283 
4284     /** Column. -1 for margin. */
4285     int             column;
4286 
4287     /** Index of splitter hit, -1 for none. */
4288     int             splitter;
4289 
4290     /** If splitter hit, offset to that */
4291     int             splitterHitOffset;
4292 };
4293 
4294 // -----------------------------------------------------------------------
4295 
4296 /** @defgroup vfbflags wxPropertyGrid Validation Failure Behavior Flags
4297     @{
4298 */
4299 
4300 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
4301 {
4302 
4303 /** Prevents user from leaving property unless value is valid. If this
4304     behavior flag is not used, then value change is instead cancelled.
4305 */
4306 wxPG_VFB_STAY_IN_PROPERTY           = 0x01,
4307 
4308 /** Calls wxBell() on validation failure.
4309 */
4310 wxPG_VFB_BEEP                       = 0x02,
4311 
4312 /** Cell with invalid value will be marked (with red colour).
4313 */
4314 wxPG_VFB_MARK_CELL                  = 0x04,
4315 
4316 /** Display a customizable text message explaining the situation.
4317 
4318     To customize the way the message is displayed, you need to
4319     reimplement wxPropertyGrid::DoShowPropertyError() in a
4320     derived class. Default behavior is to display the text on
4321     the top-level frame's status bar, if present, and otherwise
4322     using wxMessageBox.
4323 */
4324 wxPG_VFB_SHOW_MESSAGE               = 0x08,
4325 
4326 /** Similar to wxPG_VFB_SHOW_MESSAGE, except always display the
4327     message using wxMessageBox.
4328 */
4329 wxPG_VFB_SHOW_MESSAGEBOX           = 0x10,
4330 
4331 /** Similar to wxPG_VFB_SHOW_MESSAGE, except always display the
4332     message on the status bar.
4333 */
4334 wxPG_VFB_SHOW_MESSAGE_ON_STATUSBAR = 0x20,
4335 
4336 /** Defaults. */
4337 wxPG_VFB_DEFAULT                    = wxPG_VFB_STAY_IN_PROPERTY|wxPG_VFB_BEEP,
4338 
4339 /** Only used internally. */
4340 wxPG_VFB_UNDEFINED                  = 0x80
4341 
4342 };
4343 
4344 /** @}
4345 */
4346 
4347 // This being define instead of typedef is more SWIG friendly
4348 #define wxPGVFBFlags unsigned char
4349 
4350 /** @class wxPGValidationInfo
4351 	@ingroup classes
4352     @brief
4353     Used to convey validation information to and from functions that
4354     actually perform validation.
4355 */
4356 struct WXDLLIMPEXP_PG wxPGValidationInfo
4357 {
4358     /** Value to be validated.
4359     */
4360     wxVariant*      m_pValue;
4361 
4362     /** Message displayed on validation failure.
4363     */
4364     wxString        m_failureMessage;
4365 
4366     /** Validation failure behavior. Use wxPG_VFB_XXX flags.
4367     */
4368     wxPGVFBFlags    m_failureBehavior;
4369 
4370     /** @true when validation is failing. */
4371     bool            m_isFailing;
4372 
wxPGValidationInfowxPGValidationInfo4373     wxPGValidationInfo()
4374     {
4375         m_failureBehavior = 0;
4376         m_isFailing = false;
4377     }
4378 
~wxPGValidationInfowxPGValidationInfo4379     ~wxPGValidationInfo()
4380     {
4381     }
4382 
GetFailureBehaviorwxPGValidationInfo4383     wxPGVFBFlags GetFailureBehavior() const { return m_failureBehavior; }
4384 
SetFailureBehaviorwxPGValidationInfo4385     void SetFailureBehavior(wxPGVFBFlags failureBehavior) { m_failureBehavior = failureBehavior; }
4386 
GetFailureMessagewxPGValidationInfo4387     const wxString& GetFailureMessage() const { return m_failureMessage; }
4388 
SetFailureMessagewxPGValidationInfo4389     void SetFailureMessage(const wxString& message) { m_failureMessage = message; }
4390 };
4391 
4392 // -----------------------------------------------------------------------
4393 
4394 /** @defgroup pgactions wxPropertyGrid Action Identifiers
4395     These are used with wxPropertyGrid::AddActionTrigger() and wxPropertyGrid::ClearActionTriggers().
4396     @{
4397 */
4398 
4399 enum wxPG_KEYBOARD_ACTIONS
4400 {
4401     wxPG_ACTION_INVALID = 0,
4402     wxPG_ACTION_NEXT_PROPERTY,
4403     wxPG_ACTION_PREV_PROPERTY,
4404     wxPG_ACTION_EXPAND_PROPERTY,
4405     wxPG_ACTION_COLLAPSE_PROPERTY,
4406     wxPG_ACTION_CANCEL_EDIT,
4407     wxPG_ACTION_CUT,
4408     wxPG_ACTION_COPY,
4409     wxPG_ACTION_PASTE,
4410     wxPG_ACTION_SELECT_ALL,
4411     wxPG_ACTION_EDIT,
4412     wxPG_ACTION_MAX
4413 };
4414 
4415 /** @}
4416 */
4417 
4418 
4419 #ifndef SWIG
4420 // We won't need this class from wxPython
4421 
4422 /** @class wxPropertyGridState
4423 	@ingroup classes
4424     @brief
4425     Contains information of a single wxPropertyGrid page. Generally you should not use
4426     this class directly, but instead methods in wxPropertyGridInterface, wxPropertyGrid,
4427     wxPropertyGridPage, and wxPropertyGridManager.
4428 */
4429 // BM_STATE
4430 class WXDLLIMPEXP_PG wxPropertyGridState
4431 {
4432     friend class wxPGProperty;
4433     friend class wxPropertyGrid;
4434     friend class wxPGCanvas;
4435     friend class wxPropertyGridPage;
4436     friend class wxPropertyGridManager;
4437     friend class wxPropertyGridInterface;
4438 public:
4439 
4440     /** Constructor. */
4441     wxPropertyGridState();
4442 
4443     /** Destructor. */
4444     virtual ~wxPropertyGridState();
4445 
4446     /** Base append. */
4447     wxPGProperty* DoAppend( wxPGProperty* property );
4448 
4449     /** Returns property by its name. */
4450     wxPGProperty* BaseGetPropertyByName( wxPGPropNameStr name ) const;
4451 
4452     /** Called in, for example, wxPropertyGrid::Clear. */
4453     void DoClear();
4454 
4455     bool DoIsPropertySelected( wxPGProperty* prop ) const;
4456 
4457     void ClearModifiedStatus( wxPGProperty* p );
4458 
DoClearSelection()4459     bool DoClearSelection()
4460     {
4461         return DoSelectProperty(NULL);
4462     }
4463 
4464     void DoRemoveFromSelection( wxPGProperty* prop );
4465 
4466     bool DoCollapse( wxPGProperty* p );
4467 
4468     bool DoExpand( wxPGProperty* p );
4469 
4470 	void CalculateFontAndBitmapStuff( int vspacing );
4471 
4472     /** Makes sure all columns have minimum width.
4473     */
4474     void CheckColumnWidths( int widthChange = 0 );
4475 
4476     /** Override this member function to add custom behavior on property deletion.
4477     */
4478     virtual void DoDelete( wxPGProperty* item, bool doDelete = true );
4479 
4480     wxSize DoFitColumns( bool allowGridResize = false );
4481 
4482     wxPGProperty* DoGetItemAtY( int y ) const;
4483 
4484     /** Override this member function to add custom behavior on property insertion.
4485     */
4486     virtual wxPGProperty* DoInsert( wxPGProperty* parent, int index, wxPGProperty* property );
4487 
4488     /** This needs to be overridden in grid used the manager so that splitter changes
4489         can be propagated to other pages.
4490     */
4491     virtual void DoSetSplitterPosition( int pos, int splitterColumn = 0, bool allPages = false, bool fromAutoCenter = false );
4492 
4493     bool EnableCategories( bool enable );
4494 
4495     /** Make sure virtual height is up-to-date.
4496     */
EnsureVirtualHeight()4497     void EnsureVirtualHeight()
4498     {
4499         if ( m_vhCalcPending )
4500         {
4501             RecalculateVirtualHeight();
4502             m_vhCalcPending = 0;
4503         }
4504     }
4505 
4506     /** Enables or disables given property and its subproperties. */
4507     bool DoEnableProperty( wxPGProperty* p, bool enable );
4508 
4509     /** Returns (precalculated) height of contained visible properties.
4510     */
GetVirtualHeight()4511     unsigned int GetVirtualHeight() const
4512     {
4513         wxASSERT( !m_vhCalcPending );
4514         return m_virtualHeight;
4515     }
4516 
4517     /** Returns (precalculated) height of contained visible properties.
4518     */
GetVirtualHeight()4519     unsigned int GetVirtualHeight()
4520     {
4521         EnsureVirtualHeight();
4522         return m_virtualHeight;
4523     }
4524 
4525     /** Returns actual height of contained visible properties.
4526         @remarks
4527         Mostly used for internal diagnostic purposes.
4528     */
4529     inline unsigned int GetActualVirtualHeight() const;
4530 
GetColumnCount()4531     unsigned int GetColumnCount() const
4532     {
4533         return (unsigned int) m_colWidths.size();
4534     }
4535 
4536     int GetColumnMinWidth( int column ) const;
4537 
GetColumnWidth(unsigned int column)4538     int GetColumnWidth( unsigned int column ) const
4539     {
4540         return m_colWidths[column];
4541     }
4542 
GetGrid()4543     wxPropertyGrid* GetGrid() const { return m_pPropGrid; }
4544 
4545     /** Returns last item which could be iterated using given flags.
4546         @param flags
4547         @link iteratorflags List of iterator flags@endlink
4548     */
4549     wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT );
4550 
4551     const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
4552     {
4553         return ((wxPropertyGridState*)this)->GetLastItem(flags);
4554     }
4555 
4556 #if wxPG_COMPATIBILITY_1_2_0
4557     wxPGProperty* GetNextCategory( wxPGProperty* id ) const;
4558 
4559     wxPGProperty* GetNextProperty( wxPGProperty* id );
4560 
4561     wxPGProperty* GetNextSiblingProperty( wxPGProperty* id );
4562 
4563     wxPGProperty* GetPrevSiblingProperty( wxPGProperty* id );
4564 
4565     wxPGProperty* GetPrevProperty( wxPGProperty* id );
4566 #endif // wxPG_COMPATIBILITY_1_2_0
4567 
4568     wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
4569 
4570     wxPGProperty* GetPropertyByLabel( const wxString& name, wxPGProperty* parent = NULL ) const;
4571 
4572     wxVariant DoGetPropertyValues( const wxString& listname, wxPGProperty* baseparent, long flags ) const;
4573 
DoGetRoot()4574     wxPGProperty* DoGetRoot() const { return m_properties; }
4575 
4576     // Returns combined width of margin and all the columns
GetVirtualWidth()4577     int GetVirtualWidth() const
4578     {
4579         return m_width;
4580     }
4581 
4582     /** Returns minimal width for given column so that all images and texts will fit
4583         entirely.
4584 
4585         Used by SetSplitterLeft() and DoFitColumns().
4586     */
4587     int GetColumnFitWidth(wxClientDC& dc, wxPGProperty* pwc, unsigned int col, bool subProps) const;
4588 /* C::B begin */
4589     int GetColumnFullWidth( wxClientDC &dc, wxPGProperty *p, unsigned int col );
4590 /* C::B end */
4591     /**
4592         Returns currently selected property.
4593     */
GetSelection()4594     wxPGProperty* GetSelection() const
4595     {
4596         if ( m_selection.size() == 0 )
4597             return NULL;
4598         return m_selection[0];
4599     }
4600 
DoSetSelection(wxPGProperty * prop)4601     void DoSetSelection( wxPGProperty* prop )
4602     {
4603         m_selection.clear();
4604         if ( prop )
4605             m_selection.push_back(prop);
4606     }
4607 
4608     void DoSetColumnProportion( unsigned int column, int proportion );
4609 
DoGetColumnProportion(unsigned int column)4610     int DoGetColumnProportion( unsigned int column ) const
4611     {
4612         return m_columnProportions[column];
4613     }
4614 
4615     void ResetColumnSizes( bool fromAutoCenter );
4616 
4617     /**
4618         Returns information about arbitrary position in the grid.
4619 
4620         @param pt
4621             Coordinates in the virtual grid space. You may need to use
4622             wxScrolledWindow::CalcScrolledPosition() for translating
4623             wxPropertyGrid client coordinates into something this member
4624             function can use.
4625     */
4626     wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
4627 
4628     inline bool IsDisplayed() const;
4629 
IsInNonCatMode()4630     bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); }
4631 
4632     /** Only inits arrays, doesn't migrate things or such. */
4633     void InitNonCatMode ();
4634 
4635     void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true )
4636     {
4637         p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit);
4638     }
4639 
4640     bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
4641 
4642     /** widthChange is non-client.
4643     */
4644     void OnClientWidthChange( int newWidth, int widthChange, bool fromOnResize = false );
4645 
4646     /** Recalculates m_virtualHeight.
4647     */
RecalculateVirtualHeight()4648     void RecalculateVirtualHeight()
4649     {
4650         m_virtualHeight = GetActualVirtualHeight();
4651     }
4652 
4653     void SetColumnCount( int colCount );
4654 
4655     void PropagateColSizeDec( int column, int decrease, int dir );
4656 
4657     bool DoHideProperty( wxPGProperty* p, bool hide, int flags = wxPG_RECURSE );
4658 
4659     bool DoSetPropertyValueString( wxPGProperty* p, const wxString& value );
4660 
4661     bool DoSetPropertyValue( wxPGProperty* p, wxVariant& value );
4662 
4663     bool DoSetPropertyValueWxObjectPtr( wxPGProperty* p, wxObject* value );
4664     void DoSetPropertyValues( const wxVariantList& list, wxPGProperty* default_category );
4665 
4666 #ifdef wxPG_COMPATIBILITY_1_2_0
4667     #define SetPropertyUnspecified SetPropertyValueUnspecified
4668 #endif
4669 
4670     void SetSplitterLeft( bool subProps = false );
4671 
4672     /** Set virtual width for this particular page. */
4673     void SetVirtualWidth( int width );
4674 
4675     void Sort( wxPGProperty* p );
4676     void Sort();
4677 
4678     /** Called after virtual height needs to be recalculated.
4679     */
VirtualHeightChanged()4680     void VirtualHeightChanged()
4681     {
4682         m_vhCalcPending = 1;
4683     }
4684 
4685 protected:
4686 
4687     // Utility to check if two properties are visibly next to each other
4688     bool ArePropertiesAdjacent( wxPGProperty* prop1,
4689                                 wxPGProperty* prop2,
4690                                 int iterFlags = wxPG_ITERATE_VISIBLE ) const;
4691 
4692     int DoGetSplitterPosition( int splitterIndex = 0 ) const;
4693 
4694     /** Returns column at x coordinate (in GetGrid()->GetPanel()).
4695         @param pSplitterHit
4696         Give pointer to int that receives index to splitter that is at x.
4697         @param pSplitterHitOffset
4698         Distance from said splitter.
4699     */
4700     int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const;
4701 
4702 #ifndef DOXYGEN
4703     int PrepareToAddItem ( wxPGProperty* property, wxPGProperty* scheduledParent );
4704 
4705     /** If visible, then this is pointer to wxPropertyGrid.
4706         This shall *never* be NULL to indicate that this state is not visible.
4707     */
4708     wxPropertyGrid*             m_pPropGrid;
4709 
4710     /** Pointer to currently used array. */
4711     wxPGProperty*               m_properties;
4712 
4713     /** Array for categoric mode. */
4714     wxPGRootProperty            m_regularArray;
4715 
4716     /** Array for root of non-categoric mode. */
4717     wxPGRootProperty*           m_abcArray;
4718 
4719     /** Dictionary for name-based access. */
4720     wxPGHashMapS2P              m_dictName;
4721 
4722     /** List of column widths (first column does not include margin). */
4723     wxArrayInt                  m_colWidths;
4724 
4725     /** List of indices of columns the user can edit by clicking it. */
4726     wxArrayInt                  m_editableColumns;
4727 
4728     /** Column proportions */
4729     wxArrayInt                  m_columnProportions;
4730 
4731     double                      m_fSplitterX;
4732 
4733     /** Most recently added category. */
4734     wxPropertyCategory*         m_currentCategory;
4735 
4736     /** Pointer to selected property. */
4737     wxArrayPGProperty           m_selection;
4738 
4739     /** Virtual width. */
4740     int                         m_width;
4741 
4742     /** Indicates total virtual height of visible properties. */
4743     unsigned int                m_virtualHeight;
4744 
4745     /** 1 if m_lastCaption is also the bottommost caption. */
4746     unsigned char               m_lastCaptionBottomnest;
4747 
4748     /** 1 items appended/inserted, so stuff needs to be done before drawing;
4749         If m_virtualHeight == 0, then calcylatey's must be done.
4750         Otherwise just sort.
4751     */
4752     unsigned char               m_itemsAdded;
4753 
4754     /** 1 if any value is modified. */
4755     unsigned char               m_anyModified;
4756 
4757     unsigned char               m_vhCalcPending;
4758 
4759 #endif // #ifndef DOXYGEN
4760 
4761 };
4762 
4763 #endif // #ifndef SWIG
4764 
SetChoices(const wxArrayString & labels,const wxArrayInt & values)4765 inline bool wxPGProperty::SetChoices( const wxArrayString& labels,
4766                                       const wxArrayInt& values )
4767 {
4768     wxPGChoices chs(labels,values);
4769     return SetChoices(chs);
4770 }
4771 
4772 // -----------------------------------------------------------------------
4773 
4774 // GetPropertyName version used internally. Use GetPropertyName for slight speed advantage,
4775 // or GetPropertyNameA for nice assertion (essential for wxPython bindings).
4776 #define GetPropertyByNameI          GetPropertyByNameA
4777 
4778 // FOR BACKWARDS COMPATIBILITY
4779 #define GetPropertyByNameWithAssert GetPropertyByNameA
4780 
4781 
4782 // Helper macro that does necessary preparations when calling
4783 // some wxPGProperty's member function.
4784 #define wxPG_PROP_ARG_CALL_PROLOG_0(PROPERTY) \
4785     PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
4786     if ( !p ) return;
4787 
4788 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(PROPERTY, RETVAL) \
4789     PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
4790     if ( !p ) return RETVAL;
4791 
4792 #define wxPG_PROP_ARG_CALL_PROLOG() \
4793     wxPG_PROP_ARG_CALL_PROLOG_0(wxPGProperty)
4794 
4795 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL(RVAL) \
4796     wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(wxPGProperty, RVAL)
4797 
4798 #define wxPG_PROP_ID_CONST_CALL_PROLOG() \
4799     wxPG_PROP_ARG_CALL_PROLOG_0(const wxPGProperty)
4800 
4801 #define wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(RVAL) \
4802     wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(const wxPGProperty, RVAL)
4803 
4804 
4805 /** @class wxPropertyGridInterface
4806     @ingroup classes
4807     @brief In order to have most same base methods, both wxPropertyGrid and
4808     wxPropertyGridManager must derive from this.
4809 */
4810 class WXDLLIMPEXP_PG wxPropertyGridInterface
4811 // BM_METHODS
4812 {
4813     friend class wxPropertyGrid;
4814     friend class wxPropertyGridManager;
4815 public:
4816 
4817     /** Destructor */
~wxPropertyGridInterface()4818     virtual ~wxPropertyGridInterface() { };
4819 
4820     /** Adds choice to a property that can accept one.
4821         @remarks
4822         - If you need to make sure that you modify only the set of choices of
4823           a single property (and not also choices of other properties with initially
4824           identical set), call wxPropertyGrid::SetPropertyChoicesPrivate.
4825         - This usually only works for wxEnumProperty and derivatives (wxFlagsProperty
4826           can get accept new items but its items may not get updated).
4827     */
4828     void AddPropertyChoice( wxPGPropArg id, const wxString& label, int value = wxPG_INVALID_VALUE );
4829 
4830     /** Appends property to the list. wxPropertyGrid assumes ownership of the object.
4831         Becomes child of most recently added category.
4832         @remarks
4833         - wxPropertyGrid takes the ownership of the property pointer.
4834         - If appending a category with name identical to a category already in the
4835           wxPropertyGrid, then newly created category is deleted, and most recently
4836           added category (under which properties are appended) is set to the one with
4837           same name. This allows easier adding of items to same categories in multiple
4838           passes.
4839         - Does not automatically redraw the control, so you may need to call Refresh
4840           when calling this function after control has been shown for the first time.
4841     */
4842     wxPGProperty* Append( wxPGProperty* property );
4843 
4844 #if wxPG_COMPATIBILITY_1_2_0
4845     wxDEPRECATED( wxPGProperty* AppendCategory( const wxString& label, const wxString& name = wxPG_LABEL ) );
4846 #endif
4847 
4848     wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newproperty );
4849 
4850     /** Inorder to add new items into a property with fixed children (for instance, wxFlagsProperty),
4851         you need to call this method. After populating has been finished, you need to call EndAddChildren.
4852     */
4853     void BeginAddChildren( wxPGPropArg id );
4854 
4855     /** Called after population of property with fixed children has finished.
4856     */
4857     void EndAddChildren( wxPGPropArg id );
4858 
4859     /** Inserts choice to a property that can accept one.
4860 
4861         See AddPropertyChoice for more details.
4862     */
4863     void InsertPropertyChoice( wxPGPropArg id, const wxString& label, int index, int value = wxPG_INVALID_VALUE );
4864 
4865     /** Deletes all properties.
4866     */
4867     virtual void Clear() = 0;
4868 
4869     /**
4870         Clears current selection, if any. Returns true if success
4871         (ie. validator did not intercept). You can set validation = false
4872         to let selection be cleared even if property had invalid value
4873         in its editor.
4874     */
4875     bool ClearSelection( bool validation = true );
4876 
4877     /** Collapses given category or property with children.
4878         Returns true if actually collapses.
4879     */
4880     bool Collapse( wxPGPropArg id );
4881 
4882     /** Collapses all items that can be collapsed.
4883 
4884         @retval
4885         Return false if failed (may fail if editor value cannot be validated).
4886     */
CollapseAll()4887     bool CollapseAll() { return ExpandAll(false); }
4888 
4889     /** Deletes choice from a property.
4890 
4891         If selected item is deleted, then the value is set to unspecified.
4892 
4893         See AddPropertyChoice for more details.
4894     */
4895     void DeletePropertyChoice( wxPGPropArg id, int index );
4896 
4897     /** Changes value of a property, as if from an editor. Use this instead of SetPropertyValue()
4898         if you need the value to run through validation process, and also send the property
4899         change event.
4900 
4901         @retval
4902         Returns true if value was succesfully changed.
4903     */
4904     bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
4905 
4906     /** Resets value of a property to its default. */
ClearPropertyValue(wxPGPropArg id)4907     bool ClearPropertyValue( wxPGPropArg id )
4908     {
4909         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
4910         p->SetValue(p->GetDefaultValue());
4911         return true;
4912     }
4913 
4914     /** Constructs a property. Class used is given as the first
4915         string argument. It may be either normal property class
4916         name, such as "wxIntProperty" or a short one such as
4917         "Int".
4918     */
4919     static wxPGProperty* CreatePropertyByClass(const wxString &classname,
4920                                                const wxString &label,
4921                                                const wxString &name);
4922 
4923     /** Constructs a property. Value type name used is given as the first
4924         string argument. It may be "string", "long", etc. Any value returned
4925         by wxVariant::GetType fits there.
4926 
4927         Otherwise, this is similar as CreatePropertyByClass.
4928         @remarks
4929         <b>Cannot</b> generate property category.
4930     */
4931     static wxPGProperty* CreatePropertyByType(const wxString &valuetype,
4932                                               const wxString &label,
4933                                               const wxString &name);
4934 
4935     /**
4936         Removes and deletes a property.
4937 
4938         @param id
4939             Pointer or name of a property.
4940 
4941         @remarks If you delete a property in a wxPropertyGrid event
4942                  handler, the actual deletion is postponed until the next
4943                  idle event.
4944     */
4945     void DeleteProperty( wxPGPropArg id );
4946 
4947     /**
4948         Removes a property. Does not delete the property object, but
4949         instead returns it.
4950 
4951         @param id
4952             Pointer or name of a property.
4953 
4954         @remarks Removed property cannot have any children.
4955 
4956                  Also, if you remove property in a wxPropertyGrid event
4957                  handler, the actual removal is postponed until the next
4958                  idle event.
4959     */
4960     wxPGProperty* RemoveProperty( wxPGPropArg id );
4961 
4962 #if wxPG_COMPATIBILITY_1_2_0
4963     /** Deletes a property by id. If category is deleted, all children are automatically deleted as well.
4964         @deprecated
4965         Since version 1.3. Use DeleteProperty() instead.
4966     */
4967     wxDEPRECATED( void Delete( wxPGPropArg id ) );
4968 #endif
4969 
4970 #if wxPG_COMPATIBILITY_1_2_0
4971     /** Disables property.
4972         @deprecated
4973         Since version 1.3. Use wxPropertyGrid::Enable(property, false) instead.
4974     */
4975     wxDEPRECATED( bool Disable( wxPGPropArg id ) );
4976 #endif
4977 
4978     /** Disables property. */
DisableProperty(wxPGPropArg id)4979     bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); }
4980 
4981     /** Enables or disables property, depending on whether enable is true or false. */
4982     bool EnableProperty( wxPGPropArg id, bool enable = true );
4983 
4984     /** Expands given category or property with children.
4985         Returns true if actually expands.
4986     */
4987     bool Expand( wxPGPropArg id );
4988 
4989     /** Expands all items that can be expanded.
4990     */
4991     bool ExpandAll( bool expand = true );
4992 
4993     /** Returns list of expanded properties.
4994         @remarks
4995         If wxPG_USE_STL is 1, then wxArrayPGProperty is typedef of
4996         std::vector<wxPGProperty*>.
4997     */
GetExpandedProperties()4998     wxArrayPGProperty GetExpandedProperties() const
4999     {
5000         wxArrayPGProperty array;
5001         GetPropertiesWithFlag(&array, wxPG_PROP_COLLAPSED, true,
5002             wxPG_ITERATE_ALL_PARENTS_RECURSIVELY|wxPG_ITERATE_HIDDEN);
5003         return array;
5004     }
5005 
5006     /** Returns id of first child of given property.
5007         @remarks
5008         Does not return sub-properties!
5009     */
GetFirstChild(wxPGPropArg id)5010     wxPGProperty* GetFirstChild( wxPGPropArg id )
5011     {
5012         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
5013 
5014         if ( !p->GetChildCount() || p->IsFlagSet(wxPG_PROP_AGGREGATE) )
5015             return wxNullProperty;
5016 
5017         return p->Item(0);
5018     }
5019 
5020     /** Returns iterator class instance.
5021         @param flags
5022         wxPropertyGridIterator flags. If default wxPG_ITERATE_DEFAULT supplied,
5023         everything except private child properties are iterated.
5024         @link iteratorflags List of iterator flags@endlink
5025         @param firstProp
5026         Property to start iteration from. If NULL, then first child of root is used.
5027     */
5028     wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL )
5029     {
5030         return wxPropertyGridIterator( m_pState, flags, firstProp );
5031     }
5032 
5033     wxPropertyGridConstIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL ) const
5034     {
5035         return wxPropertyGridConstIterator( m_pState, flags, firstProp );
5036     }
5037 
5038     /** Returns iterator class instance.
5039         @param flags
5040         wxPropertyGridIterator flags. If default wxPG_ITERATE_DEFAULT supplied,
5041         everything except private child properties are iterated.
5042         @link iteratorflags List of iterator flags@endlink
5043         @param startPos
5044         Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start from
5045         the first property from the top, and wxBOTTOM means that the iteration will
5046         instead begin from bottommost valid item.
5047     */
GetIterator(int flags,int startPos)5048     wxPropertyGridIterator GetIterator( int flags, int startPos )
5049     {
5050         return wxPropertyGridIterator( m_pState, flags, startPos );
5051     }
5052 
GetIterator(int flags,int startPos)5053     wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const
5054     {
5055         return wxPropertyGridConstIterator( m_pState, flags, startPos );
5056     }
5057 
5058     /** Similar to GetIterator, but instead returns wxPGVIterator instance,
5059         which can be useful for forward-iterating through arbitrary property
5060         containers.
5061     */
5062     virtual wxPGVIterator GetVIterator( int flags ) const;
5063 
5064     /** Returns id of first item, whether it is a category or property.
5065         @param flags
5066         @link iteratorflags List of iterator flags@endlink
5067     */
5068     wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL )
5069     {
5070         wxPropertyGridIterator it( m_pState, flags, wxNullProperty, 1 );
5071         return *it;
5072     }
5073 
5074     const wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ) const
5075     {
5076         return ((wxPropertyGridInterface*)this)->GetFirst(flags);
5077     }
5078 
5079 #if wxPG_COMPATIBILITY_1_2_0
5080     /** Returns next item under the same parent. */
GetNextSiblingProperty(wxPGPropArg id)5081     wxPGProperty* GetNextSiblingProperty( wxPGPropArg id )
5082     {
5083         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
5084         return m_pState->GetNextSiblingProperty(p);
5085     }
5086 #endif
5087 
5088     /** Returns map-like storage of property's attributes.
5089         @remarks
5090         Note that if extra style wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES is set,
5091         then builtin-attributes are not included in the storage.
5092     */
GetPropertyAttributes(wxPGPropArg id)5093     const wxPGAttributeStorage& GetPropertyAttributes( wxPGPropArg id ) const
5094     {
5095         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(*((const wxPGAttributeStorage*)NULL));
5096         return p->GetAttributes();
5097     }
5098 
5099     /** Sets attributes from a wxPGAttributeStorage.
5100     */
SetPropertyAttributes(wxPGPropArg id,const wxPGAttributeStorage & attributes)5101     void SetPropertyAttributes( wxPGPropArg id, const wxPGAttributeStorage& attributes )
5102     {
5103         wxPG_PROP_ARG_CALL_PROLOG()
5104         p->SetAttributes(attributes);
5105     }
5106 
5107     /** Adds to 'targetArr' pointers to properties that have given
5108         flags 'flags' set. However, if 'inverse' is set to true, then
5109         only properties without given flags are stored.
5110         @param flags
5111         Property flags to use.
5112         @param iterFlags
5113         Iterator flags to use. Default is everything expect private children.
5114         @remarks
5115         If wxPG_USE_STL is 1, then wxArrayPGProperty is typedef of
5116         std::vector<wxPGProperty*>.
5117     */
5118     void GetPropertiesWithFlag( wxArrayPGProperty* targetArr,
5119                                 wxPGProperty::FlagType flags,
5120                                 bool inverse = false,
5121                                 int iterFlags = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES) ) const;
5122 
5123     /** Returns value of given attribute. If none found, returns NULL-variant.
5124     */
GetPropertyAttribute(wxPGPropArg id,const wxString & attrName)5125     wxVariant GetPropertyAttribute( wxPGPropArg id, const wxString& attrName ) const
5126     {
5127         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant)
5128         return p->GetAttribute(attrName);
5129     }
5130 
5131     /**
5132         Returns pointer to the property with given name (case-sensitive).
5133         If there is no property with such name, @NULL pointer is returned.
5134 
5135         @remarks Properties which have non-category, non-root parent
5136                  can not be accessed globally by their name. Instead, use
5137                  "<property>.<subproperty>" instead of "<subproperty>".
5138     */
GetProperty(wxPGPropNameStr name)5139     wxPGProperty* GetProperty( wxPGPropNameStr name ) const
5140     {
5141         return GetPropertyByName(name);
5142     }
5143 
5144     /**
5145         Returns pointer to the property with given name (case-sensitive).
5146         If there is no property with such name, @NULL pointer is returned.
5147 
5148         @remarks Properties which have non-category, non-root parent
5149                  can not be accessed globally by their name. Instead, use
5150                  "<property>.<subproperty>" instead of "<subproperty>".
5151     */
5152     wxPGProperty* GetPropertyByName( wxPGPropNameStr name ) const;
5153 
5154     /** Returns id of a sub-property 'subname' of property 'name'. Same as
5155         calling GetPropertyByNameI(wxT("name.subname")), albeit slightly faster.
5156     */
5157     wxPGProperty* GetPropertyByName( wxPGPropNameStr name, wxPGPropNameStr subname ) const;
5158 
5159     /** Returns writable reference to property's list of choices (and relevant
5160         values). If property does not have any choices, will return reference
5161         to an invalid set of choices that will return false on IsOk call.
5162     */
5163     wxPGChoices& GetPropertyChoices( wxPGPropArg id );
5164 
5165     /** Gets name of property's constructor function. */
GetPropertyClassName(wxPGPropArg id)5166     wxPG_CONST_WXCHAR_PTR GetPropertyClassName( wxPGPropArg id ) const
5167     {
5168         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxPG_CONST_WXCHAR_DEFVAL)
5169         return p->GetClassName();
5170     }
5171 
5172     /** Returns client data (void*) of a property. */
GetPropertyClientData(wxPGPropArg id)5173     wxPGProperty::ClientDataType GetPropertyClientData( wxPGPropArg id ) const
5174     {
5175         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
5176         return p->GetClientData();
5177     }
5178     /** Returns property's editor. */
GetPropertyEditor(wxPGPropArg id)5179     const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const
5180     {
5181         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
5182         return p->GetEditorClass();
5183     }
5184 
5185     /** Returns property's custom value image (NULL of none). */
GetPropertyImage(wxPGPropArg id)5186     wxBitmap* GetPropertyImage( wxPGPropArg id ) const
5187     {
5188         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
5189         return p->GetValueImage();
5190     }
5191 
5192     /** Returns property's position under its parent. */
GetPropertyIndex(wxPGPropArg id)5193     unsigned int GetPropertyIndex( wxPGPropArg id )
5194     {
5195         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(INT_MAX)
5196         return p->GetIndexInParent();
5197     }
5198 
5199     /** Returns label of a property. */
GetPropertyLabel(wxPGPropArg id)5200     const wxString& GetPropertyLabel( wxPGPropArg id )
5201     {
5202         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
5203         return p->GetLabel();
5204     }
5205     /** Returns name of a property, by which it is globally accessible. */
GetPropertyName(wxPGPropArg id)5206     wxString GetPropertyName( wxPGPropArg id )
5207     {
5208         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
5209         return p->GetName();
5210     }
5211 
5212     /** Returns parent item of a property. */
GetPropertyParent(wxPGPropArg id)5213     wxPGProperty* GetPropertyParent( wxPGPropArg id )
5214     {
5215         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
5216         return p->GetParent();
5217     }
5218 
5219 #if wxPG_COMPATIBILITY_1_2_0
5220     /** Returns pointer to a property.
5221     */
GetPropertyPtr(wxPGPropArg id)5222     wxPGProperty* GetPropertyPtr( wxPGPropArg id ) const
5223     {
5224         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
5225         return p;
5226     }
5227 #endif
5228 
5229     /** Returns help string associated with a property. */
GetPropertyHelpString(wxPGPropArg id)5230     wxString GetPropertyHelpString( wxPGPropArg id ) const
5231     {
5232         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
5233         return p->GetHelpString();
5234     }
5235 
5236     /** Returns short name for property's class. For example,
5237         "wxPropertyCategory" translates to "Category" and "wxIntProperty"
5238         to "Int".
5239     */
5240     wxString GetPropertyShortClassName( wxPGPropArg id );
5241 
5242 #if wxUSE_VALIDATORS
5243     /** Returns validator of a property as a reference, which you
5244         can pass to any number of SetPropertyValidator.
5245     */
GetPropertyValidator(wxPGPropArg id)5246     wxValidator* GetPropertyValidator( wxPGPropArg id )
5247     {
5248         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
5249         return p->GetValidator();
5250     }
5251 #endif
5252 
5253 #ifndef SWIG
5254     /** Returns value as wxVariant. To get wxObject pointer from it,
5255         you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro.
5256 
5257         If property value is unspecified, Null variant is returned.
5258     */
GetPropertyValue(wxPGPropArg id)5259     wxVariant GetPropertyValue( wxPGPropArg id )
5260     {
5261         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
5262         return p->GetValue();
5263     }
5264 #else
5265     %pythoncode {
5266         def GetPropertyValue(self, prop):
5267             if isinstance(prop, basestring):
5268                 prop = self.GetProperty(prop)
5269             return prop.GetValue()
5270     }
5271 #endif
5272 
5273     wxString GetPropertyValueAsString( wxPGPropArg id ) const;
5274     long GetPropertyValueAsLong( wxPGPropArg id ) const;
5275     unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const
5276     {
5277         return (unsigned long) GetPropertyValueAsLong(id);
5278     }
5279 #ifndef SWIG
5280     int GetPropertyValueAsInt( wxPGPropArg id ) const { return (int)GetPropertyValueAsLong(id); }
5281 #endif
5282     bool GetPropertyValueAsBool( wxPGPropArg id ) const;
5283     double GetPropertyValueAsDouble( wxPGPropArg id ) const;
5284     wxObject* GetPropertyValueAsWxObjectPtr( wxPGPropArg id ) const;
5285     void* GetPropertyValueAsVoidPtr( wxPGPropArg id ) const;
5286 
5287 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
5288     wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
5289     if ( p->m_value.GetType() != TYPENAME ) \
5290     { \
5291         wxPGGetFailed(p,TYPENAME); \
5292         return DEFVAL; \
5293     }
5294 
5295 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
5296     wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
5297     if ( p->m_value.GetType() != TYPENAME ) \
5298         return DEFVAL; \
5299 
5300     wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
5301     {
5302         wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("arrstring"), wxArrayString())
5303         return p->m_value.GetArrayString();
5304     }
5305 
5306     wxPoint GetPropertyValueAsPoint( wxPGPropArg id ) const
5307     {
5308         wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxPoint"), wxPoint())
5309         return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxPoint);
5310     }
5311 
5312     wxSize GetPropertyValueAsSize( wxPGPropArg id ) const
5313     {
5314         wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxSize"), wxSize())
5315         return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxSize);
5316     }
5317 
5318     wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const
5319     {
5320         wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxLongLong"), (long) GetPropertyValueAsLong(id))
5321         return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxLongLong).GetValue();
5322     }
5323 
5324     wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const
5325     {
5326         wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxULongLong"), (unsigned long) GetPropertyValueAsULong(id))
5327         return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxULongLong).GetValue();
5328     }
5329 
5330     wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const
5331     {
5332         wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxArrayInt"), wxArrayInt())
5333         wxArrayInt arr = WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxArrayInt);
5334         return arr;
5335     }
5336 
5337 #if wxUSE_DATETIME
5338     wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const
5339     {
5340         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxDateTime())
5341 
5342         if ( wxStrcmp(p->m_value.GetType(),wxT("datetime")) != 0 )
5343         {
5344             wxPGGetFailed(p,wxT("datetime"));
5345             return wxDateTime();
5346         }
5347         return p->m_value.GetDateTime();
5348     }
5349 #endif
5350 
5351 #if defined(SWIG) || defined(__WXPYTHON__)
5352     /** Returns property's value as PyObject*.Note that a reference
5353         count is incremented (ie. a new reference is returned).
5354     */
5355     PyObject* GetPropertyValueAsPyObject( wxPGPropArg id ) const;
5356 #endif
5357 
5358 #ifndef SWIG
5359     /** Returns a wxVariant list containing wxVariant versions of all
5360         property values. Order is not guaranteed.
5361         @param flags
5362         Use wxPG_KEEP_STRUCTURE to retain category structure; each sub
5363         category will be its own wxVariantList of wxVariant.
5364         Use wxPG_INC_ATTRIBUTES to include property attributes as well.
5365         Each attribute will be stored as list variant named "@@<propname>@@attr."
5366         @remarks
5367     */
5368     wxVariant GetPropertyValues( const wxString& listname = wxEmptyString,
5369         wxPGProperty* baseparent = NULL, long flags = 0 ) const
5370     {
5371         return m_pState->DoGetPropertyValues(listname, baseparent, flags);
5372     }
5373 #endif
5374 
5375     wxString GetPropertyValueType( wxPGPropArg id )
5376     {
5377         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
5378         return p->GetType();
5379     }
5380 
5381 #ifdef __WXPYTHON__
5382     ptrdiff_t GetPVTI( wxPGPropArg id )
5383     {
5384         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(1)
5385         //wxLogDebug(wxT("GetPVTI(%s)"),p->GetLabel().c_str());
5386         wxVariant v = p->GetValue();
5387         wxVariantData* data = v.GetData();
5388         if ( !data )
5389             return 0;
5390         return (ptrdiff_t)wxPGVariantDataGetClassInfo(data);
5391     }
5392 #endif
5393 
5394     /**
5395         Returns currently selected property. NULL if none.
5396 
5397         @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this
5398                  member function returns the focused property, that is the
5399                  one that can have active editor.
5400     */
5401     wxPGProperty* GetSelection() const;
5402 
5403     /**
5404         Returns list of currently selected properties.
5405 
5406         @remarks wxArrayPGProperty should be compatible with std::vector API.
5407     */
5408     const wxArrayPGProperty& GetSelectedProperties() const
5409     {
5410         return m_pState->m_selection;
5411     }
5412 
5413 #ifndef SWIG
5414     wxPropertyGridState* GetState() const { return m_pState; }
5415 #endif
5416 
5417     /** Hides or reveals a property.
5418         @param hide
5419         If true, hides property, otherwise reveals it.
5420         @param flags
5421         By default changes are applied recursively. Set this paramter wxPG_DONT_RECURSE to prevent this.
5422     */
5423     bool HideProperty( wxPGPropArg id, bool hide = true, int flags = wxPG_RECURSE );
5424 
5425 #if wxPG_INCLUDE_ADVPROPS
5426     /** Initializes additional property editors (SpinCtrl etc.). Causes references
5427         to most object files in the library, so calling this may cause significant increase
5428         in executable size when linking with static library.
5429     */
5430     static void RegisterAdditionalEditors();
5431 #else
5432     static void RegisterAdditionalEditors() { }
5433 #endif
5434 
5435 #if wxPG_INCLUDE_ADVPROPS
5436     /** Initializes *all* property types. Causes references to most object
5437         files in the library, so calling this may cause significant increase
5438         in executable size when linking with static library.
5439     */
5440     static void InitAllTypeHandlers();
5441 #else
5442     static void InitAllTypeHandlers() { }
5443 #endif
5444 
5445     /** Inserts property to the property container.
5446 
5447         @param priorThis
5448         New property is inserted just prior to this. Available only
5449         in the first variant. There are two versions of this function
5450         to allow this parameter to be either an id or name to
5451         a property.
5452 
5453         @param newproperty
5454         Pointer to the inserted property. wxPropertyGrid will take
5455         ownership of this object.
5456 
5457         @return
5458         Returns id for the property,
5459 
5460         @remarks
5461 
5462         - wxPropertyGrid takes the ownership of the property pointer.
5463 
5464         While Append may be faster way to add items, make note that when
5465         both data storages (categoric and
5466         non-categoric) are active, Insert becomes even more slow. This is
5467         especially true if current mode is non-categoric.
5468 
5469         Example of use:
5470 
5471         @code
5472 
5473             // append category
5474             wxPGProperty* my_cat_id = propertygrid->Append( new wxPropertyCategory (wxT("My Category")) );
5475 
5476             ...
5477 
5478             // insert into category - using second variant
5479             wxPGProperty* my_item_id_1 = propertygrid->Insert( my_cat_id, 0, new wxStringProperty(wxT("My String 1")) );
5480 
5481             // insert before to first item - using first variant
5482             wxPGProperty* my_item_id_2 = propertygrid->Insert( my_item_id, new wxStringProperty(wxT("My String 2")) );
5483 
5484         @endcode
5485 
5486     */
5487     wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newproperty );
5488 
5489     /** Also see documentation for @link wxPropertyGrid::Insert Insert @endlink.
5490 
5491         @param parent
5492         New property is inserted under this category. Available only
5493         in the second variant. There are two versions of this function
5494         to allow this parameter to be either an id or name to
5495         a property.
5496 
5497         @param index
5498         Index under category. Available only in the second variant.
5499         If index is < 0, property is appended in category.
5500     */
5501     wxPGProperty* Insert( wxPGPropArg parent, int index, wxPGProperty* newproperty );
5502 
5503 #if wxPG_COMPATIBILITY_1_2_0
5504     wxPGProperty* InsertCategory( wxPGPropArg id, int index, const wxString& label, const wxString& name = wxPG_LABEL )
5505     {
5506         return Insert( id, index, new wxPropertyCategory(label,name) );
5507     }
5508 #endif
5509 
5510     /** Returns true if property is enabled. */
5511     bool IsPropertyEnabled( wxPGPropArg id ) const
5512     {
5513         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
5514         return (!(p->GetFlags() & wxPG_PROP_DISABLED))?true:false;
5515     }
5516 
5517     /**
5518         Returns true if property is selected.
5519     */
5520     virtual bool IsPropertySelected( wxPGPropArg id ) const;
5521 
5522     /** Returns true if property is shown (ie. hideproperty with true not called for it). */
5523     bool IsPropertyShown( wxPGPropArg id ) const
5524     {
5525         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
5526         return (!(p->GetFlags() & wxPG_PROP_HIDDEN))?true:false;
5527     }
5528 
5529 #if wxPG_COMPATIBILITY_1_2_0
5530     /** Returns true if property's value type has name typestr.
5531         @deprecated
5532         Since version 1.3. Use GetPropertyValueType() and wxString comparison instead.
5533     */
5534     wxDEPRECATED( bool IsPropertyValueType( wxPGPropArg id, const wxChar* typestr ) const );
5535 #endif
5536 
5537     /** Returns true if given property is expanded. Naturally, always returns false
5538         for properties that cannot be expanded.
5539     */
5540     bool IsPropertyExpanded( wxPGPropArg id ) const;
5541 
5542     /** Returns true if property is of certain type.
5543         @param info
5544         Preferably use WX_PG_CLASSINFO(PROPERTYNAME). Alternative is
5545         PROPERTYNAMEClassInfo.
5546     */
5547     bool IsPropertyKindOf( wxPGPropArg id, wxClassInfo* info ) const
5548     {
5549         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
5550         return p->IsKindOf(info);
5551     }
5552 
5553 #if wxPG_COMPATIBILITY_1_2_0
5554     /** Returns true if property has been modified after value set or modify flag
5555         clear by software.
5556 
5557         @deprecated
5558         Since version 1.3. Use IsPropertyModified instead.
5559     */
5560     wxDEPRECATED( bool IsModified( wxPGPropArg id ) const );
5561 #endif
5562 
5563     /** Returns true if property is a category. */
5564     bool IsPropertyCategory( wxPGPropArg id ) const
5565     {
5566         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
5567         return p->IsCategory();
5568     }
5569 
5570     /** Returns true if property has been modified after value set or modify flag
5571         clear by software.
5572     */
5573     bool IsPropertyModified( wxPGPropArg id ) const
5574     {
5575         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
5576         return ( (p->GetFlags() & wxPG_PROP_MODIFIED) ? true : false );
5577     }
5578 
5579     /** Returns true if property value is set to unspecified.
5580     */
5581 #ifdef wxPG_COMPATIBILITY_1_0_0
5582     bool IsPropertyValueUnspecified( wxPGPropArg id ) const
5583 #else
5584     bool IsPropertyUnspecified( wxPGPropArg id ) const
5585 #endif
5586     {
5587         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
5588         return p->IsValueUnspecified();
5589     }
5590 
5591     /** Disables (limit = true) or enables (limit = false) wxTextCtrl editor of a property,
5592         if it is not the sole mean to edit the value.
5593     */
5594     void LimitPropertyEditing( wxPGPropArg id, bool limit = true );
5595 
5596     /** Converts array of properties to array of names.
5597         @remarks
5598         If wxPG_USE_STL is 1, then wxArrayPGProperty is typedef of
5599         std::vector<wxPGProperty*>.
5600     */
5601     void PropertiesToNames( wxArrayString* names, const wxArrayPGProperty& properties ) const;
5602 
5603     /** Converts array of names to array of property pointers.
5604         @remarks
5605         If wxPG_USE_STL is 1, then wxArrayPGProperty is typedef of
5606         std::vector<wxPGProperty*>.
5607     */
5608     void NamesToProperties( wxArrayPGProperty* properties, const wxArrayString& names ) const;
5609 
5610     /** If state is shown in it's grid, refresh it now.
5611     */
5612     virtual void RefreshGrid( wxPropertyGridState* state = NULL );
5613 
5614     /** Replaces property with id with newly created property. For example,
5615         this code replaces existing property named "Flags" with one that
5616         will have different set of items:
5617         @code
5618             pg->ReplaceProperty(wxT("Flags"),
5619                 wxFlagsProperty(wxT("Flags"),wxPG_LABEL,newItems))
5620         @endcode
5621         For more info, see wxPropertyGrid::Insert.
5622     */
5623     wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property );
5624 
5625     /** @anchor propgridinterface_editablestate_flags
5626 
5627         Flags for wxPropertyGridInterface::SaveEditableState() and
5628         wxPropertyGridInterface::RestoreEditableState().
5629     */
5630     enum EditableStateFlags
5631     {
5632         /** Include selected property. */
5633         SelectionState   = 0x01,
5634         /** Include expanded/collapsed property information. */
5635         ExpandedState    = 0x02,
5636         /** Include scrolled position. */
5637         ScrollPosState   = 0x04,
5638         /** Include selected page information.
5639             Only applies to wxPropertyGridManager. */
5640         PageState        = 0x08,
5641         /** Include splitter position. Stored for each page. */
5642         SplitterPosState = 0x10,
5643         /** Include description box size.
5644             Only applies to wxPropertyGridManager. */
5645         DescBoxState     = 0x20,
5646 
5647         /**
5648             Include all supported user editable state information.
5649             This is usually the default value. */
5650         AllStates        = SelectionState |
5651                            ExpandedState |
5652                            ScrollPosState |
5653                            PageState |
5654                            SplitterPosState |
5655                            DescBoxState
5656     };
5657 
5658     /**
5659         Restores user-editable state.
5660 
5661         See also wxPropertyGridInterface::SaveEditableState().
5662 
5663         @param src
5664             String generated by SaveEditableState.
5665 
5666         @param restoreStates
5667             Which parts to restore from source string. See @ref
5668             propgridinterface_editablestate_flags "list of editable state
5669             flags".
5670 
5671         @return
5672             False if there was problem reading the string.
5673 
5674         @remarks
5675         If some parts of state (such as scrolled or splitter position) fail to
5676         restore correctly, please make sure that you call this function after
5677         wxPropertyGrid size has been set (this may sometimes be tricky when
5678         sizers are used).
5679     */
5680     bool RestoreEditableState( const wxString& src,
5681                                int restoreStates = AllStates );
5682 
5683     /**
5684         Used to acquire user-editable state (selected property, expanded
5685         properties, scrolled position, splitter positions).
5686 
5687         @param includedStates
5688         Which parts of state to include. See @ref
5689         propgridinterface_editablestate_flags "list of editable state flags".
5690     */
5691     wxString SaveEditableState( int includedStates = AllStates ) const;
5692 
5693     /** Lets user to set the strings listed in the choice dropdown of a wxBoolProperty.
5694         Defaults are "True" and "False", so changing them to, say, "Yes" and "No" may
5695         be useful in some less technical applications.
5696     */
5697     static void SetBoolChoices( const wxString& true_choice, const wxString& false_choice );
5698 
5699     /**
5700         Set proportion of a auto-stretchable column.
5701 
5702         @returns Returns @false on failure.
5703 
5704         @remarks This member function will fail unless window style
5705                  wxPG_SPLITTER_AUTO_CENTER is used.
5706 
5707                  Also, you should call this for individual pages of
5708                  wxPropertyGridManager (if used).
5709 
5710         @see GetColumnProportion()
5711     */
5712     bool SetColumnProportion( unsigned int column, int proportion );
5713 
5714     /**
5715         Returns auto-resize proportion of the given column.
5716 
5717         @see SetColumnProportion()
5718     */
5719     int GetColumnProportion( unsigned int column ) const
5720     {
5721         return m_pState->DoGetColumnProportion(column);
5722     }
5723 
5724     /** Sets all properties in given array as expanded.
5725         @param expand
5726         False if you want to collapse properties instead.
5727         @remarks
5728         If wxPG_USE_STL is 1, then wxArrayPGProperty is typedef of
5729         std::vector<wxPGProperty*>.
5730     */
5731     void SetExpandedProperties( const wxArrayPGProperty& array, bool expand = true )
5732     {
5733         SetPropertiesFlag(array, wxPG_PROP_COLLAPSED, expand);
5734     }
5735 
5736     /** Sets or clears flag(s) of all properties in given array.
5737         @param flags
5738         Property flags to set or clear.
5739         @param inverse
5740         Set to true if you want to clear flag instead of setting them.
5741         @remarks
5742         If wxPG_USE_STL is 1, then wxArrayPGProperty is typedef of
5743         std::vector<wxPGProperty*>.
5744     */
5745     void SetPropertiesFlag( const wxArrayPGProperty& srcArr, wxPGProperty::FlagType flags,
5746                             bool inverse = false );
5747 
5748     /** Sets text, bitmap, and colours for given column's cell.
5749 
5750         @remarks
5751         - You can set label cell by setting column to 0.
5752         - You can use wxPG_LABEL as text to use default text for column.
5753     */
5754     void SetPropertyCell( wxPGPropArg id,
5755                           int column,
5756                           const wxString& text = wxEmptyString,
5757                           const wxBitmap& bitmap = wxNullBitmap,
5758                           const wxColour& fgCol = wxNullColour,
5759                           const wxColour& bgCol = wxNullColour )
5760     {
5761         wxPG_PROP_ARG_CALL_PROLOG()
5762         p->SetCell( column, new wxPGCell(text, bitmap, fgCol, bgCol) );
5763     }
5764 
5765     /**
5766         Set choices of a property to specified set of labels and values.
5767 
5768         @remarks This operation clears the property value. Also, if you
5769                  try to use this on a property which cannot hold choices,
5770                  a run-time error will be shown.
5771 
5772                  This function will deselect the property, if
5773                  necessary.
5774     */
5775     void SetPropertyChoices( wxPGPropArg id, wxPGChoices& choices)
5776     {
5777         wxPG_PROP_ARG_CALL_PROLOG()
5778         p->SetChoices(choices);
5779     }
5780 
5781 
5782     /** If property's set of choices is shared, then calling this method converts
5783         it to private.
5784     */
5785     void SetPropertyChoicesExclusive( wxPGPropArg id )
5786     {
5787         wxPG_PROP_ARG_CALL_PROLOG()
5788         p->SetChoicesExclusive();
5789     }
5790 
5791     /** Sets an attribute of a property. Ids and relevants values are totally
5792         specific to property classes and may affect either the given instance
5793         or all instances of that class. See @ref attrids for list of built-in
5794         attributes.
5795         @param argFlags
5796         Optional. Use wxPG_RECURSE to set the attribute to child properties
5797         as well.
5798         @remarks
5799         - Settings attribute's value to Null variant will simply remove it
5800           from property's set of attributes.
5801         - wxVariant doesn't have int constructor (as of 2.5.4), so <b>you will
5802           need to cast int values (including most numeral constants) to long</b>.
5803     */
5804     void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName, wxVariant value, long argFlags = 0 )
5805     {
5806         DoSetPropertyAttribute(id,attrName,value,argFlags);
5807     }
5808 
5809 #ifndef SWIG
5810     /** Sets editor control of a property. As editor argument, use
5811         wxPG_EDITOR(EditorName), where basic built-in editor names are TextCtrl, Choice,
5812         ComboBox, CheckBox, TextCtrlAndButton, and ChoiceAndButton. Additional editors
5813         include SpinCtrl and DatePickerCtrl, which also require wxPropertyGrid::RegisterAdditionalEditors()
5814         call prior using.
5815     */
5816     void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor )
5817     {
5818         wxPG_PROP_ARG_CALL_PROLOG()
5819         wxCHECK_RET( editor, wxT("unknown/NULL editor") );
5820         p->SetEditor(editor);
5821         RefreshProperty(p);
5822     }
5823 #endif // #ifndef SWIG
5824 
5825     /** Sets editor control of a property. As editor argument, use
5826         editor name string, such as wxT("TextCtrl") or wxT("Choice").
5827     */
5828     void SetPropertyEditor( wxPGPropArg id, const wxString& editorName )
5829     {
5830         SetPropertyEditor(id,GetEditorByName(editorName));
5831     }
5832 
5833     /** Sets label of a property.
5834 
5835         @remarks
5836         - Properties under same parent may have same labels. However,
5837         property names must still remain unique.
5838     */
5839     void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel );
5840 
5841     /** Sets client data (void*) of a property.
5842         @remarks
5843         This untyped client data has to be deleted manually.
5844     */
5845     void SetPropertyClientData( wxPGPropArg id, wxPGProperty::ClientDataType clientData )
5846     {
5847         wxPG_PROP_ARG_CALL_PROLOG()
5848         p->SetClientData(clientData);
5849     }
5850 
5851     /** Sets property's value to unspecified. If it has children (it may be category),
5852         then the same thing is done to them.
5853     */
5854     void SetPropertyValueUnspecified( wxPGPropArg id )
5855     {
5856         wxPG_PROP_ARG_CALL_PROLOG()
5857         p->SetValueToUnspecified();
5858     }
5859 
5860     /** Sets property (and, recursively, its children) to have read-only
5861         value. In other words, user cannot change the value in the editor,
5862         but they can still copy it.
5863 
5864         @param flags
5865             By default changes are applied recursively. Set this paramter
5866             wxPG_DONT_RECURSE to prevent this.
5867 
5868         @remarks This is mainly for use with textctrl editor. Not all other
5869                  editors fully support it.
5870 
5871                  Also note that read-only state does not immediately become
5872                  active for currently open property editor.
5873     */
5874     void SetPropertyReadOnly( wxPGPropArg id, bool set = true,
5875                               int flags = wxPG_RECURSE )
5876     {
5877         wxPG_PROP_ARG_CALL_PROLOG()
5878         if ( flags & wxPG_RECURSE )
5879             p->SetFlagRecursively(wxPG_PROP_READONLY, set);
5880         else
5881             p->ChangeFlag(wxPG_PROP_READONLY, set);
5882     }
5883 
5884 #ifndef SWIG
5885     /**
5886 		Sets property values from a list of wxVariants.
5887     */
5888     void SetPropertyValues( const wxVariantList& list,
5889 							wxPGPropArg defaultCategory = wxNullProperty )
5890     {
5891         wxPGProperty *p;
5892         if ( defaultCategory.HasName() ) p = defaultCategory.GetPtr(this);
5893         else p = defaultCategory.GetPtr0();
5894         m_pState->DoSetPropertyValues(list, p);
5895     }
5896 
5897     /**
5898 		Sets property values from a list of wxVariants.
5899     */
5900     void SetPropertyValues( const wxVariant& list,
5901 							wxPGPropArg defaultCategory = wxNullProperty )
5902     {
5903         SetPropertyValues(list.GetList(),defaultCategory);
5904     }
5905 #endif
5906 
5907     /** Returns pointer of property's nearest parent category. If no category
5908         found, returns NULL.
5909     */
5910     wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const
5911     {
5912         wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL)
5913         return m_pState->GetPropertyCategory(p);
5914     }
5915 
5916     /** Associates the help string with property.
5917         @remarks
5918         By default, text is shown either in the manager's "description"
5919         text box or in the status bar. If extra window style wxPG_EX_HELP_AS_TOOLTIPS
5920         is used, then the text will appear as a tooltip.
5921     */
5922     void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString )
5923     {
5924         wxPG_PROP_ARG_CALL_PROLOG()
5925         p->SetHelpString(helpString);
5926     }
5927 
5928     /** Set wxBitmap in front of the value.
5929         @remarks
5930         - Bitmap will be scaled to a size returned by wxPropertyGrid::GetImageSize();
5931     */
5932     void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp )
5933     {
5934         wxPG_PROP_ARG_CALL_PROLOG()
5935         p->SetValueImage(bmp);
5936         RefreshProperty(p);
5937     }
5938 
5939     /** Sets max length of property's text.
5940     */
5941     bool SetPropertyMaxLength( wxPGPropArg id, int maxLen );
5942 
5943 #if wxUSE_VALIDATORS
5944     /** Sets validator of a property.
5945     */
5946     void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator )
5947     {
5948         wxPG_PROP_ARG_CALL_PROLOG()
5949         p->SetValidator(validator);
5950     }
5951 #endif
5952 
5953     /** Sets value (long integer) of a property.
5954     */
5955     void SetPropertyValueLong( wxPGPropArg id, long value )
5956     {
5957         wxVariant v(value);
5958         SetPropVal( id, v );
5959     }
5960 
5961 #ifndef __WXPYTHON__
5962     /** Sets value (integer) of a property.
5963     */
5964     void SetPropertyValue( wxPGPropArg id, int value )
5965     {
5966         wxVariant v((long)value);
5967         SetPropVal( id, v );
5968     }
5969 #endif
5970     /** Sets value (floating point) of a property.
5971     */
5972     void SetPropertyValueDouble( wxPGPropArg id, double value )
5973     {
5974         wxVariant v(value);
5975         SetPropVal( id, v );
5976     }
5977     /** Sets value (bool) of a property.
5978     */
5979     void SetPropertyValueBool( wxPGPropArg id, bool value )
5980     {
5981         wxVariant v(value);
5982         SetPropVal( id, v );
5983     }
5984 #ifndef __WXPYTHON__
5985     void SetPropertyValue( wxPGPropArg id, const wxChar* value )
5986     {
5987         SetPropertyValueString( id, wxString(value) );
5988     }
5989 #endif
5990 
5991     /** Sets value (wxArrayString) of a property.
5992     */
5993     void SetPropertyValueArrstr2( wxPGPropArg id, const wxArrayString& value )
5994     {
5995         wxVariant v(value);
5996         SetPropVal( id, v );
5997     }
5998 
5999 
6000 #if wxUSE_DATETIME
6001     void SetPropertyValueDatetime( wxPGPropArg id, const wxDateTime& value )
6002     {
6003         wxVariant v(value);
6004         SetPropVal( id, v );
6005     }
6006 #endif
6007 
6008     /** Sets value (wxString) of a property.
6009         @remarks
6010         This method uses wxPGProperty::SetValueFromString, which all properties
6011         should implement. This means that there should not be a type error,
6012         and instead the string is converted to property's actual value type.
6013     */
6014     void SetPropertyValueString( wxPGPropArg id, const wxString& value );
6015 
6016     /** Sets value (wxObject*) of a property.
6017     */
6018     void SetPropertyValueWxObjectPtr( wxPGPropArg id, wxObject* value )
6019     {
6020         wxVariant v(value);
6021         SetPropVal( id, v );
6022     }
6023 
6024 #ifndef __WXPYTHON__
6025     /** Sets value (void*) of a property. */
6026     void SetPropertyValue( wxPGPropArg id, void* value )
6027     {
6028         wxVariant v(value);
6029         SetPropVal( id, v );
6030     }
6031     void SetPropertyValue ( wxPGPropArg id, wxObject& value )
6032     {
6033         wxVariant v(&value);
6034         SetPropVal( id, v );
6035     }
6036 #endif
6037 
6038     /** Sets value (wxVariant&) of a property.
6039 
6040         @remarks
6041         Use wxPropertyGrid::ChangePropertyValue() instead if you need to run through
6042         validation process and send property change event.
6043     */
6044     void SetPropertyValue( wxPGPropArg id, wxVariant value )
6045     {
6046         SetPropVal( id, value );
6047     }
6048 
6049     /** Sets value (wxPoint&) of a property.
6050     */
6051     void SetPropertyValuePoint( wxPGPropArg id, const wxPoint& value )
6052     {
6053         wxVariant v = WXVARIANT(value);
6054         SetPropVal( id, v );
6055     }
6056     /** Sets value (wxSize&) of a property.
6057     */
6058     void SetPropertyValueSize( wxPGPropArg id, const wxSize& value )
6059     {
6060         wxVariant v = WXVARIANT(value);
6061         SetPropVal( id, v );
6062     }
6063     /** Sets value (wxLongLong&) of a property.
6064     */
6065     void SetPropertyValueLongLong( wxPGPropArg id, wxLongLong_t value )
6066     {
6067         wxVariant v = WXVARIANT(wxLongLong(value));
6068         SetPropVal( id, v );
6069     }
6070     /** Sets value (wxULongLong&) of a property.
6071     */
6072     void SetPropertyValueULongLong( wxPGPropArg id, wxULongLong_t value )
6073     {
6074         wxVariant v = WXVARIANT(wxULongLong(value));
6075         SetPropVal( id, v );
6076     }
6077     /** Sets value (wxArrayInt&) of a property.
6078     */
6079     void SetPropertyValueArrint2( wxPGPropArg id, const wxArrayInt& value )
6080     {
6081         wxVariant v = WXVARIANT(value);
6082         SetPropVal( id, v );
6083     }
6084     /** Sets value (wxDateTime&) of a property.
6085     */
6086 #ifdef __WXPYTHON__
6087     void SetPropertyValuePyObject( wxPGPropArg id, PyObject* value )
6088     {
6089         wxVariant v = WXVARIANT(value);
6090         SetPropVal( id, v );
6091     }
6092 #endif
6093 
6094 #ifndef SWIG
6095     /** Sets value (wxVariant&) of a property. Same as SetPropertyValue, but
6096         accepts reference. */
6097     void SetPropVal( wxPGPropArg id, wxVariant& value );
6098 #endif
6099 
6100     /** Adjusts how wxPropertyGrid behaves when invalid value is entered
6101         in a property.
6102         @param vfbFlags
6103         See @link vfbflags list of valid flags values@endlink
6104     */
6105     void SetValidationFailureBehavior( int vfbFlags );
6106 
6107 #ifdef SWIG
6108     %pythoncode {
6109         def MapType(class_,factory):
6110             "Registers Python type/class to property mapping.\n\nfactory: Property builder function/class."
6111             global _type2property
6112             try:
6113                 mappings = _type2property
6114             except NameError:
6115                 raise AssertionError("call only after a propertygrid or manager instance constructed")
6116 
6117             mappings[class_] = factory
6118 
6119 
6120         def DoDefaultTypeMappings(self):
6121             "Map built-in properties."
6122             global _type2property
6123             try:
6124                 mappings = _type2property
6125 
6126                 return
6127             except NameError:
6128                 mappings = {}
6129                 _type2property = mappings
6130 
6131             mappings[str] = StringProperty
6132             mappings[unicode] = StringProperty
6133             mappings[int] = IntProperty
6134             mappings[float] = FloatProperty
6135             mappings[bool] = BoolProperty
6136             mappings[list] = ArrayStringProperty
6137             mappings[tuple] = ArrayStringProperty
6138             mappings[wx.Font] = FontProperty
6139             mappings[wx.Colour] = ColourProperty
6140             mappings[wx.Size] = SizeProperty
6141             mappings[wx.Point] = PointProperty
6142             mappings[wx.FontData] = FontDataProperty
6143 
6144 
6145         def SetPropertyValueArrstr(self,p,v):
6146             "NB: We must implement this in Python because SWIG has problems combining"
6147             "    conversion of list to wxArrayXXX and overloaded arguments."
6148             if not isinstance(p,basestring):
6149                 self._SetPropertyValueArrstr(p,v)
6150             else:
6151                 self._SetPropertyValueArrstr(self.GetPropertyByNameI(p),v)
6152 
6153 
6154         def SetPropertyValueArrint(self,p,v):
6155             "NB: We must implement this in Python because SWIG has problems combining"
6156             "    conversion of list to wxArrayXXX and overloaded arguments."
6157             if not isinstance(p,basestring):
6158                 self._SetPropertyValueArrint(p,v)
6159             else:
6160                 self._SetPropertyValueArrint(self.GetPropertyByNameI(p),v)
6161 
6162 
6163         def DoDefaultValueTypeMappings(self):
6164             "Map pg value type ids to getter methods."
6165             global _vt2getter
6166             try:
6167                 vt2getter = _vt2getter
6168 
6169                 return
6170             except NameError:
6171                 vt2getter = {}
6172                 _vt2getter = vt2getter
6173 
6174 
6175         def _GetValues(self,parent,fc,dict_,getter,inc_attributes):
6176             p = fc
6177 
6178             while p:
6179                 pfc = self.GetFirstChild(p)
6180                 if pfc:
6181                     self._GetValues(p,pfc,dict_,getter,inc_attributes)
6182                 else:
6183                     dict_[p.GetName()] = getter(p)
6184 
6185                 if inc_attributes:
6186                     attrs = p.GetAttributes()
6187                     if attrs and len(attrs):
6188                         dict_['@%s@attr'%(p.GetName())] = attrs
6189 
6190                 p = self.GetNextSiblingProperty(p)
6191 
6192 
6193         def GetPropertyValues(self,dict_=None, as_strings=False, inc_attributes=False):
6194             "Returns values in the grid."
6195             ""
6196             "dict_: if not given, then a new one is created. dict_ can be"
6197             "  object as well, in which case it's __dict__ is used."
6198             "as_strings: if True, then string representations of values"
6199             "  are fetched instead of native types. Useful for config and such."
6200             "inc_attributes: if True, then property attributes are added"
6201             "  as @<propname>@<attr>."
6202             ""
6203             "Return value: dictionary with values. It is always a dictionary,"
6204             "so if dict_ was object with __dict__ attribute, then that attribute"
6205             "is returned."
6206 
6207             if dict_ is None:
6208                 dict_ = {}
6209             elif hasattr(dict_,'__dict__'):
6210                 dict_ = dict_.__dict__
6211 
6212             if not as_strings:
6213                 getter = self.GetPropertyValue
6214             else:
6215                 getter = self.GetPropertyValueAsString
6216 
6217             root = self.GetGrid().GetRoot()
6218             self._GetValues(root,self.GetFirstChild(root),dict_,getter,inc_attributes)
6219 
6220             return dict_
6221 
6222         GetValues = GetPropertyValues
6223 
6224 
6225         def SetPropertyValues(self,dict_):
6226             "Sets property values from dict_, which can be either\ndictionary or an object with __dict__ attribute."
6227             ""
6228             "autofill: If true, keys with not relevant properties"
6229             "  are auto-created. For more info, see AutoFill."
6230             ""
6231             "Notes:"
6232             "  * Keys starting with underscore are ignored."
6233             "  * Attributes can be set with entries named @<propname>@<attr>."
6234             ""
6235 
6236             autofill = False
6237 
6238             if dict_ is None:
6239                 dict_ = {}
6240             elif hasattr(dict_,'__dict__'):
6241                 dict_ = dict_.__dict__
6242 
6243             attr_dicts = []
6244 
6245             def set_sub_obj(k0,dict_):
6246                 for k,v in dict_.iteritems():
6247                     if k[0] != '_':
6248                         if k.endswith('@attr'):
6249                             attr_dicts.append((k[1:-5],v))
6250                         else:
6251                             try:
6252                                 self.SetPropertyValue(k,v)
6253                             except:
6254                                 try:
6255                                     if autofill:
6256                                         self._AutoFillOne(k0,k,v)
6257                                         continue
6258                                 except:
6259                                     if isinstance(v,dict):
6260                                         set_sub_obj(k,v)
6261                                     elif hasattr(v,'__dict__'):
6262                                         set_sub_obj(k,v.__dict__)
6263 
6264 
6265             for k,v in attr_dicts:
6266                 p = GetPropertyByName(k)
6267                 if not p:
6268                     raise AssertionError("No such property: '%s'"%k)
6269                 for an,av in v.iteritems():
6270                     p.SetAttribute(an, av)
6271 
6272 
6273             cur_page = False
6274             is_manager = isinstance(self,PropertyGridManager)
6275 
6276             try:
6277                 set_sub_obj(self.GetGrid().GetRoot(),dict_)
6278             except:
6279                 import traceback
6280                 traceback.print_exc()
6281 
6282             self.Refresh()
6283 
6284 
6285         SetValues = SetPropertyValues
6286 
6287 
6288         def _AutoFillMany(self,cat,dict_):
6289             for k,v in dict_.iteritems():
6290                 self._AutoFillOne(cat,k,v)
6291 
6292 
6293         def _AutoFillOne(self,cat,k,v):
6294             global _type2property
6295 
6296             factory = _type2property.get(v.__class__,None)
6297 
6298             if factory:
6299                 self.AppendIn( cat, factory(k,k,v) )
6300             elif hasattr(v,'__dict__'):
6301                 cat2 = self.AppendIn( cat, PropertyCategory(k) )
6302                 self._AutoFillMany(cat2,v.__dict__)
6303             elif isinstance(v,dict):
6304                 cat2 = self.AppendIn( cat, PropertyCategory(k) )
6305                 self._AutoFillMany(cat2,v)
6306             elif not k.startswith('_'):
6307                 raise AssertionError("member '%s' is of unregisted type/class '%s'"%(k,v.__class__))
6308 
6309 
6310         def AutoFill(self,obj,parent=None):
6311             "Clears properties and re-fills to match members and\nvalues of given object or dictionary obj."
6312 
6313             self.edited_objects[parent] = obj
6314 
6315             cur_page = False
6316             is_manager = isinstance(self,PropertyGridManager)
6317 
6318             if not parent:
6319                 if is_manager:
6320                     page = self.GetCurrentPage()
6321                     page.Clear()
6322                     parent = page.GetRoot()
6323                 else:
6324                     self.Clear()
6325                     parent = self.GetGrid().GetRoot()
6326             else:
6327                 p = self.GetFirstChild(parent)
6328                 while p:
6329                     self.Delete(p)
6330                     p = self.GetNextSiblingProperty(p)
6331 
6332             if not is_manager or page == self.GetCurrentPage():
6333                 self.Freeze()
6334                 cur_page = True
6335 
6336             try:
6337                 self._AutoFillMany(parent,obj.__dict__)
6338             except:
6339                 import traceback
6340                 traceback.print_exc()
6341 
6342             if cur_page:
6343                 self.Thaw()
6344 
6345 
6346         def RegisterEditor(self, editor, editorName=None):
6347             "Transform class into instance, if necessary."
6348             if not isinstance(editor, PGEditor):
6349                 editor = editor()
6350             if not editorName:
6351                 editorName = editor.__class__.__name__
6352             try:
6353                 self._editor_instances.append(editor)
6354             except:
6355                 self._editor_instances = [editor]
6356             RegisterEditor(editor, editorName)
6357 
6358     }
6359 #endif
6360 
6361     // GetPropertyByNameI With nice assertion error message.
6362     wxPGProperty* GetPropertyByNameA( wxPGPropNameStr name ) const;
6363 
6364     static wxPGEditor* GetEditorByName( const wxString& editorName );
6365 
6366     // NOTE: This function reselects the property and may cause
6367     //       excess flicker, so to just call Refresh() on a rect
6368     //       of single property, call DrawItem() instead.
6369     virtual void RefreshProperty( wxPGProperty* p ) = 0;
6370 
6371 protected:
6372 
6373     bool DoClearSelection( bool validation,
6374                            int selFlags = 0 );
6375 
6376     /**
6377         In derived class, implement to set editable state component with
6378         given name to given value.
6379     */
6380     virtual bool SetEditableStateItem( const wxString& name, wxVariant value )
6381     {
6382         wxUnusedVar(name);
6383         wxUnusedVar(value);
6384         return false;
6385     }
6386 
6387     /**
6388         In derived class, implement to return editable state component with
6389         given name.
6390     */
6391     virtual wxVariant GetEditableStateItem( const wxString& name ) const
6392     {
6393         wxUnusedVar(name);
6394         return wxNullVariant;
6395     }
6396 
6397     // Returns page state data for given (sub) page (-1 means current page).
6398     virtual wxPropertyGridState* GetPageState( int pageIndex ) const
6399     {
6400         if ( pageIndex <= 0 )
6401             return m_pState;
6402         return NULL;
6403     }
6404 
6405     virtual bool DoSelectPage( int WXUNUSED(index) ) { return true; }
6406 
6407     // Default call's m_pState's BaseGetPropertyByName
6408     virtual wxPGProperty* DoGetPropertyByName( wxPGPropNameStr name ) const;
6409 
6410 #ifndef SWIG
6411     // Deriving classes must set this (it must be only or current page).
6412     wxPropertyGridState*         m_pState;
6413 
6414     // Intermediate version needed due to wxVariant copying inefficiency
6415     void DoSetPropertyAttribute( wxPGPropArg id, const wxString& name, wxVariant& value, long argFlags );
6416 
6417     // Empty string object to return from member functions returning const wxString&.
6418     wxString                    m_emptyString;
6419 
6420 private:
6421     // Cannot be GetGrid() due to ambiguity issues.
6422     wxPropertyGrid* GetPropertyGrid()
6423     {
6424         if ( !m_pState )
6425             return NULL;
6426         return m_pState->GetGrid();
6427     }
6428     const wxPropertyGrid* GetPropertyGrid() const
6429     {
6430         if ( !m_pState )
6431             return NULL;
6432         return (const wxPropertyGrid*) m_pState->GetGrid();
6433     }
6434 #endif // #ifndef SWIG
6435 };
6436 
6437 // For backwards compatibility
6438 typedef wxPropertyGridInterface wxPropertyContainerMethods;
6439 
6440 // -----------------------------------------------------------------------
6441 
6442 
6443 // wxPropertyGrid::DoSelectProperty flags (selFlags)
6444 #define wxPG_SEL_FOCUS      0x0001 // Focuses to created editor
6445 #define wxPG_SEL_FORCE      0x0002 // Forces deletion and recreation of editor
6446 #define wxPG_SEL_NONVISIBLE 0x0004 // For example, doesn't cause EnsureVisible
6447 #define wxPG_SEL_NOVALIDATE 0x0008 // Do not validate editor's value before selecting
6448 #define wxPG_SEL_DELETING   0x0010 // Property being deselected is about to be deleted
6449 #define wxPG_SEL_SETUNSPEC  0x0020 // Property's values was set to unspecified by the user
6450 #define wxPG_SEL_DIALOGVAL  0x0040 // Property's event handler changed the value
6451 
6452 // Set to disable sending of wxEVT_PG_SELECTED event
6453 // NOTE! This doesn't do anything in wxPG 1.4, is just here
6454 //       to reduce code difference with wxWidgets 2.9.
6455 #define wxPG_SEL_DONT_SEND_EVENT        0x0080
6456 
6457 #define wxPG_SEL_NO_REFRESH             0x0100 // Do not call Refresh()
6458 
6459 
6460 // -----------------------------------------------------------------------
6461 
6462 #ifndef SWIG
6463 
6464 // Internal flags
6465 #define wxPG_FL_INITIALIZED                 0x0001
6466 #define wxPG_FL_ACTIVATION_BY_CLICK         0x0002 // Set when creating editor controls if it was clicked on.
6467 #define wxPG_FL_DONT_CENTER_SPLITTER        0x0004
6468 #define wxPG_FL_FOCUSED                     0x0008
6469 #define wxPG_FL_MOUSE_CAPTURED              0x0010
6470 #define wxPG_FL_MOUSE_INSIDE                0x0020
6471 #define wxPG_FL_VALUE_MODIFIED              0x0040
6472 #define wxPG_FL_PRIMARY_FILLS_ENTIRE        0x0080 // don't clear background of m_wndEditor
6473 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE       0x0100 // currently active editor uses custom image
6474 #define wxPG_FL_CELL_OVERRIDES_SEL          0x0200 // cell colours override selection colours for selected cell
6475 #define wxPG_FL_SCROLLED                    0x0400
6476 #define wxPG_FL_ADDING_HIDEABLES            0x0800 // set when all added/inserted properties get hideable flag
6477 #define wxPG_FL_NOSTATUSBARHELP             0x1000 // Disables showing help strings on statusbar.
6478 #define wxPG_FL_CREATEDSTATE                0x2000 // Marks that we created the state, so we have to destroy it too.
6479 #define wxPG_FL_SCROLLBAR_DETECTED          0x4000 // Set if scrollbar's existence was detected in last onresize.
6480 #define wxPG_FL_DESC_REFRESH_REQUIRED       0x8000 // Set if wxPGMan requires redrawing of description text box.
6481 #define wxPG_FL_IN_MANAGER                  0x00020000 // Set if contained in wxPropertyGridManager
6482 #define wxPG_FL_GOOD_SIZE_SET               0x00040000 // Set after wxPropertyGrid is shown in its initial good size
6483 #define wxPG_FL_IGNORE_NEXT_NAVKEY          0x00080000 // Next navigation key event will get ignored
6484 #define wxPG_FL_IN_SELECT_PROPERTY          0x00100000 // Set when in SelectProperty.
6485 #define wxPG_FL_STRING_IN_STATUSBAR         0x00200000 // Set when help string is shown in status bar
6486 #define wxPG_FL_SPLITTER_PRE_SET            0x00400000 // Splitter position has been custom-set by the user
6487 #define wxPG_FL_VALIDATION_FAILED           0x00800000 // Validation failed. Clear on modify event.
6488 #define wxPG_FL_CATMODE_AUTO_SORT           0x01000000 // Auto sort is enabled (for categorized mode)
6489 #define wxPG_MAN_FL_PAGE_INSERTED           0x02000000 // Set after page has been inserted to manager
6490 #define wxPG_FL_ABNORMAL_EDITOR             0x04000000 // Active editor control is abnormally large
6491 #define wxPG_FL_IN_ONCUSTOMEDITOREVENT      0x08000000 // Recursion guard for OnCustomEditorEvent
6492 #define wxPG_FL_VALUE_CHANGE_IN_EVENT       0x10000000
6493 #define wxPG_FL_FIXED_WIDTH_EDITOR          0x20000000 // Editor control width should not change on resize
6494 #define wxPG_FL_HAS_VIRTUAL_WIDTH           0x40000000 // Width of panel can be different than width of grid
6495 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE  0x80000000 // Prevents RecalculateVirtualSize re-entrancy
6496 
6497 #endif // #ifndef SWIG
6498 
6499 #if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
6500     // Reduce compile time, but still include in user app
6501     #include "props.h"
6502 #endif
6503 
6504 // -----------------------------------------------------------------------
6505 
6506 #define wxPG_USE_STATE  m_pState
6507 
6508 /** @class wxPropertyGrid
6509 	@ingroup classes
6510     @brief
6511     wxPropertyGrid is a specialized two-column grid for editing properties
6512     such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
6513     used to do the very same thing, but it hasn't been updated for a while
6514     and it is currently deprecated.
6515 
6516     Please note that most member functions are inherited and as such not documented on
6517     this page. This means you will probably also want to read wxPropertyGridInterface
6518     class reference.
6519 
6520     <h4>Derived from</h4>
6521 
6522     wxPropertyGridInterface\n
6523     wxScrolledWindow\n
6524     wxPanel\n
6525     wxWindow\n
6526     wxEvtHandler\n
6527     wxObject\n
6528 
6529     <h4>Include files</h4>
6530 
6531     <wx/propertygrid/propertygrid.h>
6532 
6533     <h4>Window styles</h4>
6534 
6535     @link wndflags Additional Window Styles@endlink
6536 
6537     <h4>Event handling</h4>
6538 
6539     To process input from a propertygrid control, use these event handler macros to
6540     direct input to member functions that take a wxPropertyGridEvent argument.
6541 
6542     <table>
6543     <tr><td>EVT_PG_SELECTED (id, func)</td><td>Property is selected.</td></tr>
6544     <tr><td>EVT_PG_CHANGED (id, func)</td><td>Property value is modified.</td></tr>
6545     <tr><td>EVT_PG_CHANGING (id, func)</td><td>Property value is about to be changed. Use wxPropertyGridEvent::GetValue() to take a peek at the pending value, and wxPropertyGridEvent::Veto() to prevent change from taking place, if necessary.</td></tr>
6546     <tr><td>EVT_PG_HIGHLIGHTED (id, func)</td><td>Mouse moves over property. Event's property is NULL if hovered on area that is not a property.</td></tr>
6547     <tr><td>EVT_PG_RIGHT_CLICK (id, func)</td><td>Mouse right-clicked on a property.</td></tr>
6548     <tr><td>EVT_PG_DOUBLE_CLICK (id, func)</td><td>Mouse double-clicked on a property.</td></tr>
6549     <tr><td>EVT_PG_ITEM_COLLAPSED (id, func)</td><td>User collapses a property or category.</td></tr>
6550     <tr><td>EVT_PG_ITEM_EXPANDED (id, func)</td><td>User expands a property or category.</td></tr>
6551     <tr><td>EVT_PG_LABEL_EDIT_BEGIN (id, func)</td><td>User is about to begin editing a property label. You can veto this event to prevent the action.</td></tr>
6552     <tr><td>EVT_PG_LABEL_EDIT_ENDING (id, func)</td><td>User is about to end editing of a property label. You can veto this event to prevent the action.</td></tr>
6553 
6554     <tr><td>EVT_BUTTON (id, func)</td><td>Button in a property editor was clicked. Only occurs if the property doesn't handle button clicks itself.</td></tr>
6555     <tr><td>EVT_TEXT (id, func)</td><td>wxTextCtrl based editor was updated (but property value was not yet modified)</td></tr>
6556     </table>
6557 
6558     @sa @link wxPropertyGridEvent wxPropertyGridEvent@endlink
6559 
6560     @remarks
6561 
6562     - Following functions do not automatically update the screen: Append. You
6563       probably need to explicitly call Refresh() <b>if</b> you called one of these
6564       functions outside parent window constructor.
6565 
6566     - Use Freeze() and Thaw() respectively to disable and enable drawing. This
6567       will also delay sorting etc. miscellaneous calculations to the last possible
6568       moment.
6569 
6570     For code examples, see the main page.
6571 
6572 */
6573 // BM_GRID
6574 class WXDLLIMPEXP_PG wxPropertyGrid : public wxScrolledWindow, public wxPropertyGridInterface
6575 {
6576 #ifndef SWIG
6577     friend class wxPropertyGridState;
6578     friend class wxPropertyGridInterface;
6579     friend class wxPropertyGridManager;
6580     friend class wxPGCanvas;
6581 
6582     DECLARE_DYNAMIC_CLASS(wxPropertyGrid)
6583 #endif
6584 
6585 public:
6586 	/** Two step constructor. Call Create when this constructor is called to build up the
6587 	    wxPropertyGrid
6588 	*/
6589 
6590 #ifdef SWIG
6591     %pythonAppend wxPropertyGrid {
6592         self._setOORInfo(self)
6593         self.DoDefaultTypeMappings()
6594         self.edited_objects = {}
6595         self.DoDefaultValueTypeMappings()
6596         if not hasattr(self.__class__,'_vt2setter'):
6597             self.__class__._vt2setter = {}
6598     }
6599     %pythonAppend wxPropertyGrid() ""
6600 
6601     wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
6602                	    const wxPoint& pos = wxDefaultPosition,
6603                	    const wxSize& size = wxDefaultSize,
6604                	    long style = wxPG_DEFAULT_STYLE,
6605                	    const wxString& name = wxPyPropertyGridNameStr );
6606     %RenameCtor(PrePropertyGrid,  wxPropertyGrid());
6607 
6608 #else
6609 
6610     wxPropertyGrid();
6611 
6612     /** The default constructor. The styles to be used are styles valid for
6613         the wxWindow and wxScrolledWindow.
6614         @sa @link wndflags Additional Window Styles@endlink
6615     */
6616     wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
6617                	    const wxPoint& pos = wxDefaultPosition,
6618                	    const wxSize& size = wxDefaultSize,
6619                	    long style = wxPG_DEFAULT_STYLE,
6620                	    const wxString& name = wxPropertyGridNameStr );
6621 
6622     /** Destructor */
6623     ~wxPropertyGrid() override;
6624 #endif
6625 
6626     /** Adds given key combination to trigger given action.
6627         @param action
6628         Which action to trigger. See @link pgactions List of list of wxPropertyGrid actions@endlink.
6629     */
6630     void AddActionTrigger( int action, int keycode, int modifiers = 0 );
6631 
6632     /** This static function enables or disables automatic use of wxGetTranslation for
6633         following strings: wxEnumProperty list labels, wxFlagsProperty sub-property
6634         labels.
6635         Default is false.
6636     */
6637     static void AutoGetTranslation( bool enable );
6638 
6639     /** Returns true if all property grid data changes have been committed. Usually
6640         only returns false if value in active editor has been invalidated by a
6641         wxValidator.
6642     */
6643     bool CanClose()
6644     {
6645         return DoEditorValidate();
6646     }
6647 
6648     /** Clears action triggers for given action.
6649         @param action
6650         Which action to trigger. See @link pgactions List of list of wxPropertyGrid actions@endlink.
6651     */
6652     void ClearActionTriggers( int action );
6653 
6654     /** Returns true if all property grid data changes have been committed. Usually
6655         only returns false if value in active editor has been invalidated by a
6656         wxValidator.
6657     */
6658     bool EditorValidate()
6659     {
6660         return DoEditorValidate();
6661     }
6662 
6663     /**
6664         Centers the splitter.
6665 
6666         @param enableAutoResizing
6667             If @true, automatic column resizing is enabled (only applicapple
6668             if window style wxPG_SPLITTER_AUTO_CENTER is used).
6669     */
6670     void CenterSplitter( bool enableAutoResizing = false );
6671 
6672     /** Changes value of a property, as if from an editor. Use this instead of SetPropertyValue()
6673         if you need the value to run through validation process, and also send the property
6674         change event.
6675 
6676         @retval
6677         Returns true if value was succesfully changed.
6678     */
6679     bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
6680 
6681     /** Two step creation. Whenever the control is created without any parameters, use Create to actually
6682         create it. Don't access the control's public methods before this is called
6683         @sa @link wndflags Additional Window Styles@endlink
6684     */
6685     bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
6686                  const wxPoint& pos = wxDefaultPosition,
6687                  const wxSize& size = wxDefaultSize,
6688                  long style = wxPG_DEFAULT_STYLE,
6689                  const wxString& name = wxPropertyGridNameStr );
6690 
6691     /** Deletes all properties. Does not free memory allocated for arrays etc.
6692         This should *not* be called in wxPropertyGridManager.
6693     */
6694     void Clear() override;
6695 
6696     /** Resets modified status of a property and all sub-properties.
6697     */
6698     void ClearModifiedStatus( wxPGPropArg id )
6699     {
6700         wxPG_PROP_ARG_CALL_PROLOG()
6701         m_pState->ClearModifiedStatus(p);
6702     }
6703 
6704     /** Resets modified status of all properties.
6705     */
6706     void ClearModifiedStatus()
6707     {
6708         m_pState->ClearModifiedStatus(m_pState->m_properties);
6709         m_pState->m_anyModified = false;
6710     }
6711 
6712     /** Unfocuses or closes editor if one was open, but does not deselect property.
6713     */
6714     bool UnfocusEditor();
6715 
6716 #if wxPG_COMPATIBILITY_1_2_0
6717     /** Synonymous to Clear.
6718 
6719         @deprecated
6720         Since version 1.3.
6721     */
6722     wxDEPRECATED( void ClearTargetPage() );
6723 #endif
6724 
6725     /** Enables or disables (shows/hides) categories according to parameter enable. */
6726     bool EnableCategories( bool enable );
6727 
6728     /** Returns wxWindow that the properties are painted on, and which should be used
6729         as the parent for editor controls.
6730     */
6731     wxPanel* GetPanel() const
6732     {
6733         return m_canvas;
6734     }
6735 
6736     const wxPGCommonValue* GetCommonValue( unsigned int i ) const
6737     {
6738         return (wxPGCommonValue*) m_commonValues[i];
6739     }
6740 
6741     /** Returns number of common values.
6742     */
6743     unsigned int GetCommonValueCount() const
6744     {
6745         return (unsigned int) m_commonValues.size();
6746     }
6747 
6748     /** Returns label of given common value.
6749     */
6750     wxString GetCommonValueLabel( unsigned int i ) const
6751     {
6752         wxASSERT( GetCommonValue(i) );
6753         return GetCommonValue(i)->GetLabel();
6754     }
6755 
6756     /** Scrolls and/or expands items to ensure that the given item is visible.
6757         Returns true if something was actually done.
6758     */
6759     bool EnsureVisible( wxPGPropArg id );
6760 
6761     /** Reduces column sizes to minimum possible that contents are still visibly (naturally
6762         some margin space will be applied as well).
6763 
6764         @retval
6765         Minimum size for the grid to still display everything.
6766 
6767         @remarks
6768         Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
6769 
6770         This function only works properly if grid size prior to call was already
6771         fairly large.
6772 
6773         Note that you can also get calculated column widths by calling GetState->GetColumnWidth()
6774         immediately after this function returns.
6775     */
6776     wxSize FitColumns()
6777     {
6778         wxSize sz = m_pState->DoFitColumns();
6779         return sz;
6780     }
6781 
6782     wxFont& GetCaptionFont() { return m_captionFont; }
6783 
6784 #ifndef SWIG
6785     const wxFont& GetCaptionFont() const { return m_captionFont; }
6786 #endif
6787 
6788     /** Returns current category caption background colour. */
6789     wxColour GetCaptionBackgroundColour() const { return m_colCapBack; }
6790 
6791     /** Returns current category caption text colour. */
6792     wxColour GetCaptionForegroundColour() const { return m_colCapFore; }
6793 
6794     /** Returns current cell background colour. */
6795     wxColour GetCellBackgroundColour() const { return m_colPropBack; }
6796 
6797     /** Returns current cell text colour when disabled. */
6798     wxColour GetCellDisabledTextColour() const { return m_colDisPropFore; }
6799 
6800     /** Returns current cell text colour. */
6801     wxColour GetCellTextColour() const { return m_colPropFore; }
6802 
6803     /** Returns number of children of the root property.
6804     */
6805     unsigned int GetChildrenCount()
6806     {
6807         return GetChildrenCount( m_pState->m_properties );
6808     }
6809 
6810     /** Returns number of children for the property.
6811 
6812         NB: Cannot be in container methods class due to name hiding.
6813     */
6814     unsigned int GetChildrenCount( wxPGPropArg id ) const
6815     {
6816         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
6817         return p->GetChildCount();
6818     }
6819 
6820     unsigned int GetColumnCount() const
6821     {
6822         return (unsigned int) m_pState->m_colWidths.size();
6823     }
6824 
6825     /** Returns colour of empty space below properties. */
6826     wxColour GetEmptySpaceColour() const { return m_colEmptySpace; }
6827 
6828 #if wxPG_COMPATIBILITY_1_2_0
6829     /** Returns id of first visible item, whether it is a category or property.
6830         Note that visible item means category, property, or sub-property which
6831         user can see when control is scrolled properly. It does not only mean
6832         items that are actually painted on the screen.
6833 
6834         @deprecated
6835         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6836     */
6837     const wxPGProperty* GetFirstVisible() const
6838     {
6839         return wxPropertyGridInterface::GetFirst( wxPG_ITERATE_VISIBLE );
6840     }
6841 
6842     wxPGProperty* GetFirstVisible()
6843     {
6844         return wxPropertyGridInterface::GetFirst( wxPG_ITERATE_VISIBLE );
6845     }
6846 #endif
6847 
6848     /** Returns height of highest characters of used font. */
6849     int GetFontHeight() const { return m_fontHeight; }
6850 
6851     /** Returns pointer to itself. Dummy function that enables same kind
6852         of code to use wxPropertyGrid and wxPropertyGridManager.
6853     */
6854     wxPropertyGrid* GetGrid() { return this; }
6855 
6856 #if wxPG_COMPATIBILITY_1_2_0
6857     /** Returns id of first category (from target page).
6858 
6859         @deprecated
6860         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6861     */
6862     wxPGProperty* GetFirstCategory() const
6863     {
6864         return (wxPGProperty*) wxPropertyGridInterface::GetFirst( wxPG_ITERATE_CATEGORIES );
6865     }
6866 
6867     /** Returns id of first property that is not a category.
6868 
6869         @deprecated
6870         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6871     */
6872     wxPGProperty* GetFirstProperty()
6873     {
6874         return (wxPGProperty*) wxPropertyGridInterface::GetFirst( wxPG_ITERATE_DEFAULT );
6875     }
6876 #endif
6877 
6878     /** Returns size of the custom paint image in front of property.
6879         If no argument is given, returns preferred size.
6880     */
6881     wxSize GetImageSize( wxPGProperty* p = NULL, int item = -1 ) const;
6882 
6883     wxRect GetImageRect( wxPGProperty* p, int item ) const;
6884 
6885     /** Returns GetCustomPaintWidth for odcombo, GetImageSize(GetSelection()) otherwise.
6886     */
6887     //wxSize GetEditorImageSize() const;
6888 
6889     /** Returns property (or category) at given y coordinate (relative to control's
6890         top left).
6891     */
6892     wxPGProperty* GetItemAtY( int y ) const { return DoGetItemAtY(y); }
6893 
6894     /** Returns last item which could be iterated using given flags.
6895         @param flags
6896         @link iteratorflags List of iterator flags@endlink
6897     */
6898     wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT )
6899     {
6900         return m_pState->GetLastItem(flags);
6901     }
6902 
6903     const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
6904     {
6905         return m_pState->GetLastItem(flags);
6906     }
6907 
6908 #if wxPG_COMPATIBILITY_1_2_0
6909     /** Returns id of last item. Ignores categories and sub-properties.
6910 
6911         @deprecated
6912         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6913     */
6914     wxPGProperty* GetLastProperty()
6915     {
6916         if ( !m_pState->m_properties->GetCount() ) return NULL;
6917         wxPGProperty* p = GetLastItem(wxPG_ITERATE_DEFAULT);
6918         if ( p->IsCategory() )
6919             return GetPrevProperty(p);
6920         return p;
6921     }
6922 
6923     /** Returns id of last child of given property.
6924         @remarks
6925         Returns even sub-properties.
6926 
6927         @deprecated
6928         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6929     */
6930     wxPGProperty* GetLastChild( wxPGPropArg id )
6931     {
6932         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
6933 
6934         if ( !p->GetChildCount() ) return wxNullProperty;
6935 
6936         return p->Last();
6937     }
6938     /** Returns id of last visible item. Does <b>not</b> ignore categories sub-properties.
6939 
6940         @deprecated
6941         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6942     */
6943     wxPGProperty* GetLastVisible()
6944     {
6945         return GetLastItem(wxPG_ITERATE_VISIBLE);
6946     }
6947 #endif // wxPG_COMPATIBILITY_1_2_0
6948 
6949     /** Returns colour of lines between cells. */
6950     wxColour GetLineColour() const { return m_colLine; }
6951 
6952     /** Returns background colour of margin. */
6953     wxColour GetMarginColour() const { return m_colMargin; }
6954 
6955 #if wxPG_COMPATIBILITY_1_2_0
6956     /** Returns id of next property. This does <b>not</b> iterate to sub-properties
6957         or categories, unlike GetNextVisible.
6958         @deprecated
6959         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6960     */
6961     wxPGProperty* GetNextProperty( wxPGPropArg id )
6962     {
6963         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
6964         return m_pState->GetNextProperty(p);
6965     }
6966 
6967     /** Returns id of next category after a given property (which does not have to be category).
6968         @deprecated
6969         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6970     */
6971     wxPGProperty* GetNextCategory( wxPGPropArg id ) const
6972     {
6973         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
6974         return m_pState->GetNextCategory(p);
6975     }
6976 
6977     /** Returns id of next visible item.
6978         Note that visible item means category, property, or sub-property which
6979         user can see when control is scrolled properly. It does not only mean
6980         items that are actually painted on the screen.
6981         @deprecated
6982         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6983     */
6984     wxPGProperty* GetNextVisible( wxPGPropArg id ) const
6985     {
6986         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
6987         return wxPropertyGridIterator::OneStep(m_pState,wxPG_ITERATE_VISIBLE,p,1);
6988     }
6989 #endif // wxPG_COMPATIBILITY_1_2_0
6990 
6991 #if wxPG_COMPATIBILITY_1_2_0
6992     /** Returns id of previous property. Unlike GetPrevVisible, this skips categories
6993         and sub-properties.
6994         @deprecated
6995         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
6996     */
6997     wxPGProperty* GetPrevProperty( wxPGPropArg id )
6998     {
6999         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
7000         return m_pState->GetPrevProperty(p);
7001     }
7002     /** Returns id of previous item under the same parent.
7003         @deprecated
7004         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
7005     */
7006     wxPGProperty* GetPrevSiblingProperty( wxPGPropArg id )
7007     {
7008         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
7009         return m_pState->GetPrevSiblingProperty(p);
7010     }
7011     /** Returns id of previous visible property.
7012         @deprecated
7013         Since version 1.3. Use wxPropertyGridInterface::GetIterator() instead.
7014     */
7015     wxPGProperty* GetPrevVisible( wxPGPropArg id )
7016     {
7017         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
7018         return wxPropertyGridIterator::OneStep(m_pState,wxPG_ITERATE_VISIBLE,p,-1);
7019     }
7020 #endif // wxPG_COMPATIBILITY_1_2_0
7021 
7022     /** Returns cell background colour of a property. */
7023     wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const;
7024 
7025     /** Returns cell background colour of a property. */
7026     wxColour GetPropertyColour( wxPGPropArg id ) const
7027     {
7028         return GetPropertyBackgroundColour( id );
7029     }
7030 
7031     /** Returns cell background colour of a property. */
7032     wxColour GetPropertyTextColour( wxPGPropArg id ) const;
7033 
7034     /** Returns id of property with given label (case-sensitive). If there is no
7035         property with such label, returned property id is invalid ( i.e. it will return
7036         false with IsOk method). If there are multiple properties with identical name,
7037         most recent added is returned.
7038     */
7039     wxPGProperty* GetPropertyByLabel( const wxString& name ) const
7040     {
7041         return m_pState->GetPropertyByLabel(name);
7042     }
7043 
7044     /** Returns "root property". It does not have name, etc. and it is not
7045         visible. It is only useful for accessing its children.
7046     */
7047     wxPGProperty* GetRoot() const { return m_pState->m_properties; }
7048 
7049     /** Returns height of a single grid row (in pixels). */
7050     int GetRowHeight() const { return m_lineHeight; }
7051 
7052 /* C::B begin */
7053     /** Returns the width of the margin. */
7054     int GetMarginWidth() const { return m_marginWidth; }
7055 /* C::B end */
7056 
7057     wxPGProperty* GetSelectedProperty () const { return GetSelection(); }
7058 
7059     /** Returns current selection background colour. */
7060     wxColour GetSelectionBackgroundColour() const { return m_colSelBack; }
7061 
7062     /** Returns current selection text colour. */
7063     wxColour GetSelectionForegroundColour() const { return m_colSelFore; }
7064 
7065     /** Returns current splitter x position. */
7066     int GetSplitterPosition() const { return m_pState->DoGetSplitterPosition(0); }
7067 
7068     /** Returns wxTextCtrl active in currently selected property, if any. Takes
7069         into account wxOwnerDrawnComboBox.
7070     */
7071     wxTextCtrl* GetEditorTextCtrl() const;
7072 
7073     /** Returns index of common value that will truly change value to unspecified.
7074     */
7075     int GetUnspecifiedCommonValue() const { return m_cvUnspecified; }
7076 
7077     wxPGValidationInfo& GetValidationInfo()
7078     {
7079         return m_validationInfo;
7080     }
7081 
7082     /** Returns current vertical spacing. */
7083     int GetVerticalSpacing() const { return (int)m_vspacing; }
7084 
7085     /** Returns true if a property is selected. */
7086     bool HasSelection() const { return (m_pState->m_selection.size() > 0); }
7087 
7088     bool HasVirtualWidth() const { return (m_iFlags & wxPG_FL_HAS_VIRTUAL_WIDTH)?true:false; }
7089 
7090     /** Returns information about arbitrary position in the grid.
7091     */
7092     wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
7093 
7094     /** Returns true if any property has been modified by the user. */
7095     bool IsAnyModified() const { return (m_pState->m_anyModified>0); }
7096 
7097     /** Returns true if updating is frozen (ie. Freeze() called but not yet Thaw() ). */
7098     bool IsFrozen() const override { return (m_frozen>0)?true:false; }
7099 
7100     /**
7101         It is recommended that you call this function any time your code causes
7102         wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
7103         handler should be able to detect most changes, but it is not perfect.
7104 
7105         @param newTLP
7106             New top-level parent that is about to be set. Old one should
7107             still exist as the current one.
7108 
7109         @remarks This function is automatically called from wxPropertyGrid::
7110                  Reparent() and wxPropertyGridManager::Reparent().
7111     */
7112     void OnTLPChanging( wxWindow* newTLP );
7113 
7114     void RefreshProperty( wxPGProperty* p ) override;
7115 
7116     /**
7117         If selected property's editor is active, then update it's value.
7118     */
7119     void RefreshEditor();
7120 
7121     /** Set number of columns (2+).
7122     */
7123     void SetColumnCount( int colCount )
7124     {
7125         m_pState->SetColumnCount(colCount);
7126         Refresh();
7127     }
7128 
7129     /** Moves splitter as left as possible, while still allowing all
7130         labels to be shown in full.
7131         @param subProps
7132         If false, will still allow sub-properties (ie. properties which
7133         parent is not root or category) to be cropped.
7134     */
7135     void SetSplitterLeft( bool subProps = false )
7136     {
7137         m_pState->SetSplitterLeft(subProps);
7138     }
7139 
7140 #ifndef SWIG
7141     /** Registers a new editor class.
7142         @retval
7143         Pointer to the editor class instance that should be used.
7144     */
7145     static wxPGEditor* RegisterEditorClass( wxPGEditor* editor, const wxString& name,
7146                                             bool noDefCheck = false );
7147 #endif
7148 
7149     /** Resets all colours to the original system values.
7150     */
7151     void ResetColours();
7152 
7153     /**
7154         Resets column sizes and splitter positions, based on proportions.
7155 
7156         @param enableAutoResizing
7157             If @true, automatic column resizing is enabled (only applicapple
7158             if window style wxPG_SPLITTER_AUTO_CENTER is used).
7159 
7160         @see wxPropertyGridInterface::SetColumnProportion()
7161     */
7162     void ResetColumnSizes( bool enableAutoResizing = false );
7163 
7164     /** Changes keyboard shortcut to push the editor button.
7165         @remarks
7166         You can set default with keycode 0. Good value for the platform is guessed,
7167         but don't expect it to be very accurate.
7168     */
7169     void SetButtonShortcut( int keycode, bool ctrlDown = false, bool altDown = false );
7170 
7171     /** Sets text colour of a category caption (but not it's children).
7172     */
7173     void SetCaptionTextColour( wxPGPropArg id, const wxColour& col );
7174 
7175     /** Sets the current category - Append will add non-categories under this one.
7176     */
7177     void SetCurrentCategory( wxPGPropArg id )
7178     {
7179         wxPG_PROP_ARG_CALL_PROLOG()
7180         wxPropertyCategory* pc = (wxPropertyCategory*)p;
7181         wxASSERT( !pc || pc->IsCategory() );
7182         m_pState->m_currentCategory = pc;
7183     }
7184 
7185     /** Sets property attribute for all applicapple properties.
7186         Be sure to use this method after all properties have been
7187         added to the grid.
7188     */
7189     void SetPropertyAttributeAll( const wxString& attrName, wxVariant value );
7190 
7191     /**
7192         Sets background colour of property and all its children. Colours of
7193         captions are not affected. Background brush cache is optimized for often
7194         set colours to be set last.
7195 
7196         @param flags
7197             Default is wxPG_RECURSE which causes colour to be set recursively.
7198             Omit this flag to only set colour for the property in question
7199             and not any of its children.
7200     */
7201     void SetPropertyBackgroundColour( wxPGPropArg id, const wxColour& col,
7202                                       int flags = wxPG_RECURSE );
7203 
7204 #if wxPG_COMPATIBILITY_1_2_0
7205     /** Sets background colour of property and all its children. Colours of
7206         captions are not affected. Background brush cache is optimized for often
7207         set colours to be set last.
7208 
7209         @deprecated
7210         Since version 1.3. Use SetPropertyBackgroundColour instead.
7211     */
7212     wxDEPRECATED( void SetPropertyColour( wxPGPropArg id, const wxColour& col ) );
7213 #endif
7214 
7215     /**
7216         Sets text colour of property and all its children.
7217 
7218         @param flags
7219             Default is wxPG_RECURSE which causes colour to be set recursively.
7220             Omit this flag to only set colour for the property in question
7221             and not any of its children.
7222     */
7223     void SetPropertyTextColour( wxPGPropArg id, const wxColour& col,
7224                                 int flags = wxPG_RECURSE );
7225 
7226     /** Sets background and text colour of property and all its children to the default. */
7227     void SetPropertyColourToDefault( wxPGPropArg id );
7228 
7229     /** Sets category caption background colour. */
7230     void SetCaptionBackgroundColour(const wxColour& col);
7231 
7232     /** Sets category caption text colour. */
7233     void SetCaptionForegroundColour(const wxColour& col);
7234 
7235     /** Sets default cell background colour - applies to property cells.
7236         Note that appearance of editor widgets may not be affected.
7237     */
7238     void SetCellBackgroundColour(const wxColour& col);
7239 
7240     /** Sets cell text colour for disabled properties.
7241     */
7242     void SetCellDisabledTextColour(const wxColour& col);
7243 
7244     /** Sets default cell text colour - applies to property name and value text.
7245         Note that appearance of editor widgets may not be affected.
7246     */
7247     void SetCellTextColour(const wxColour& col);
7248 
7249     /** Sets colour of empty space below properties. */
7250     void SetEmptySpaceColour(const wxColour& col);
7251 
7252     /** Sets colour of lines between cells. */
7253     void SetLineColour(const wxColour& col);
7254 
7255     /** Sets background colour of margin. */
7256     void SetMarginColour(const wxColour& col);
7257 
7258     /** Sets selection background colour - applies to selected property name background. */
7259     void SetSelectionBackground(const wxColour& col);
7260 
7261     /** Sets selection foreground colour - applies to selected property name text. */
7262     void SetSelectionForeground(const wxColour& col);
7263 
7264     /** Sets x coordinate of the splitter.
7265         @remarks
7266         Splitter position cannot exceed grid size, and therefore setting it during
7267         form creation may fail as initial grid size is often smaller than desired
7268         splitter position, especially when sizers are being used.
7269     */
7270     void SetSplitterPosition( int newxpos, bool refresh = true )
7271     {
7272         DoSetSplitterPosition_(newxpos,refresh,0);
7273         m_iFlags |= wxPG_FL_SPLITTER_PRE_SET;
7274     }
7275 
7276     /**
7277         Sets the property sorting function.
7278 
7279         @param sortFunction
7280             The sorting function to be used. It should return a value greater
7281             than 0 if position of p1 is after p2. So, for instance, when
7282             comparing property names, you can use following implementation:
7283 
7284             @code
7285                 int MyPropertySortFunction(wxPropertyGrid* propGrid,
7286                                            wxPGProperty* p1,
7287                                            wxPGProperty* p2)
7288                 {
7289                     return p1->GetBaseName().compare( p2->GetBaseName() );
7290                 }
7291             @endcode
7292 
7293         @remarks
7294             Default property sort function sorts properties by their labels.
7295     */
7296     void SetSortFunction( wxPGSortCallback sortFunction )
7297     {
7298         m_sortFunction = sortFunction;
7299     }
7300 
7301     /**
7302         Returns the property sort function (NULL is default).
7303     */
7304     wxPGSortCallback GetSortFunction() const
7305     {
7306         return m_sortFunction;
7307     }
7308 
7309     /**
7310         Sets appearance of value cells representing an unspecified property
7311         value. Default appearance is blank.
7312 
7313         @see wxPGProperty::SetValueToUnspecified(),
7314              wxPGProperty::IsValueUnspecified(),
7315     */
7316     void SetUnspecifiedValueAppearance( const wxPGCell& cell )
7317     {
7318         m_unspecifiedAppearance.Assign(cell);
7319     }
7320 
7321     /**
7322         Returns current appearance of unspecified value cells.
7323 
7324         @remarks If you set the unspecified value to have any
7325                  textual representation, then that will override
7326                  "InlineHelp" attribute.
7327 
7328         @see SetUnspecifiedValueAppearance()
7329     */
7330     const wxPGCell& GetUnspecifiedValueAppearance() const
7331     {
7332         return m_unspecifiedAppearance;
7333     }
7334 
7335     /**
7336         Returns (visual) text representation of the unspecified
7337         property value.
7338     */
7339     wxString GetUnspecifiedValueText( int argFlags = 0 ) const;
7340 
7341     /** Set index of common value that will truly change value to unspecified.
7342         Using -1 will set none to have such effect.
7343         Default is 0.
7344     */
7345     void SetUnspecifiedCommonValue( int index ) { m_cvUnspecified = index; }
7346 
7347     /** Set virtual width for this particular page. Width -1 indicates that the
7348         virtual width should be disabled. */
7349     void SetVirtualWidth( int width );
7350 
7351     /** Selects a property. Editor widget is automatically created, but
7352         not focused unless focus is true. This will generate wxEVT_PG_SELECT event.
7353         @param id
7354         Id to property to select.
7355         @retval
7356         True if selection finished succesfully. Usually only fails if current
7357         value in editor is not valid.
7358 
7359         @remarks This clears any previous selection.
7360 
7361         @see wxPropertyGridInterface::ClearSelection()
7362     */
7363     bool SelectProperty( wxPGPropArg id, bool focus = false )
7364     {
7365         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
7366         return DoSelectProperty(p, focus ? wxPG_SEL_FOCUS : 0);
7367     }
7368 
7369     /**
7370         Set entire new selection from given list of properties.
7371     */
7372     void SetSelection( const wxArrayPGProperty& newSelection )
7373     {
7374         DoSetSelection( newSelection, wxPG_SEL_DONT_SEND_EVENT );
7375     }
7376 
7377     /**
7378         Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
7379         extra style is not used, then this has same effect as
7380         calling SelectProperty().
7381 
7382         @remarks Multiple selection is not supported for categories. This
7383                  means that if you have properties selected, you cannot
7384                  add category to selection, and also if you have category
7385                  selected, you cannot add other properties to selection.
7386                  This member function will fail silently in these cases,
7387                  even returning true.
7388     */
7389     bool AddToSelection( wxPGPropArg id )
7390     {
7391         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
7392         return DoAddToSelection(p, wxPG_SEL_DONT_SEND_EVENT);
7393     }
7394 
7395     /**
7396         Removes given property from selection. If property is not selected,
7397         an assertion failure will occur.
7398     */
7399     bool RemoveFromSelection( wxPGPropArg id )
7400     {
7401         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
7402         return DoRemoveFromSelection(p, wxPG_SEL_DONT_SEND_EVENT);
7403     }
7404 
7405     /**
7406         Makes given column editable by user.
7407 
7408         @param editable
7409             Using @false here will disable column from being editable.
7410     */
7411     void MakeColumnEditable( unsigned int column, bool editable = true );
7412 
7413     /**
7414         Creates label editor wxTextCtrl for given column, for property
7415         that is currently selected. When multiple selection is
7416         enabled, this applies to whatever property GetSelection()
7417         returns.
7418 
7419         @param colIndex
7420             Which column's label to edit. Note that you should not
7421             use value 1, which is reserved for property value
7422             column.
7423     */
7424     void BeginLabelEdit( unsigned int column = 0 )
7425     {
7426         DoBeginLabelEdit(column, wxPG_SEL_DONT_SEND_EVENT);
7427     }
7428 
7429     /**
7430         Destroys label editor wxTextCtrl, if any.
7431 
7432         @param commit
7433             Use @true (default) to store edited label text in
7434             property cell data.
7435     */
7436     void EndLabelEdit( bool commit = true )
7437     {
7438         DoEndLabelEdit(commit, wxPG_SEL_DONT_SEND_EVENT);
7439     }
7440 
7441     /**
7442         Returns currently active label editor, NULL if none.
7443     */
7444     wxTextCtrl* GetLabelEditor() const;
7445 
7446     /** Mostly useful for page switching.
7447     */
7448 #ifndef SWIG
7449     void SwitchState( wxPropertyGridState* pNewState );
7450 #endif
7451 
7452     /** Sets name of a property.
7453         @param id
7454         Id of a property.
7455         @param newname
7456         New name.
7457     */
7458     void SetPropertyName( wxPGPropArg id, const wxString& newname )
7459     {
7460         wxPG_PROP_ARG_CALL_PROLOG()
7461         DoSetPropertyName( p, newname );
7462     }
7463 
7464     /** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
7465         height. Value of 2 should be default on most platforms.
7466         @remarks
7467         On wxMSW, wxComboBox, when used as property editor widget, will spill
7468         out with anything less than 3.
7469     */
7470     void SetVerticalSpacing( int vspacing )
7471     {
7472         m_vspacing = (unsigned char)vspacing;
7473         CalculateFontAndBitmapStuff( vspacing );
7474         if ( !m_pState->m_itemsAdded ) Refresh();
7475     }
7476 
7477     /** Shows an brief error message that is related to a property. */
7478     void ShowPropertyError( wxPGPropArg id, const wxString& msg )
7479     {
7480         wxPG_PROP_ARG_CALL_PROLOG()
7481         DoShowPropertyError(p, msg);
7482     }
7483 
7484     /** Sorts all items at all levels (except sub-properties). */
7485     void Sort();
7486 
7487     /** Sorts children of a category.
7488     */
7489     void Sort( wxPGPropArg id );
7490 
7491     /** Overridden function.
7492         @sa @link wndflags Additional Window Styles@endlink
7493     */
7494     void SetWindowStyleFlag( long style ) override;
7495 
7496     /** Call when editor widget's contents is modified. For example, this is called
7497         when changes text in wxTextCtrl (used in wxStringProperty and wxIntProperty).
7498         @remarks
7499         This should only be called by properties.
7500         @sa @link wxPGProperty::OnEvent @endlink
7501     */
7502     void EditorsValueWasModified() { m_iFlags |= wxPG_FL_VALUE_MODIFIED; }
7503 
7504     /** Reverse of EditorsValueWasModified(). */
7505     void EditorsValueWasNotModified()
7506     {
7507         m_iFlags &= ~(wxPG_FL_VALUE_MODIFIED);
7508     }
7509 
7510     /** Returns true if editor's value was marked modified. */
7511     bool IsEditorsValueModified() const { return  ( m_iFlags & wxPG_FL_VALUE_MODIFIED ) ? true : false; }
7512 
7513     /** Shortcut for creating dialog-caller button. Used, for example, by wxFontProperty.
7514         @remarks
7515         This should only be called by properties.
7516     */
7517     wxWindow* GenerateEditorButton( const wxPoint& pos, const wxSize& sz );
7518 
7519     /** Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
7520         fits as one). Call after control has been created (but before
7521         shown).
7522     */
7523     void FixPosForTextCtrl( wxWindow* ctrl,
7524                             unsigned int forColumn = 1,
7525                             const wxPoint& offset = wxPoint(0, 0) );
7526 
7527     /** Shortcut for creating text editor widget.
7528         @param pos
7529         Same as pos given for CreateEditor.
7530         @param sz
7531         Same as sz given for CreateEditor.
7532         @param value
7533         Initial text for wxTextCtrl.
7534         @param secondary
7535         If right-side control, such as button, also created, then create it first
7536         and pass it as this parameter.
7537         @param extraStyle
7538         Extra style flags to pass for wxTextCtrl.
7539         @remarks
7540         Note that this should generally be called only by new classes derived
7541         from wxPGProperty.
7542     */
7543     wxWindow* GenerateEditorTextCtrl( const wxPoint& pos,
7544                                       const wxSize& sz,
7545                                       const wxString& value,
7546                                       wxWindow* secondary,
7547                                       int extraStyle = 0,
7548                                       int maxLen = 0,
7549                                       unsigned int forColumn = 1 );
7550 
7551     /* Generates both textctrl and button.
7552     */
7553     wxWindow* GenerateEditorTextCtrlAndButton( const wxPoint& pos,
7554         const wxSize& sz, wxWindow** psecondary, int limited_editing,
7555         wxPGProperty* property );
7556 
7557     /** Generates position for a widget editor dialog box.
7558         @param p
7559         Property for which dialog is positioned.
7560         @param sz
7561         Known or over-approximated size of the dialog.
7562         @retval
7563         Position for dialog.
7564     */
7565     wxPoint GetGoodEditorDialogPosition( wxPGProperty* p,
7566                                          const wxSize& sz );
7567 
7568     // Converts escape sequences in src_str to newlines,
7569     // tabs, etc. and copies result to dst_str.
7570     static wxString& ExpandEscapeSequences( wxString& dst_str, wxString& src_str );
7571 
7572     // Converts newlines, tabs, etc. in src_str to escape
7573     // sequences, and copies result to dst_str.
7574     static wxString& CreateEscapeSequences( wxString& dst_str, wxString& src_str );
7575 
7576     /** Returns rectangle that fully contains properties between and including p1 and p2.
7577     */
7578     wxRect GetPropertyRect( const wxPGProperty* p1, const wxPGProperty* p2 ) const;
7579 
7580     /** Returns pointer to current active primary editor control (NULL if none).
7581 
7582         If editor uses clipper window, pointer is returned to the actual editor, not the clipper.
7583     */
7584     wxWindow* GetEditorControl() const;
7585 
7586     /**
7587         Returns @true if editor control has focus
7588     */
7589     bool IsEditorFocused() const;
7590 
7591     /** Adjusts given position if topCtrlWnd is child of clipper window.
7592     */
7593     bool AdjustPosForClipperWindow( wxWindow* topCtrlWnd, int* x, int* y );
7594 
7595     wxWindow* GetPrimaryEditor() const
7596     {
7597         return GetEditorControl();
7598     }
7599 
7600     /** Returns pointer to current active secondary editor control (NULL if none).
7601     */
7602     wxWindow* GetEditorControlSecondary() const
7603     {
7604         return m_wndEditor2;
7605     }
7606 
7607 #ifdef __WXPYTHON__
7608     // Dummy method to put wxRect type info into the wrapper
7609     wxRect DummywxRectTypeInit() const { return wxRect(1,2,3,4); }
7610 #endif
7611 
7612     /** Forces updating the value of property from the editor control.
7613         Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using ProcessEvent,
7614         meaning your event handlers will be called immediately.
7615 
7616         @retval
7617         Returns true if anything was changed.
7618     */
7619     virtual bool CommitChangesFromEditor( wxUint32 flags = 0 );
7620 
7621     bool HasInternalFlag( long flag ) const { return (m_iFlags & flag) ? true : false; }
7622     long GetInternalFlags() const { return m_iFlags; }
7623     void SetInternalFlag( long flag ) { m_iFlags |= flag; }
7624     void ClearInternalFlag( long flag ) { m_iFlags &= ~(flag); }
7625 
7626     /**
7627         Override in derived class to display error messages in custom manner
7628         (these message usually only result from validation failure).
7629 
7630         @remarks If you implement this, then you also need to implement
7631                  DoHidePropertyError() - possibly to do nothing, if error
7632                  does not need hiding (e.g. it was logged or shown in a
7633                  message box).
7634 
7635         @see DoHidePropertyError()
7636     */
7637     virtual void DoShowPropertyError( wxPGProperty* property,
7638                                       const wxString& msg );
7639 
7640     /**
7641         Override in derived class to hide an error displayed by
7642         DoShowPropertyError().
7643 
7644         @see DoShowPropertyError()
7645     */
7646     virtual void DoHidePropertyError( wxPGProperty* property );
7647 
7648 #if wxUSE_STATUSBAR
7649     /**
7650         Return wxStatusBar that is used by this wxPropertyGrid. You can
7651         reimplement this member function in derived class to override
7652         the default behavior of using the top-level wxFrame's status
7653         bar, if any.
7654     */
7655     virtual wxStatusBar* GetStatusBar();
7656 #endif
7657 
7658 #ifndef SWIG
7659 
7660     /** Generates contents for string dst based on the convetents of wxArrayString
7661         src. Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim)
7662         and so on. Set flags to 1 inorder to convert backslashes to double-back-
7663         slashes and "(preDelims)"'s to "(preDelims)".
7664     */
7665     static void ArrayStringToString( wxString& dst, const wxArrayString& src,
7666                                      wxChar preDelim, wxChar postDelim,
7667                                      int flags );
7668 
7669     /** Pass this function to Connect calls in propertyclass::CreateEditor.
7670     */
7671     void OnCustomEditorEvent( wxCommandEvent &event );
7672 
7673     bool HandleCustomEditorEvent( wxCommandEvent &event );
7674 
7675     void IncFrozen() { m_frozen++; }
7676     void DecFrozen() { m_frozen--; }
7677 
7678     void OnComboItemPaint( wxPGCustomComboControl* pCb,int item,wxDC* pDc,
7679                            wxRect& rect,int flags );
7680 
7681     // Used by simple check box for keyboard navigation
7682     void SendNavigationKeyEvent( int dir );
7683 
7684     /** Standardized double-to-string conversion.
7685     */
7686     static void DoubleToString( wxString& target,
7687                                 double value,
7688                                 int precision,
7689                                 bool removeZeroes,
7690                                 wxString* precTemplate );
7691 
7692     /** Call this from wxPGProperty::OnEvent() to cause property value to be changed
7693         after the function returns (with true as return value). ValueChangeInEvent()
7694         must be used if you wish the application to be able to use wxEVT_PG_CHANGING
7695         to potentially veto the given value.
7696     */
7697     void ValueChangeInEvent( wxVariant variant )
7698     {
7699         m_changeInEventValue = variant;
7700         m_iFlags |= wxPG_FL_VALUE_CHANGE_IN_EVENT;
7701     }
7702 
7703     /**
7704         You can use this member function, for instance, to detect in
7705         wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
7706         already called in wxPGEditor::OnEvent(). It really only detects
7707         if was value was changed using wxPGProperty::SetValueInEvent(), which
7708         is usually used when a 'picker' dialog is displayed. If value was
7709         written by "normal means" in wxPGProperty::StringToValue() or
7710         IntToValue(), then this function will return false (on the other hand,
7711         wxPGProperty::OnEvent() is not even called in those cases).
7712     */
7713     bool WasValueChangedInEvent() const
7714     {
7715         return (m_iFlags & wxPG_FL_VALUE_CHANGE_IN_EVENT) ? true : false;
7716     }
7717 
7718     /** Returns true if given event is from first of an array of buttons
7719         (as can be in case when wxPGMultiButton is used).
7720     */
7721     bool IsMainButtonEvent( const wxEvent& event )
7722     {
7723         return (event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) && (m_wndSecId == event.GetId());
7724     }
7725 
7726     /** Pending value is expected to be passed in PerformValidation().
7727     */
7728     virtual bool DoPropertyChanged( wxPGProperty* p, unsigned int selFlags = 0 );
7729 
7730     /** Runs all validation functionality (includes sending wxEVT_PG_CHANGING). Returns true
7731         if all tests passed.
7732     */
7733     virtual bool PerformValidation( wxPGProperty* p, wxVariant& pendingValue );
7734 
7735     /** Called when validation for given property fails.
7736         @param invalidValue
7737         Value which failed in validation.
7738         @retval
7739         Return true if user is allowed to change to another property even if current
7740         has invalid value.
7741         @remarks
7742         To add your own validation failure behavior, override wxPropertyGrid::DoOnValidationFailure().
7743     */
7744     bool OnValidationFailure( wxPGProperty* property, wxVariant& invalidValue );
7745 
7746     /** Called to indicate property and editor has valid value now.
7747     */
7748     void OnValidationFailureReset( wxPGProperty* property )
7749     {
7750         if ( property && property->HasFlag(wxPG_PROP_INVALID_VALUE) )
7751         {
7752             DoOnValidationFailureReset(property);
7753             property->ClearFlag(wxPG_PROP_INVALID_VALUE);
7754         }
7755         m_validationInfo.m_failureMessage.clear();
7756     }
7757 
7758     /** Override to customize property validation failure behavior.
7759         @param invalidValue
7760         Value which failed in validation.
7761         @retval
7762         Return true if user is allowed to change to another property even if current
7763         has invalid value.
7764     */
7765     virtual bool DoOnValidationFailure( wxPGProperty* property, wxVariant& invalidValue );
7766 
7767     /** Override to customize resetting of property validation failure status.
7768         @remarks
7769         Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
7770     */
7771     virtual void DoOnValidationFailureReset( wxPGProperty* property );
7772 
7773     int GetSpacingY() const { return m_spacingy; }
7774 
7775     /** Must be called in wxPGEditor::CreateControls() if primary editor window is wxTextCtrl,
7776         just before textctrl is created.
7777         @param text
7778         Initial text value of created wxTextCtrl.
7779     */
7780     void SetupTextCtrlValue( const wxString text ) { m_prevTcValue = text; }
7781 
7782     void DrawItem( wxPGProperty* p )
7783     {
7784         DrawItems(p,p);
7785     }
7786 
7787     virtual void DrawItemAndChildren( wxPGProperty* p );
7788 
7789     /** Draws item, children, and consequtive parents as long as category is not met. */
7790     void DrawItemAndValueRelated( wxPGProperty* p );
7791 
7792 protected:
7793 
7794     /** wxPropertyGridState used by the grid is created here. If grid is used
7795         in wxPropertyGridManager, there is no point overriding this - instead,
7796         set custom wxPropertyGridPage classes.
7797     */
7798     virtual wxPropertyGridState* CreateState() const;
7799 
7800 #ifndef DOXYGEN
7801 public:
7802 
7803     // Control font changer helper.
7804     void SetCurControlBoldFont();
7805 
7806     //
7807     // Public methods for semi-public use
7808     //
7809     bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
7810 
7811     // Overridden functions.
7812     bool Destroy() override;
7813     wxSize DoGetBestSize() const override;
7814     void Refresh( bool eraseBackground = true,
7815                           const wxRect *rect = (const wxRect *) NULL ) override;
7816     bool SetFont( const wxFont& font ) override;
7817 #if wxPG_SUPPORT_TOOLTIPS
7818     void SetToolTip( const wxString& tipString );
7819 #endif
7820     void Freeze() override;
7821     void SetExtraStyle( long exStyle ) override;
7822     void Thaw() override;
7823     bool Reparent( wxWindowBase *newParent ) override;
7824 
7825 protected:
7826 
7827 #ifndef wxPG_ICON_WIDTH
7828 	wxBitmap            *m_expandbmp, *m_collbmp;
7829 #endif
7830 
7831     wxCursor            *m_cursorSizeWE;
7832 
7833     /** wxWindow pointers to editor control(s). */
7834     wxWindow            *m_wndEditor;
7835     wxWindow            *m_wndEditor2;
7836 
7837     /** wxPGCanvas instance. */
7838     wxPanel             *m_canvas;
7839 
7840 #if wxPG_DOUBLE_BUFFER
7841     wxBitmap            *m_doubleBuffer;
7842 #endif
7843 
7844     wxArrayPtrVoid      *m_windowsToDelete;
7845 
7846     /** Local time ms when control was created. */
7847     wxLongLong          m_timeCreated;
7848 
7849     /** wxPGProperty::OnEvent can change value by setting this. */
7850     wxVariant           m_changeInEventValue;
7851 
7852     /** Id of m_wndEditor2, or its first child, if any. */
7853     int                 m_wndSecId;
7854 
7855 	/** Extra Y spacing between the items. */
7856 	int                 m_spacingy;
7857 
7858     /** Control client area width; updated on resize. */
7859     int                 m_width;
7860 
7861     /** Control client area height; updated on resize. */
7862     int                 m_height;
7863 
7864     /** Current non-client width (needed when auto-centering). */
7865     int                 m_ncWidth;
7866 
7867     /** Non-client width (auto-centering helper). */
7868     //int                 m_fWidth;
7869 
7870     /** Previously recorded scroll start position. */
7871     int                 m_prevVY;
7872 
7873 	/** The gutter spacing in front and back of the image. This determines the amount of spacing in front
7874 	    of each item */
7875 	int                 m_gutterWidth;
7876 
7877     /** Includes separator line. */
7878     int                 m_lineHeight;
7879 
7880     /** Gutter*2 + image width. */
7881     int                 m_marginWidth;
7882 
7883     int                 m_buttonSpacingY; // y spacing for expand/collapse button.
7884 
7885     /** Extra margin for expanded sub-group items. */
7886     int                 m_subgroup_extramargin;
7887 
7888 	/** The image width of the [+] icon. This is also calculated in the gutter */
7889 	int                 m_iconWidth;
7890 
7891 #ifndef wxPG_ICON_WIDTH
7892 
7893 	/** The image height of the [+] icon. This is calculated as minimal size and to align */
7894 	int                 m_iconHeight;
7895 #endif
7896 
7897     /** Current cursor id. */
7898     int                 m_curcursor;
7899 
7900 	/** This captionFont is made equal to the font of the wxScrolledWindow. As extra the bold face
7901 	    is set on it when this is wanted by the user (see flags) */
7902 	wxFont              m_captionFont;
7903 
7904 	int                 m_fontHeight;  // Height of the font.
7905 
7906     int                 m_pushButKeyCode;  // Base keycode for triggering push button.
7907 
7908     /** m_splitterx when drag began. */
7909     int                 m_startingSplitterX;
7910 
7911     /** Index to splitter currently being dragged (0=one after the first column). */
7912     int                 m_draggedSplitter;
7913 
7914     /** Changed property, calculated in PerformValidation(). */
7915     wxPGProperty*       m_chgInfo_changedProperty;
7916 
7917     /** Lowest property for which editing happened, but which does not have aggregate parent. */
7918     wxPGProperty*       m_chgInfo_baseChangedProperty;
7919 
7920     /** Changed property value, calculated in PerformValidation(). */
7921     wxVariant           m_chgInfo_pendingValue;
7922 
7923     /** Passed to SetValue. */
7924     wxVariant           m_chgInfo_valueList;
7925 
7926     /** Validation information. */
7927     wxPGValidationInfo  m_validationInfo;
7928 
7929     /** Actions and keys that trigger them. */
7930     wxPGHashMapI2I      m_actionTriggers;
7931 
7932     /** Appearance of currently active editor. */
7933     wxPGCell            m_editorAppearance;
7934 
7935     /** Appearance of a unspecified value cell. */
7936     wxPGCell            m_unspecifiedAppearance;
7937 
7938     /** List of properties to be deleted/removed in idle event handler. */
7939     wxArrayPGProperty   m_deletedProperties;
7940     wxArrayPGProperty   m_removedProperties;
7941 
7942     //
7943     // Temporary values
7944     //
7945 
7946     /** Bits are used to indicate which colours are customized. */
7947     unsigned short      m_coloursCustomized;
7948 
7949     /** x - m_splitterx. */
7950     signed char                 m_dragOffset;
7951 
7952     /** 0 = not dragging, 1 = drag just started, 2 = drag in progress */
7953     unsigned char       m_dragStatus;
7954 
7955     /** 0 = margin, 1 = label, 2 = value. */
7956     unsigned char       m_mouseSide;
7957 
7958     /** True when editor control is focused. */
7959     unsigned char       m_editorFocused;
7960 
7961     /** 1 if m_latsCaption is also the bottommost caption. */
7962     //unsigned char       m_lastCaptionBottomnest;
7963 
7964     /** Set to 1 when graphics frozen. */
7965     unsigned char       m_frozen;
7966 
7967     unsigned char       m_vspacing;
7968 
7969     unsigned char       m_pushButKeyCodeNeedsAlt;  // Does triggering push button need Alt down?
7970 
7971     unsigned char       m_pushButKeyCodeNeedsCtrl;  // Does triggering push button need Ctrl down?
7972 
7973     unsigned char       m_keyComboConsumed;  // Used to track when Alt/Ctrl+Key was consumed.
7974 
7975     /** 1 if in DoPropertyChanged() */
7976     unsigned char       m_inDoPropertyChanged;
7977 
7978     /** 1 if in CommitChangesFromEditor() */
7979     unsigned char       m_inCommitChangesFromEditor;
7980 
7981     /** 1 if in DoSelectProperty() */
7982     bool                m_inDoSelectProperty;
7983 
7984     /** @true if in OnValidationFailure() */
7985     bool                m_inOnValidationFailure;
7986 
7987     wxPGVFBFlags        m_permanentValidationFailureBehavior;  // Set by app
7988 
7989     /** Internal flags - see wxPG_FL_XXX constants. */
7990     wxUint32            m_iFlags;
7991 
7992     /** When drawing next time, clear this many item slots at the end. */
7993     int                 m_clearThisMany;
7994 
7995     // Mouse is hovering over this column (index)
7996     unsigned int        m_colHover;
7997 
7998     wxPGProperty*       m_propHover;  // pointer to property that has mouse hovering
7999 
8000     // Active label editor
8001     wxWindow*           m_labelEditor;
8002 
8003     // For which property the label editor is active
8004     wxPGProperty*       m_labelEditorProperty;
8005 
8006     wxWindow*           m_eventObject;  // EventObject for wxPropertyGridEvents
8007 
8008     wxWindow*           m_curFocused;  // What (global) window is currently focused
8009                                        // (needed to resolve event handling mess).
8010 
8011     // Last closed top-level parent
8012     wxWindow*           m_tlpClosed;
8013 
8014     // Local time ms when tlp was closed.
8015     wxLongLong          m_tlpClosedTime;
8016 
8017     wxWindow*           m_tlp;  // Last known top-level parent
8018 
8019     // Event currently being sent - NULL if no event being sent right now
8020     wxPropertyGridEvent*    m_processedEvent;
8021 
8022     wxPGSortCallback    m_sortFunction;  // Sort function
8023 
8024     int                 m_propHoverY;   // y coordinate of property that mouse hovering
8025     unsigned int        m_selColumn;  // Which column's editor is selected (usually 1)?
8026 
8027     int                 m_ctrlXAdjust; // x relative to splitter (needed for resize).
8028 
8029     wxColour            m_colLine;     // lines between cells
8030     wxColour            m_colPropFore; // property labels and values are written in this colour
8031     wxColour            m_colDisPropFore;  // or with this colour when disabled
8032     wxColour            m_colPropBack; // background for m_colPropFore
8033     wxColour            m_colCapFore;  // text color for captions
8034     wxColour            m_colCapBack;  // background color for captions
8035     wxColour            m_colSelFore;  // foreground for selected property
8036     wxColour            m_colSelBack;  // background for selected property (actually use background color when control out-of-focus)
8037     wxColour            m_colMargin;   // background colour for margin
8038     wxColour            m_colEmptySpace;  // background colour for empty space below the grid
8039 
8040     wxArrayPtrVoid      m_visPropArray;  // temp property array used in DoDrawItems
8041 
8042     // NB: These *cannot* be moved to globals.
8043     wxArrayPtrVoid      m_arrBgBrushes; // Array of background colour brushes.
8044     wxArrayPtrVoid      m_arrFgCols; // Array of foreground colours.
8045 
8046     wxArrayPtrVoid      m_commonValues;  // labels when properties use common values
8047     int                 m_cvUnspecified;  // Which cv selection really sets value to unspecified?
8048 
8049     wxString            m_prevTcValue;  // Used to skip excess text editor events
8050 
8051 protected:
8052 
8053     // Sets some members to defaults (called constructors).
8054 	void Init1();
8055 
8056     // Initializes some members (called by Create and complex constructor).
8057 	void Init2();
8058 
8059     // main event receivers
8060     void OnMouseMove( wxMouseEvent &event );
8061     void OnMouseMoveBottom( wxMouseEvent &event );
8062     void OnMouseClick( wxMouseEvent &event );
8063     void OnMouseRightClick( wxMouseEvent &event );
8064     void OnMouseDoubleClick( wxMouseEvent &event );
8065     void OnMouseUp( wxMouseEvent &event );
8066     void OnKey( wxKeyEvent &event );
8067     void OnKeyUp( wxKeyEvent &event );
8068     void OnNavigationKey( wxNavigationKeyEvent& event );
8069     void OnResize( wxSizeEvent &event );
8070     void OnPaint( wxPaintEvent& event );
8071 
8072     // event handlers
8073     bool HandleMouseMove( int x, unsigned int y, wxMouseEvent &event );
8074     bool HandleMouseClick( int x, unsigned int y, wxMouseEvent &event );
8075     bool HandleMouseRightClick( int x, unsigned int y, wxMouseEvent &event );
8076     bool HandleMouseDoubleClick( int x, unsigned int y, wxMouseEvent &event );
8077     bool HandleMouseUp( int x, unsigned int y, wxMouseEvent &event );
8078     void HandleKeyEvent( wxKeyEvent &event );
8079     bool HandleChildKey( wxKeyEvent& event ); // Handle TAB and ESCAPE in control
8080 
8081     void OnMouseEntry( wxMouseEvent &event );
8082 
8083     void OnIdle( wxIdleEvent &event );
8084     void OnFocusEvent( wxFocusEvent &event );
8085     void OnChildFocusEvent( wxChildFocusEvent& event );
8086 
8087     bool OnMouseCommon( wxMouseEvent &event, int* px, int *py );
8088     bool OnMouseChildCommon( wxMouseEvent &event, int* px, int *py );
8089 
8090     // sub-control event handlers
8091     void OnMouseClickChild( wxMouseEvent &event );
8092     void OnMouseRightClickChild( wxMouseEvent &event );
8093     void OnMouseMoveChild( wxMouseEvent &event );
8094     void OnMouseUpChild( wxMouseEvent &event );
8095     void OnChildKeyDown( wxKeyEvent &event );
8096     void OnChildKeyUp( wxKeyEvent &event );
8097 
8098     void OnCaptureChange( wxMouseCaptureChangedEvent &event );
8099 
8100     void OnScrollEvent( wxScrollWinEvent &event );
8101 
8102     void OnSysColourChanged( wxSysColourChangedEvent &event );
8103 
8104     void OnTLPClose( wxCloseEvent& event );
8105 
8106 protected:
8107 
8108     bool AddToSelectionFromInputEvent( wxPGProperty* prop,
8109                                        unsigned int colIndex,
8110                                        wxMouseEvent* event = NULL,
8111                                        int selFlags = 0 );
8112 
8113 	/** Adjust the centering of the bitmap icons (collapse / expand) when the caption font changes. They need to
8114 	    be centered in the middle of the font, so a bit of deltaY adjustment is needed.
8115         On entry, m_captionFont must be set to window font. It will be modified properly.
8116     */
8117 	void CalculateFontAndBitmapStuff( int vspacing );
8118 
8119     wxRect GetEditorWidgetRect( wxPGProperty* p, int column ) const;
8120 
8121     void CorrectEditorWidgetSizeX();
8122 
8123     /** Called in RecalculateVirtualSize() to reposition control
8124         on virtual height changes.
8125     */
8126     void CorrectEditorWidgetPosY();
8127 
8128 #ifdef __WXDEBUG__
8129     void _log_items();
8130     void OnScreenNote( const wxChar* format, ... );
8131 #endif
8132 
8133     int DoDrawItems( wxDC& dc,
8134                      const wxPGProperty* first_item,
8135                      const wxPGProperty* last_item,
8136                      const wxRect* clip_rect,
8137                      bool isBuffered ) const;
8138 
8139     /** Draws an expand/collapse (ie. +/-) button.
8140     */
8141     virtual void DrawExpanderButton( wxDC& dc, const wxRect& rect,
8142                                      wxPGProperty* property ) const;
8143 
8144     /** Draws items from topitemy to bottomitemy */
8145     void DrawItems( wxDC& dc, unsigned int topitemy, unsigned int bottomitemy,
8146                     const wxRect* clip_rect = (const wxRect*) NULL );
8147 
8148     void DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 );
8149 
8150 #if wxPG_COMPATIBILITY_1_2_0
8151     /** Returns property reference for given property id. */
8152     wxPGProperty& GetPropertyById( wxPGPropArg id )
8153     {
8154         wxPG_PROP_ARG_CALL_PROLOG_RETVAL(*((wxPGProperty*)NULL))
8155         return *p;
8156     }
8157 #endif
8158 
8159     // Translate wxKeyEvent to wxPG_ACTION_XXX
8160     int KeyEventToActions(wxKeyEvent &event, int* pSecond) const;
8161 
8162     int KeyEventToAction(wxKeyEvent &event) const
8163     {
8164         return KeyEventToActions(event, NULL);
8165     }
8166 
8167     void ImprovedClientToScreen( int* px, int* py );
8168 
8169     // Called by focus event handlers. newFocused is the window that becomes focused.
8170     void HandleFocusChange( wxWindow* newFocused );
8171 
8172     /** Reloads all non-customized colours from system settings. */
8173     void RegainColours();
8174 
8175     bool DoEditorValidate();
8176 
8177     // Similar to DoSelectProperty() but also works on columns
8178     // other than 1. Does not active editor if column is not
8179     // editable.
8180     bool DoSelectAndEdit( wxPGProperty* prop,
8181                           unsigned int colIndex,
8182                           unsigned int selFlags );
8183 
8184     void DoSetSelection( const wxArrayPGProperty& newSelection,
8185                          int selFlags = 0 );
8186 
8187     bool DoAddToSelection( wxPGProperty* prop,
8188                            int selFlags = 0 );
8189 
8190     bool DoRemoveFromSelection( wxPGProperty* prop,
8191                                 int selFlags = 0 );
8192 
8193     void DoBeginLabelEdit( unsigned int colIndex, int selFlags = 0 );
8194     void DoEndLabelEdit( bool commit, int selFlags = 0 );
8195     void OnLabelEditorEnterPress( wxCommandEvent& event );
8196     void OnLabelEditorKeyPress( wxKeyEvent& event );
8197 
8198     wxPGProperty* DoGetItemAtY( int y ) const;
8199 
8200     void DoSetSplitterPosition_( int newxpos, bool refresh = true, int splitterIndex = 0, bool allPages = false );
8201 
8202     void DestroyEditorWnd( wxWindow* wnd );
8203     void FreeEditors();
8204 
8205     virtual bool DoExpand( wxPGProperty* p, bool sendEvent /* C::B patch: = false*/);
8206 
8207     virtual bool DoCollapse( wxPGProperty* p, bool sendEvent /* C::B patch:  = false*/);
8208 
8209     // Returns nearest paint visible property (such that will be painted unless
8210     // window is scrolled or resized). If given property is paint visible, then
8211     // it itself will be returned.
8212     wxPGProperty* GetNearestPaintVisible( wxPGProperty* p ) const;
8213 
8214     static void RegisterDefaultEditors();
8215 
8216     // Sets m_bgColIndex to this property and all its children.
8217     void SetBackgroundColourIndex( wxPGProperty* p, int index,
8218                                    int flags = wxPG_RECURSE );
8219 
8220     // Sets m_fgColIndex to this property and all its children.
8221     void SetTextColourIndex( wxPGProperty* p, int index, int flags );
8222 
8223     int CacheColour( const wxColour& colour );
8224 
8225     void DoSetPropertyName( wxPGProperty* p, const wxString& newname );
8226 
8227     // Setups event handling for child control
8228     void SetupEventHandling( wxWindow* wnd, int id );
8229 
8230     void CustomSetCursor( int type, bool override = false );
8231 
8232     bool ProcessEvent(wxEvent& event) override;
8233 
8234     /** Repositions scrollbar and underlying panel according to changed virtual size.
8235     */
8236     void RecalculateVirtualSize( int forceXPos = -1 );
8237 
8238     void SetEditorAppearance( const wxPGCell& cell );
8239 
8240     void ResetEditorAppearance()
8241     {
8242         wxPGCell cell;
8243         SetEditorAppearance(cell);
8244     }
8245 
8246     void PrepareAfterItemsAdded();
8247 
8248     // Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
8249     bool SendEvent( int eventType, wxPGProperty* p,
8250                     wxVariant* pValue = NULL,
8251                     unsigned int selFlags = wxPG_SEL_NOVALIDATE,
8252                     unsigned int column = 1 );
8253 
8254     void SetFocusOnCanvas()
8255     {
8256         m_canvas->SetFocusIgnoringChildren();
8257         m_editorFocused = 0;
8258     }
8259 
8260     bool DoHideProperty( wxPGProperty* p, bool hide, int flags );
8261 
8262 private:
8263 
8264     bool ButtonTriggerKeyTest( wxKeyEvent &event );
8265 
8266 #endif // DOXYGEN_SHOULD_SKIP_THIS
8267 
8268 private:
8269     DECLARE_EVENT_TABLE()
8270 #endif // #ifndef SWIG
8271 };
8272 
8273 #undef wxPG_USE_STATE
8274 
8275 // -----------------------------------------------------------------------
8276 //
8277 // Bunch of inlines that need to resolved after all classes have been defined.
8278 //
8279 
8280 #ifndef SWIG
8281 inline bool wxPropertyGridState::IsDisplayed() const
8282 {
8283     return ( this == m_pPropGrid->GetState() );
8284 }
8285 
8286 inline unsigned int wxPropertyGridState::GetActualVirtualHeight() const
8287 {
8288     return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
8289 }
8290 #endif
8291 
8292 inline int wxPGProperty::GetDisplayedCommonValueCount() const
8293 {
8294     if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE) )
8295     {
8296         wxPropertyGrid* pg = GetGrid();
8297         if ( pg )
8298             return (int) pg->GetCommonValueCount();
8299     }
8300     return 0;
8301 }
8302 
8303 inline void wxPGProperty::SetEditor( const wxString& editorName )
8304 {
8305     m_customEditor = wxPropertyGridInterface::GetEditorByName(editorName);
8306 }
8307 
8308 inline bool wxPGProperty::SetMaxLength( int maxLen )
8309 {
8310     return GetGrid()->SetPropertyMaxLength(this,maxLen);
8311 }
8312 
8313 // -----------------------------------------------------------------------
8314 
8315 
8316 #ifndef SWIG
8317 
8318 #define wxPG_BASE_EVT_PRE_ID     1775
8319 
8320 BEGIN_DECLARE_EVENT_TYPES()
8321     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_SELECTED,           wxPG_BASE_EVT_PRE_ID)
8322     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_CHANGING,           wxPG_BASE_EVT_PRE_ID+1)
8323     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_CHANGED,            wxPG_BASE_EVT_PRE_ID+2)
8324     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_HIGHLIGHTED,        wxPG_BASE_EVT_PRE_ID+3)
8325     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_RIGHT_CLICK,        wxPG_BASE_EVT_PRE_ID+4)
8326     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_PAGE_CHANGED,       wxPG_BASE_EVT_PRE_ID+5)
8327     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_ITEM_COLLAPSED,     wxPG_BASE_EVT_PRE_ID+6)
8328     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_ITEM_EXPANDED,      wxPG_BASE_EVT_PRE_ID+7)
8329     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_DOUBLE_CLICK,       wxPG_BASE_EVT_PRE_ID+8)
8330     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_LABEL_EDIT_BEGIN,   wxPG_BASE_EVT_PRE_ID+9)
8331     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_LABEL_EDIT_ENDING,  wxPG_BASE_EVT_PRE_ID+10)
8332 END_DECLARE_EVENT_TYPES()
8333 #else
8334     enum {
8335         wxEVT_PG_SELECTED = wxPG_BASE_EVT_PRE_ID,
8336         wxEVT_PG_CHANGING,
8337         wxEVT_PG_CHANGED,
8338         wxEVT_PG_HIGHLIGHTED,
8339         wxEVT_PG_RIGHT_CLICK,
8340         wxEVT_PG_PAGE_CHANGED,
8341         wxEVT_PG_ITEM_COLLAPSED,
8342         wxEVT_PG_ITEM_EXPANDED,
8343         wxEVT_PG_DOUBLE_CLICK,
8344         wxEVT_PG_LABEL_EDIT_BEGIN,
8345         wxEVT_PG_LABEL_EDIT_ENDING
8346     };
8347 #endif
8348 
8349 
8350 #define wxPG_BASE_EVT_TYPE       wxEVT_PG_SELECTED
8351 #define wxPG_MAX_EVT_TYPE        (wxPG_BASE_EVT_TYPE+30)
8352 
8353 
8354 #ifndef SWIG
8355 typedef void (wxEvtHandler::*wxPropertyGridEventFunction)(wxPropertyGridEvent&);
8356 
8357 #define EVT_PG_SELECTED(id, fn)              DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8358 #define EVT_PG_CHANGING(id, fn)              DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8359 #define EVT_PG_CHANGED(id, fn)               DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8360 #define EVT_PG_HIGHLIGHTED(id, fn)           DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8361 #define EVT_PG_RIGHT_CLICK(id, fn)           DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8362 #define EVT_PG_DOUBLE_CLICK(id, fn)          DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8363 #define EVT_PG_PAGE_CHANGED(id, fn)          DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8364 #define EVT_PG_ITEM_COLLAPSED(id, fn)        DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8365 #define EVT_PG_ITEM_EXPANDED(id, fn)         DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8366 #define EVT_PG_LABEL_EDIT_BEGIN(id, fn)      DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_BEGIN, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8367 #define EVT_PG_LABEL_EDIT_ENDING(id, fn)     DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_ENDING, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
8368 
8369 #define wxPropertyGridEventHandler(A) ((wxObjectEventFunction)(wxEventFunction)(wxPropertyGridEventFunction)&A)
8370 
8371 #endif
8372 
8373 
8374 /** @class wxPropertyGridEvent
8375 	@ingroup classes
8376     @brief A propertygrid event holds information about events associated with
8377     wxPropertyGrid objects.
8378 
8379     <h4>Derived from</h4>
8380 
8381     wxNotifyEvent\n
8382     wxCommandEvent\n
8383     wxEvent\n
8384     wxObject\n
8385 
8386     <h4>Include files</h4>
8387 
8388     <wx/propertygrid/propertygrid.h>
8389 */
8390 class WXDLLIMPEXP_PG wxPropertyGridEvent : public wxCommandEvent
8391 {
8392 public:
8393 
8394     /** Constructor. */
8395     wxPropertyGridEvent(wxEventType commandType=0, int id=0);
8396 #ifndef SWIG
8397     /** Copy constructor. */
8398     wxPropertyGridEvent(const wxPropertyGridEvent& event);
8399 #endif
8400     /** Destructor. */
8401     ~wxPropertyGridEvent() override;
8402 
8403     /** Copyer. */
8404     wxEvent* Clone() const override;
8405 
8406     /** Enables property. */
8407     void EnableProperty( bool enable = true )
8408     {
8409         m_pg->EnableProperty(m_property,enable);
8410     }
8411 
8412     /** Disables property. */
8413     void DisableProperty()
8414     {
8415         m_pg->EnableProperty(m_property,false);
8416     }
8417 
8418     /**
8419         Returns the column index associated with this event.
8420     */
8421     unsigned int GetColumn() const
8422     {
8423         return m_column;
8424     }
8425 
8426     wxPGProperty* GetMainParent() const
8427     {
8428         wxASSERT(m_property);
8429         return m_property->GetMainParent();
8430     }
8431 
8432     /** Returns id of associated property. */
8433     wxPGProperty* GetProperty() const
8434     {
8435         return m_property;
8436     }
8437 
8438 #if wxPG_COMPATIBILITY_1_2_0
8439   #ifndef SWIG
8440     /** Returns pointer to associated property.
8441         @deprecated
8442         Since version 1.3. Use GetProperty() instead.
8443     */
8444     wxPGProperty* GetPropertyPtr() const
8445     {
8446         return m_property;
8447     }
8448   #endif
8449 #endif
8450 
8451     /** Returns label of associated property. */
8452     const wxString& GetPropertyLabel() const
8453     {
8454         wxASSERT( m_property );
8455         return m_property->GetLabel();
8456     }
8457 
8458     /** Returns global name of associated property. */
8459     wxString GetPropertyName() const
8460     {
8461         wxASSERT( m_property );
8462         return m_property->GetName();
8463     }
8464 
8465     /** Returns client data of relevant property. */
8466     wxPGProperty::ClientDataType GetPropertyClientData() const
8467     {
8468         wxASSERT( m_property );
8469         return m_property->GetClientData();
8470     }
8471 
8472 #ifndef SWIG
8473     /** Returns value of relevant property. */
8474     wxVariant GetPropertyValue() const
8475     {
8476         wxASSERT( m_property );
8477         return m_property->GetValue();
8478     }
8479 
8480     wxString GetPropertyValueAsString() const
8481     {
8482         return m_pg->GetPropertyValueAsString( m_property );
8483     }
8484     long GetPropertyValueAsLong() const
8485     {
8486         return m_pg->GetPropertyValueAsLong( m_property );
8487     }
8488     int GetPropertyValueAsInt() const
8489     {
8490         return (int)GetPropertyValueAsLong();
8491     }
8492     long GetPropertyValueAsBool() const
8493     {
8494         return m_pg->GetPropertyValueAsBool( m_property );
8495     }
8496     double GetPropertyValueAsDouble() const
8497     {
8498         return m_pg->GetPropertyValueAsDouble( m_property );
8499     }
8500     const wxObject* GetPropertyValueAsWxObjectPtr() const
8501     {
8502         return m_pg->GetPropertyValueAsWxObjectPtr( m_property );
8503     }
8504     void* GetPropertyValueAsVoidPtr() const
8505     {
8506         return m_pg->GetPropertyValueAsVoidPtr( m_property );
8507     }
8508     wxArrayString GetPropertyValueAsArrayString() const
8509     {
8510         return m_pg->GetPropertyValueAsArrayString( m_property );
8511     }
8512     wxPoint GetPropertyValueAsPoint() const
8513     {
8514         return m_pg->GetPropertyValueAsPoint( m_property );
8515     }
8516     wxSize GetPropertyValueAsSize() const
8517     {
8518         return m_pg->GetPropertyValueAsSize( m_property );
8519     }
8520     wxArrayInt GetPropertyValueAsArrayInt() const
8521     {
8522         return m_pg->GetPropertyValueAsArrayInt( m_property );
8523     }
8524 
8525 #else
8526     %pythoncode {
8527         def GetPropertyValue(self):
8528             return self.GetProperty().GetValue()
8529     }
8530 #endif
8531 
8532     wxPGValidationInfo& GetValidationInfo()
8533     {
8534         wxASSERT(m_validationInfo);
8535         return *m_validationInfo;
8536     }
8537 
8538     /** Returns true if event has associated property. */
8539     bool HasProperty() const { return ( m_property != (wxPGProperty*) NULL ); }
8540 
8541     bool IsPropertyEnabled() const
8542     {
8543         return m_pg->IsPropertyEnabled(m_property);
8544     }
8545 
8546     /** Returns true if you can veto the action that the event is signaling.
8547     */
8548     bool CanVeto() const { return m_canVeto; }
8549 
8550     /** Call this from your event handler to veto action that the event is signaling.
8551         You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns true.
8552         @remarks
8553         Currently only wxEVT_PG_CHANGING supports vetoing.
8554     */
8555     void Veto( bool veto = true ) { m_wasVetoed = veto; }
8556 
8557     /** Returns value that is about to be set for wxEVT_PG_CHANGING.
8558     */
8559     const wxVariant& GetValue() const
8560     {
8561         wxASSERT_MSG( m_validationInfo,
8562                       wxT("Only call GetValue from a handler of event type that supports it") );
8563         return *m_validationInfo->m_pValue;
8564     }
8565 
8566     /** Set override validation failure behavior. Only effective if Veto was also called,
8567         and only allowed if event type is wxEVT_PG_CHANGING.
8568     */
8569     void SetValidationFailureBehavior( int flags )
8570     {
8571         wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
8572         m_validationInfo->m_failureBehavior = (wxPGVFBFlags) flags;
8573     }
8574 
8575     /** Sets custom failure message for this time only. Only applies if
8576         wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
8577     */
8578     void SetValidationFailureMessage( const wxString& message )
8579     {
8580         wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
8581         m_validationInfo->m_failureMessage = message;
8582     }
8583 
8584 #ifndef SWIG
8585     wxPGVFBFlags GetValidationFailureBehavior() const
8586     {
8587         wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
8588         return m_validationInfo->m_failureBehavior;
8589     }
8590 
8591     void SetCanVeto( bool canVeto ) { m_canVeto = canVeto; }
8592     bool WasVetoed() const { return m_wasVetoed; }
8593 
8594     /** Changes the associated property. */
8595     void SetProperty( wxPGProperty* p ) { m_property = p; }
8596 
8597     void SetPropertyGrid( wxPropertyGrid* pg ) { m_pg = pg; }
8598 
8599     void SetupValidationInfo()
8600     {
8601         wxASSERT(m_pg);
8602         wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
8603         m_validationInfo = &m_pg->GetValidationInfo();
8604     }
8605 
8606     void SetColumn( unsigned int column )
8607     {
8608         m_column = column;
8609     }
8610 
8611 private:
8612     void Init();
8613     DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent)
8614 
8615     wxPGProperty*       m_property;
8616     wxPropertyGrid*     m_pg;
8617     wxPGValidationInfo* m_validationInfo;
8618 
8619     unsigned int        m_column;
8620 
8621     bool                m_canVeto;
8622     bool                m_wasVetoed;
8623 
8624 #endif
8625 };
8626 
8627 
8628 // -----------------------------------------------------------------------
8629 
8630 /** @class wxPropertyGridPopulator
8631     @ingroup classes
8632     @brief Allows populating wxPropertyGrid from arbitrary text source.
8633 */
8634 class WXDLLIMPEXP_PG wxPropertyGridPopulator
8635 {
8636 public:
8637     /** Default constructor.
8638     */
8639     wxPropertyGridPopulator();
8640 
8641     /** Destructor. */
8642     virtual ~wxPropertyGridPopulator();
8643 
8644     void SetState( wxPropertyGridState* state );
8645 
8646     void SetGrid( wxPropertyGrid* pg );
8647 
8648     /** Appends a new property under bottommost parent.
8649         @param propClass
8650         Property class as string.
8651     */
8652     wxPGProperty* Add( const wxString& propClass,
8653                        const wxString& propLabel,
8654                        const wxString& propName,
8655                        const wxString* propValue,
8656                        wxPGChoices* pChoices = NULL );
8657 
8658     /** Pushes property to the back of parent array (ie. it becomes bottommost parent),
8659         and starts scanning/adding children for it. When finished, parent array is
8660         returned to the original state.
8661     */
8662     void AddChildren( wxPGProperty* property );
8663 
8664     /** Adds attribute to the bottommost property.
8665         @param type
8666         Allowed values: "string", (same as string), "int", "bool". Empty string
8667           mean autodetect.
8668     */
8669     bool AddAttribute( const wxString& name,
8670                        const wxString& type,
8671                        const wxString& value );
8672 
8673     /** Called once in AddChildren.
8674     */
8675     virtual void DoScanForChildren() = 0;
8676 
8677     /** Returns id of parent property for which children can currently be added. */
8678     wxPGProperty* GetCurParent() const
8679     {
8680         return (wxPGProperty*) m_propHierarchy[m_propHierarchy.size()-1];
8681     }
8682 
8683     wxPropertyGridState* GetState() { return m_state; }
8684     const wxPropertyGridState* GetState() const { return m_state; }
8685 
8686     /** Like wxString::ToLong, except allows N% in addition of N.
8687     */
8688     static bool ToLongPCT( const wxString& s, long* pval, long max );
8689 
8690     /** Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
8691         wxPGChoices. Registers parsed result using idString (if not empty). Also,
8692         if choices with given id already registered, then don't parse but return
8693         those choices instead.
8694     */
8695     wxPGChoices ParseChoices( const wxString& choicesString,
8696                               const wxString& idString );
8697 
8698     /** Implement in derived class to do custom process when an error occurs.
8699         Default implementation uses wxLogError.
8700     */
8701     virtual void ProcessError( const wxString& msg );
8702 
8703 protected:
8704 
8705     /** Used property grid. */
8706     wxPropertyGrid*         m_pg;
8707 
8708     /** Used property grid state. */
8709     wxPropertyGridState*    m_state;
8710 
8711     /** Tree-hierarchy of added properties (that can have children). */
8712     wxArrayPGProperty       m_propHierarchy;
8713 
8714     /** Hashmap for string-id to wxPGChoicesData mapping. */
8715     wxPGHashMapS2P          m_dictIdChoices;
8716 };
8717 
8718 // -----------------------------------------------------------------------
8719 
8720 //
8721 // Undefine macros that are not needed outside propertygrid sources
8722 //
8723 #ifndef __wxPG_SOURCE_FILE__
8724     #undef wxPG_FL_DESC_REFRESH_REQUIRED
8725     #undef wxPG_FL_SCROLLBAR_DETECTED
8726     #undef wxPG_FL_CREATEDSTATE
8727     #undef wxPG_FL_NOSTATUSBARHELP
8728     #undef wxPG_FL_SCROLLED
8729     #undef wxPG_FL_FOCUS_INSIDE_CHILD
8730     #undef wxPG_FL_FOCUS_INSIDE
8731     #undef wxPG_FL_MOUSE_INSIDE_CHILD
8732     #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
8733     #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
8734     #undef wxPG_FL_VALUE_MODIFIED
8735     #undef wxPG_FL_MOUSE_INSIDE
8736     #undef wxPG_FL_FOCUSED
8737     #undef wxPG_FL_MOUSE_CAPTURED
8738     #undef wxPG_FL_INITIALIZED
8739     #undef wxPG_FL_ACTIVATION_BY_CLICK
8740     #undef wxPG_FL_DONT_CENTER_SPLITTER
8741     #undef wxPG_SUPPORT_TOOLTIPS
8742     #undef wxPG_DOUBLE_BUFFER
8743     #undef wxPG_ICON_WIDTH
8744     #undef wxPG_USE_RENDERER_NATIVE
8745 // Following are needed by the manager headers
8746 //    #undef wxPGPropNameStr
8747 #endif
8748 
8749 // Doxygen special
8750 #ifdef DOXYGEN
8751     #include "editor.h"
8752     #include "manager.h"
8753 #endif
8754 
8755 // -----------------------------------------------------------------------
8756 
8757 #endif // __WX_PROPGRID_PROPGRID_H__
8758 
8759