00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef __WX_PROPGRID_PROPGRID_H__
00013 #define __WX_PROPGRID_PROPGRID_H__
00014
00015 #include <wx/dynarray.h>
00016 #include <wx/hashmap.h>
00017 #include <wx/variant.h>
00018 #include <wx/longlong.h>
00019 #include <wx/dcclient.h>
00020 #include <wx/scrolwin.h>
00021 #include <wx/tooltip.h>
00022 #include <wx/datetime.h>
00023
00024
00025 #if defined(SWIG) || defined(SWIG_TYPE_TABLE)
00026 #if !defined(__WXPYTHON__) && !defined(__NOTWXPYTHON__)
00027 #define __WXPYTHON__
00028 #endif
00029 #endif
00030
00031
00032
00033 #if !defined(DOXYGEN) && !defined(_WX_WINDOW_H_BASE_) && !defined(SWIG)
00034 #define DOXYGEN
00035 #endif
00036
00037 #if defined(SWIG) || defined(DOXYGEN)
00038 #define wxDEPRECATED(A) A
00039 #endif
00040
00041
00042
00043 #ifdef DOXYGEN
00044 #include "pg_dox_mainpage.h"
00045 #include "propdev.h"
00046 #endif
00047
00048
00049
00050
00051 #ifdef DOXYGEN
00052 #define wxUSE_VALIDATORS 1
00053 #define wxUSE_DATETIME 1
00054 #define wxUSE_TOOLTIPS 1
00055 #define wxUSE_SPINBTN 1
00056 #define wxUSE_DATEPICKCTRL 1
00057 #define wxPG_COMPATIBILITY_1_2_0 1
00058 #endif
00059
00060
00061
00062
00063
00064 #ifndef wxUSE_VALIDATORS
00065 #error "wxUSE_VALIDATORS not defined"
00066 #endif
00067
00068 #ifndef wxUSE_DATETIME
00069 #error "wxUSE_DATETIME not defined"
00070 #endif
00071
00072 #ifndef wxUSE_DATEPICKCTRL
00073 #error "wxUSE_DATEPICKCTRL not defined"
00074 #endif
00075
00076
00077 #if defined(__WXPYTHON__)
00078 #include <Python.h>
00079 #endif
00080
00081
00082
00083
00084
00085 #define wxPROPGRID_MAJOR 1
00086 #define wxPROPGRID_MINOR 4
00087 #define wxPROPGRID_RELEASE 7
00088
00089
00090
00091
00092 #define wxCHECK_PROPGRID_VERSION(major,minor,release) \
00093 (wxPROPGRID_MAJOR > (major) || \
00094 (wxPROPGRID_MAJOR == (major) && wxPROPGRID_MINOR > (minor)) || \
00095 (wxPROPGRID_MAJOR == (major) && wxPROPGRID_MINOR == (minor) && wxPROPGRID_RELEASE >= (release)))
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 #ifndef SWIG
00107
00108 #if defined(__WXMSW__)
00109
00110
00111 #define wxPG_XBEFORETEXT 4 // space between vertical line and value text
00112 #define wxPG_XBEFOREWIDGET 1 // space between vertical line and value editor control
00113
00114 #define wxPG_TEXTCTRLXADJUST 3 // x position adjustment for wxTextCtrl (and like)
00115
00116 #define wxPG_ICON_WIDTH 9 // comment to use bitmap buttons
00117 #define wxPG_USE_RENDERER_NATIVE 0 // 1 if wxRendererNative should be employed
00118
00119 #define wxPG_DOUBLE_BUFFER 1 // 1 to use double-buffer that guarantees flicker-free painting
00120
00121 #define wxPG_SUPPORT_TOOLTIPS 1 // Enable tooltips
00122
00123 #elif defined(__WXGTK__)
00124
00125
00126 #define wxPG_XBEFORETEXT 5 // space between vertical line and value text
00127 #define wxPG_XBEFOREWIDGET 1 // space between vertical line and value editor control
00128
00129 #define wxPG_TEXTCTRLXADJUST 3 // x position adjustment for wxTextCtrl (and like)
00130
00131 #define wxPG_ICON_WIDTH 9 // comment to use bitmap buttons
00132 #define wxPG_USE_RENDERER_NATIVE 0 // 1 if wxRendererNative should be employed
00133
00134 #define wxPG_DOUBLE_BUFFER 1 // 1 to use double-buffer that guarantees flicker-free painting
00135
00136 #define wxPG_SUPPORT_TOOLTIPS 1 // Enable tooltips
00137
00138 #elif defined(__WXMAC__)
00139
00140
00141 #define wxPG_XBEFORETEXT 4 // space between vertical line and value text
00142 #define wxPG_XBEFOREWIDGET 1 // space between vertical line and value editor widget
00143
00144 #define wxPG_TEXTCTRLXADJUST 3 // x position adjustment for wxTextCtrl (and like)
00145
00146 #define wxPG_ICON_WIDTH 11 // comment to use bitmap buttons
00147 #define wxPG_USE_RENDERER_NATIVE 1 // 1 if wxRendererNative should be employed
00148
00149 #define wxPG_DOUBLE_BUFFER 0 // 1 to use double-buffer that guarantees flicker-free painting
00150
00151 #define wxPG_SUPPORT_TOOLTIPS 1 // Enable tooltips
00152
00153 #else
00154
00155
00156
00157 #define wxPG_XBEFORETEXT 5 // space between vertical line and value text
00158 #define wxPG_XBEFOREWIDGET 1 // space between vertical line and value editor widget
00159
00160 #define wxPG_TEXTCTRLXADJUST 3 // x position adjustment for wxTextCtrl (and like)
00161
00162 #define wxPG_ICON_WIDTH 9 // comment to use bitmap buttons
00163 #define wxPG_USE_RENDERER_NATIVE 0 // 1 if wxRendererNative should be employed
00164
00165 #define wxPG_DOUBLE_BUFFER 0 // 1 to use double-buffer that guarantees flicker-free painting
00166
00167 #define wxPG_SUPPORT_TOOLTIPS 0 // Enable tooltips
00168
00169 #endif // #if defined(__WXMSW__)
00170
00171
00172 #define wxPG_CONTROL_MARGIN 0 // space between splitter and control
00173
00174 #define wxCC_CUSTOM_IMAGE_MARGIN1 4 // before image
00175 #define wxCC_CUSTOM_IMAGE_MARGIN2 5 // after image
00176
00177
00178 #define wxPG_STD_CUST_IMAGE_HEIGHT(LINEHEIGHT) (LINEHEIGHT-3)
00179
00180
00181 #if defined(__WXWINCE__)
00182 #define wxPG_SMALL_SCREEN 1
00183 #undef wxPG_DOUBLE_BUFFER
00184 #define wxPG_DOUBLE_BUFFER 0
00185 #else
00186 #define wxPG_SMALL_SCREEN 0
00187 #endif
00188
00189 #endif // #ifndef SWIG
00190
00191
00192
00193
00194
00195
00196 #if !wxUSE_TOOLTIPS
00197 #undef wxPG_SUPPORT_TOOLTIPS
00198 #define wxPG_SUPPORT_TOOLTIPS 0
00199 #endif
00200
00201
00202 #ifndef wxPG_INCLUDE_ADVPROPS
00203 #define wxPG_INCLUDE_ADVPROPS 1
00204 #endif
00205
00206
00207 #ifndef wxPG_INCLUDE_MANAGER
00208 #define wxPG_INCLUDE_MANAGER 1
00209 #endif
00210
00211
00212 #define wxPG_INCLUDE_CHECKBOX 1
00213
00214
00215 #ifndef wxPG_USE_STL
00216 #define wxPG_USE_STL wxUSE_STL
00217 #endif
00218
00219 #ifndef wxPG_USING_WXOWNERDRAWNCOMBOBOX
00220 #if wxCHECK_VERSION(2,8,0)
00221 #define wxPG_USING_WXOWNERDRAWNCOMBOBOX 1
00222 #else
00223 #define wxPG_USING_WXOWNERDRAWNCOMBOBOX 0
00224 #endif
00225 #endif
00226
00227 #if wxPG_USING_WXOWNERDRAWNCOMBOBOX
00228 #define wxPGOwnerDrawnComboBox wxOwnerDrawnComboBox
00229 #define wxPGCC_DCLICK_CYCLES wxCC_SPECIAL_DCLICK
00230 #define wxPGCC_PAINTING_CONTROL wxODCB_PAINTING_CONTROL
00231 #define wxPGCC_PAINTING_SELECTED wxODCB_PAINTING_SELECTED
00232 #define wxPGCC_PROCESS_ENTER wxTE_PROCESS_ENTER
00233 #define wxPGCC_ALT_KEYS 0
00234 #endif
00235
00236
00237 #if !wxCHECK_VERSION(2,7,1)
00238 #define wxPGRectContains Inside
00239 #else
00240 #define wxPGRectContains Contains
00241 #endif
00242
00243 #if wxCHECK_VERSION(2,7,0)
00244 #define wxPGIndex unsigned int
00245 #else
00246 #define wxPGIndex int
00247 #endif
00248
00249 #ifdef __WXMSW__
00250 #if wxCHECK_VERSION(2,9,0)
00251 #define wxPG_GetHDCOf(DC) ((HDC)((const wxMSWDCImpl *)DC.GetImpl())->GetHDC())
00252 #else
00253 #define wxPG_GetHDCOf(DC) ((HDC)DC.GetHDC())
00254 #endif
00255 #endif
00256
00257
00258 #if !wxCHECK_VERSION(2,8,0)
00259 #ifndef wxBORDER_THEME
00260 #define wxBORDER_THEME wxSIMPLE_BORDER
00261 #endif
00262 #endif
00263
00264
00265
00266 #ifndef wxPG_COMPATIBILITY_1_2_0
00267 #define wxPG_COMPATIBILITY_1_2_0 1
00268 #endif
00269
00270
00271 #if wxPG_COMPATIBILITY_1_2_0
00272
00273
00274 #define wxPG_VERSION ((wxPROPGRID_MAJOR*1000)+(wxPROPGRID_MINOR*100)+(wxPROPGRID_RELEASE*10))
00275
00276 #endif
00277
00278
00279 #ifdef wxPG_COMPATIBILITY_1_0_0
00280
00281 #define wxRECURSE wxPG_RECURSE
00282 #define wxKEEP_STRUCTURE wxPG_KEEP_STRUCTURE
00283 #define wxPGConstants wxPGChoices
00284 #define wxPG_EX_CLASSIC_SPACING 0
00285
00286 #define wxPGCtrlClass wxWindow
00287 #define wxCCustomTextCtrl wxTextCtrl
00288 #define wxCCustomComboBox wxPGOwnerDrawnComboBox
00289 #define wxCCustomButton wxButton
00290
00291 #endif // #ifdef wxPG_COMPATIBILITY_1_0_0
00292
00293 #ifdef __WXPYTHON__
00294 #define wxPG_VALUETYPE_IS_STRING 0 // 1
00295 #else
00296 #define wxPG_VALUETYPE_IS_STRING 0
00297 #endif
00298
00299 #ifndef SWIG
00300 #if !wxCHECK_VERSION(2,9,0)
00301 #if !defined(wxUniChar)
00302 #define wxUniChar wxChar
00303 #endif
00304
00305 #define wxPGGetIterChar(str, i) *i
00306 #else
00307 #define wxPGGetIterChar(str, i) *i
00308 #endif
00309 #endif
00310
00311 #if wxPG_COMPATIBILITY_1_2_0
00312 #define wxPGRegisterPropertyClass(A)
00313 #endif
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325 #ifndef __WXPYTHON__
00326
00327
00328
00329
00330 #define wxPG_CONST_WXCHAR_PTR const wxChar*
00331 #define wxPG_CONST_WXCHAR_DEFVAL ((const wxChar*)NULL)
00332 #define wxPG_TO_WXCHAR_PTR(A) A
00333
00334
00335 #define SetPropertyValueLong SetPropertyValue
00336 #define SetPropertyValueDouble SetPropertyValue
00337 #define SetPropertyValueBool SetPropertyValue
00338 #define SetPropertyValueString SetPropertyValue
00339 #define SetPropertyValueWxObjectPtr SetPropertyValue
00340 #define SetPropertyValuePoint SetPropertyValue
00341 #define SetPropertyValueSize SetPropertyValue
00342 #define SetPropertyValueArrint2 SetPropertyValue
00343 #define SetPropertyValueArrstr2 SetPropertyValue
00344 #define SetPropertyValueDatetime SetPropertyValue
00345 #define SetPropertyValueLongLong SetPropertyValue
00346 #define SetPropertyValueULongLong SetPropertyValue
00347
00348 #define WX_PG_NOT_PURE_IN_WXPYTHON =0
00349
00350 #else
00351
00352
00353
00354
00355 #define wxPG_CONST_WXCHAR_PTR wxString
00356 #define wxPG_CONST_WXCHAR_DEFVAL wxEmptyString
00357 #define wxPG_TO_WXCHAR_PTR(A) A //(A.c_str())
00358
00359
00360
00361
00362 #define SetPropertyValueArrstr2 _SetPropertyValueArrstr
00363 #define SetPropertyValueArrint2 _SetPropertyValueArrint
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 class wxPGVariantAndBool
00374 {
00375 public:
00376
00377 wxPGVariantAndBool()
00378 {
00379 m_valueValid = false;
00380 m_result = false;
00381 }
00382
00383 wxPGVariantAndBool( bool result, const wxVariant& variant )
00384 {
00385 m_valueValid = true;
00386 m_result = result;
00387 m_value = variant;
00388 }
00389
00390 wxPGVariantAndBool( const wxVariant& variant )
00391 {
00392 m_valueValid = true;
00393 m_result = true;
00394 m_value = variant;
00395 }
00396
00397 wxPGVariantAndBool( bool result )
00398 {
00399 Init(result);
00400 }
00401
00402 ~wxPGVariantAndBool() { }
00403
00404 void Init( bool result = false )
00405 {
00406 m_valueValid = false;
00407 m_result = result;
00408 }
00409
00410 const wxVariant& GetValue() const
00411 {
00412 wxASSERT(m_valueValid);
00413 return m_value;
00414 }
00415
00416 public:
00417 wxVariant m_value;
00418 bool m_valueValid;
00419 bool m_result;
00420 };
00421
00422 #define WX_PG_NOT_PURE_IN_WXPYTHON
00423
00424 #endif
00425
00426
00427 #define wxPG_NO_DECL
00428
00429 #ifndef wxEMPTY_PARAMETER_VALUE
00430 #define wxEMPTY_PARAMETER_VALUE
00431 #endif
00432
00433
00434
00435 #ifdef WXMAKINGLIB_PROPGRID
00436 #define WXDLLIMPEXP_PG
00437 #elif defined(WXMAKINGDLL_PROPGRID)
00438 #define WXDLLIMPEXP_PG WXEXPORT
00439 #elif defined(WXUSINGDLL)
00440 #define WXDLLIMPEXP_PG WXIMPORT
00441 #else // not making nor using DLL
00442 #define WXDLLIMPEXP_PG wxEMPTY_PARAMETER_VALUE
00443 #endif
00444
00445
00446
00447 #ifndef SWIG
00448 class WXDLLIMPEXP_PG wxPGEditor;
00449 class WXDLLIMPEXP_PG wxPGProperty;
00450 class WXDLLIMPEXP_PG wxPropertyCategory;
00451 class WXDLLIMPEXP_PG wxPGChoices;
00452 class WXDLLIMPEXP_PG wxPropertyGridState;
00453 class WXDLLIMPEXP_PG wxPGCell;
00454 class WXDLLIMPEXP_PG wxPGChoiceEntry;
00455 class WXDLLIMPEXP_PG wxPropertyGridInterface;
00456 class WXDLLIMPEXP_PG wxPropertyGrid;
00457 class WXDLLIMPEXP_PG wxPropertyGridEvent;
00458 class WXDLLIMPEXP_PG wxPropertyGridManager;
00459 class WXDLLIMPEXP_PG wxPGOwnerDrawnComboBox;
00460 class WXDLLIMPEXP_PG wxPGCustomComboControl;
00461 class WXDLLIMPEXP_PG wxPGEditorDialogAdapter;
00462
00463 extern WXDLLIMPEXP_PG const wxChar *wxPropertyGridNameStr;
00464
00465 struct wxPGValidationInfo;
00466
00467 #endif // #ifndef SWIG
00468
00469
00470 #ifdef __WXPYTHON__
00471 class wxPGPyEditor;
00472 #endif // #ifndef __WXPYTHON__
00473
00474
00479 struct wxPGPaintData
00480 {
00482 const wxPropertyGrid* m_parent;
00483
00485 int m_choiceItem;
00486
00488 int m_drawnWidth;
00489
00491 int m_drawnHeight;
00492 };
00493
00494
00495 #ifndef SWIG
00496
00502 class WXDLLIMPEXP_PG wxPGCellRenderer
00503 {
00504 public:
00505
00506 wxPGCellRenderer( unsigned int refCount = 1 )
00507 : m_refCount(refCount) { }
00508 virtual ~wxPGCellRenderer() { }
00509
00510
00511 enum
00512 {
00513 Selected = 0x00010000,
00514 Control = 0x00020000
00515 };
00516
00517 virtual void Render( wxDC& dc,
00518 const wxRect& rect,
00519 const wxPropertyGrid* propertyGrid,
00520 wxPGProperty* property,
00521 int column,
00522 int item,
00523 int flags ) const = 0;
00524
00530 virtual wxSize GetImageSize( const wxPGProperty* property,
00531 int column,
00532 int item ) const;
00533
00536 virtual void DrawCaptionSelectionRect( wxDC& dc, int x, int y, int w, int h ) const;
00537
00540 void DrawText( wxDC& dc,
00541 const wxRect& rect,
00542 int imageWidth,
00543 const wxString& text ) const;
00544
00547 void DrawEditorValue( wxDC& dc, const wxRect& rect,
00548 int xOffset, const wxString& text,
00549 wxPGProperty* property,
00550 const wxPGEditor* editor ) const;
00551
00556 int PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell& cell, int flags ) const;
00557
00558 void IncRef()
00559 {
00560 m_refCount++;
00561 }
00562
00563 void DecRef()
00564 {
00565 m_refCount--;
00566 if ( !m_refCount )
00567 delete this;
00568 }
00569 protected:
00570
00571 private:
00572 unsigned int m_refCount;
00573 };
00574
00575
00581 class WXDLLIMPEXP_PG wxPGCell
00582 {
00583 public:
00584 wxPGCell();
00585 wxPGCell( const wxString& text,
00586 const wxBitmap& bitmap = wxNullBitmap,
00587 const wxColour& fgCol = wxNullColour,
00588 const wxColour& bgCol = wxNullColour,
00589 const wxFont& font = wxNullFont );
00590
00591 virtual ~wxPGCell() { }
00592
00593 void SetText( const wxString& text ) { m_text = text; }
00594 void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
00595 void SetFgCol( const wxColour& col ) { m_fgCol = col; }
00596 void SetBgCol( const wxColour& col ) { m_bgCol = col; }
00597 void SetFont( const wxFont& font ) { m_font = font; }
00598
00599 const wxString& GetText() const { return m_text; }
00600 const wxBitmap& GetBitmap() const { return m_bitmap; }
00601 const wxColour& GetFgCol() const { return m_fgCol; }
00602 const wxColour& GetBgCol() const { return m_bgCol; }
00603 const wxFont& GetFont() const { return m_font; }
00604
00605 protected:
00606 wxString m_text;
00607 wxBitmap m_bitmap;
00608 wxColour m_fgCol;
00609 wxColour m_bgCol;
00610 wxFont m_font;
00611 };
00612
00613
00620 class WXDLLIMPEXP_PG wxPGDefaultRenderer : public wxPGCellRenderer
00621 {
00622 public:
00623 virtual void Render( wxDC& dc,
00624 const wxRect& rect,
00625 const wxPropertyGrid* propertyGrid,
00626 wxPGProperty* property,
00627 int column,
00628 int item,
00629 int flags ) const;
00630
00631 virtual wxSize GetImageSize( const wxPGProperty* property,
00632 int column,
00633 int item ) const;
00634
00635 protected:
00636 };
00637
00638 #endif // !SWIG
00639
00645 #define wxPG_EMPTY_ARRAYINT wxArrayInt()
00646 #define wxPG_EMPTY_ARRAYSTRING wxArrayString()
00647
00648 #if !defined(SWIG)
00649 #define wxPG_LABEL (*((wxString*)NULL)) // Used to tell wxPGProperty to use label as name as well.
00650 #define wxPG_NULL_BITMAP wxNullBitmap
00651 #define wxPG_COLOUR_BLACK (*wxBLACK)
00652 #else
00653 #define wxPG_LABEL wxString_wxPG_LABEL
00654 #define wxPG_NULL_BITMAP wxBitmap_NULL
00655 #define wxPG_COLOUR_BLACK wxColour_BLACK
00656 #endif // #ifndef SWIG
00657
00658
00659
00660
00661 #define wxPG_INVALID_VALUE INT_MAX
00662
00663
00666 #define wxPG_COLOUR(R,G,B) ((wxUint32)(R+(G<<8)+(B<<16)))
00667
00668
00672 #define wxPG_DEFAULT_IMAGE_SIZE wxSize(-1, -1)
00673
00674
00688 typedef bool (*wxPropertyGridCallback)(wxPropertyGrid* propGrid,
00689 wxPGProperty* property,
00690 wxWindow* ctrl,
00691 int data);
00692
00698 typedef void (*wxPGPaintCallback)(wxPGProperty* property,
00699 wxDC& dc,
00700 const wxRect& rect,
00701 wxPGPaintData& paintdata);
00702
00720 typedef int (*wxPGSortCallback)(wxPropertyGrid* propGrid,
00721 wxPGProperty* p1,
00722 wxPGProperty* p2);
00723
00724
00730 #define WX_PG_CLASSINFO(NAME) (&NAME::ms_classInfo)
00731
00732
00733 typedef wxString wxPGCachedString;
00734
00738
00739
00744 enum wxPG_WINDOW_STYLES
00745 {
00746
00752 wxPG_AUTO_SORT = 0x00000010,
00753
00759 wxPG_HIDE_CATEGORIES = 0x00000020,
00760
00761
00762
00763 wxPG_ALPHABETIC_MODE = (wxPG_HIDE_CATEGORIES|wxPG_AUTO_SORT),
00764
00768 wxPG_BOLD_MODIFIED = 0x00000040,
00769
00773 wxPG_SPLITTER_AUTO_CENTER = 0x00000080,
00774
00778 wxPG_TOOLTIPS = 0x00000100,
00779
00784 wxPG_HIDE_MARGIN = 0x00000200,
00785
00788 wxPG_STATIC_SPLITTER = 0x00000400,
00789
00793 wxPG_STATIC_LAYOUT = (wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER),
00794
00799 wxPG_LIMITED_EDITING = 0x00000800,
00800
00801 #ifdef DOXYGEN
00802
00809 wxTAB_TRAVERSAL = 0x00080000,
00810
00811 #endif
00812
00814 wxPG_TOOLBAR = 0x00001000,
00815
00819 wxPG_DESCRIPTION = 0x00002000,
00820
00824 wxPG_THEME_BORDER = 0x00004000,
00825
00829 wxPG_NO_INTERNAL_BORDER = 0x00008000
00830
00831 };
00832
00833 enum wxPG_EX_WINDOW_STYLES
00834 {
00835
00848 wxPG_EX_INIT_NOCAT = 0x00001000,
00849
00853 wxPG_EX_NO_FLAT_TOOLBAR = 0x00002000,
00854
00857 wxPG_EX_MODE_BUTTONS = 0x00008000,
00858
00862 wxPG_EX_HELP_AS_TOOLTIPS = 0x00010000,
00863
00870
00871
00872 #if wxPG_COMPATIBILITY_1_2_0
00873
00874
00875 wxPG_EX_GREY_LABEL_WHEN_DISABLED = 0x00000000,
00876 #endif
00877
00880 wxPG_EX_NATIVE_DOUBLE_BUFFERING = 0x00080000,
00881
00882 #if wxPG_COMPATIBILITY_1_2_0
00883
00886 wxPG_EX_PROCESS_EVENTS_IMMEDIATELY = 0x00000000,
00887 #endif
00888
00893 wxPG_EX_AUTO_UNSPECIFIED_VALUES = 0x00200000,
00894
00900 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES = 0x00400000,
00901
00902 #if wxPG_COMPATIBILITY_1_2_0
00903
00909 wxPG_EX_TRADITIONAL_VALIDATORS = 0x00000000,
00910 #endif
00911
00914 wxPG_EX_LEGACY_VALIDATORS = 0x00800000,
00915
00918 wxPG_EX_HIDE_PAGE_BUTTONS = 0x01000000,
00919
00922 wxPG_EX_UNFOCUS_ON_ENTER = 0x02000000,
00923
00935 wxPG_EX_MULTIPLE_SELECTION = 0x04000000,
00936
00946 wxPG_EX_DISABLE_TLP_TRACKING = 0x08000000,
00947
00950 wxPG_EX_NO_TOOLBAR_DIVIDER = 0x10000000,
00951
00956 wxPG_EX_TOOLBAR_SEPARATOR = 0x20000000
00957
00958 };
00959
00963 #define wxPG_EX_ENABLE_TLP_TRACKING 0x00000000
00964
00965
00968 #define wxPG_DEFAULT_STYLE (0)
00969
00972 #define wxPGMAN_DEFAULT_STYLE (0)
00973
00977 enum wxPG_GETPROPERTYVALUES_FLAGS
00978 {
00979
00981 wxPG_KEEP_STRUCTURE = 0x00000010,
00982
00984 wxPG_RECURSE = 0x00000020,
00985
00987 wxPG_INC_ATTRIBUTES = 0x00000040,
00988
00990 wxPG_RECURSE_STARTS = 0x00000080,
00991
00993 wxPG_FORCE = 0x00000100
00994
00995 };
00996
00998 #define wxPG_DONT_RECURSE 0x00000000
00999
01000
01001
01002
01003 enum wxPG_MISC_ARG_FLAGS
01004 {
01005
01006 wxPG_FULL_VALUE = 0x00000001,
01007
01008 wxPG_REPORT_ERROR = 0x00000002,
01009
01010 wxPG_PROPERTY_SPECIFIC = 0x00000004,
01011
01012 wxPG_EDITABLE_VALUE = 0x00000008,
01013
01014
01015 wxPG_COMPOSITE_FRAGMENT = 0x00000010,
01016
01017 wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = 0x00000020,
01018
01019
01020 wxPG_PROGRAMMATIC_VALUE = 0x00000040
01021 };
01022
01023
01024
01025
01026
01027 enum wxPG_SETVALUE_FLAGS
01028 {
01029 wxPG_SETVAL_REFRESH_EDITOR = 0x0001,
01030 wxPG_SETVAL_AGGREGATED = 0x0002,
01031 wxPG_SETVAL_FROM_PARENT = 0x0004,
01032 wxPG_SETVAL_BY_USER = 0x0008
01033 };
01034
01035
01036
01037
01038 #define wxNullProperty ((wxPGProperty*)NULL)
01039
01040 #if wxPG_COMPATIBILITY_1_2_0
01041 inline bool wxPGIdIsOk(wxPGProperty* id)
01042 {
01043 return (id != NULL) ? true : false;
01044 }
01045 #endif
01046
01047 typedef wxPGProperty* wxPGId;
01048
01049 #ifndef SWIG
01050
01057 class WXDLLIMPEXP_PG wxPGPropArgCls
01058 {
01059 public:
01060 wxPGPropArgCls() { }
01061 wxPGPropArgCls( const wxPGProperty* property )
01062 {
01063 m_ptr.property = (wxPGProperty*) property;
01064 m_isName = false;
01065 }
01066 wxPGPropArgCls( const wxString& str )
01067 {
01068 m_ptr.name = &str;
01069 m_isName = 1;
01070 }
01071 wxPGPropArgCls( const wxPGPropArgCls& id )
01072 {
01073 m_ptr = id.m_ptr;
01074 m_isName = id.m_isName;
01075 }
01076 #ifdef __WXPYTHON__
01077 wxPGPropArgCls( wxString* str, bool WXUNUSED(deallocPtr) )
01078 {
01079 m_ptr.name = str;
01080 m_isName = 3;
01081 }
01082 ~wxPGPropArgCls()
01083 {
01084 if ( m_isName == 3 )
01085 delete m_ptr.name;
01086 }
01087 #endif
01088 wxPGProperty* GetPtr() const { wxCHECK( !m_isName, NULL ); return m_ptr.property; }
01089 wxPGPropArgCls( const wxChar* str )
01090 {
01091 m_ptr.rawname = str;
01092 m_isName = 2;
01093 }
01095 wxPGPropArgCls( int )
01096 {
01097 m_ptr.property = (wxPGProperty*) NULL;
01098 m_isName = false;
01099 }
01100 wxPGProperty* GetPtr( wxPropertyGridInterface* methods ) const;
01101 wxPGProperty* GetPtr( const wxPropertyGridInterface* methods ) const
01102 {
01103 return GetPtr((wxPropertyGridInterface*)methods);
01104 }
01105 wxPGProperty* GetPtr0() const { return m_ptr.property; }
01106 unsigned char HasName() const { return m_isName; }
01107 const wxString& GetName() const { return *m_ptr.name; }
01108 private:
01109 union
01110 {
01111 wxPGProperty* property;
01112 const wxChar* rawname;
01113 const wxString* name;
01114 } m_ptr;
01115 unsigned char m_isName;
01116 };
01117
01118 #else
01119
01120 class WXDLLIMPEXP_PG wxPGPropArgCls;
01121
01122 #endif
01123
01124 typedef const wxPGPropArgCls& wxPGPropArg;
01125
01126
01127
01128 WXDLLIMPEXP_PG void wxPGTypeOperationFailed( const wxPGProperty* p, const wxChar* typestr, const wxChar* op );
01129 WXDLLIMPEXP_PG void wxPGGetFailed( const wxPGProperty* p, const wxChar* typestr );
01130
01131
01132
01137 enum wxPG_PROPERTY_FLAGS
01138 {
01139
01142 wxPG_PROP_MODIFIED = 0x0001,
01143
01146 wxPG_PROP_DISABLED = 0x0002,
01147
01150 wxPG_PROP_HIDDEN = 0x0004,
01151
01156 wxPG_PROP_CUSTOMIMAGE = 0x0008,
01157
01161 wxPG_PROP_NOEDITOR = 0x0010,
01162
01165 wxPG_PROP_COLLAPSED = 0x0020,
01166
01173 wxPG_PROP_INVALID_VALUE = 0x0040,
01174
01175
01176
01180 wxPG_PROP_WAS_MODIFIED = 0x0200,
01181
01185 wxPG_PROP_AGGREGATE = 0x0400,
01186
01190 wxPG_PROP_CHILDREN_ARE_COPIES = 0x0800,
01191
01194 wxPG_PROP_PROPERTY = 0x1000,
01195
01198 wxPG_PROP_CATEGORY = 0x2000,
01199
01203 wxPG_PROP_MISC_PARENT = 0x4000,
01204
01207 wxPG_PROP_READONLY = 0x8000,
01208
01209
01210
01211
01212
01217 wxPG_PROP_COMPOSED_VALUE = 0x00010000,
01218
01223 wxPG_PROP_USES_COMMON_VALUE = 0x00020000,
01224
01233 wxPG_PROP_AUTO_UNSPECIFIED = 0x00040000,
01234
01237 wxPG_PROP_CLASS_SPECIFIC_1 = 0x00080000,
01238
01241 wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000,
01242
01245 wxPG_PROP_BEING_DELETED = 0x00200000
01246
01247 };
01248
01251 #define wxPG_PROP_MAX wxPG_PROP_AUTO_UNSPECIFIED
01252
01256 #define wxPG_PROP_PARENTAL_FLAGS (wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY|wxPG_PROP_MISC_PARENT)
01257
01261
01262 #define wxPG_INHERITED_PROPFLAGS (wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR)
01263
01264
01265 #define wxPG_STRING_STORED_FLAGS (wxPG_PROP_DISABLED|wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR|wxPG_PROP_COLLAPSED)
01266
01267
01268
01269 #ifndef SWIG
01270
01284 #define wxPG_ATTR_MIN wxT("Min")
01285
01288 #define wxPG_ATTR_MAX wxT("Max")
01289
01294 #define wxPG_ATTR_UNITS wxT("Units")
01295
01299 #define wxPG_ATTR_INLINE_HELP wxT("InlineHelp")
01300
01304 #define wxPG_BOOL_USE_CHECKBOX wxT("UseCheckbox")
01305
01309 #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxT("UseDClickCycling")
01310
01315 #define wxPG_FLOAT_PRECISION wxT("Precision")
01316
01319 #define wxPG_STRING_PASSWORD wxT("Password")
01320
01325 #define wxPG_UINT_BASE wxT("Base")
01326
01332 #define wxPG_UINT_PREFIX wxT("Prefix")
01333
01338 #define wxPG_FILE_WILDCARD wxT("Wildcard")
01339
01343 #define wxPG_FILE_SHOW_FULL_PATH wxT("ShowFullPath")
01344
01348 #define wxPG_FILE_SHOW_RELATIVE_PATH wxT("ShowRelativePath")
01349
01353 #define wxPG_FILE_INITIAL_PATH wxT("InitialPath")
01354
01358 #define wxPG_FILE_DIALOG_TITLE wxT("DialogTitle")
01359
01363 #define wxPG_DIR_DIALOG_MESSAGE wxT("DialogMessage")
01364
01367 #define wxPG_DATE_FORMAT wxT("DateFormat")
01368
01372 #define wxPG_DATE_PICKER_STYLE wxT("PickerStyle")
01373
01377 #define wxPG_ATTR_SPINCTRL_STEP wxT("Step")
01378
01381 #define wxPG_ATTR_SPINCTRL_WRAP wxT("Wrap")
01382
01386 #define wxPG_ATTR_SPINCTRL_MOTIONSPIN wxT("MotionSpin")
01387
01391 #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxT("UserStringMode")
01392
01393 #ifdef wxPG_COMPATIBILITY_1_0_0
01394
01400 #define wxPG_CUSTOM_EDITOR wxT("128")
01401
01406 #define wxPG_CUSTOM_IMAGE wxT("129")
01407
01411 #define wxPG_CUSTOM_CALLBACK wxT("130")
01412
01413 #endif // wxPG_COMPATIBILITY_1_0_0
01414
01423 #define wxPG_CUSTOM_PAINT_CALLBACK wxT("PaintCallback")
01424
01425
01433 #define wxPG_CUSTOM_PRIVATE_CHILDREN wxT("PrivateChildren")
01434
01435
01439 #define wxPG_COLOUR_ALLOW_CUSTOM wxT("AllowCustom")
01440
01441
01445
01446
01450 #ifndef DOXYGEN
01451
01452
01453 #undef wxPG_ATTR_DEFAULT_VALUE
01454 #define wxPG_ATTR_DEFAULT_VALUE wxPGGlobalVars->m_strDefaultValue
01455 #undef wxPG_ATTR_MIN
01456 #define wxPG_ATTR_MIN wxPGGlobalVars->m_strMin
01457 #undef wxPG_ATTR_MAX
01458 #define wxPG_ATTR_MAX wxPGGlobalVars->m_strMax
01459 #undef wxPG_ATTR_UNITS
01460 #define wxPG_ATTR_UNITS wxPGGlobalVars->m_strUnits
01461 #undef wxPG_ATTR_INLINE_HELP
01462 #define wxPG_ATTR_INLINE_HELP wxPGGlobalVars->m_strInlineHelp
01463
01464 #endif // !DOXYGEN
01465
01466 #endif // !SWIG
01467
01468
01469
01470
01471
01472 #define wxPG_BASE_OCT (long)8
01473 #define wxPG_BASE_DEC (long)10
01474 #define wxPG_BASE_HEX (long)16
01475 #define wxPG_BASE_HEXL (long)32
01476
01477
01478
01479 #define wxPG_PREFIX_NONE (long)0
01480 #define wxPG_PREFIX_0x (long)1
01481 #define wxPG_PREFIX_DOLLAR_SIGN (long)2
01482
01483
01484
01485
01486
01487
01488 #define wxPG_EDITOR(T) wxPGEditor_##T
01489
01490
01491 #define WX_PG_DECLARE_EDITOR_WITH_DECL(EDITOR,DECL) \
01492 extern DECL wxPGEditor* wxPGEditor_##EDITOR; \
01493 extern DECL wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
01494
01495
01496 #define WX_PG_DECLARE_EDITOR(EDITOR) \
01497 extern wxPGEditor* wxPGEditor_##EDITOR; \
01498 extern wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
01499
01500
01501 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrl,WXDLLIMPEXP_PG)
01502 WX_PG_DECLARE_EDITOR_WITH_DECL(Choice,WXDLLIMPEXP_PG)
01503 WX_PG_DECLARE_EDITOR_WITH_DECL(ComboBox,WXDLLIMPEXP_PG)
01504 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrlAndButton,WXDLLIMPEXP_PG)
01505 #if wxPG_INCLUDE_CHECKBOX
01506 WX_PG_DECLARE_EDITOR_WITH_DECL(CheckBox,WXDLLIMPEXP_PG)
01507 #endif
01508 WX_PG_DECLARE_EDITOR_WITH_DECL(ChoiceAndButton,WXDLLIMPEXP_PG)
01509
01510
01511
01512
01513 #ifdef SWIG
01514 #define wxVARIANT_REFCOUNTED 1
01515 #endif
01516
01517
01518
01519 #ifndef wxVARIANT_REFCOUNTED
01520 #if wxCHECK_VERSION(2,8,0)
01521 #define wxVARIANT_REFCOUNTED 1
01522 #else
01523 #define wxVARIANT_REFCOUNTED 0
01524 #error "Only supports wxWidgets 2.6 that has been patched with refcounted wxVariant"
01525 #endif
01526 #endif
01527
01528
01529 #if !defined(SWIG)
01530
01555 class WXDLLIMPEXP_PG wxPGVariantData : public wxVariantData
01556 {
01557 #if !wxCHECK_VERSION(2,9,0)
01558 DECLARE_ABSTRACT_CLASS(wxPGVariantData)
01559 #endif
01560 public:
01561 virtual void* GetValuePtr() = 0;
01562 virtual wxVariant GetDefaultValue() const = 0;
01563 protected:
01564 };
01565
01566
01567
01568
01569 #if wxCHECK_VERSION(2,9,0)
01570 #ifdef wxNO_RTTI
01571 #error "You need to enable compiler RTTI support when using wxWidgets 2.9.0 or later"
01572 #endif
01573 #define WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(A)
01574 #define WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(A, B)
01575 typedef const std::type_info* wxPGVariantDataClassInfo;
01576 #define wxPGVariantDataGetClassInfo(A) (&typeid(*A))
01577 #define wxPG_VARIANT_EQ(A, B) ( ((A).GetData() && (B).GetData() && typeid(*(A).GetData()) == typeid(*(B).GetData()) && (A == B)) || (!(A).GetData() && !(B).GetData()) )
01578 #else
01579 #define WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA DECLARE_DYNAMIC_CLASS
01580 #define WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA IMPLEMENT_DYNAMIC_CLASS
01581 typedef wxList wxVariantList;
01582 typedef wxClassInfo* wxPGVariantDataClassInfo;
01583 #define wxPGVariantDataGetClassInfo(A) (A->GetClassInfo())
01584 #define wxPG_VARIANT_EQ(A, B) ( ((A).GetData() && (B).GetData() && (A).GetData()->GetClassInfo() == (B).GetData()->GetClassInfo() && (A == B)) || (!(A).GetData() && !(B).GetData()) )
01585 #endif
01586
01587 #ifndef wxDynamicCastVariantData
01588 #define wxDynamicCastVariantData wxDynamicCast
01589 #endif
01590
01591
01592 inline void wxPGDoesNothing() {}
01593
01594
01595 #define _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, AS_ARG, AS_ARG_CONST, CTOR_CODE, DEFAULT_VALUE, SET_CODE) \
01596 WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME) \
01597 protected: \
01598 DATATYPE m_value; \
01599 public: \
01600 CLASSNAME() { CTOR_CODE; } \
01601 CLASSNAME(AS_ARG_CONST value) { CTOR_CODE; SET_CODE; m_value = value; } \
01602 DATATYPE GetValue() const { return m_value; } \
01603 AS_ARG_CONST GetValueRef() const { return m_value; } \
01604 AS_ARG GetValueRef() { return m_value; } \
01605 void SetValue(AS_ARG_CONST value) { SET_CODE; m_value = value; } \
01606 virtual wxString GetType() const { return wxT(#DATATYPE); } \
01607 virtual wxVariantData* Clone() { return new CLASSNAME; } \
01608 virtual bool Read(wxString &) { return false; } \
01609 virtual bool Write(wxString &) const { return true; } \
01610 virtual wxVariant GetDefaultValue() const { return DEFAULT_VALUE; }
01611
01612
01613 #define _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
01614 virtual bool Eq(wxVariantData& other) const \
01615 { return (this == (const wxVariantData*) &other); }
01616
01617 #define _WX_PG_IMPLEMENT_VARIANT_DATA_PROPER_EQ(CLASSNAME, DATATYPE) \
01618 virtual bool Eq(wxVariantData& other) const \
01619 { \
01620 if ( other.GetType() != wxT(#DATATYPE) ) \
01621 return false; \
01622 CLASSNAME* pOther = wxStaticCast(&other, CLASSNAME); \
01623 return (m_value == pOther->GetValueRef()); \
01624 }
01625
01626
01627
01628
01629 template<class T>
01630 wxVariant WXVARIANT( const T& value )
01631 {
01632 return wxVariant((void*)&value);
01633 }
01634
01635 template<> inline wxVariant WXVARIANT( const int& value ) { return wxVariant((long)value); }
01636 template<> inline wxVariant WXVARIANT( const long& value ) { return wxVariant(value); }
01637 template<> inline wxVariant WXVARIANT( const bool& value ) { return wxVariant(value); }
01638 template<> inline wxVariant WXVARIANT( const double& value ) { return wxVariant(value); }
01639
01640
01641
01642
01643 template<> inline wxVariant WXVARIANT( const wxArrayString& value ) { return wxVariant(value); }
01644 template<> inline wxVariant WXVARIANT( const wxString& value ) { return wxVariant(value); }
01645 #if wxUSE_DATETIME
01646 template<> inline wxVariant WXVARIANT( const wxDateTime& value ) { return wxVariant(value); }
01647 #endif
01648
01649 #if wxCHECK_VERSION(2,9,0)
01650 #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME) \
01651 extern int CLASSNAME##_d_;
01652 #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
01653 int CLASSNAME##_d_;
01654 #else
01655 #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME) \
01656 extern wxPGVariantDataClassInfo CLASSNAME##_ClassInfo
01657 #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
01658 wxPGVariantDataClassInfo CLASSNAME##_ClassInfo = &CLASSNAME::ms_classInfo;
01659 #endif
01660
01661 #define _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, AS_ARG, AS_CONST_ARG, NULLVAL, BASECLASS) \
01662 _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
01663 WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME, BASECLASS) \
01664 AS_ARG operator <<( AS_ARG value, const wxVariant &variant ) \
01665 { \
01666 CLASSNAME *data = wxDynamicCastVariantData( variant.GetData(), CLASSNAME ); \
01667 wxASSERT( data ); \
01668 value = data->GetValue(); \
01669 return value; \
01670 } \
01671 wxVariant& operator <<( wxVariant &variant, AS_CONST_ARG value ) \
01672 { \
01673 CLASSNAME *data = new CLASSNAME( value ); \
01674 variant.SetData( data ); \
01675 return variant; \
01676 } \
01677 AS_ARG DATATYPE##FromVariant( const wxVariant& v ) \
01678 { \
01679 CLASSNAME *data = wxDynamicCastVariantData( v.GetData(), CLASSNAME ); \
01680 if ( !data ) \
01681 return NULLVAL; \
01682 return data->GetValueRef(); \
01683 } \
01684 wxVariant DATATYPE##ToVariant( AS_CONST_ARG value ) \
01685 { \
01686 wxVariant variant( new CLASSNAME( value ) ); \
01687 return variant; \
01688 }
01689
01690 #define WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE) \
01691 class CLASSNAME : public wxPGVariantData \
01692 { \
01693 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
01694 const DATATYPE&, wxPGDoesNothing(), \
01695 wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
01696 _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
01697 public: \
01698 virtual void* GetValuePtr() { return (void*)&m_value; } \
01699 }; \
01700 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
01701
01702 #define WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA(CLASSNAME, DATATYPE) \
01703 class CLASSNAME : public wxPGVariantData \
01704 { \
01705 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
01706 const DATATYPE&, wxPGDoesNothing(), \
01707 wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
01708 _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
01709 public: \
01710 virtual void* GetValuePtr() { return (void*)&m_value; } \
01711 virtual wxClassInfo* GetValueClassInfo() { return m_value.GetClassInfo(); } \
01712 }; \
01713 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
01714
01715
01716 #define WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA_WITH_PROPER_EQ(CLASSNAME, DATATYPE) \
01717 class CLASSNAME : public wxPGVariantData \
01718 { \
01719 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
01720 const DATATYPE&, wxPGDoesNothing(), \
01721 wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
01722 _WX_PG_IMPLEMENT_VARIANT_DATA_PROPER_EQ(CLASSNAME, DATATYPE) \
01723 public: \
01724 virtual void* GetValuePtr() { return (void*)&m_value; } \
01725 virtual wxClassInfo* GetValueClassInfo() { return m_value.GetClassInfo(); } \
01726 }; \
01727 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
01728
01729
01730 #define WX_PG_DECLARE_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
01731 DECL DATATYPE& operator <<( DATATYPE& value, const wxVariant &variant ); \
01732 DECL wxVariant& operator <<( wxVariant &variant, const DATATYPE& value ); \
01733 DECL DATATYPE& DATATYPE##FromVariant( const wxVariant& variant ); \
01734 DECL wxVariant DATATYPE##ToVariant( const DATATYPE& value ); \
01735 template<> inline wxVariant WXVARIANT( const DATATYPE& value ) { return DATATYPE##ToVariant(value); } \
01736 DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
01737
01738 #define WX_PG_DECLARE_WXOBJECT_VARIANT_DATA WX_PG_DECLARE_VARIANT_DATA
01739
01740 #define WX_PG_DECLARE_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
01741 DECL DATATYPE* operator <<( DATATYPE* value, const wxVariant &variant ); \
01742 DECL wxVariant& operator <<( wxVariant &variant, DATATYPE* value ); \
01743 DECL DATATYPE* DATATYPE##FromVariant( const wxVariant& variant ); \
01744 DECL wxVariant DATATYPE##ToVariant( DATATYPE* value ); \
01745 DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
01746
01747
01748 #define WX_PG_IMPLEMENT_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DEFAULT) \
01749 class CLASSNAME : public wxPGVariantData \
01750 { \
01751 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE*, DATATYPE*, \
01752 DATATYPE*, m_value = NULL, \
01753 DEFAULT, if (m_value) Py_DECREF(m_value); if (!value) value = Py_None; Py_INCREF(value) ) \
01754 _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
01755 ~CLASSNAME() { if (m_value) Py_DECREF(m_value); } \
01756 public: \
01757 virtual void* GetValuePtr() { return (void*)m_value; } \
01758 }; \
01759 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE*, DATATYPE*, NULL, wxPGVariantData)
01760
01761
01762 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataPoint, wxPoint, WXDLLIMPEXP_PG)
01763 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataSize, wxSize, WXDLLIMPEXP_PG)
01764 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataArrayInt, wxArrayInt, WXDLLIMPEXP_PG)
01765 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataLongLong, wxLongLong, WXDLLIMPEXP_PG)
01766 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataULongLong, wxULongLong, WXDLLIMPEXP_PG)
01767 #ifdef __WXPYTHON__
01768 WX_PG_DECLARE_PTR_VARIANT_DATA(wxPGVariantDataPyObject, PyObject, WXDLLIMPEXP_PG)
01769 #endif
01770
01771 WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataFont, wxFont, WXDLLIMPEXP_PG)
01772 #if !wxCHECK_VERSION(2,8,0)
01773 WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataColour, wxColour, WXDLLIMPEXP_PG)
01774 #else
01775 template<> inline wxVariant WXVARIANT( const wxColour& value )
01776 {
01777 wxVariant variant;
01778 variant << value;
01779 return variant;
01780 }
01781 #endif
01782
01783 #endif // !SWIG
01784
01785 #define WX_PG_VARIANT_GETVALUEREF(P, T) (*((T*)((wxPGVariantData*)(P.GetData()))->GetValuePtr()))
01786
01787
01788 WXDLLIMPEXP_PG long wxPGVariantToInt( const wxVariant& variant, long defVal = 1 );
01789
01790
01791 WXDLLIMPEXP_PG bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult );
01792
01793
01794 WXDLLIMPEXP_PG bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult );
01795
01796
01797 WXDLLIMPEXP_PG bool wxPGVariantToDouble( const wxVariant& variant, double* pResult );
01798
01799
01800
01801
01802
01803
01804 WXDLLIMPEXP_PG void wxPGInitResourceModule();
01805
01806
01807
01808
01809 #if !defined(SWIG)
01810
01811 #if wxPG_USE_STL
01812 typedef std::vector<wxPGProperty*> wxArrayPGProperty;
01813 #else
01814 WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty*, wxArrayPGProperty,
01815 wxBaseArrayPtrVoid, class WXDLLIMPEXP_PG);
01816 #endif
01817
01818
01819 WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
01820 wxPGHashMapS2P,
01821 class WXDLLIMPEXP_PG);
01822
01823 #else
01824
01825 class WXDLLIMPEXP_PG wxArrayPGProperty;
01826 class WXDLLIMPEXP_PG wxPGHashMapS2P;
01827
01828 #endif
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839 #ifndef SWIG
01840 #define WX_PG_DECLARE_DOGETEDITORCLASS virtual const wxPGEditor* DoGetEditorClass() const;
01841 #else
01842 #define WX_PG_DECLARE_DOGETEDITORCLASS
01843 #endif
01844
01845 #ifndef SWIG
01846 #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
01847 public: \
01848 DECLARE_DYNAMIC_CLASS(CLASSNAME) \
01849 WX_PG_DECLARE_DOGETEDITORCLASS \
01850 private:
01851 #else
01852 #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME)
01853 #endif
01854
01855
01856 #define WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(PROPNAME,T,EDITOR) \
01857 const wxPGEditor* PROPNAME::DoGetEditorClass() const \
01858 { \
01859 return wxPGEditor_##EDITOR; \
01860 }
01861
01862
01863
01864
01865
01866
01867
01868 #define wxPG_SUBID1 2
01869 #define wxPG_SUBID2 3
01870 #define wxPG_SUBID_TEMP1 4
01871
01872
01873 #ifndef SWIG
01874
01875
01876
01877
01878 struct wxPGChoiceInfo
01879 {
01880 wxPGChoices* m_choices;
01881 };
01882
01883
01884
01890 class WXDLLIMPEXP_PG wxPGAttributeStorage
01891 {
01892 public:
01893 wxPGAttributeStorage();
01894 ~wxPGAttributeStorage();
01895
01896 void Set( const wxString& name, const wxVariant& value );
01897 unsigned int GetCount() const
01898 {
01899 return (unsigned int) m_map.size();
01900 }
01901 wxVariant FindValue( const wxString& name ) const
01902 {
01903 wxPGHashMapS2P::const_iterator it = m_map.find(name);
01904 if ( it != m_map.end() )
01905 {
01906 wxVariantData* data = (wxVariantData*) it->second;
01907 data->IncRef();
01908 return wxVariant(data, it->first);
01909 }
01910 return wxVariant();
01911 }
01912
01913 typedef wxPGHashMapS2P::const_iterator const_iterator;
01914 const_iterator StartIteration() const
01915 {
01916 return m_map.begin();
01917 }
01918 bool GetNext( const_iterator& it, wxVariant& variant ) const
01919 {
01920 if ( it == m_map.end() )
01921 return false;
01922
01923 wxVariantData* data = (wxVariantData*) it->second;
01924 data->IncRef();
01925 variant.SetData(data);
01926 variant.SetName(it->first);
01927 it++;
01928 return true;
01929 }
01930
01931 protected:
01932 wxPGHashMapS2P m_map;
01933 };
01934
01935 #endif // !SWIG
01936
01937
01938
01943 class WXDLLIMPEXP_PG wxPGProperty : public wxObject
01944 {
01945 #ifndef SWIG
01946 friend class wxPropertyGrid;
01947 friend class wxPropertyGridInterface;
01948 friend class wxPropertyGridState;
01949 friend class wxPropertyGridPopulator;
01950 friend class wxStringProperty;
01951 DECLARE_ABSTRACT_CLASS(wxPGProperty)
01952 #endif
01953 public:
01954 typedef wxUint32 FlagType;
01955 #ifndef __WXPYTHON__
01956 typedef void* ClientDataType;
01957 #else
01958 typedef PyObject* ClientDataType;
01959 #endif
01960
01961
01962
01963 #ifndef PYSWIG
01964
01966 wxPGProperty();
01967 #endif
01968
01995 wxPGProperty( const wxString& label, const wxString& name );
01996
01998 virtual ~wxPGProperty();
01999
02010 virtual void OnSetValue();
02011
02014 virtual wxVariant DoGetValue() const { return m_value; }
02015
02016 #ifndef DOXYGEN
02017 private:
02018 #else
02019 public:
02020 #endif
02021
02022
02023
02031 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
02032
02049 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
02050
02066 virtual bool IntToValue( wxVariant& value, int number, int argFlags = 0 ) const;
02067 public:
02068
02087 virtual wxString GetValueAsString( int argFlags = 0 ) const;
02088
02096 #if wxPG_COMPATIBILITY_1_2_0
02097 virtual
02098 #endif
02099 bool SetValueFromString( const wxString& text, int flags = wxPG_PROGRAMMATIC_VALUE );
02100
02110 #if wxPG_COMPATIBILITY_1_2_0
02111 virtual
02112 #endif
02113 bool SetValueFromInt( long value, int flags = 0 );
02114
02115 #if wxPG_COMPATIBILITY_1_2_0
02116
02119 virtual wxSize GetImageSize() const;
02120 #endif
02121
02132 virtual wxSize OnMeasureImage( int item = -1 ) const;
02133
02151 virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event );
02152
02188 virtual void ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const;
02189
02190 #ifdef __WXPYTHON__
02191
02192
02193 virtual wxPGVariantAndBool PyValidateValue( const wxVariant& value, wxPGValidationInfo& validationInfo ) const;
02194 virtual wxPGVariantAndBool PyStringToValue( const wxString& text, int argFlags = 0 ) const;
02195 virtual wxPGVariantAndBool PyIntToValue( int number, int argFlags = 0 ) const;
02196 #endif
02197
02198 bool ActualValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const
02199 {
02200 #ifdef __WXPYTHON__
02201 if ( m_scriptObject )
02202 {
02203 wxPGVariantAndBool vab = PyValidateValue(value, validationInfo);
02204 if ( vab.m_valueValid )
02205 value = vab.m_value;
02206 return vab.m_result;
02207 }
02208 #endif
02209
02210 return ValidateValue(value, validationInfo);
02211 }
02212
02213 bool ActualStringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const
02214 {
02215 #ifdef __WXPYTHON__
02216 if ( m_scriptObject )
02217 {
02218 wxPGVariantAndBool vab = PyStringToValue(text, argFlags);
02219 if ( vab.m_valueValid )
02220 variant = vab.m_value;
02221 return vab.m_result;
02222 }
02223 #endif
02224
02225 return StringToValue(variant, text, argFlags);
02226 }
02227
02228 bool ActualIntToValue( wxVariant& variant, int number, int argFlags = 0 ) const
02229 {
02230 #ifdef __WXPYTHON__
02231 if ( m_scriptObject )
02232 {
02233 wxPGVariantAndBool vab = PyIntToValue(number, argFlags);
02234 if ( vab.m_valueValid )
02235 variant = vab.m_value;
02236 return vab.m_result;
02237 }
02238 #endif
02239
02240 return IntToValue(variant, number, argFlags);
02241 }
02242
02243 wxString GetValueType() const
02244 {
02245 return m_value.GetType();
02246 }
02247
02248 #ifndef SWIG
02249
02251 virtual const wxPGEditor* DoGetEditorClass() const;
02252 #endif
02253
02254 #ifdef __WXPYTHON__
02255
02257 virtual wxString GetEditor() const;
02258 #endif
02259
02290 virtual wxValidator* DoGetValidator () const;
02291
02301 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
02302
02339 virtual void OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& paintdata );
02340
02345 virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
02346
02349 virtual void RefreshChildren();
02350
02358 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
02359
02366 virtual wxVariant DoGetAttribute( const wxString& name ) const;
02367
02374 virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
02375
02383 virtual void OnValidationFailure( wxVariant& pendingValue );
02384
02388 int AppendChoice( const wxString& label, int value = wxPG_INVALID_VALUE )
02389 {
02390 return InsertChoice(label,-1,value);
02391 }
02392
02396 wxPGCell* AcquireCell( unsigned int column )
02397 {
02398 if ( column >= m_cells.size() )
02399 return NULL;
02400
02401 wxPGCell* cell = (wxPGCell*) m_cells[column];
02402 m_cells[column] = NULL;
02403 return cell;
02404 }
02405
02409 bool AreChildrenComponents() const
02410 {
02411 if ( m_flags & (wxPG_PROP_COMPOSED_VALUE|wxPG_PROP_AGGREGATE) )
02412 return true;
02413
02414 return false;
02415 }
02416
02428 void AddPrivateChild( wxPGProperty* prop )
02429 {
02430 AddChild(prop);
02431 }
02432
02438 wxPGProperty* AppendChild( wxPGProperty* prop )
02439 {
02440 return InsertChild(-1, prop);
02441 }
02442
02454 wxPGProperty* InsertChild( int index, wxPGProperty* childProperty );
02455
02459 void DeleteChildren();
02460
02465 void DeleteChoice( int index );
02466
02470 void Empty()
02471 {
02472 DeleteChildren();
02473 }
02474
02480 void EnableCommonValue( bool enable = true )
02481 {
02482 if ( enable ) SetFlag( wxPG_PROP_USES_COMMON_VALUE );
02483 else ClearFlag( wxPG_PROP_USES_COMMON_VALUE );
02484 }
02485
02487 void GenerateComposedValue( wxString& text, int argFlags = 0 ) const;
02488
02490 const wxString& GetLabel() const { return m_label; }
02491
02493 wxString GetName() const;
02494
02496 const wxString& GetBaseName() const { return m_name; }
02497
02498 wxPGChoices& GetChoices();
02499
02500 const wxPGChoices& GetChoices() const;
02501
02502 const wxPGChoiceEntry* GetCurrentChoice() const;
02503
02507 int GetY() const;
02508
02509 wxVariant GetValue() const
02510 {
02511 #ifdef __WXPYTHON__
02512 wxVariant val = DoGetValue();
02513 if ( val.IsNull() )
02514 return PyObjectToVariant( Py_None );
02515 return val;
02516 #else
02517 return DoGetValue();
02518 #endif
02519 }
02520
02525 wxVariant& GetValueRef()
02526 {
02527 return m_value;
02528 }
02529
02530 const wxVariant& GetValueRef() const
02531 {
02532 return m_value;
02533 }
02534
02537 wxString GetValueString( int argFlags = 0 ) const;
02538
02547 wxPGCell* GetCell( unsigned int column ) const
02548 {
02549 if ( column >= m_cells.size() )
02550 return NULL;
02551
02552 return (wxPGCell*) m_cells[column];
02553 }
02554
02559 wxPGCell* GetOrCreateCell( unsigned int column );
02560
02561 const wxChar* GetClassName() const
02562 {
02563 return GetClassInfo()->GetClassName();
02564 }
02565
02566 unsigned int GetChoiceCount() const;
02567
02568 wxString GetChoiceString( unsigned int index );
02569
02572 int GetDisplayedCommonValueCount() const;
02573
02574 wxString GetDisplayedString() const
02575 {
02576 return GetValueString(0);
02577 }
02578
02579 #if wxPG_COMPATIBILITY_1_2_0
02580
02581 wxPGId GetId() { return this; }
02582 #endif
02583
02585 wxPropertyGrid* GetGrid() const;
02586
02589 wxPropertyGrid* GetGridIfDisplayed() const;
02590
02597 wxPGProperty* GetMainParent() const;
02598
02600 wxPGProperty* GetParent() const { return m_parent; }
02601
02602 bool IsFlagSet( FlagType flag ) const
02603 {
02604 return ( m_flags & flag ) ? true : false;
02605 }
02606
02614 bool IsTextEditable() const;
02615
02616 bool IsValueUnspecified() const
02617 {
02618 return m_value.IsNull();
02619 }
02620
02621 FlagType HasFlag( FlagType flag ) const
02622 {
02623 return ( m_flags & flag );
02624 }
02625
02629 bool CanHaveExtraChildren() const
02630 {
02631 return !IsFlagSet(wxPG_PROP_AGGREGATE);
02632 }
02633
02636 const wxPGAttributeStorage& GetAttributes() const
02637 {
02638 return m_attributes;
02639 }
02640
02643 wxVariant GetAttributesAsList() const;
02644
02645 FlagType GetFlags() const
02646 {
02647 return m_flags;
02648 }
02649
02650 const wxPGEditor* GetEditorClass() const;
02651
02654 const wxPGEditor* GetColumnEditor( int column ) const
02655 {
02656 if ( column == 1 )
02657 return GetEditorClass();
02658
02659 return NULL;
02660 }
02661
02664 int GetCommonValue() const
02665 {
02666 return m_commonValue;
02667 }
02668
02672 wxString GetType() const
02673 {
02674 return m_value.GetType();
02675 }
02676
02679 bool HasVisibleChildren() const;
02680
02684 int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
02685
02688 bool IsCategory() const { return IsFlagSet(wxPG_PROP_CATEGORY); }
02689
02692 bool IsRoot() const { return (m_parent == NULL); }
02693
02695 bool IsSubProperty() const
02696 {
02697 wxPGProperty* parent = (wxPGProperty*)m_parent;
02698 if ( parent && !parent->IsCategory() )
02699 return true;
02700 return false;
02701 }
02702
02705 const wxPGProperty* GetLastVisibleSubItem() const;
02706
02707 wxVariant GetDefaultValue() const;
02708
02709 int GetMaxLength() const
02710 {
02711 return (int) m_maxLen;
02712 }
02713
02714 #ifdef SWIG
02715 %pythoncode {
02716 def GetValue(self):
02717 return self.GetGrid().GetPropertyValue(self)
02718 }
02719 #else
02720
02721 #if wxPG_COMPATIBILITY_1_2_0
02726 wxVariant GetValueAsVariant() const
02727 {
02728 return GetValue();
02729 }
02730 #endif
02731 #endif
02732
02735 bool AreAllChildrenSpecified( wxVariant* pendingList = NULL ) const;
02736
02743 wxPGProperty* UpdateParentValues();
02744
02747 FlagType UsesAutoUnspecified() const
02748 {
02749 return HasFlag(wxPG_PROP_AUTO_UNSPECIFIED);
02750 }
02751
02752 wxBitmap* GetValueImage() const
02753 {
02754 return m_valueBitmap;
02755 }
02756
02757 wxVariant GetAttribute( const wxString& name ) const;
02758
02761 wxString GetAttribute( const wxString& name, const wxString& defVal ) const;
02762
02765 long GetAttributeAsLong( const wxString& name, long defVal ) const;
02766
02769 double GetAttributeAsDouble( const wxString& name, double defVal ) const;
02770
02771 inline unsigned int GetArrIndex() const { return m_arrIndex; }
02772
02773 inline unsigned int GetDepth() const { return (unsigned int)m_depth; }
02774
02780 wxString GetFlagsAsString( FlagType flagsMask ) const;
02781
02783 unsigned int GetIndexInParent() const
02784 {
02785 return m_arrIndex;
02786 }
02787
02794 inline bool Hide( bool hide, int flags = wxPG_RECURSE );
02795
02796 bool IsExpanded() const { return (!(m_flags & wxPG_PROP_COLLAPSED) && GetChildCount()); }
02797
02800 bool IsVisible() const;
02801
02802 bool IsEnabled() const
02803 {
02804 return ( m_flags & wxPG_PROP_DISABLED ) ? false : true;
02805 }
02806
02810 bool RecreateEditor();
02811
02814 void RefreshEditor();
02815
02823 void SetAttribute( const wxString& name, wxVariant value );
02824
02827 void SetAttributes( const wxPGAttributeStorage& attributes );
02828
02835 void SetDefaultValue( wxVariant& value )
02836 {
02837 SetAttribute(wxT("DefaultValue"), value);
02838 }
02839
02841 #ifndef SWIG
02842 void SetEditor( const wxPGEditor* editor )
02843 {
02844 m_customEditor = editor;
02845 }
02846 #endif
02847
02849 inline void SetEditor( const wxString& editorName );
02850
02855 void SetCell( int column, wxPGCell* cellObj );
02856
02859 void SetChoiceSelection( int newValue, const wxPGChoiceInfo& choiceInfo );
02860
02863 void SetCommonValue( int commonValue )
02864 {
02865 m_commonValue = commonValue;
02866 }
02867
02871 void SetFlagsFromString( const wxString& str );
02872
02880 void SetValueInEvent( wxVariant value ) const;
02881
02900 void SetValue( wxVariant value, wxVariant* pList = NULL,
02901 int flags = wxPG_SETVAL_REFRESH_EDITOR );
02902
02906 void SetValueImage( wxBitmap& bmp );
02907
02911 void SetChoicesExclusive();
02912
02913 void SetExpanded( bool expanded )
02914 {
02915 if ( !expanded ) m_flags |= wxPG_PROP_COLLAPSED;
02916 else m_flags &= ~wxPG_PROP_COLLAPSED;
02917 }
02918
02922 void SetFlag( FlagType flag ) { m_flags |= flag; }
02923
02927 void ChangeFlag( FlagType flag, bool set )
02928 {
02929 if ( set )
02930 m_flags |= flag;
02931 else
02932 m_flags &= ~flag;
02933 }
02934
02935 void SetFlagRecursively( FlagType flag, bool set );
02936
02937 void SetHelpString( const wxString& helpString )
02938 {
02939 m_helpString = helpString;
02940 }
02941
02948 void SetLabel( const wxString& label ) { m_label = label; }
02949
02950 void SetName( const wxString& newName );
02951
02952 void SetValueToUnspecified()
02953 {
02954 wxVariant val;
02955 SetValue(val);
02956 }
02957
02958 #if wxUSE_VALIDATORS
02959
02960 void SetValidator( const wxValidator& validator )
02961 {
02962 m_validator = wxDynamicCast(validator.Clone(),wxValidator);
02963 }
02964
02966 wxValidator* GetValidator() const
02967 {
02968 if ( m_validator )
02969 return m_validator;
02970 return DoGetValidator();
02971 }
02972 #endif // #if wxUSE_VALIDATORS
02973
02989 bool PrepareValueForDialogEditing( wxPropertyGrid* propgrid );
02990
02991
02992
02993
02994
02995
02996
02997
02998
02999
03000
03001 ClientDataType GetClientData() const
03002 {
03003 #ifdef __WXPYTHON__
03004 if ( m_clientData )
03005 Py_INCREF( m_clientData );
03006 else
03007 Py_RETURN_NONE;
03008 #endif
03009 return m_clientData;
03010 }
03011
03016 void SetClientData( ClientDataType clientData )
03017 {
03018 #ifdef __WXPYTHON__
03019 if ( m_clientData )
03020 Py_DECREF( m_clientData );
03021
03022 if ( clientData == Py_None )
03023 {
03024 m_clientData = NULL;
03025 return;
03026 }
03027
03028 Py_INCREF( clientData );
03029 #endif
03030 m_clientData = clientData;
03031 }
03032
03040 bool SetChoices( wxPGChoices& choices );
03041
03044 inline bool SetChoices( const wxArrayString& labels,
03045 const wxArrayInt& values = wxPG_EMPTY_ARRAYINT );
03046
03049 inline bool SetMaxLength( int maxLen );
03050
03054 void SetWasModified( bool set = true )
03055 {
03056 if ( set ) m_flags |= wxPG_PROP_WAS_MODIFIED;
03057 else m_flags &= ~wxPG_PROP_WAS_MODIFIED;
03058 }
03059
03060 const wxString& GetHelpString() const
03061 {
03062 return m_helpString;
03063 }
03064
03065 void ClearFlag( FlagType flag ) { m_flags &= ~(flag); }
03066
03067
03068 bool IsSomeParent( wxPGProperty* candidate_parent ) const;
03069
03070 #if defined(__WXPYTHON__) && !defined(SWIG)
03071
03072 PyObject* m_scriptObject;
03073 #endif
03074
03077 void AdaptListToValue( wxVariant& list, wxVariant* value ) const;
03078
03084 int GetChildrenHeight( int lh, int iMax = -1 ) const;
03085
03087 unsigned int GetChildCount() const
03088 {
03089 return (unsigned int) m_children.GetCount();
03090 }
03091
03093 unsigned int GetCount() const
03094 {
03095 return GetChildCount();
03096 }
03097
03099 wxPGProperty* Item( unsigned int i ) const
03100 {
03101 return (wxPGProperty*)m_children.Item(i);
03102 }
03103
03106 wxPGProperty* Last() const { return (wxPGProperty*)m_children.Last(); }
03107
03109 int Index( const wxPGProperty* p ) const { return m_children.Index((wxPGProperty*)p); }
03110
03111
03112 void FixIndexesOfChildren( unsigned int starthere = 0 );
03113
03114 #ifndef SWIG
03115
03116 wxPropertyGridState* GetParentState() const { return m_parentState; }
03117 #endif
03118
03119 wxPGProperty* GetItemAtY( unsigned int y, unsigned int lh, unsigned int* nextItemY ) const;
03120
03123 wxPGProperty* GetPropertyByName( const wxString& name ) const;
03124
03128 int GetImageOffset( int imageWidth ) const;
03129
03130 protected:
03131
03148 void AddChild( wxPGProperty* prop );
03149
03150 #ifndef SWIG
03151
03154 wxString GetColumnText( unsigned int col ) const;
03155
03165 wxPGProperty* GetPropertyByNameWH( const wxString& name, unsigned int hintIndex ) const;
03166
03168 void AddChild2( wxPGProperty* prop, int index = -1, bool correct_mode = true );
03169
03170 void DoSetName(const wxString& str) { m_name = str; }
03171
03173 void DoEmpty();
03174
03175
03176 void PrepareSubProperties();
03177
03178 void SetParentalType( int flag )
03179 {
03180 m_flags = (m_flags&(~(wxPG_PROP_PROPERTY|wxPG_PROP_PARENTAL_FLAGS)))|flag;
03181 }
03182
03183 void SetParentState( wxPropertyGridState* pstate ) { m_parentState = pstate; }
03184
03185
03186
03187
03188 void SubPropsChanged( int oldSelInd = -1 );
03189
03190 int GetY2( int lh ) const;
03191
03192 wxString m_label;
03193 wxString m_name;
03194 wxPGProperty* m_parent;
03195 wxPropertyGridState* m_parentState;
03196 ClientDataType m_clientData;
03197 const wxPGEditor* m_customEditor;
03198 #if wxUSE_VALIDATORS
03199 wxValidator* m_validator;
03200 #endif
03201
03202 wxBitmap* m_valueBitmap;
03203
03204 wxVariant m_value;
03205 wxPGAttributeStorage m_attributes;
03206 wxArrayPtrVoid m_children;
03207 wxArrayPtrVoid m_cells;
03208 wxString m_helpString;
03209
03210 unsigned int m_arrIndex;
03211 int m_commonValue;
03212
03213 FlagType m_flags;
03214
03215 short m_maxLen;
03216
03217
03218
03219
03220
03221 unsigned char m_depth;
03222
03223
03224
03225 unsigned char m_depthBgCol;
03226
03227 unsigned char m_bgColIndex;
03228 unsigned char m_fgColIndex;
03229
03230 private:
03231
03232 void Init();
03233 void Init( const wxString& label, const wxString& name );
03234 #endif // #ifndef SWIG
03235 };
03236
03237
03238 #if wxPG_COMPATIBILITY_1_2_0
03239 typedef wxPGProperty wxPGPropertyWithChildren;
03240 #endif
03241
03242 #define wxPGPropNameStr const wxString&
03243 #define wxPGNameConv(STR) STR
03244
03245
03246
03247
03248 #ifndef SWIG
03249
03250 WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(void*,
03251 wxPGHashMapP2P,
03252 class WXDLLIMPEXP_PG);
03253
03254 #else
03255 class WXDLLIMPEXP_PG wxPGHashMapP2P;
03256 #endif // #ifndef SWIG
03257
03258
03259
03260 #ifndef SWIG
03261
03262 WX_DECLARE_HASH_MAP_WITH_DECL(wxInt32,
03263 wxInt32,
03264 wxIntegerHash,
03265 wxIntegerEqual,
03266 wxPGHashMapI2I,
03267 class WXDLLIMPEXP_PG);
03268
03269 #else
03270 class WXDLLIMPEXP_PG wxPGHashMapI2I;
03271 #endif // #ifndef SWIG
03272
03273
03274
03275 #ifndef SWIG
03276
03281 class WXDLLIMPEXP_PG wxPGRootProperty : public wxPGProperty
03282 {
03283 public:
03284 WX_PG_DECLARE_PROPERTY_CLASS(wxPGRootProperty)
03285 public:
03286
03288 wxPGRootProperty();
03289 virtual ~wxPGRootProperty();
03290
03291 virtual bool StringToValue( wxVariant&, const wxString&, int ) const
03292 {
03293 return false;
03294 }
03295
03296 virtual void ChildChanged( wxVariant&, int, wxVariant& ) const
03297 {
03298 }
03299
03300 protected:
03301 };
03302
03303
03304
03309 class WXDLLIMPEXP_PG wxPropertyCategory : public wxPGProperty
03310 {
03311 WX_PG_DECLARE_PROPERTY_CLASS(wxPropertyCategory)
03312 public:
03313
03315 wxPropertyCategory();
03316
03324 wxPropertyCategory( const wxString& label, const wxString& name = wxPG_LABEL );
03325 ~wxPropertyCategory();
03326
03328 virtual wxString GetValueAsString( int argFlags ) const;
03329
03330 virtual void ChildChanged( wxVariant&, int, wxVariant& ) const
03331 {
03332 }
03333
03334 int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const;
03335
03336 void CalculateTextExtent( wxWindow* wnd, const wxFont& font );
03337
03338 void SetTextColIndex( unsigned int colInd ) { m_capFgColIndex = (wxByte) colInd; }
03339 unsigned int GetTextColIndex() const { return (unsigned int) m_capFgColIndex; }
03340
03341 protected:
03342 int m_textExtent;
03343 wxByte m_capFgColIndex;
03344
03345 private:
03346 void Init();
03347 };
03348
03349 #endif // !SWIG
03350
03351
03352
03358 class WXDLLIMPEXP_PG wxPGCommonValue
03359 {
03360 public:
03361
03362 wxPGCommonValue( const wxString& label, wxPGCellRenderer* renderer )
03363 {
03364 m_label = label;
03365 m_renderer = renderer;
03366 renderer->IncRef();
03367 }
03368 virtual ~wxPGCommonValue()
03369 {
03370 m_renderer->DecRef();
03371 }
03372
03373 virtual wxString GetEditableText() const { return m_label; }
03374 const wxString& GetLabel() const { return m_label; }
03375 wxPGCellRenderer* GetRenderer() const { return m_renderer; }
03376
03377 protected:
03378 wxString m_label;
03379 wxPGCellRenderer* m_renderer;
03380 };
03381
03382
03383
03384
03385 #ifndef SWIG
03386
03391 class WXDLLIMPEXP_PG wxPGChoiceEntry : public wxPGCell
03392 {
03393 public:
03394 wxPGChoiceEntry();
03395 wxPGChoiceEntry( const wxPGChoiceEntry& entry );
03396 wxPGChoiceEntry( const wxString& label,
03397 int value = wxPG_INVALID_VALUE )
03398 : wxPGCell(), m_value(value)
03399 {
03400 m_text = label;
03401 }
03402
03403 wxPGChoiceEntry( const wxString& label,
03404 int value,
03405 const wxBitmap& bitmap,
03406 const wxColour& fgCol = wxNullColour,
03407 const wxColour& bgCol = wxNullColour )
03408 : wxPGCell(label, bitmap, fgCol, bgCol), m_value(value)
03409 {
03410 }
03411
03412 virtual ~wxPGChoiceEntry()
03413 {
03414 }
03415
03416 void SetValue( int value ) { m_value = value; }
03417
03418 int GetValue() const { return m_value; }
03419
03420 protected:
03421 int m_value;
03422 };
03423
03424
03425 typedef void* wxPGChoicesId;
03426
03427 class WXDLLIMPEXP_PG wxPGChoicesData
03428 {
03429 friend class wxPGChoices;
03430 public:
03431
03432 wxPGChoicesData();
03433
03434 void CopyDataFrom( wxPGChoicesData* data );
03435
03436
03437 void Insert( int index, wxPGChoiceEntry* item )
03438 {
03439 wxArrayPtrVoid::iterator it;
03440 if ( index == -1 )
03441 {
03442 it = m_items.end();
03443 index = (int) m_items.size();
03444 }
03445 else
03446 {
03447 it = m_items.begin() + index;
03448 }
03449
03450
03451 if ( item->GetValue() == wxPG_INVALID_VALUE )
03452 item->SetValue(index);
03453
03454 m_items.insert(it, item);
03455 }
03456
03457
03458 void Clear();
03459
03460 unsigned int GetCount() const
03461 {
03462 return (unsigned int) m_items.size();
03463 }
03464
03465 wxPGChoiceEntry* Item( unsigned int i ) const
03466 {
03467 return (wxPGChoiceEntry*) m_items[i];
03468 }
03469
03470 void DecRef()
03471 {
03472 m_refCount--;
03473 wxASSERT( m_refCount >= 0 );
03474 if ( m_refCount == 0 )
03475 delete this;
03476 }
03477
03478 private:
03479 wxArrayPtrVoid m_items;
03480
03481
03482 int m_refCount;
03483
03484 virtual ~wxPGChoicesData();
03485 };
03486
03487 #define wxPGChoicesEmptyData ((wxPGChoicesData*)NULL)
03488
03489 #endif // SWIG
03490
03491
03506 class WXDLLIMPEXP_PG wxPGChoices
03507 {
03508 public:
03509
03511 wxPGChoices()
03512 {
03513 Init();
03514 }
03515
03520 wxPGChoices( const wxPGChoices& src )
03521 {
03522 if ( src.m_data != wxPGChoicesEmptyData )
03523 {
03524 m_data = src.m_data;
03525 m_data->m_refCount++;
03526 }
03527 }
03528
03538 wxPGChoices( const wxChar** labels, const long* values = NULL )
03539 {
03540 Init();
03541 Set(labels,values);
03542 }
03543
03553 wxPGChoices( const wxArrayString& labels, const wxArrayInt& values = wxPG_EMPTY_ARRAYINT )
03554 {
03555 Init();
03556 Set(labels,values);
03557 }
03558
03560 wxPGChoices( wxPGChoicesData* data )
03561 {
03562 wxASSERT(data);
03563 m_data = data;
03564 data->m_refCount++;
03565 }
03566
03568 ~wxPGChoices()
03569 {
03570 Free();
03571 }
03572
03573 void AssignData( wxPGChoicesData* data );
03574
03579 void Assign( const wxPGChoices& src )
03580 {
03581 AssignData(src.m_data);
03582 }
03583
03584 #ifndef SWIG
03585 void operator= (const wxPGChoices& a)
03586 {
03587 AssignData(a.m_data);
03588 }
03589 #endif
03590
03591 typedef long ValArrItem;
03592
03603 void Add( const wxChar** labels, const ValArrItem* values = NULL );
03604
03606 void Add( const wxArrayString& arr, const ValArrItem* values = NULL );
03607
03609 void Add( const wxArrayString& arr, const wxArrayInt& arrint );
03610
03620 wxPGChoiceEntry& Add( const wxString& label, int value = wxPG_INVALID_VALUE );
03621
03623 wxPGChoiceEntry& Add( const wxString& label, const wxBitmap& bitmap, int value = wxPG_INVALID_VALUE );
03624
03626 wxPGChoiceEntry& Add( const wxPGChoiceEntry& entry )
03627 {
03628 return Insert(entry, -1);
03629 }
03630
03632 wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE );
03633
03635 void Clear()
03636 {
03637 if ( m_data != wxPGChoicesEmptyData )
03638 m_data->Clear();
03639 }
03640
03644 wxPGChoices Copy() const
03645 {
03646 wxPGChoices dst;
03647 dst.EnsureData();
03648 dst.m_data->CopyDataFrom(m_data);
03649 return dst;
03650 }
03651
03652 void EnsureData()
03653 {
03654 if ( m_data == wxPGChoicesEmptyData )
03655 m_data = new wxPGChoicesData();
03656 }
03657
03658 const wxPGChoiceEntry& Item( unsigned int i ) const
03659 {
03660 wxASSERT( IsOk() );
03661 return *m_data->Item(i);
03662 }
03663
03664 wxPGChoiceEntry& Item( unsigned int i )
03665 {
03666 wxASSERT( IsOk() );
03667 return *m_data->Item(i);
03668 }
03669
03670 wxPGChoiceEntry& operator[](unsigned int i)
03671 {
03672 return Item(i);
03673 }
03674
03675 const wxPGChoiceEntry& operator[](unsigned int i) const
03676 {
03677 return Item(i);
03678 }
03679
03683 bool IsOk() const
03684 {
03685 return ( m_data != wxPGChoicesEmptyData );
03686 }
03687
03689 wxPGChoicesId GetId() const { return (wxPGChoicesId) m_data; };
03690
03692 void RemoveAt(size_t nIndex, size_t count = 1);
03693
03694 #ifndef SWIG
03695
03696 void Set( const wxChar** labels, const long* values = NULL )
03697 {
03698 Free();
03699 Add(labels,values);
03700 }
03701
03705 void Set( wxArrayString& arr, const long* values = (const long*) NULL )
03706 {
03707 Free();
03708 Add(arr,values);
03709 }
03710 #endif // SWIG
03711
03713 void Set( const wxArrayString& labels, const wxArrayInt& values = wxPG_EMPTY_ARRAYINT )
03714 {
03715 Free();
03716 if ( &values )
03717 Add(labels,values);
03718 else
03719 Add(labels);
03720 }
03721
03722
03723 void SetExclusive()
03724 {
03725 if ( m_data->m_refCount != 1 )
03726 {
03727 wxPGChoicesData* data = new wxPGChoicesData();
03728 data->CopyDataFrom(m_data);
03729 Free();
03730 m_data = data;
03731 }
03732 }
03733
03734 const wxString& GetLabel( unsigned int ind ) const
03735 {
03736 wxASSERT( ind >= 0 && ind < GetCount() );
03737 return Item(ind).GetText();
03738 }
03739
03740 unsigned int GetCount () const
03741 {
03742 if ( m_data )
03743 return m_data->GetCount();
03744 return 0;
03745 }
03746
03747 #if wxPG_COMPATIBILITY_1_2_0
03748
03756 wxDEPRECATED( bool HasValues() const );
03757
03765 wxDEPRECATED( bool HasValue( unsigned int i ) const );
03766 #endif
03767
03768 int GetValue( unsigned int ind ) const { return Item(ind).GetValue(); }
03769
03773 wxArrayInt GetValuesForStrings( const wxArrayString& strings ) const;
03774
03778 wxArrayInt GetIndicesForStrings( const wxArrayString& strings, wxArrayString* unmatched = NULL ) const;
03779
03780 int Index( const wxString& str ) const;
03781 int Index( int val ) const;
03782
03784 wxPGChoiceEntry& Insert( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
03785
03787 wxPGChoiceEntry& Insert( const wxPGChoiceEntry& entry, int index );
03788
03789
03790 wxPGChoicesData* GetData()
03791 {
03792 wxASSERT( m_data->m_refCount != 0xFFFFFFF );
03793 m_data->m_refCount++;
03794 return m_data;
03795 }
03796
03797
03798 wxPGChoicesData* GetDataPtr() const { return m_data; }
03799
03800
03801 wxPGChoicesData* ExtractData()
03802 {
03803 wxPGChoicesData* data = m_data;
03804 m_data = wxPGChoicesEmptyData;
03805 return data;
03806 }
03807
03808 wxArrayString GetLabels() const;
03809
03810 #ifndef SWIG
03811
03812 protected:
03813 wxPGChoicesData* m_data;
03814
03815 void Init();
03816 void Free();
03817 #endif
03818 };
03819
03820
03821
03822
03823 #ifndef SWIG
03824 #if wxMINOR_VERSION < 7 || ( wxMINOR_VERSION == 7 && wxRELEASE_NUMBER < 1 )
03825
03826
03827 WX_DECLARE_OBJARRAY_WITH_DECL(double, wxArrayDouble, class WXDLLIMPEXP_PG);
03828 #endif
03829 #endif // !SWIG
03830
03831
03832
03833
03834
03835 #define wxPG_CONSTFUNC(PROP) PROP##Create
03836 #define wxPG_PROPCLASS(PROP) PROP
03837
03838
03839 #define wxPG_NEWPROPERTY(PROP,LABEL,NAME,VALUE) wx##PROP##Property(LABEL,NAME,VALUE)
03840
03841
03842 WXDLLIMPEXP_PG wxObject* wxPG_VariantToWxObject( const wxVariant& variant, wxClassInfo* classInfo );
03843
03844
03845
03846
03847
03848 #undef wxGetVariantCast
03849 #define wxGetVariantCast(var,classname) (classname*)wxPG_VariantToWxObject(var,&classname::ms_classInfo)
03850
03851
03852 #define WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) (CLASSNAME*)wxPG_VariantToWxObject(VARIANT,&CLASSNAME::ms_classInfo)
03853
03854
03855
03856 #define wxPG_IT_CHILDREN(A) (A<<16)
03857
03865 enum wxPG_ITERATOR_FLAGS
03866 {
03867
03870 wxPG_ITERATE_PROPERTIES = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
03871 wxPG_PROP_COLLAPSED|((wxPG_PROP_MISC_PARENT|wxPG_PROP_CATEGORY)<<16)),
03872
03875 wxPG_ITERATE_HIDDEN = (wxPG_PROP_HIDDEN|wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED)),
03876
03879 wxPG_ITERATE_FIXED_CHILDREN = (wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)|wxPG_ITERATE_PROPERTIES),
03880
03884 wxPG_ITERATE_CATEGORIES = (wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY)|wxPG_PROP_COLLAPSED),
03885
03886 wxPG_ITERATE_ALL_PARENTS = (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY),
03887
03888 wxPG_ITERATE_ALL_PARENTS_RECURSIVELY = (wxPG_ITERATE_ALL_PARENTS|wxPG_IT_CHILDREN(wxPG_ITERATE_ALL_PARENTS)),
03889
03890 wxPG_ITERATOR_FLAGS_ALL = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
03891 wxPG_PROP_HIDDEN|wxPG_PROP_CATEGORY|wxPG_PROP_COLLAPSED),
03892
03893 wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL,
03894
03895 wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL,
03896
03900 wxPG_ITERATE_VISIBLE = (wxPG_ITERATE_PROPERTIES|wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)),
03901
03904 wxPG_ITERATE_ALL = (wxPG_ITERATE_VISIBLE|wxPG_ITERATE_HIDDEN),
03905
03909 wxPG_ITERATE_NORMAL = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN),
03910
03913 wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
03914
03915 };
03916
03921 #define wxPG_ITERATOR_CREATE_MASKS(FLAGS, A, B) \
03922 A = (FLAGS ^ wxPG_ITERATOR_MASK_OP_ITEM) & wxPG_ITERATOR_MASK_OP_ITEM & 0xFFFF; \
03923 B = ((FLAGS>>16) ^ wxPG_ITERATOR_MASK_OP_PARENT) & wxPG_ITERATOR_MASK_OP_PARENT & 0xFFFF;
03924
03925
03926
03927 #define wxPG_ITERATOR_PARENTEXMASK_TEST(PWC, PARENTMASK) \
03928 ( \
03929 !(PWC->GetFlags() & PARENTMASK) && \
03930 PWC->GetChildCount() \
03931 )
03932
03933
03938 class WXDLLIMPEXP_PG wxPropertyGridIteratorBase
03939 {
03940 public:
03941 wxPropertyGridIteratorBase()
03942 {
03943 }
03944
03945 void Assign( const wxPropertyGridIteratorBase& it );
03946
03947 bool AtEnd() const { return m_property == NULL; }
03948
03951 wxPGProperty* GetProperty() const { return m_property; }
03952
03953 void Init( wxPropertyGridState* state, int flags, wxPGProperty* property, int dir = 1 );
03954
03955 void Init( wxPropertyGridState* state, int flags, int startPos = wxTOP, int dir = 0 );
03956
03959 void Next( bool iterateChildren = true );
03960
03963 void Prev();
03964
03969 void SetBaseParent( wxPGProperty* baseParent ) { m_baseParent = baseParent; }
03970
03971 protected:
03972
03973 wxPGProperty* m_property;
03974
03975 private:
03976 wxPropertyGridState* m_state;
03977 wxPGProperty* m_baseParent;
03978
03979
03980 int m_itemExMask;
03981 int m_parentExMask;
03982 };
03983
03984
03985 #define wxPG_IMPLEMENT_ITERATOR(CLASS, PROPERTY, STATE) \
03986 CLASS( STATE* state, int flags = wxPG_ITERATE_DEFAULT, PROPERTY* property = NULL, int dir = 1 ) \
03987 : wxPropertyGridIteratorBase() \
03988 { Init( (wxPropertyGridState*)state, flags, (wxPGProperty*)property, dir ); } \
03989 CLASS( STATE* state, int flags, int startPos, int dir = 0 ) \
03990 : wxPropertyGridIteratorBase() \
03991 { Init( (wxPropertyGridState*)state, flags, startPos, dir ); } \
03992 CLASS() \
03993 : wxPropertyGridIteratorBase() \
03994 { \
03995 m_property = NULL; \
03996 } \
03997 CLASS( const CLASS& it ) \
03998 : wxPropertyGridIteratorBase( ) \
03999 { \
04000 Assign(it); \
04001 } \
04002 ~CLASS() \
04003 { \
04004 } \
04005 const CLASS& operator=( const CLASS& it ) \
04006 { \
04007 Assign(it); \
04008 return *this; \
04009 } \
04010 CLASS& operator++() { Next(); return *this; } \
04011 CLASS operator++(int) { CLASS it=*this;Next();return it; } \
04012 CLASS& operator--() { Prev(); return *this; } \
04013 CLASS operator--(int) { CLASS it=*this;Prev();return it; } \
04014 PROPERTY* operator *() const { return (PROPERTY*)m_property; } \
04015 static PROPERTY* OneStep( STATE* state, int flags = wxPG_ITERATE_DEFAULT, PROPERTY* property = NULL, int dir = 1 ) \
04016 { \
04017 CLASS it( state, flags, property, dir ); \
04018 if ( property ) \
04019 { \
04020 if ( dir == 1 ) it.Next(); \
04021 else it.Prev(); \
04022 } \
04023 return *it; \
04024 }
04025
04026
04034 class WXDLLIMPEXP_PG wxPropertyGridIterator : public wxPropertyGridIteratorBase
04035 {
04036 public:
04037
04038 wxPG_IMPLEMENT_ITERATOR(wxPropertyGridIterator,
04039 wxPGProperty,
04040 wxPropertyGridState)
04041
04042 protected:
04043 };
04044
04045
04050 class WXDLLIMPEXP_PG wxPropertyGridConstIterator : public wxPropertyGridIteratorBase
04051 {
04052 public:
04053 wxPG_IMPLEMENT_ITERATOR(wxPropertyGridConstIterator,
04054 const wxPGProperty,
04055 const wxPropertyGridState)
04056
04057
04060 wxPropertyGridConstIterator( const wxPropertyGridIterator& other )
04061 {
04062 Assign(other);
04063 }
04064
04068 const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it )
04069 {
04070 Assign(it);
04071 return *this;
04072 }
04073
04074 protected:
04075 };
04076
04077
04078
04081 class WXDLLIMPEXP_PG wxPGVIteratorBase
04082 {
04083 friend class wxPGVIterator;
04084 public:
04085 wxPGVIteratorBase() { m_refCount = 1; }
04086 virtual void Next() = 0;
04087 void IncRef()
04088 {
04089 m_refCount++;
04090 }
04091 void DecRef()
04092 {
04093 m_refCount--;
04094 if ( m_refCount <= 0 )
04095 delete this;
04096 }
04097 protected:
04098 virtual ~wxPGVIteratorBase() { }
04099
04100 wxPropertyGridIterator m_it;
04101 private:
04102 int m_refCount;
04103 };
04104
04112 class WXDLLIMPEXP_PG wxPGVIterator
04113 {
04114 public:
04115 wxPGVIterator() { m_pIt = NULL; }
04116 wxPGVIterator( wxPGVIteratorBase* obj ) { m_pIt = obj; }
04117 ~wxPGVIterator() { UnRef(); }
04118 void UnRef() { if (m_pIt) m_pIt->DecRef(); }
04119 wxPGVIterator( const wxPGVIterator& it )
04120 {
04121 m_pIt = it.m_pIt;
04122 m_pIt->IncRef();
04123 }
04124 #ifndef SWIG
04125 const wxPGVIterator& operator=( const wxPGVIterator& it )
04126 {
04127 UnRef();
04128 m_pIt = it.m_pIt;
04129 m_pIt->IncRef();
04130 return *this;
04131 }
04132 #endif
04133 void Next() { m_pIt->Next(); }
04134 bool AtEnd() const { return m_pIt->m_it.AtEnd(); }
04135 wxPGProperty* GetProperty() const { return m_pIt->m_it.GetProperty(); }
04136 protected:
04137 wxPGVIteratorBase* m_pIt;
04138 };
04139
04140
04141
04147 class WXDLLIMPEXP_PG wxPropertyGridHitTestResult
04148 {
04149 friend class wxPropertyGrid;
04150 public:
04151 wxPropertyGridHitTestResult()
04152 {
04153 property = NULL;
04154 column = -1;
04155 splitter = -1;
04156 splitterHitOffset = 0;
04157 }
04158
04159 ~wxPropertyGridHitTestResult()
04160 {
04161 }
04162
04166 int GetColumn() const { return column; }
04167
04172 wxPGProperty* GetProperty() const
04173 {
04174 return property;
04175 }
04176
04180 int GetSplitter() const { return splitter; }
04181
04186 int GetSplitterHitOffset() const { return splitterHitOffset; }
04187
04189 wxPGProperty* property;
04190
04192 int column;
04193
04195 int splitter;
04196
04198 int splitterHitOffset;
04199 };
04200
04201
04202
04207 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
04208 {
04209
04213 wxPG_VFB_STAY_IN_PROPERTY = 0x01,
04214
04217 wxPG_VFB_BEEP = 0x02,
04218
04221 wxPG_VFB_MARK_CELL = 0x04,
04222
04225 wxPG_VFB_SHOW_MESSAGE = 0x08,
04226
04228 wxPG_VFB_DEFAULT = wxPG_VFB_STAY_IN_PROPERTY|wxPG_VFB_BEEP,
04229
04231 wxPG_VFB_UNDEFINED = 0x80
04232
04233 };
04234
04238 typedef wxByte wxPGVFBFlags;
04239
04246 struct wxPGValidationInfo
04247 {
04250 wxVariant* m_pValue;
04251
04254 wxString m_failureMessage;
04255
04258 wxPGVFBFlags m_failureBehavior;
04259
04260 wxPGVFBFlags GetFailureBehavior() const { return m_failureBehavior; }
04261
04262 void SetFailureBehavior(wxPGVFBFlags failureBehavior) { m_failureBehavior = failureBehavior; }
04263
04264 const wxString& GetFailureMessage() const { return m_failureMessage; }
04265
04266 void SetFailureMessage(const wxString& message) { m_failureMessage = message; }
04267 };
04268
04269
04270
04276 enum wxPG_KEYBOARD_ACTIONS
04277 {
04278 wxPG_ACTION_INVALID = 0,
04279 wxPG_ACTION_NEXT_PROPERTY,
04280 wxPG_ACTION_PREV_PROPERTY,
04281 wxPG_ACTION_EXPAND_PROPERTY,
04282 wxPG_ACTION_COLLAPSE_PROPERTY,
04283 wxPG_ACTION_CANCEL_EDIT,
04284 wxPG_ACTION_CUT,
04285 wxPG_ACTION_COPY,
04286 wxPG_ACTION_PASTE,
04287 wxPG_ACTION_SELECT_ALL,
04288 wxPG_ACTION_MAX
04289 };
04290
04295 #ifndef SWIG
04296
04297
04305
04306 class WXDLLIMPEXP_PG wxPropertyGridState
04307 {
04308 friend class wxPGProperty;
04309 friend class wxPropertyGrid;
04310 friend class wxPGCanvas;
04311 friend class wxPropertyGridPage;
04312 friend class wxPropertyGridManager;
04313 friend class wxPropertyGridInterface;
04314 public:
04315
04317 wxPropertyGridState();
04318
04320 virtual ~wxPropertyGridState();
04321
04323 wxPGProperty* DoAppend( wxPGProperty* property );
04324
04326 wxPGProperty* BaseGetPropertyByName( wxPGPropNameStr name ) const;
04327
04329 void DoClear();
04330
04331 bool DoIsPropertySelected( wxPGProperty* prop ) const;
04332
04333 void ClearModifiedStatus( wxPGProperty* p );
04334
04335 bool DoClearSelection()
04336 {
04337 return DoSelectProperty(NULL);
04338 }
04339
04340 void DoRemoveFromSelection( wxPGProperty* prop );
04341
04342 bool DoCollapse( wxPGProperty* p );
04343
04344 bool DoExpand( wxPGProperty* p );
04345
04346 void CalculateFontAndBitmapStuff( int vspacing );
04347
04350 void CheckColumnWidths( int widthChange = 0 );
04351
04354 virtual void DoDelete( wxPGProperty* item, bool doDelete = true );
04355
04356 wxSize DoFitColumns( bool allowGridResize = false );
04357
04358 wxPGProperty* DoGetItemAtY( int y ) const;
04359
04362 virtual wxPGProperty* DoInsert( wxPGProperty* parent, int index, wxPGProperty* property );
04363
04367 virtual void DoSetSplitterPosition( int pos, int splitterColumn = 0, bool allPages = false, bool fromAutoCenter = false );
04368
04369 bool EnableCategories( bool enable );
04370
04373 void EnsureVirtualHeight()
04374 {
04375 if ( m_vhCalcPending )
04376 {
04377 RecalculateVirtualHeight();
04378 m_vhCalcPending = 0;
04379 }
04380 }
04381
04383 bool DoEnableProperty( wxPGProperty* p, bool enable );
04384
04387 unsigned int GetVirtualHeight() const
04388 {
04389 wxASSERT( !m_vhCalcPending );
04390 return m_virtualHeight;
04391 }
04392
04395 unsigned int GetVirtualHeight()
04396 {
04397 EnsureVirtualHeight();
04398 return m_virtualHeight;
04399 }
04400
04405 inline unsigned int GetActualVirtualHeight() const;
04406
04407 unsigned int GetColumnCount() const
04408 {
04409 return (unsigned int) m_colWidths.size();
04410 }
04411
04412 int GetColumnMinWidth( int column ) const;
04413
04414 int GetColumnWidth( unsigned int column ) const
04415 {
04416 return m_colWidths[column];
04417 }
04418
04419 wxPropertyGrid* GetGrid() const { return m_pPropGrid; }
04420
04425 wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT );
04426
04427 const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
04428 {
04429 return ((wxPropertyGridState*)this)->GetLastItem(flags);
04430 }
04431
04432 #if wxPG_COMPATIBILITY_1_2_0
04433 wxPGProperty* GetNextCategory( wxPGProperty* id ) const;
04434
04435 wxPGProperty* GetNextProperty( wxPGProperty* id );
04436
04437 wxPGProperty* GetNextSiblingProperty( wxPGProperty* id );
04438
04439 wxPGProperty* GetPrevSiblingProperty( wxPGProperty* id );
04440
04441 wxPGProperty* GetPrevProperty( wxPGProperty* id );
04442 #endif // wxPG_COMPATIBILITY_1_2_0
04443
04444 wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
04445
04446 wxPGProperty* GetPropertyByLabel( const wxString& name, wxPGProperty* parent = NULL ) const;
04447
04448 wxVariant DoGetPropertyValues( const wxString& listname, wxPGProperty* baseparent, long flags ) const;
04449
04450 wxPGProperty* DoGetRoot() const { return m_properties; }
04451
04452
04453 int GetVirtualWidth() const
04454 {
04455 return m_width;
04456 }
04457
04463 int GetColumnFitWidth(wxClientDC& dc, wxPGProperty* pwc, unsigned int col, bool subProps) const;
04464
04468 wxPGProperty* GetSelection() const
04469 {
04470 if ( m_selection.size() == 0 )
04471 return NULL;
04472 return m_selection[0];
04473 }
04474
04475 void DoSetSelection( wxPGProperty* prop )
04476 {
04477 m_selection.clear();
04478 if ( prop )
04479 m_selection.push_back(prop);
04480 }
04481
04491 wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
04492
04493 inline bool IsDisplayed() const;
04494
04495 bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); }
04496
04498 void InitNonCatMode ();
04499
04500 void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true )
04501 {
04502 p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit);
04503 }
04504
04505 bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
04506
04509 void OnClientWidthChange( int newWidth, int widthChange, bool fromOnResize = false );
04510
04513 void RecalculateVirtualHeight()
04514 {
04515 m_virtualHeight = GetActualVirtualHeight();
04516 }
04517
04518 void SetColumnCount( int colCount );
04519
04520 void PropagateColSizeDec( int column, int decrease, int dir );
04521
04522 bool DoHideProperty( wxPGProperty* p, bool hide, int flags = wxPG_RECURSE );
04523
04524 bool DoSetPropertyValueString( wxPGProperty* p, const wxString& value );
04525
04526 bool DoSetPropertyValue( wxPGProperty* p, wxVariant& value );
04527
04528 bool DoSetPropertyValueWxObjectPtr( wxPGProperty* p, wxObject* value );
04529 void DoSetPropertyValues( const wxVariantList& list, wxPGProperty* default_category );
04530
04531 #ifdef wxPG_COMPATIBILITY_1_2_0
04532 #define SetPropertyUnspecified SetPropertyValueUnspecified
04533 #endif
04534
04535 void SetSplitterLeft( bool subProps = false );
04536
04538 void SetVirtualWidth( int width );
04539
04540 void Sort( wxPGProperty* p );
04541 void Sort();
04542
04545 void VirtualHeightChanged()
04546 {
04547 m_vhCalcPending = 1;
04548 }
04549
04550 protected:
04551
04552
04553 bool ArePropertiesAdjacent( wxPGProperty* prop1,
04554 wxPGProperty* prop2,
04555 int iterFlags = wxPG_ITERATE_VISIBLE ) const;
04556
04557 int DoGetSplitterPosition( int splitterIndex = 0 ) const;
04558
04565 int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const;
04566
04567 #ifndef DOXYGEN
04568 int PrepareToAddItem ( wxPGProperty* property, wxPGProperty* scheduledParent );
04569
04573 wxPropertyGrid* m_pPropGrid;
04574
04576 wxPGProperty* m_properties;
04577
04579 wxPGRootProperty m_regularArray;
04580
04582 wxPGRootProperty* m_abcArray;
04583
04585 wxPGHashMapS2P m_dictName;
04586
04588 wxArrayInt m_colWidths;
04589
04591 wxArrayInt m_editableColumns;
04592
04593 double m_fSplitterX;
04594
04596 wxPropertyCategory* m_currentCategory;
04597
04599 wxArrayPGProperty m_selection;
04600
04602 int m_width;
04603
04605 unsigned int m_virtualHeight;
04606
04608 unsigned char m_lastCaptionBottomnest;
04609
04614 unsigned char m_itemsAdded;
04615
04617 unsigned char m_anyModified;
04618
04619 unsigned char m_vhCalcPending;
04620
04621 #endif // #ifndef DOXYGEN
04622
04623 };
04624
04625 #endif // #ifndef SWIG
04626
04627 inline bool wxPGProperty::SetChoices( const wxArrayString& labels,
04628 const wxArrayInt& values )
04629 {
04630 wxPGChoices chs(labels,values);
04631 return SetChoices(chs);
04632 }
04633
04634
04635
04636
04637
04638 #define GetPropertyByNameI GetPropertyByNameA
04639
04640
04641 #define GetPropertyByNameWithAssert GetPropertyByNameA
04642
04643
04644
04645
04646 #define wxPG_PROP_ARG_CALL_PROLOG_0(PROPERTY) \
04647 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
04648 if ( !p ) return;
04649
04650 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(PROPERTY, RETVAL) \
04651 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
04652 if ( !p ) return RETVAL;
04653
04654 #define wxPG_PROP_ARG_CALL_PROLOG() \
04655 wxPG_PROP_ARG_CALL_PROLOG_0(wxPGProperty)
04656
04657 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL(RVAL) \
04658 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(wxPGProperty, RVAL)
04659
04660 #define wxPG_PROP_ID_CONST_CALL_PROLOG() \
04661 wxPG_PROP_ARG_CALL_PROLOG_0(const wxPGProperty)
04662
04663 #define wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(RVAL) \
04664 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(const wxPGProperty, RVAL)
04665
04666
04672 class WXDLLIMPEXP_PG wxPropertyGridInterface
04673
04674 {
04675 friend class wxPropertyGrid;
04676 friend class wxPropertyGridManager;
04677 public:
04678
04680 virtual ~wxPropertyGridInterface() { };
04681
04690 void AddPropertyChoice( wxPGPropArg id, const wxString& label, int value = wxPG_INVALID_VALUE );
04691
04704 wxPGProperty* Append( wxPGProperty* property );
04705
04706 #if wxPG_COMPATIBILITY_1_2_0
04707 wxDEPRECATED( wxPGProperty* AppendCategory( const wxString& label, const wxString& name = wxPG_LABEL ) );
04708 #endif
04709
04710 wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newproperty );
04711
04715 void BeginAddChildren( wxPGPropArg id );
04716
04719 void EndAddChildren( wxPGPropArg id );
04720
04725 void InsertPropertyChoice( wxPGPropArg id, const wxString& label, int index, int value = wxPG_INVALID_VALUE );
04726
04729 virtual void Clear() = 0;
04730
04737 bool ClearSelection( bool validation = true );
04738
04742 bool Collapse( wxPGPropArg id );
04743
04749 bool CollapseAll() { return ExpandAll(false); }
04750
04757 void DeletePropertyChoice( wxPGPropArg id, int index );
04758
04766 bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
04767
04769 bool ClearPropertyValue( wxPGPropArg id )
04770 {
04771 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
04772 p->SetValue(p->GetDefaultValue());
04773 return true;
04774 }
04775
04781 static wxPGProperty* CreatePropertyByClass(const wxString &classname,
04782 const wxString &label,
04783 const wxString &name);
04784
04793 static wxPGProperty* CreatePropertyByType(const wxString &valuetype,
04794 const wxString &label,
04795 const wxString &name);
04796
04798 void DeleteProperty( wxPGPropArg id );
04799
04808 wxPGProperty* RemoveProperty( wxPGPropArg id );
04809
04810 #if wxPG_COMPATIBILITY_1_2_0
04811
04815 wxDEPRECATED( void Delete( wxPGPropArg id ) );
04816 #endif
04817
04818 #if wxPG_COMPATIBILITY_1_2_0
04819
04823 wxDEPRECATED( bool Disable( wxPGPropArg id ) );
04824 #endif
04825
04827 bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); }
04828
04830 bool EnableProperty( wxPGPropArg id, bool enable = true );
04831
04835 bool Expand( wxPGPropArg id );
04836
04839 bool ExpandAll( bool expand = true );
04840
04846 wxArrayPGProperty GetExpandedProperties() const
04847 {
04848 wxArrayPGProperty array;
04849 GetPropertiesWithFlag(&array, wxPG_PROP_COLLAPSED, true,
04850 wxPG_ITERATE_ALL_PARENTS_RECURSIVELY|wxPG_ITERATE_HIDDEN);
04851 return array;
04852 }
04853
04858 wxPGProperty* GetFirstChild( wxPGPropArg id )
04859 {
04860 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
04861
04862 if ( !p->GetChildCount() || p->IsFlagSet(wxPG_PROP_AGGREGATE) )
04863 return wxNullProperty;
04864
04865 return p->Item(0);
04866 }
04867
04876 wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL )
04877 {
04878 return wxPropertyGridIterator( m_pState, flags, firstProp );
04879 }
04880
04881 wxPropertyGridConstIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL ) const
04882 {
04883 return wxPropertyGridConstIterator( m_pState, flags, firstProp );
04884 }
04885
04896 wxPropertyGridIterator GetIterator( int flags, int startPos )
04897 {
04898 return wxPropertyGridIterator( m_pState, flags, startPos );
04899 }
04900
04901 wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const
04902 {
04903 return wxPropertyGridConstIterator( m_pState, flags, startPos );
04904 }
04905
04910 virtual wxPGVIterator GetVIterator( int flags ) const;
04911
04916 wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL )
04917 {
04918 wxPropertyGridIterator it( m_pState, flags, wxNullProperty, 1 );
04919 return *it;
04920 }
04921
04922 const wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ) const
04923 {
04924 return ((wxPropertyGridInterface*)this)->GetFirst(flags);
04925 }
04926
04927 #if wxPG_COMPATIBILITY_1_2_0
04928
04929 wxPGProperty* GetNextSiblingProperty( wxPGPropArg id )
04930 {
04931 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
04932 return m_pState->GetNextSiblingProperty(p);
04933 }
04934 #endif
04935
04941 const wxPGAttributeStorage& GetPropertyAttributes( wxPGPropArg id ) const
04942 {
04943 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(*((const wxPGAttributeStorage*)NULL));
04944 return p->GetAttributes();
04945 }
04946
04949 void SetPropertyAttributes( wxPGPropArg id, const wxPGAttributeStorage& attributes )
04950 {
04951 wxPG_PROP_ARG_CALL_PROLOG()
04952 p->SetAttributes(attributes);
04953 }
04954
04966 void GetPropertiesWithFlag( wxArrayPGProperty* targetArr,
04967 wxPGProperty::FlagType flags,
04968 bool inverse = false,
04969 int iterFlags = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES) ) const;
04970
04973 wxVariant GetPropertyAttribute( wxPGPropArg id, const wxString& attrName ) const
04974 {
04975 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant)
04976 return p->GetAttribute(attrName);
04977 }
04978
04987 wxPGProperty* GetProperty( wxPGPropNameStr name ) const
04988 {
04989 return GetPropertyByName(name);
04990 }
04991
05000 wxPGProperty* GetPropertyByName( wxPGPropNameStr name ) const;
05001
05005 wxPGProperty* GetPropertyByName( wxPGPropNameStr name, wxPGPropNameStr subname ) const;
05006
05011 wxPGChoices& GetPropertyChoices( wxPGPropArg id );
05012
05014 wxPG_CONST_WXCHAR_PTR GetPropertyClassName( wxPGPropArg id ) const
05015 {
05016 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxPG_CONST_WXCHAR_DEFVAL)
05017 return p->GetClassName();
05018 }
05019
05021 wxPGProperty::ClientDataType GetPropertyClientData( wxPGPropArg id ) const
05022 {
05023 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05024 return p->GetClientData();
05025 }
05027 const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const
05028 {
05029 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05030 return p->GetEditorClass();
05031 }
05032
05034 wxBitmap* GetPropertyImage( wxPGPropArg id ) const
05035 {
05036 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05037 return p->GetValueImage();
05038 }
05039
05041 unsigned int GetPropertyIndex( wxPGPropArg id )
05042 {
05043 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(INT_MAX)
05044 return p->GetIndexInParent();
05045 }
05046
05048 const wxString& GetPropertyLabel( wxPGPropArg id )
05049 {
05050 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
05051 return p->GetLabel();
05052 }
05054 wxString GetPropertyName( wxPGPropArg id )
05055 {
05056 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
05057 return p->GetName();
05058 }
05059
05061 wxPGProperty* GetPropertyParent( wxPGPropArg id )
05062 {
05063 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
05064 return p->GetParent();
05065 }
05066
05067 #if wxPG_COMPATIBILITY_1_2_0
05068
05070 wxPGProperty* GetPropertyPtr( wxPGPropArg id ) const
05071 {
05072 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05073 return p;
05074 }
05075 #endif
05076
05078 wxString GetPropertyHelpString( wxPGPropArg id ) const
05079 {
05080 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
05081 return p->GetHelpString();
05082 }
05083
05088 wxString GetPropertyShortClassName( wxPGPropArg id );
05089
05090 #if wxUSE_VALIDATORS
05091
05094 wxValidator* GetPropertyValidator( wxPGPropArg id )
05095 {
05096 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05097 return p->GetValidator();
05098 }
05099 #endif
05100
05101 #ifndef SWIG
05102
05107 wxVariant GetPropertyValue( wxPGPropArg id )
05108 {
05109 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
05110 return p->GetValue();
05111 }
05112 #endif
05113
05114 wxString GetPropertyValueAsString( wxPGPropArg id ) const;
05115 long GetPropertyValueAsLong( wxPGPropArg id ) const;
05116 unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const
05117 {
05118 return (unsigned long) GetPropertyValueAsLong(id);
05119 }
05120 #ifndef SWIG
05121 int GetPropertyValueAsInt( wxPGPropArg id ) const { return (int)GetPropertyValueAsLong(id); }
05122 #endif
05123 bool GetPropertyValueAsBool( wxPGPropArg id ) const;
05124 double GetPropertyValueAsDouble( wxPGPropArg id ) const;
05125 wxObject* GetPropertyValueAsWxObjectPtr( wxPGPropArg id ) const;
05126 void* GetPropertyValueAsVoidPtr( wxPGPropArg id ) const;
05127
05128 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
05129 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
05130 if ( p->m_value.GetType() != TYPENAME ) \
05131 { \
05132 wxPGGetFailed(p,TYPENAME); \
05133 return DEFVAL; \
05134 }
05135
05136 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
05137 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
05138 if ( p->m_value.GetType() != TYPENAME ) \
05139 return DEFVAL; \
05140
05141 wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
05142 {
05143 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("arrstring"), wxArrayString())
05144 return p->m_value.GetArrayString();
05145 }
05146
05147 wxPoint GetPropertyValueAsPoint( wxPGPropArg id ) const
05148 {
05149 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxPoint"), wxPoint())
05150 return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxPoint);
05151 }
05152
05153 wxSize GetPropertyValueAsSize( wxPGPropArg id ) const
05154 {
05155 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxSize"), wxSize())
05156 return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxSize);
05157 }
05158
05159 wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const
05160 {
05161 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxLongLong"), (long) GetPropertyValueAsLong(id))
05162 return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxLongLong).GetValue();
05163 }
05164
05165 wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const
05166 {
05167 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxULongLong"), (unsigned long) GetPropertyValueAsULong(id))
05168 return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxULongLong).GetValue();
05169 }
05170
05171 wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const
05172 {
05173 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxArrayInt"), wxArrayInt())
05174 wxArrayInt arr = WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxArrayInt);
05175 return arr;
05176 }
05177
05178 #if wxUSE_DATETIME
05179 wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const
05180 {
05181 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxDateTime())
05182
05183 if ( wxStrcmp(p->m_value.GetType(),wxT("datetime")) != 0 )
05184 {
05185 wxPGGetFailed(p,wxT("datetime"));
05186 return wxDateTime();
05187 }
05188 return p->m_value.GetDateTime();
05189 }
05190 #endif
05191
05192 #if defined(SWIG) || defined(__WXPYTHON__)
05193
05196 PyObject* GetPropertyValueAsPyObject( wxPGPropArg id ) const;
05197 #endif
05198
05199 #ifndef SWIG
05200
05209 wxVariant GetPropertyValues( const wxString& listname = wxEmptyString,
05210 wxPGProperty* baseparent = NULL, long flags = 0 ) const
05211 {
05212 return m_pState->DoGetPropertyValues(listname, baseparent, flags);
05213 }
05214 #endif
05215
05216 wxString GetPropertyValueType( wxPGPropArg id )
05217 {
05218 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
05219 return p->GetType();
05220 }
05221
05222 #ifdef __WXPYTHON__
05223 ptrdiff_t GetPVTI( wxPGPropArg id )
05224 {
05225 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(1)
05226
05227 wxVariant v = p->GetValue();
05228 wxVariantData* data = v.GetData();
05229 if ( !data )
05230 return 0;
05231 return (ptrdiff_t)wxPGVariantDataGetClassInfo(data);
05232 }
05233 #endif
05234
05242 wxPGProperty* GetSelection() const;
05243
05249 const wxArrayPGProperty& GetSelectedProperties() const
05250 {
05251 return m_pState->m_selection;
05252 }
05253
05254 #ifndef SWIG
05255 wxPropertyGridState* GetState() const { return m_pState; }
05256 #endif
05257
05264 bool HideProperty( wxPGPropArg id, bool hide = true, int flags = wxPG_RECURSE );
05265
05266 #if wxPG_INCLUDE_ADVPROPS
05267
05271 static void RegisterAdditionalEditors();
05272 #else
05273 static void RegisterAdditionalEditors() { }
05274 #endif
05275
05276 #if wxPG_INCLUDE_ADVPROPS
05277
05281 static void InitAllTypeHandlers();
05282 #else
05283 static void InitAllTypeHandlers() { }
05284 #endif
05285
05328 wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newproperty );
05329
05342 wxPGProperty* Insert( wxPGPropArg parent, int index, wxPGProperty* newproperty );
05343
05344 #if wxPG_COMPATIBILITY_1_2_0
05345 wxPGProperty* InsertCategory( wxPGPropArg id, int index, const wxString& label, const wxString& name = wxPG_LABEL )
05346 {
05347 return Insert( id, index, new wxPropertyCategory(label,name) );
05348 }
05349 #endif
05350
05352 bool IsPropertyEnabled( wxPGPropArg id ) const
05353 {
05354 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05355 return (!(p->GetFlags() & wxPG_PROP_DISABLED))?true:false;
05356 }
05357
05361 virtual bool IsPropertySelected( wxPGPropArg id ) const;
05362
05364 bool IsPropertyShown( wxPGPropArg id ) const
05365 {
05366 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05367 return (!(p->GetFlags() & wxPG_PROP_HIDDEN))?true:false;
05368 }
05369
05370 #if wxPG_COMPATIBILITY_1_2_0
05371
05375 wxDEPRECATED( bool IsPropertyValueType( wxPGPropArg id, const wxChar* typestr ) const );
05376 #endif
05377
05381 bool IsPropertyExpanded( wxPGPropArg id ) const;
05382
05388 bool IsPropertyKindOf( wxPGPropArg id, wxClassInfo* info ) const
05389 {
05390 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05391 return p->IsKindOf(info);
05392 }
05393
05394 #if wxPG_COMPATIBILITY_1_2_0
05395
05401 wxDEPRECATED( bool IsModified( wxPGPropArg id ) const );
05402 #endif
05403
05405 bool IsPropertyCategory( wxPGPropArg id ) const
05406 {
05407 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05408 return p->IsCategory();
05409 }
05410
05414 bool IsPropertyModified( wxPGPropArg id ) const
05415 {
05416 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05417 return ( (p->GetFlags() & wxPG_PROP_MODIFIED) ? true : false );
05418 }
05419
05422 #ifdef wxPG_COMPATIBILITY_1_0_0
05423 bool IsPropertyValueUnspecified( wxPGPropArg id ) const
05424 #else
05425 bool IsPropertyUnspecified( wxPGPropArg id ) const
05426 #endif
05427 {
05428 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05429 return p->IsValueUnspecified();
05430 }
05431
05435 void LimitPropertyEditing( wxPGPropArg id, bool limit = true );
05436
05442 void PropertiesToNames( wxArrayString* names, const wxArrayPGProperty& properties ) const;
05443
05449 void NamesToProperties( wxArrayPGProperty* properties, const wxArrayString& names ) const;
05450
05453 virtual void RefreshGrid( wxPropertyGridState* state = NULL );
05454
05464 wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property );
05465
05471 enum EditableStateFlags
05472 {
05474 SelectionState = 0x01,
05476 ExpandedState = 0x02,
05478 ScrollPosState = 0x04,
05481 PageState = 0x08,
05483 SplitterPosState = 0x10,
05486 DescBoxState = 0x20,
05487
05491 AllStates = SelectionState |
05492 ExpandedState |
05493 ScrollPosState |
05494 PageState |
05495 SplitterPosState |
05496 DescBoxState
05497 };
05498
05521 bool RestoreEditableState( const wxString& src,
05522 int restoreStates = AllStates );
05523
05532 wxString SaveEditableState( int includedStates = AllStates ) const;
05533
05538 static void SetBoolChoices( const wxString& true_choice, const wxString& false_choice );
05539
05547 void SetExpandedProperties( const wxArrayPGProperty& array, bool expand = true )
05548 {
05549 SetPropertiesFlag(array, wxPG_PROP_COLLAPSED, expand);
05550 }
05551
05561 void SetPropertiesFlag( const wxArrayPGProperty& srcArr, wxPGProperty::FlagType flags,
05562 bool inverse = false );
05563
05570 void SetPropertyCell( wxPGPropArg id,
05571 int column,
05572 const wxString& text = wxEmptyString,
05573 const wxBitmap& bitmap = wxNullBitmap,
05574 const wxColour& fgCol = wxNullColour,
05575 const wxColour& bgCol = wxNullColour )
05576 {
05577 wxPG_PROP_ARG_CALL_PROLOG()
05578 p->SetCell( column, new wxPGCell(text, bitmap, fgCol, bgCol) );
05579 }
05580
05588 void SetPropertyChoices( wxPGPropArg id, wxPGChoices& choices)
05589 {
05590 wxPG_PROP_ARG_CALL_PROLOG()
05591 p->SetChoices(choices);
05592 }
05593
05594
05598 void SetPropertyChoicesExclusive( wxPGPropArg id )
05599 {
05600 wxPG_PROP_ARG_CALL_PROLOG()
05601 p->SetChoicesExclusive();
05602 }
05603
05617 void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName, wxVariant value, long argFlags = 0 )
05618 {
05619 DoSetPropertyAttribute(id,attrName,value,argFlags);
05620 }
05621
05622 #ifndef SWIG
05623
05629 void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor )
05630 {
05631 wxPG_PROP_ARG_CALL_PROLOG()
05632 wxCHECK_RET( editor, wxT("unknown/NULL editor") );
05633 p->SetEditor(editor);
05634 RefreshProperty(p);
05635 }
05636 #endif // #ifndef SWIG
05637
05641 void SetPropertyEditor( wxPGPropArg id, const wxString& editorName )
05642 {
05643 SetPropertyEditor(id,GetEditorByName(editorName));
05644 }
05645
05652 void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel );
05653
05658 void SetPropertyClientData( wxPGPropArg id, wxPGProperty::ClientDataType clientData )
05659 {
05660 wxPG_PROP_ARG_CALL_PROLOG()
05661 p->SetClientData(clientData);
05662 }
05663
05667 void SetPropertyValueUnspecified( wxPGPropArg id )
05668 {
05669 wxPG_PROP_ARG_CALL_PROLOG()
05670 wxVariant nullVariant;
05671 SetPropVal(p, nullVariant);
05672 }
05673
05682 void SetPropertyReadOnly( wxPGPropArg id, bool set = true, int flags = wxPG_RECURSE )
05683 {
05684 wxPG_PROP_ARG_CALL_PROLOG()
05685 if ( flags & wxPG_RECURSE )
05686 p->SetFlagRecursively(wxPG_PROP_READONLY, set);
05687 else
05688 p->ChangeFlag(wxPG_PROP_READONLY, set);
05689 }
05690
05691 #ifndef SWIG
05692
05695 void SetPropertyValues( const wxVariantList& list,
05696 wxPGPropArg defaultCategory = wxNullProperty )
05697 {
05698 wxPGProperty *p;
05699 if ( defaultCategory.HasName() ) p = defaultCategory.GetPtr(this);
05700 else p = defaultCategory.GetPtr0();
05701 m_pState->DoSetPropertyValues(list, p);
05702 }
05703
05707 void SetPropertyValues( const wxVariant& list,
05708 wxPGPropArg defaultCategory = wxNullProperty )
05709 {
05710 SetPropertyValues(list.GetList(),defaultCategory);
05711 }
05712 #endif
05713
05717 wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const
05718 {
05719 wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL)
05720 return m_pState->GetPropertyCategory(p);
05721 }
05722
05729 void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString )
05730 {
05731 wxPG_PROP_ARG_CALL_PROLOG()
05732 p->SetHelpString(helpString);
05733 }
05734
05739 void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp )
05740 {
05741 wxPG_PROP_ARG_CALL_PROLOG()
05742 p->SetValueImage(bmp);
05743 RefreshProperty(p);
05744 }
05745
05748 bool SetPropertyMaxLength( wxPGPropArg id, int maxLen );
05749
05750 #if wxUSE_VALIDATORS
05751
05753 void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator )
05754 {
05755 wxPG_PROP_ARG_CALL_PROLOG()
05756 p->SetValidator(validator);
05757 }
05758 #endif
05759
05762 void SetPropertyValueLong( wxPGPropArg id, long value )
05763 {
05764 wxVariant v(value);
05765 SetPropVal( id, v );
05766 }
05767
05768 #ifndef __WXPYTHON__
05769
05771 void SetPropertyValue( wxPGPropArg id, int value )
05772 {
05773 wxVariant v((long)value);
05774 SetPropVal( id, v );
05775 }
05776 #endif
05777
05779 void SetPropertyValueDouble( wxPGPropArg id, double value )
05780 {
05781 wxVariant v(value);
05782 SetPropVal( id, v );
05783 }
05786 void SetPropertyValueBool( wxPGPropArg id, bool value )
05787 {
05788 wxVariant v(value);
05789 SetPropVal( id, v );
05790 }
05791 #ifndef __WXPYTHON__
05792 void SetPropertyValue( wxPGPropArg id, const wxChar* value )
05793 {
05794 SetPropertyValueString( id, wxString(value) );
05795 }
05796 #endif
05797
05800 void SetPropertyValueArrstr2( wxPGPropArg id, const wxArrayString& value )
05801 {
05802 wxVariant v(value);
05803 SetPropVal( id, v );
05804 }
05805
05806
05807 #if wxUSE_DATETIME
05808 void SetPropertyValueDatetime( wxPGPropArg id, const wxDateTime& value )
05809 {
05810 wxVariant v(value);
05811 SetPropVal( id, v );
05812 }
05813 #endif
05814
05821 void SetPropertyValueString( wxPGPropArg id, const wxString& value );
05822
05825 void SetPropertyValueWxObjectPtr( wxPGPropArg id, wxObject* value )
05826 {
05827 wxVariant v(value);
05828 SetPropVal( id, v );
05829 }
05830
05831 #ifndef __WXPYTHON__
05832
05833 void SetPropertyValue( wxPGPropArg id, void* value )
05834 {
05835 wxVariant v(value);
05836 SetPropVal( id, v );
05837 }
05838 void SetPropertyValue ( wxPGPropArg id, wxObject& value )
05839 {
05840 wxVariant v(&value);
05841 SetPropVal( id, v );
05842 }
05843
05850 void SetPropertyValue( wxPGPropArg id, wxVariant value )
05851 {
05852 SetPropVal( id, value );
05853 }
05854 #endif
05855
05858 void SetPropertyValuePoint( wxPGPropArg id, const wxPoint& value )
05859 {
05860 wxVariant v = WXVARIANT(value);
05861 SetPropVal( id, v );
05862 }
05865 void SetPropertyValueSize( wxPGPropArg id, const wxSize& value )
05866 {
05867 wxVariant v = WXVARIANT(value);
05868 SetPropVal( id, v );
05869 }
05872 void SetPropertyValueLongLong( wxPGPropArg id, wxLongLong_t value )
05873 {
05874 wxVariant v = WXVARIANT(wxLongLong(value));
05875 SetPropVal( id, v );
05876 }
05879 void SetPropertyValueULongLong( wxPGPropArg id, wxULongLong_t value )
05880 {
05881 wxVariant v = WXVARIANT(wxULongLong(value));
05882 SetPropVal( id, v );
05883 }
05886 void SetPropertyValueArrint2( wxPGPropArg id, const wxArrayInt& value )
05887 {
05888 wxVariant v = WXVARIANT(value);
05889 SetPropVal( id, v );
05890 }
05893 #ifdef __WXPYTHON__
05894 void SetPropertyValuePyObject( wxPGPropArg id, PyObject* value )
05895 {
05896 wxVariant v = WXVARIANT(value);
05897 SetPropVal( id, v );
05898 }
05899 #endif
05900
05901 #ifndef SWIG
05902
05904 void SetPropVal( wxPGPropArg id, wxVariant& value );
05905 #endif
05906
05912 void SetValidationFailureBehavior( int vfbFlags );
05913
05914 #ifdef SWIG
05915 %pythoncode {
05916 def MapType(class_,factory):
05917 "Registers Python type/class to property mapping.\n\nfactory: Property builder function/class."
05918 global _type2property
05919 try:
05920 mappings = _type2property
05921 except NameError:
05922 raise AssertionError("call only after a propertygrid or manager instance constructed")
05923
05924 mappings[class_] = factory
05925
05926
05927 def DoDefaultTypeMappings(self):
05928 "Map built-in properties."
05929 global _type2property
05930 try:
05931 mappings = _type2property
05932
05933 return
05934 except NameError:
05935 mappings = {}
05936 _type2property = mappings
05937
05938 mappings[str] = StringProperty
05939 mappings[unicode] = StringProperty
05940 mappings[int] = IntProperty
05941 mappings[float] = FloatProperty
05942 mappings[bool] = BoolProperty
05943 mappings[list] = ArrayStringProperty
05944 mappings[tuple] = ArrayStringProperty
05945 mappings[wx.Font] = FontProperty
05946 mappings[wx.Colour] = ColourProperty
05947 mappings[wx.Size] = SizeProperty
05948 mappings[wx.Point] = PointProperty
05949 mappings[wx.FontData] = FontDataProperty
05950
05951
05952 def GetPropertyValue(self,p):
05953 "Returns Python object value for property.\n\nCaches getters on value type id basis for performance purposes."
05954 global _vt2getter
05955 vtid = self.GetPVTI(p)
05956 if not vtid:
05957 return None
05958 if vtid == 1:
05959 raise TypeError("Property '%s' doesn't have valid value type"%(p.GetName()))
05960 try:
05961 getter = _vt2getter[vtid]
05962 except KeyError:
05963
05964 cls = PropertyGridInterface
05965 vtn = self.GetPropertyValueType(p)
05966
05967 if vtn == 'long':
05968 getter = cls.GetPropertyValueAsLong
05969 elif vtn == 'string':
05970 getter = cls.GetPropertyValueAsString
05971 elif vtn == 'double':
05972 getter = cls.GetPropertyValueAsDouble
05973 elif vtn == 'bool':
05974 getter = cls.GetPropertyValueAsBool
05975 elif vtn == 'arrstring':
05976 getter = cls.GetPropertyValueAsArrayString
05977 elif vtn == 'wxArrayInt':
05978 getter = cls.GetPropertyValueAsArrayInt
05979 elif vtn == 'PyObject*':
05980 getter = cls.GetPropertyValueAsPyObject
05981 elif vtn == 'datetime':
05982 getter = cls.GetPropertyValueAsDateTime
05983 elif vtn == 'wxPoint':
05984 getter = cls.GetPropertyValueAsPoint
05985 elif vtn == 'wxSize':
05986 getter = cls.GetPropertyValueAsSize
05987 elif vtn.startswith('wx'):
05988 getter = cls.GetPropertyValueAsWxObjectPtr
05989 elif vtn == 'null':
05990 return None
05991 elif not vtn:
05992 if p:
05993 raise ValueError("no property with name '%s'"%p)
05994 else:
05995 raise ValueError("NULL property")
05996 else:
05997 raise AssertionError("Unregistered property grid value type '%s'"%vtn)
05998 _vt2getter[vtid] = getter
05999 return getter(self,p)
06000
06001
06002 def SetPropertyValueArrstr(self,p,v):
06003 "NB: We must implement this in Python because SWIG has problems combining"
06004 " conversion of list to wxArrayXXX and overloaded arguments."
06005 if not isinstance(p,basestring):
06006 self._SetPropertyValueArrstr(p,v)
06007 else:
06008 self._SetPropertyValueArrstr(self.GetPropertyByNameI(p),v)
06009
06010
06011 def SetPropertyValueArrint(self,p,v):
06012 "NB: We must implement this in Python because SWIG has problems combining"
06013 " conversion of list to wxArrayXXX and overloaded arguments."
06014 if not isinstance(p,basestring):
06015 self._SetPropertyValueArrint(p,v)
06016 else:
06017 self._SetPropertyValueArrint(self.GetPropertyByNameI(p),v)
06018
06019
06020 def DoDefaultValueTypeMappings(self):
06021 "Map pg value type ids to getter methods."
06022 global _vt2getter
06023 try:
06024 vt2getter = _vt2getter
06025
06026 return
06027 except NameError:
06028 vt2getter = {}
06029 _vt2getter = vt2getter
06030
06031
06032 def _GetValues(self,parent,fc,dict_,getter,inc_attributes):
06033 p = fc
06034
06035 while p:
06036 pfc = self.GetFirstChild(p)
06037 if pfc:
06038 self._GetValues(p,pfc,dict_,getter,inc_attributes)
06039 else:
06040 dict_[p.GetName()] = getter(p)
06041
06042 if inc_attributes:
06043 attrs = p.GetAttributes()
06044 if attrs and len(attrs):
06045 dict_['@%s@attr'%(p.GetName())] = attrs
06046
06047 p = self.GetNextSiblingProperty(p)
06048
06049
06050 def GetPropertyValues(self,dict_=None, as_strings=False, inc_attributes=False):
06051 "Returns values in the grid."
06052 ""
06053 "dict_: if not given, then a new one is created. dict_ can be"
06054 " object as well, in which case it's __dict__ is used."
06055 "as_strings: if True, then string representations of values"
06056 " are fetched instead of native types. Useful for config and such."
06057 "inc_attributes: if True, then property attributes are added"
06058 " as @<propname>@<attr>."
06059 ""
06060 "Return value: dictionary with values. It is always a dictionary,"
06061 "so if dict_ was object with __dict__ attribute, then that attribute"
06062 "is returned."
06063
06064 if dict_ is None:
06065 dict_ = {}
06066 elif hasattr(dict_,'__dict__'):
06067 dict_ = dict_.__dict__
06068
06069 if not as_strings:
06070 getter = self.GetPropertyValue
06071 else:
06072 getter = self.GetPropertyValueAsString
06073
06074 root = self.GetGrid().GetRoot()
06075 self._GetValues(root,self.GetFirstChild(root),dict_,getter,inc_attributes)
06076
06077 return dict_
06078
06079 GetValues = GetPropertyValues
06080
06081
06082 def SetPropertyValues(self,dict_):
06083 "Sets property values from dict_, which can be either\ndictionary or an object with __dict__ attribute."
06084 ""
06085 "autofill: If true, keys with not relevant properties"
06086 " are auto-created. For more info, see AutoFill."
06087 ""
06088 "Notes:"
06089 " * Keys starting with underscore are ignored."
06090 " * Attributes can be set with entries named @<propname>@<attr>."
06091 ""
06092
06093 autofill = False
06094
06095 if dict_ is None:
06096 dict_ = {}
06097 elif hasattr(dict_,'__dict__'):
06098 dict_ = dict_.__dict__
06099
06100 attr_dicts = []
06101
06102 def set_sub_obj(k0,dict_):
06103 for k,v in dict_.iteritems():
06104 if k[0] != '_':
06105 if k.endswith('@attr'):
06106 attr_dicts.append((k[1:-5],v))
06107 else:
06108 try:
06109 self.SetPropertyValue(k,v)
06110 except:
06111 try:
06112 if autofill:
06113 self._AutoFillOne(k0,k,v)
06114 continue
06115 except:
06116 if isinstance(v,dict):
06117 set_sub_obj(k,v)
06118 elif hasattr(v,'__dict__'):
06119 set_sub_obj(k,v.__dict__)
06120
06121
06122 for k,v in attr_dicts:
06123 p = GetPropertyByName(k)
06124 if not p:
06125 raise AssertionError("No such property: '%s'"%k)
06126 for an,av in v.iteritems():
06127 p.SetAttribute(an, av)
06128
06129
06130 cur_page = False
06131 is_manager = isinstance(self,PropertyGridManager)
06132
06133 try:
06134 set_sub_obj(self.GetGrid().GetRoot(),dict_)
06135 except:
06136 import traceback
06137 traceback.print_exc()
06138
06139 self.Refresh()
06140
06141
06142 SetValues = SetPropertyValues
06143
06144
06145 def _AutoFillMany(self,cat,dict_):
06146 for k,v in dict_.iteritems():
06147 self._AutoFillOne(cat,k,v)
06148
06149
06150 def _AutoFillOne(self,cat,k,v):
06151 global _type2property
06152
06153 factory = _type2property.get(v.__class__,None)
06154
06155 if factory:
06156 self.AppendIn( cat, factory(k,k,v) )
06157 elif hasattr(v,'__dict__'):
06158 cat2 = self.AppendIn( cat, PropertyCategory(k) )
06159 self._AutoFillMany(cat2,v.__dict__)
06160 elif isinstance(v,dict):
06161 cat2 = self.AppendIn( cat, PropertyCategory(k) )
06162 self._AutoFillMany(cat2,v)
06163 elif not k.startswith('_'):
06164 raise AssertionError("member '%s' is of unregisted type/class '%s'"%(k,v.__class__))
06165
06166
06167 def AutoFill(self,obj,parent=None):
06168 "Clears properties and re-fills to match members and\nvalues of given object or dictionary obj."
06169
06170 self.edited_objects[parent] = obj
06171
06172 cur_page = False
06173 is_manager = isinstance(self,PropertyGridManager)
06174
06175 if not parent:
06176 if is_manager:
06177 page = self.GetCurrentPage()
06178 page.Clear()
06179 parent = page.GetRoot()
06180 else:
06181 self.Clear()
06182 parent = self.GetGrid().GetRoot()
06183 else:
06184 p = self.GetFirstChild(parent)
06185 while p:
06186 self.Delete(p)
06187 p = self.GetNextSiblingProperty(p)
06188
06189 if not is_manager or page == self.GetCurrentPage():
06190 self.Freeze()
06191 cur_page = True
06192
06193 try:
06194 self._AutoFillMany(parent,obj.__dict__)
06195 except:
06196 import traceback
06197 traceback.print_exc()
06198
06199 if cur_page:
06200 self.Thaw()
06201
06202
06203 def RegisterEditor(self, editor, editorName=None):
06204 "Transform class into instance, if necessary."
06205 if not isinstance(editor, PGEditor):
06206 editor = editor()
06207 if not editorName:
06208 editorName = editor.__class__.__name__
06209 try:
06210 self._editor_instances.append(editor)
06211 except:
06212 self._editor_instances = [editor]
06213 RegisterEditor(editor, editorName)
06214
06215 }
06216 #endif
06217
06218
06219 wxPGProperty* GetPropertyByNameA( wxPGPropNameStr name ) const;
06220
06221 static wxPGEditor* GetEditorByName( const wxString& editorName );
06222
06223
06224
06225
06226 virtual void RefreshProperty( wxPGProperty* p ) = 0;
06227
06228 protected:
06229
06230 bool DoClearSelection( bool validation,
06231 int selFlags = 0 );
06232
06237 virtual bool SetEditableStateItem( const wxString& name, wxVariant value )
06238 {
06239 wxUnusedVar(name);
06240 wxUnusedVar(value);
06241 return false;
06242 }
06243
06248 virtual wxVariant GetEditableStateItem( const wxString& name ) const
06249 {
06250 wxUnusedVar(name);
06251 return wxNullVariant;
06252 }
06253
06254
06255 virtual wxPropertyGridState* GetPageState( int pageIndex ) const
06256 {
06257 if ( pageIndex <= 0 )
06258 return m_pState;
06259 return NULL;
06260 }
06261
06262 virtual bool DoSelectPage( int WXUNUSED(index) ) { return true; }
06263
06264
06265 virtual wxPGProperty* DoGetPropertyByName( wxPGPropNameStr name ) const;
06266
06267 #ifndef SWIG
06268
06269 wxPropertyGridState* m_pState;
06270
06271
06272 void DoSetPropertyAttribute( wxPGPropArg id, const wxString& name, wxVariant& value, long argFlags );
06273
06274
06275 wxString m_emptyString;
06276
06277 private:
06278
06279 wxPropertyGrid* GetPropertyGrid()
06280 {
06281 if ( !m_pState )
06282 return NULL;
06283 return m_pState->GetGrid();
06284 }
06285 const wxPropertyGrid* GetPropertyGrid() const
06286 {
06287 if ( !m_pState )
06288 return NULL;
06289 return (const wxPropertyGrid*) m_pState->GetGrid();
06290 }
06291 #endif // #ifndef SWIG
06292 };
06293
06294
06295 typedef wxPropertyGridInterface wxPropertyContainerMethods;
06296
06297
06298
06299
06300
06301 #define wxPG_SEL_FOCUS 0x0001 // Focuses to created editor
06302 #define wxPG_SEL_FORCE 0x0002 // Forces deletion and recreation of editor
06303 #define wxPG_SEL_NONVISIBLE 0x0004 // For example, doesn't cause EnsureVisible
06304 #define wxPG_SEL_NOVALIDATE 0x0008 // Do not validate editor's value before selecting
06305 #define wxPG_SEL_DELETING 0x0010 // Property being deselected is about to be deleted
06306 #define wxPG_SEL_SETUNSPEC 0x0020 // Property's values was set to unspecified by the user
06307 #define wxPG_SEL_DIALOGVAL 0x0040 // Property's event handler changed the value
06308
06309
06310
06311
06312 #define wxPG_SEL_DONT_SEND_EVENT 0x0080
06313
06314 #define wxPG_SEL_NO_REFRESH 0x0100 // Do not call Refresh()
06315
06316
06317
06318
06319 #ifndef SWIG
06320
06321
06322 #define wxPG_FL_INITIALIZED 0x0001
06323 #define wxPG_FL_ACTIVATION_BY_CLICK 0x0002 // Set when creating editor controls if it was clicked on.
06324 #define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
06325 #define wxPG_FL_FOCUSED 0x0008
06326 #define wxPG_FL_MOUSE_CAPTURED 0x0010
06327 #define wxPG_FL_MOUSE_INSIDE 0x0020
06328 #define wxPG_FL_VALUE_MODIFIED 0x0040
06329 #define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080 // don't clear background of m_wndEditor
06330 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100 // currently active editor uses custom image
06331 #define wxPG_FL_CELL_OVERRIDES_SEL 0x0200 // cell colours override selection colours for selected cell
06332 #define wxPG_FL_SCROLLED 0x0400
06333 #define wxPG_FL_ADDING_HIDEABLES 0x0800 // set when all added/inserted properties get hideable flag
06334 #define wxPG_FL_NOSTATUSBARHELP 0x1000 // Disables showing help strings on statusbar.
06335 #define wxPG_FL_CREATEDSTATE 0x2000 // Marks that we created the state, so we have to destroy it too.
06336 #define wxPG_FL_SCROLLBAR_DETECTED 0x4000 // Set if scrollbar's existence was detected in last onresize.
06337 #define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000 // Set if wxPGMan requires redrawing of description text box.
06338 #define wxPG_FL_IN_MANAGER 0x00020000 // Set if contained in wxPropertyGridManager
06339 #define wxPG_FL_GOOD_SIZE_SET 0x00040000 // Set after wxPropertyGrid is shown in its initial good size
06340 #define wxPG_FL_IGNORE_NEXT_NAVKEY 0x00080000 // Next navigation key event will get ignored
06341 #define wxPG_FL_IN_SELECT_PROPERTY 0x00100000 // Set when in SelectProperty.
06342 #define wxPG_FL_STRING_IN_STATUSBAR 0x00200000 // Set when help string is shown in status bar
06343 #define wxPG_FL_SPLITTER_PRE_SET 0x00400000 // Splitter position has been custom-set by the user
06344 #define wxPG_FL_VALIDATION_FAILED 0x00800000 // Validation failed. Clear on modify event.
06345 #define wxPG_FL_CATMODE_AUTO_SORT 0x01000000 // Auto sort is enabled (for categorized mode)
06346 #define wxPG_MAN_FL_PAGE_INSERTED 0x02000000 // Set after page has been inserted to manager
06347 #define wxPG_FL_ABNORMAL_EDITOR 0x04000000 // Active editor control is abnormally large
06348 #define wxPG_FL_IN_ONCUSTOMEDITOREVENT 0x08000000 // Recursion guard for OnCustomEditorEvent
06349 #define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
06350 #define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000 // Editor control width should not change on resize
06351 #define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000 // Width of panel can be different than width of grid
06352 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000 // Prevents RecalculateVirtualSize re-entrancy
06353
06354 #endif // #ifndef SWIG
06355
06356 #if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
06357
06358 #include "props.h"
06359 #endif
06360
06361
06362
06363 #define wxPG_USE_STATE m_pState
06364
06430
06431 class WXDLLIMPEXP_PG wxPropertyGrid : public wxScrolledWindow, public wxPropertyGridInterface
06432 {
06433 #ifndef SWIG
06434 friend class wxPropertyGridState;
06435 friend class wxPropertyGridInterface;
06436 friend class wxPropertyGridManager;
06437 friend class wxPGCanvas;
06438
06439 DECLARE_DYNAMIC_CLASS(wxPropertyGrid)
06440 #endif
06441
06442 public:
06447 #ifdef SWIG
06448 %pythonAppend wxPropertyGrid {
06449 self._setOORInfo(self)
06450 self.DoDefaultTypeMappings()
06451 self.edited_objects = {}
06452 self.DoDefaultValueTypeMappings()
06453 if not hasattr(self.__class__,'_vt2setter'):
06454 self.__class__._vt2setter = {}
06455 }
06456 %pythonAppend wxPropertyGrid() ""
06457
06458 wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
06459 const wxPoint& pos = wxDefaultPosition,
06460 const wxSize& size = wxDefaultSize,
06461 long style = wxPG_DEFAULT_STYLE,
06462 const wxChar* name = wxPyPropertyGridNameStr );
06463 %RenameCtor(PrePropertyGrid, wxPropertyGrid());
06464
06465 #else
06466
06467 wxPropertyGrid();
06468
06473 wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
06474 const wxPoint& pos = wxDefaultPosition,
06475 const wxSize& size = wxDefaultSize,
06476 long style = wxPG_DEFAULT_STYLE,
06477 const wxChar* name = wxPropertyGridNameStr );
06478
06480 virtual ~wxPropertyGrid();
06481 #endif
06482
06487 void AddActionTrigger( int action, int keycode, int modifiers = 0 );
06488
06494 static void AutoGetTranslation( bool enable );
06495
06500 bool CanClose()
06501 {
06502 return DoEditorValidate();
06503 }
06504
06509 void ClearActionTriggers( int action );
06510
06515 bool EditorValidate()
06516 {
06517 return DoEditorValidate();
06518 }
06519
06523 void CenterSplitter( bool enable_auto_centering = false );
06524
06532 bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
06533
06538 bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
06539 const wxPoint& pos = wxDefaultPosition,
06540 const wxSize& size = wxDefaultSize,
06541 long style = wxPG_DEFAULT_STYLE,
06542 const wxChar* name = wxPropertyGridNameStr );
06543
06547 virtual void Clear();
06548
06551 void ClearModifiedStatus( wxPGPropArg id )
06552 {
06553 wxPG_PROP_ARG_CALL_PROLOG()
06554 m_pState->ClearModifiedStatus(p);
06555 }
06556
06559 void ClearModifiedStatus()
06560 {
06561 m_pState->ClearModifiedStatus(m_pState->m_properties);
06562 m_pState->m_anyModified = false;
06563 }
06564
06567 bool UnfocusEditor();
06568
06569 #if wxPG_COMPATIBILITY_1_2_0
06570
06575 wxDEPRECATED( void ClearTargetPage() );
06576 #endif
06577
06579 bool EnableCategories( bool enable );
06580
06584 wxPanel* GetPanel() const
06585 {
06586 return m_canvas;
06587 }
06588
06589 const wxPGCommonValue* GetCommonValue( unsigned int i ) const
06590 {
06591 return (wxPGCommonValue*) m_commonValues[i];
06592 }
06593
06596 unsigned int GetCommonValueCount() const
06597 {
06598 return (unsigned int) m_commonValues.size();
06599 }
06600
06603 wxString GetCommonValueLabel( unsigned int i ) const
06604 {
06605 wxASSERT( GetCommonValue(i) );
06606 return GetCommonValue(i)->GetLabel();
06607 }
06608
06612 bool EnsureVisible( wxPGPropArg id );
06613
06629 wxSize FitColumns()
06630 {
06631 wxSize sz = m_pState->DoFitColumns();
06632 return sz;
06633 }
06634
06635 wxFont& GetCaptionFont() { return m_captionFont; }
06636
06637 #ifndef SWIG
06638 const wxFont& GetCaptionFont() const { return m_captionFont; }
06639 #endif
06640
06642 wxColour GetCaptionBackgroundColour() const { return m_colCapBack; }
06643
06645 wxColour GetCaptionForegroundColour() const { return m_colCapFore; }
06646
06648 wxColour GetCellBackgroundColour() const { return m_colPropBack; }
06649
06651 wxColour GetCellDisabledTextColour() const { return m_colDisPropFore; }
06652
06654 wxColour GetCellTextColour() const { return m_colPropFore; }
06655
06658 unsigned int GetChildrenCount()
06659 {
06660 return GetChildrenCount( m_pState->m_properties );
06661 }
06662
06667 unsigned int GetChildrenCount( wxPGPropArg id ) const
06668 {
06669 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
06670 return p->GetChildCount();
06671 }
06672
06673 unsigned int GetColumnCount() const
06674 {
06675 return (unsigned int) m_pState->m_colWidths.size();
06676 }
06677
06679 wxColour GetEmptySpaceColour() const { return m_colEmptySpace; }
06680
06681 #if wxPG_COMPATIBILITY_1_2_0
06682
06690 const wxPGProperty* GetFirstVisible() const
06691 {
06692 return wxPropertyGridInterface::GetFirst( wxPG_ITERATE_VISIBLE );
06693 }
06694
06695 wxPGProperty* GetFirstVisible()
06696 {
06697 return wxPropertyGridInterface::GetFirst( wxPG_ITERATE_VISIBLE );
06698 }
06699 #endif
06700
06702 int GetFontHeight() const { return m_fontHeight; }
06703
06707 wxPropertyGrid* GetGrid() { return this; }
06708
06709 #if wxPG_COMPATIBILITY_1_2_0
06710
06715 wxPGProperty* GetFirstCategory() const
06716 {
06717 return (wxPGProperty*) wxPropertyGridInterface::GetFirst( wxPG_ITERATE_CATEGORIES );
06718 }
06719
06725 wxPGProperty* GetFirstProperty()
06726 {
06727 return (wxPGProperty*) wxPropertyGridInterface::GetFirst( wxPG_ITERATE_DEFAULT );
06728 }
06729 #endif
06730
06734 wxSize GetImageSize( wxPGProperty* p = NULL, int item = -1 ) const;
06735
06736 wxRect GetImageRect( wxPGProperty* p, int item ) const;
06737
06740
06741
06745 wxPGProperty* GetItemAtY( int y ) const { return DoGetItemAtY(y); }
06746
06751 wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT )
06752 {
06753 return m_pState->GetLastItem(flags);
06754 }
06755
06756 const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
06757 {
06758 return m_pState->GetLastItem(flags);
06759 }
06760
06761 #if wxPG_COMPATIBILITY_1_2_0
06762
06767 wxPGProperty* GetLastProperty()
06768 {
06769 if ( !m_pState->m_properties->GetCount() ) return NULL;
06770 wxPGProperty* p = GetLastItem(wxPG_ITERATE_DEFAULT);
06771 if ( p->IsCategory() )
06772 return GetPrevProperty(p);
06773 return p;
06774 }
06775
06783 wxPGProperty* GetLastChild( wxPGPropArg id )
06784 {
06785 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06786
06787 if ( !p->GetChildCount() ) return wxNullProperty;
06788
06789 return p->Last();
06790 }
06796 wxPGProperty* GetLastVisible()
06797 {
06798 return GetLastItem(wxPG_ITERATE_VISIBLE);
06799 }
06800 #endif // wxPG_COMPATIBILITY_1_2_0
06801
06803 wxColour GetLineColour() const { return m_colLine; }
06804
06806 wxColour GetMarginColour() const { return m_colMargin; }
06807
06808 #if wxPG_COMPATIBILITY_1_2_0
06809
06814 wxPGProperty* GetNextProperty( wxPGPropArg id )
06815 {
06816 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06817 return m_pState->GetNextProperty(p);
06818 }
06819
06824 wxPGProperty* GetNextCategory( wxPGPropArg id ) const
06825 {
06826 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06827 return m_pState->GetNextCategory(p);
06828 }
06829
06837 wxPGProperty* GetNextVisible( wxPGPropArg id ) const
06838 {
06839 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06840 return wxPropertyGridIterator::OneStep(m_pState,wxPG_ITERATE_VISIBLE,p,1);
06841 }
06842 #endif // wxPG_COMPATIBILITY_1_2_0
06843
06844 #if wxPG_COMPATIBILITY_1_2_0
06845
06850 wxPGProperty* GetPrevProperty( wxPGPropArg id )
06851 {
06852 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
06853 return m_pState->GetPrevProperty(p);
06854 }
06859 wxPGProperty* GetPrevSiblingProperty( wxPGPropArg id )
06860 {
06861 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06862 return m_pState->GetPrevSiblingProperty(p);
06863 }
06868 wxPGProperty* GetPrevVisible( wxPGPropArg id )
06869 {
06870 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06871 return wxPropertyGridIterator::OneStep(m_pState,wxPG_ITERATE_VISIBLE,p,-1);
06872 }
06873 #endif // wxPG_COMPATIBILITY_1_2_0
06874
06876 wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const;
06877
06879 wxColour GetPropertyColour( wxPGPropArg id ) const
06880 {
06881 return GetPropertyBackgroundColour( id );
06882 }
06883
06885 wxColour GetPropertyTextColour( wxPGPropArg id ) const;
06886
06892 wxPGProperty* GetPropertyByLabel( const wxString& name ) const
06893 {
06894 return m_pState->GetPropertyByLabel(name);
06895 }
06896
06900 wxPGProperty* GetRoot() const { return m_pState->m_properties; }
06901
06903 int GetRowHeight() const { return m_lineHeight; }
06904
06905 wxPGProperty* GetSelectedProperty () const { return GetSelection(); }
06906
06908 wxPGProperty* GetSelection() const
06909 {
06910 return m_pState->GetSelection();
06911 }
06912
06914 wxColour GetSelectionBackgroundColour() const { return m_colSelBack; }
06915
06917 wxColour GetSelectionForegroundColour() const { return m_colSelFore; }
06918
06920 int GetSplitterPosition() const { return m_pState->DoGetSplitterPosition(0); }
06921
06925 wxTextCtrl* GetEditorTextCtrl() const;
06926
06929 int GetUnspecifiedCommonValue() const { return m_cvUnspecified; }
06930
06931 wxPGValidationInfo& GetValidationInfo()
06932 {
06933 return m_validationInfo;
06934 }
06935
06937 int GetVerticalSpacing() const { return (int)m_vspacing; }
06938
06940 bool HasSelection() const { return (m_pState->m_selection.size() > 0); }
06941
06942 bool HasVirtualWidth() const { return (m_iFlags & wxPG_FL_HAS_VIRTUAL_WIDTH)?true:false; }
06943
06946 wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
06947
06949 bool IsAnyModified() const { return (m_pState->m_anyModified>0); }
06950
06952 bool IsFrozen() const { return (m_frozen>0)?true:false; }
06953
06966 void OnTLPChanging( wxWindow* newTLP );
06967
06968 virtual void RefreshProperty( wxPGProperty* p );
06969
06973 void RefreshEditor();
06974
06977 void SetColumnCount( int colCount )
06978 {
06979 m_pState->SetColumnCount(colCount);
06980 Refresh();
06981 }
06982
06989 void SetSplitterLeft( bool subProps = false )
06990 {
06991 m_pState->SetSplitterLeft(subProps);
06992 }
06993
06994 #ifndef SWIG
06995
06999 static wxPGEditor* RegisterEditorClass( wxPGEditor* editor, const wxString& name,
07000 bool noDefCheck = false );
07001 #endif
07002
07005 void ResetColours();
07006
07012 void SetButtonShortcut( int keycode, bool ctrlDown = false, bool altDown = false );
07013
07016 void SetCaptionTextColour( wxPGPropArg id, const wxColour& col );
07017
07020 void SetCurrentCategory( wxPGPropArg id )
07021 {
07022 wxPG_PROP_ARG_CALL_PROLOG()
07023 wxPropertyCategory* pc = (wxPropertyCategory*)p;
07024 wxASSERT( !pc || pc->IsCategory() );
07025 m_pState->m_currentCategory = pc;
07026 }
07027
07032 void SetPropertyAttributeAll( const wxString& attrName, wxVariant value );
07033
07038 void SetPropertyBackgroundColour( wxPGPropArg id, const wxColour& col );
07039
07040 #if wxPG_COMPATIBILITY_1_2_0
07041
07048 wxDEPRECATED( void SetPropertyColour( wxPGPropArg id, const wxColour& col ) );
07049 #endif
07050
07053 void SetPropertyTextColour( wxPGPropArg id, const wxColour& col );
07054
07056 void SetPropertyColourToDefault( wxPGPropArg id );
07057
07059 void SetCaptionBackgroundColour(const wxColour& col);
07060
07062 void SetCaptionForegroundColour(const wxColour& col);
07063
07067 void SetCellBackgroundColour(const wxColour& col);
07068
07071 void SetCellDisabledTextColour(const wxColour& col);
07072
07076 void SetCellTextColour(const wxColour& col);
07077
07079 void SetEmptySpaceColour(const wxColour& col);
07080
07082 void SetLineColour(const wxColour& col);
07083
07085 void SetMarginColour(const wxColour& col);
07086
07088 void SetSelectionBackground(const wxColour& col);
07089
07091 void SetSelectionForeground(const wxColour& col);
07092
07099 void SetSplitterPosition( int newxpos, bool refresh = true )
07100 {
07101 DoSetSplitterPosition_(newxpos,refresh,0);
07102 m_iFlags |= wxPG_FL_SPLITTER_PRE_SET;
07103 }
07104
07125 void SetSortFunction( wxPGSortCallback sortFunction )
07126 {
07127 m_sortFunction = sortFunction;
07128 }
07129
07133 wxPGSortCallback GetSortFunction() const
07134 {
07135 return m_sortFunction;
07136 }
07137
07142 void SetUnspecifiedCommonValue( int index ) { m_cvUnspecified = index; }
07143
07146 void SetVirtualWidth( int width );
07147
07160 bool SelectProperty( wxPGPropArg id, bool focus = false )
07161 {
07162 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
07163 return DoSelectProperty(p, focus ? wxPG_SEL_FOCUS : 0);
07164 }
07165
07169 void SetSelection( const wxArrayPGProperty& newSelection )
07170 {
07171 DoSetSelection( newSelection, wxPG_SEL_DONT_SEND_EVENT );
07172 }
07173
07186 bool AddToSelection( wxPGPropArg id )
07187 {
07188 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
07189 return DoAddToSelection(p, wxPG_SEL_DONT_SEND_EVENT);
07190 }
07191
07196 bool RemoveFromSelection( wxPGPropArg id )
07197 {
07198 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
07199 return DoRemoveFromSelection(p, wxPG_SEL_DONT_SEND_EVENT);
07200 }
07201
07208 void MakeColumnEditable( unsigned int column, bool editable = true );
07209
07221 void BeginLabelEdit( unsigned int column = 0 )
07222 {
07223 DoBeginLabelEdit(column, wxPG_SEL_DONT_SEND_EVENT);
07224 }
07225
07233 void EndLabelEdit( bool commit = true )
07234 {
07235 DoEndLabelEdit(commit, wxPG_SEL_DONT_SEND_EVENT);
07236 }
07237
07241 wxTextCtrl* GetLabelEditor() const;
07242
07245 #ifndef SWIG
07246 void SwitchState( wxPropertyGridState* pNewState );
07247 #endif
07248
07255 void SetPropertyName( wxPGPropArg id, const wxString& newname )
07256 {
07257 wxPG_PROP_ARG_CALL_PROLOG()
07258 DoSetPropertyName( p, newname );
07259 }
07260
07267 void SetVerticalSpacing( int vspacing )
07268 {
07269 m_vspacing = (unsigned char)vspacing;
07270 CalculateFontAndBitmapStuff( vspacing );
07271 if ( !m_pState->m_itemsAdded ) Refresh();
07272 }
07273
07275 void ShowPropertyError( wxPGPropArg id, const wxString& msg )
07276 {
07277 wxPG_PROP_ARG_CALL_PROLOG()
07278 DoShowPropertyError(p, msg);
07279 }
07280
07282 void Sort();
07283
07286 void Sort( wxPGPropArg id );
07287
07291 virtual void SetWindowStyleFlag( long style );
07292
07299 void EditorsValueWasModified() { m_iFlags |= wxPG_FL_VALUE_MODIFIED; }
07300
07302 void EditorsValueWasNotModified()
07303 {
07304 m_iFlags &= ~(wxPG_FL_VALUE_MODIFIED);
07305 }
07306
07308 bool IsEditorsValueModified() const { return ( m_iFlags & wxPG_FL_VALUE_MODIFIED ) ? true : false; }
07309
07314 wxWindow* GenerateEditorButton( const wxPoint& pos, const wxSize& sz );
07315
07320 void FixPosForTextCtrl( wxWindow* ctrl,
07321 unsigned int forColumn = 1,
07322 const wxPoint& offset = wxPoint(0, 0) );
07323
07340 wxWindow* GenerateEditorTextCtrl( const wxPoint& pos,
07341 const wxSize& sz,
07342 const wxString& value,
07343 wxWindow* secondary,
07344 int extraStyle = 0,
07345 int maxLen = 0,
07346 unsigned int forColumn = 1 );
07347
07348
07349
07350 wxWindow* GenerateEditorTextCtrlAndButton( const wxPoint& pos,
07351 const wxSize& sz, wxWindow** psecondary, int limited_editing,
07352 wxPGProperty* property );
07353
07362 wxPoint GetGoodEditorDialogPosition( wxPGProperty* p,
07363 const wxSize& sz );
07364
07365
07366
07367 static wxString& ExpandEscapeSequences( wxString& dst_str, wxString& src_str );
07368
07369
07370
07371 static wxString& CreateEscapeSequences( wxString& dst_str, wxString& src_str );
07372
07375 wxRect GetPropertyRect( const wxPGProperty* p1, const wxPGProperty* p2 ) const;
07376
07381 wxWindow* GetEditorControl() const;
07382
07386 bool IsEditorFocused() const;
07387
07390 bool AdjustPosForClipperWindow( wxWindow* topCtrlWnd, int* x, int* y );
07391
07392 wxWindow* GetPrimaryEditor() const
07393 {
07394 return GetEditorControl();
07395 }
07396
07399 wxWindow* GetEditorControlSecondary() const
07400 {
07401 return m_wndEditor2;
07402 }
07403
07404 #ifdef __WXPYTHON__
07405
07406 wxRect DummywxRectTypeInit() const { return wxRect(1,2,3,4); }
07407 #endif
07408
07416 virtual bool CommitChangesFromEditor( wxUint32 flags = 0 );
07417
07418 #ifndef SWIG
07419
07425 static void ArrayStringToString( wxString& dst, const wxArrayString& src,
07426 wxChar preDelim, wxChar postDelim,
07427 int flags );
07428
07431 void OnCustomEditorEvent( wxCommandEvent &event );
07432
07433 bool HasInternalFlag( long flag ) const { return (m_iFlags & flag) ? true : false; }
07434 long GetInternalFlags() const { return m_iFlags; }
07435 void SetInternalFlag( long flag ) { m_iFlags |= flag; }
07436 void ClearInternalFlag( long flag ) { m_iFlags &= ~(flag); }
07437 void IncFrozen() { m_frozen++; }
07438 void DecFrozen() { m_frozen--; }
07439
07440 void OnComboItemPaint( wxPGCustomComboControl* pCb,int item,wxDC& dc,
07441 wxRect& rect,int flags );
07442
07443
07444 void SendNavigationKeyEvent( int dir );
07445
07448 static void DoubleToString( wxString& target,
07449 double value,
07450 int precision,
07451 bool removeZeroes,
07452 wxString* precTemplate );
07453
07459 void ValueChangeInEvent( wxVariant variant )
07460 {
07461 m_changeInEventValue = variant;
07462 m_iFlags |= wxPG_FL_VALUE_CHANGE_IN_EVENT;
07463 }
07464
07475 bool WasValueChangedInEvent() const
07476 {
07477 return (m_iFlags & wxPG_FL_VALUE_CHANGE_IN_EVENT) ? true : false;
07478 }
07479
07483 bool IsMainButtonEvent( const wxEvent& event )
07484 {
07485 return (event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) && (m_wndSecId == event.GetId());
07486 }
07487
07490 virtual bool DoPropertyChanged( wxPGProperty* p, unsigned int selFlags = 0 );
07491
07495 virtual bool PerformValidation( wxPGProperty* p, wxVariant& pendingValue );
07496
07506 bool OnValidationFailure( wxPGProperty* property, wxVariant& invalidValue );
07507
07510 void OnValidationFailureReset( wxPGProperty* property )
07511 {
07512 if ( property && property->HasFlag(wxPG_PROP_INVALID_VALUE) )
07513 {
07514 DoOnValidationFailureReset(property);
07515 property->ClearFlag(wxPG_PROP_INVALID_VALUE);
07516 }
07517 m_validationInfo.m_failureMessage.clear();
07518 }
07519
07523 virtual void DoShowPropertyError( wxPGProperty* property, const wxString& msg );
07524
07532 virtual bool DoOnValidationFailure( wxPGProperty* property, wxVariant& invalidValue );
07533
07538 virtual void DoOnValidationFailureReset( wxPGProperty* property );
07539
07540 int GetSpacingY() const { return m_spacingy; }
07541
07547 void SetupTextCtrlValue( const wxString text ) { m_prevTcValue = text; }
07548
07549 void DrawItem( wxPGProperty* p )
07550 {
07551 DrawItems(p,p);
07552 }
07553
07554 virtual void DrawItemAndChildren( wxPGProperty* p );
07555
07557 void DrawItemAndValueRelated( wxPGProperty* p );
07558
07559 protected:
07560
07565 virtual wxPropertyGridState* CreateState() const;
07566
07567 #ifndef DOXYGEN
07568 public:
07569
07570
07571 void SetCurControlBoldFont();
07572
07573
07574
07575
07576 bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
07577
07578
07579 virtual bool Destroy();
07580 virtual wxSize DoGetBestSize() const;
07581 virtual void Refresh( bool eraseBackground = true,
07582 const wxRect *rect = (const wxRect *) NULL );
07583 virtual bool SetFont( const wxFont& font );
07584 #if wxPG_SUPPORT_TOOLTIPS
07585 void SetToolTip( const wxString& tipString );
07586 #endif
07587 virtual void Freeze();
07588 virtual void SetExtraStyle( long exStyle );
07589 virtual void Thaw();
07590 virtual bool Reparent( wxWindowBase *newParent );
07591
07592 protected:
07593
07594 #ifndef wxPG_ICON_WIDTH
07595 wxBitmap *m_expandbmp, *m_collbmp;
07596 #endif
07597
07598 wxCursor *m_cursorSizeWE;
07599
07601 wxWindow *m_wndEditor;
07602 wxWindow *m_wndEditor2;
07603
07605 wxPanel *m_canvas;
07606
07607 #if wxPG_DOUBLE_BUFFER
07608 wxBitmap *m_doubleBuffer;
07609 #endif
07610
07611 wxArrayPtrVoid *m_windowsToDelete;
07612
07614 wxLongLong m_timeCreated;
07615
07617 wxVariant m_changeInEventValue;
07618
07620 int m_wndSecId;
07621
07623 int m_spacingy;
07624
07626 int m_width;
07627
07629 int m_height;
07630
07632 int m_ncWidth;
07633
07635
07636
07638 int m_prevVY;
07639
07642 int m_gutterWidth;
07643
07645 int m_lineHeight;
07646
07648 int m_marginWidth;
07649
07650 int m_buttonSpacingY;
07651
07653 int m_subgroup_extramargin;
07654
07656 int m_iconWidth;
07657
07658 #ifndef wxPG_ICON_WIDTH
07659
07661 int m_iconHeight;
07662 #endif
07663
07665 int m_curcursor;
07666
07669 wxFont m_captionFont;
07670
07671 int m_fontHeight;
07672
07673 int m_pushButKeyCode;
07674
07676 int m_startingSplitterX;
07677
07679 int m_draggedSplitter;
07680
07682 wxPGProperty* m_chgInfo_changedProperty;
07683
07685 wxPGProperty* m_chgInfo_baseChangedProperty;
07686
07688 wxVariant m_chgInfo_pendingValue;
07689
07691 wxVariant m_chgInfo_valueList;
07692
07694 wxPGValidationInfo m_validationInfo;
07695
07697 wxPGHashMapI2I m_actionTriggers;
07698
07699
07700
07701
07702
07704 unsigned short m_coloursCustomized;
07705
07707 signed char m_dragOffset;
07708
07710 unsigned char m_dragStatus;
07711
07713 unsigned char m_mouseSide;
07714
07716 unsigned char m_editorFocused;
07717
07719
07720
07722 unsigned char m_frozen;
07723
07724 unsigned char m_vspacing;
07725
07726 unsigned char m_pushButKeyCodeNeedsAlt;
07727
07728 unsigned char m_pushButKeyCodeNeedsCtrl;
07729
07730 unsigned char m_keyComboConsumed;
07731
07733 unsigned char m_inDoPropertyChanged;
07734
07736 unsigned char m_inCommitChangesFromEditor;
07737
07739 unsigned char m_inDoSelectProperty;
07740
07741 wxPGVFBFlags m_permanentValidationFailureBehavior;
07742
07744 wxUint32 m_iFlags;
07745
07747 int m_clearThisMany;
07748
07749
07750 unsigned int m_colHover;
07751
07752 wxPGProperty* m_propHover;
07753
07754
07755 wxWindow* m_labelEditor;
07756
07757
07758 wxPGProperty* m_labelEditorProperty;
07759
07760 wxWindow* m_eventObject;
07761
07762 wxWindow* m_curFocused;
07763
07764
07765
07766 wxWindow* m_tlpClosed;
07767
07768
07769 wxLongLong m_tlpClosedTime;
07770
07771 wxWindow* m_tlp;
07772
07773
07774 wxPropertyGridEvent* m_processedEvent;
07775
07776 wxPGSortCallback m_sortFunction;
07777
07778 int m_propHoverY;
07779 unsigned int m_selColumn;
07780
07781 int m_ctrlXAdjust;
07782
07783 wxColour m_colLine;
07784 wxColour m_colPropFore;
07785 wxColour m_colDisPropFore;
07786 wxColour m_colPropBack;
07787 wxColour m_colCapFore;
07788 wxColour m_colCapBack;
07789 wxColour m_colSelFore;
07790 wxColour m_colSelBack;
07791 wxColour m_colMargin;
07792 wxColour m_colEmptySpace;
07793
07794 wxArrayPtrVoid m_visPropArray;
07795
07796
07797 wxArrayPtrVoid m_arrBgBrushes;
07798 wxArrayPtrVoid m_arrFgCols;
07799
07800 wxArrayPtrVoid m_commonValues;
07801 int m_cvUnspecified;
07802
07803 wxString m_prevTcValue;
07804
07805 protected:
07806
07807
07808 void Init1();
07809
07810
07811 void Init2();
07812
07813 void OnPaint(wxPaintEvent &event );
07814
07815
07816 void OnMouseMove( wxMouseEvent &event );
07817 void OnMouseMoveBottom( wxMouseEvent &event );
07818 void OnMouseClick( wxMouseEvent &event );
07819 void OnMouseRightClick( wxMouseEvent &event );
07820 void OnMouseDoubleClick( wxMouseEvent &event );
07821 void OnMouseUp( wxMouseEvent &event );
07822 void OnKey( wxKeyEvent &event );
07823 void OnKeyUp( wxKeyEvent &event );
07824 void OnNavigationKey( wxNavigationKeyEvent& event );
07825 void OnResize( wxSizeEvent &event );
07826
07827
07828 bool HandleMouseMove( int x, unsigned int y, wxMouseEvent &event );
07829 bool HandleMouseClick( int x, unsigned int y, wxMouseEvent &event );
07830 bool HandleMouseRightClick( int x, unsigned int y, wxMouseEvent &event );
07831 bool HandleMouseDoubleClick( int x, unsigned int y, wxMouseEvent &event );
07832 bool HandleMouseUp( int x, unsigned int y, wxMouseEvent &event );
07833 void HandleKeyEvent( wxKeyEvent &event );
07834 bool HandleChildKey( wxKeyEvent& event );
07835
07836 void OnMouseEntry( wxMouseEvent &event );
07837
07838 void OnIdle( wxIdleEvent &event );
07839 void OnFocusEvent( wxFocusEvent &event );
07840 void OnChildFocusEvent( wxChildFocusEvent& event );
07841
07842 bool OnMouseCommon( wxMouseEvent &event, int* px, int *py );
07843 bool OnMouseChildCommon( wxMouseEvent &event, int* px, int *py );
07844
07845
07846 void OnMouseClickChild( wxMouseEvent &event );
07847 void OnMouseRightClickChild( wxMouseEvent &event );
07848 void OnMouseMoveChild( wxMouseEvent &event );
07849 void OnMouseUpChild( wxMouseEvent &event );
07850 void OnChildKeyDown( wxKeyEvent &event );
07851 void OnChildKeyUp( wxKeyEvent &event );
07852
07853 void OnCaptureChange( wxMouseCaptureChangedEvent &event );
07854
07855 void OnScrollEvent( wxScrollWinEvent &event );
07856
07857 void OnSysColourChanged( wxSysColourChangedEvent &event );
07858
07859 void OnTLPClose( wxCloseEvent& event );
07860
07861 protected:
07862
07863 bool AddToSelectionFromInputEvent( wxPGProperty* prop,
07864 unsigned int colIndex,
07865 wxMouseEvent* event = NULL,
07866 int selFlags = 0 );
07867
07872 void CalculateFontAndBitmapStuff( int vspacing );
07873
07874 wxRect GetEditorWidgetRect( wxPGProperty* p, int column ) const;
07875
07876 void CorrectEditorWidgetSizeX();
07877
07881 void CorrectEditorWidgetPosY();
07882
07883 #ifdef __WXDEBUG__
07884 void _log_items();
07885 void OnScreenNote( const wxChar* format, ... );
07886 #endif
07887
07888 int DoDrawItems( wxDC& dc,
07889 const wxPGProperty* first_item,
07890 const wxPGProperty* last_item,
07891 const wxRect* clip_rect,
07892 bool isBuffered ) const;
07893
07896 virtual void DrawExpanderButton( wxDC& dc, const wxRect& rect,
07897 wxPGProperty* property ) const;
07898
07900 void DrawItems( wxDC& dc, unsigned int topitemy, unsigned int bottomitemy,
07901 const wxRect* clip_rect = (const wxRect*) NULL );
07902
07903 void DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 );
07904
07905 #if wxPG_COMPATIBILITY_1_2_0
07906
07907 wxPGProperty& GetPropertyById( wxPGPropArg id )
07908 {
07909 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(*((wxPGProperty*)NULL))
07910 return *p;
07911 }
07912 #endif
07913
07914
07915 int KeyEventToActions(wxKeyEvent &event, int* pSecond) const;
07916
07917 int KeyEventToAction(wxKeyEvent &event) const
07918 {
07919 return KeyEventToActions(event, NULL);
07920 }
07921
07922 void ImprovedClientToScreen( int* px, int* py );
07923
07924
07925 void HandleFocusChange( wxWindow* newFocused );
07926
07928 void RegainColours();
07929
07930 bool DoEditorValidate();
07931
07932
07933
07934
07935 bool DoSelectAndEdit( wxPGProperty* prop,
07936 unsigned int colIndex,
07937 unsigned int selFlags );
07938
07939 void DoSetSelection( const wxArrayPGProperty& newSelection,
07940 int selFlags = 0 );
07941
07942 bool DoAddToSelection( wxPGProperty* prop,
07943 int selFlags = 0 );
07944
07945 bool DoRemoveFromSelection( wxPGProperty* prop,
07946 int selFlags = 0 );
07947
07948 void DoBeginLabelEdit( unsigned int colIndex, int selFlags = 0 );
07949 void DoEndLabelEdit( bool commit, int selFlags = 0 );
07950 void OnLabelEditorEnterPress( wxCommandEvent& event );
07951 void OnLabelEditorKeyPress( wxKeyEvent& event );
07952
07953 wxPGProperty* DoGetItemAtY( int y ) const;
07954
07955 void DoSetSplitterPosition_( int newxpos, bool refresh = true, int splitterIndex = 0, bool allPages = false );
07956
07957 void DestroyEditorWnd( wxWindow* wnd );
07958 void FreeEditors();
07959
07960 virtual bool DoExpand( wxPGProperty* p, bool sendEvent = false );
07961
07962 virtual bool DoCollapse( wxPGProperty* p, bool sendEvent = false );
07963
07964
07965
07966
07967 wxPGProperty* GetNearestPaintVisible( wxPGProperty* p ) const;
07968
07969 static void RegisterDefaultEditors();
07970
07971
07972 void SetBackgroundColourIndex( wxPGProperty* p, int index );
07973
07974
07975 void SetTextColourIndex( wxPGProperty* p, int index, int flags );
07976
07977 int CacheColour( const wxColour& colour );
07978
07979 void DoSetPropertyName( wxPGProperty* p, const wxString& newname );
07980
07981
07982 void SetupEventHandling( wxWindow* wnd, int id );
07983
07984 void CustomSetCursor( int type, bool override = false );
07985
07986 virtual bool ProcessEvent(wxEvent& event);
07987
07990 void RecalculateVirtualSize( int forceXPos = -1 );
07991
07992 void PrepareAfterItemsAdded();
07993
07994
07995 bool SendEvent( int eventType, wxPGProperty* p,
07996 wxVariant* pValue = NULL,
07997 unsigned int selFlags = wxPG_SEL_NOVALIDATE,
07998 unsigned int column = 1 );
07999
08000 void SetFocusOnCanvas()
08001 {
08002 m_canvas->SetFocusIgnoringChildren();
08003 m_editorFocused = 0;
08004 }
08005
08006 bool DoHideProperty( wxPGProperty* p, bool hide, int flags );
08007
08008 private:
08009
08010 bool ButtonTriggerKeyTest( wxKeyEvent &event );
08011
08012 #endif // DOXYGEN_SHOULD_SKIP_THIS
08013
08014 private:
08015 DECLARE_EVENT_TABLE()
08016 #endif // #ifndef SWIG
08017 };
08018
08019 #undef wxPG_USE_STATE
08020
08021
08022
08023
08024
08025
08026 #ifndef SWIG
08027 inline bool wxPropertyGridState::IsDisplayed() const
08028 {
08029 return ( this == m_pPropGrid->GetState() );
08030 }
08031
08032 inline unsigned int wxPropertyGridState::GetActualVirtualHeight() const
08033 {
08034 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
08035 }
08036 #endif
08037
08038 inline int wxPGProperty::GetDisplayedCommonValueCount() const
08039 {
08040 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE) )
08041 {
08042 wxPropertyGrid* pg = GetGrid();
08043 if ( pg )
08044 return (int) pg->GetCommonValueCount();
08045 }
08046 return 0;
08047 }
08048
08049 inline void wxPGProperty::SetEditor( const wxString& editorName )
08050 {
08051 m_customEditor = wxPropertyGridInterface::GetEditorByName(editorName);
08052 }
08053
08054 inline bool wxPGProperty::Hide( bool hide, int flags )
08055 {
08056 return GetGrid()->HideProperty(this, hide, flags);
08057 }
08058
08059 inline bool wxPGProperty::SetMaxLength( int maxLen )
08060 {
08061 return GetGrid()->SetPropertyMaxLength(this,maxLen);
08062 }
08063
08064
08065
08066
08067 #ifndef SWIG
08068
08069 #define wxPG_BASE_EVT_PRE_ID 1775
08070
08071 BEGIN_DECLARE_EVENT_TYPES()
08072 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_SELECTED, wxPG_BASE_EVT_PRE_ID)
08073 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_CHANGING, wxPG_BASE_EVT_PRE_ID+1)
08074 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_CHANGED, wxPG_BASE_EVT_PRE_ID+2)
08075 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_HIGHLIGHTED, wxPG_BASE_EVT_PRE_ID+3)
08076 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_RIGHT_CLICK, wxPG_BASE_EVT_PRE_ID+4)
08077 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_PAGE_CHANGED, wxPG_BASE_EVT_PRE_ID+5)
08078 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_ITEM_COLLAPSED, wxPG_BASE_EVT_PRE_ID+6)
08079 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_ITEM_EXPANDED, wxPG_BASE_EVT_PRE_ID+7)
08080 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_DOUBLE_CLICK, wxPG_BASE_EVT_PRE_ID+8)
08081 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_LABEL_EDIT_BEGIN, wxPG_BASE_EVT_PRE_ID+9)
08082 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_LABEL_EDIT_ENDING, wxPG_BASE_EVT_PRE_ID+10)
08083 END_DECLARE_EVENT_TYPES()
08084 #else
08085 enum {
08086 wxEVT_PG_SELECTED = wxPG_BASE_EVT_PRE_ID,
08087 wxEVT_PG_CHANGING,
08088 wxEVT_PG_CHANGED,
08089 wxEVT_PG_HIGHLIGHTED,
08090 wxEVT_PG_RIGHT_CLICK,
08091 wxEVT_PG_PAGE_CHANGED,
08092 wxEVT_PG_ITEM_COLLAPSED,
08093 wxEVT_PG_ITEM_EXPANDED,
08094 wxEVT_PG_DOUBLE_CLICK,
08095 wxEVT_PG_LABEL_EDIT_BEGIN,
08096 wxEVT_PG_LABEL_EDIT_ENDING
08097 };
08098 #endif
08099
08100
08101 #define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
08102 #define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
08103
08104
08105 #ifndef SWIG
08106 typedef void (wxEvtHandler::*wxPropertyGridEventFunction)(wxPropertyGridEvent&);
08107
08108 #define EVT_PG_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08109 #define EVT_PG_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08110 #define EVT_PG_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08111 #define EVT_PG_HIGHLIGHTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08112 #define EVT_PG_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08113 #define EVT_PG_DOUBLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08114 #define EVT_PG_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08115 #define EVT_PG_ITEM_COLLAPSED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08116 #define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08117 #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 ),
08118 #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 ),
08119
08120 #define wxPropertyGridEventHandler(A) ((wxObjectEventFunction)(wxEventFunction)(wxPropertyGridEventFunction)&A)
08121
08122 #endif
08123
08124
08141 class WXDLLIMPEXP_PG wxPropertyGridEvent : public wxCommandEvent
08142 {
08143 public:
08144
08146 wxPropertyGridEvent(wxEventType commandType=0, int id=0);
08147 #ifndef SWIG
08148
08149 wxPropertyGridEvent(const wxPropertyGridEvent& event);
08150 #endif
08151
08152 ~wxPropertyGridEvent();
08153
08155 virtual wxEvent* Clone() const;
08156
08158 void EnableProperty( bool enable = true )
08159 {
08160 m_pg->EnableProperty(m_property,enable);
08161 }
08162
08164 void DisableProperty()
08165 {
08166 m_pg->EnableProperty(m_property,false);
08167 }
08168
08172 unsigned int GetColumn() const
08173 {
08174 return m_column;
08175 }
08176
08177 wxPGProperty* GetMainParent() const
08178 {
08179 wxASSERT(m_property);
08180 return m_property->GetMainParent();
08181 }
08182
08184 wxPGProperty* GetProperty() const
08185 {
08186 return m_property;
08187 }
08188
08189 #if wxPG_COMPATIBILITY_1_2_0
08190 #ifndef SWIG
08191
08195 wxPGProperty* GetPropertyPtr() const
08196 {
08197 return m_property;
08198 }
08199 #endif
08200 #endif
08201
08203 const wxString& GetPropertyLabel() const
08204 {
08205 wxASSERT( m_property );
08206 return m_property->GetLabel();
08207 }
08208
08210 wxString GetPropertyName() const
08211 {
08212 wxASSERT( m_property );
08213 return m_property->GetName();
08214 }
08215
08217 wxPGProperty::ClientDataType GetPropertyClientData() const
08218 {
08219 wxASSERT( m_property );
08220 return m_property->GetClientData();
08221 }
08222
08223 #ifndef SWIG
08224
08225 wxVariant GetPropertyValue() const
08226 {
08227 wxASSERT( m_property );
08228 return m_property->GetValue();
08229 }
08230
08231 wxString GetPropertyValueAsString() const
08232 {
08233 return m_pg->GetPropertyValueAsString( m_property );
08234 }
08235 long GetPropertyValueAsLong() const
08236 {
08237 return m_pg->GetPropertyValueAsLong( m_property );
08238 }
08239 int GetPropertyValueAsInt() const
08240 {
08241 return (int)GetPropertyValueAsLong();
08242 }
08243 long GetPropertyValueAsBool() const
08244 {
08245 return m_pg->GetPropertyValueAsBool( m_property );
08246 }
08247 double GetPropertyValueAsDouble() const
08248 {
08249 return m_pg->GetPropertyValueAsDouble( m_property );
08250 }
08251 const wxObject* GetPropertyValueAsWxObjectPtr() const
08252 {
08253 return m_pg->GetPropertyValueAsWxObjectPtr( m_property );
08254 }
08255 void* GetPropertyValueAsVoidPtr() const
08256 {
08257 return m_pg->GetPropertyValueAsVoidPtr( m_property );
08258 }
08259 wxArrayString GetPropertyValueAsArrayString() const
08260 {
08261 return m_pg->GetPropertyValueAsArrayString( m_property );
08262 }
08263 wxPoint GetPropertyValueAsPoint() const
08264 {
08265 return m_pg->GetPropertyValueAsPoint( m_property );
08266 }
08267 wxSize GetPropertyValueAsSize() const
08268 {
08269 return m_pg->GetPropertyValueAsSize( m_property );
08270 }
08271 wxArrayInt GetPropertyValueAsArrayInt() const
08272 {
08273 return m_pg->GetPropertyValueAsArrayInt( m_property );
08274 }
08275
08276 #else
08277 %pythoncode {
08278 def GetPropertyValue(self):
08279 return self.GetProperty().GetValue()
08280 }
08281 #endif
08282
08283 wxPGValidationInfo& GetValidationInfo()
08284 {
08285 wxASSERT(m_validationInfo);
08286 return *m_validationInfo;
08287 }
08288
08290 bool HasProperty() const { return ( m_property != (wxPGProperty*) NULL ); }
08291
08292 bool IsPropertyEnabled() const
08293 {
08294 return m_pg->IsPropertyEnabled(m_property);
08295 }
08296
08299 bool CanVeto() const { return m_canVeto; }
08300
08306 void Veto( bool veto = true ) { m_wasVetoed = veto; }
08307
08310 const wxVariant& GetValue() const
08311 {
08312 wxASSERT_MSG( m_validationInfo,
08313 wxT("Only call GetValue from a handler of event type that supports it") );
08314 return *m_validationInfo->m_pValue;
08315 }
08316
08320 void SetValidationFailureBehavior( int flags )
08321 {
08322 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
08323 m_validationInfo->m_failureBehavior = (wxPGVFBFlags) flags;
08324 }
08325
08329 void SetValidationFailureMessage( const wxString& message )
08330 {
08331 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
08332 m_validationInfo->m_failureMessage = message;
08333 }
08334
08335 #ifndef SWIG
08336 wxPGVFBFlags GetValidationFailureBehavior() const
08337 {
08338 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
08339 return m_validationInfo->m_failureBehavior;
08340 }
08341
08342 void SetCanVeto( bool canVeto ) { m_canVeto = canVeto; }
08343 bool WasVetoed() const { return m_wasVetoed; }
08344
08346 void SetProperty( wxPGProperty* p ) { m_property = p; }
08347
08348 void SetPropertyGrid( wxPropertyGrid* pg ) { m_pg = pg; }
08349
08350 void SetupValidationInfo()
08351 {
08352 wxASSERT(m_pg);
08353 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
08354 m_validationInfo = &m_pg->GetValidationInfo();
08355 }
08356
08357 void SetColumn( unsigned int column )
08358 {
08359 m_column = column;
08360 }
08361
08362 private:
08363 void Init();
08364 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent)
08365
08366 wxPGProperty* m_property;
08367 wxPropertyGrid* m_pg;
08368 wxPGValidationInfo* m_validationInfo;
08369
08370 unsigned int m_column;
08371
08372 bool m_canVeto;
08373 bool m_wasVetoed;
08374
08375 #endif
08376 };
08377
08378
08379
08380
08385 class WXDLLIMPEXP_PG wxPropertyGridPopulator
08386 {
08387 public:
08390 wxPropertyGridPopulator();
08391
08393 virtual ~wxPropertyGridPopulator();
08394
08395 void SetState( wxPropertyGridState* state );
08396
08397 void SetGrid( wxPropertyGrid* pg );
08398
08403 wxPGProperty* Add( const wxString& propClass,
08404 const wxString& propLabel,
08405 const wxString& propName,
08406 const wxString* propValue,
08407 wxPGChoices* pChoices = NULL );
08408
08413 void AddChildren( wxPGProperty* property );
08414
08420 bool AddAttribute( const wxString& name,
08421 const wxString& type,
08422 const wxString& value );
08423
08426 virtual void DoScanForChildren() = 0;
08427
08429 wxPGProperty* GetCurParent() const
08430 {
08431 return (wxPGProperty*) m_propHierarchy[m_propHierarchy.size()-1];
08432 }
08433
08434 wxPropertyGridState* GetState() { return m_state; }
08435 const wxPropertyGridState* GetState() const { return m_state; }
08436
08439 static bool ToLongPCT( const wxString& s, long* pval, long max );
08440
08446 wxPGChoices ParseChoices( const wxString& choicesString,
08447 const wxString& idString );
08448
08452 virtual void ProcessError( const wxString& msg );
08453
08454 protected:
08455
08457 wxPropertyGrid* m_pg;
08458
08460 wxPropertyGridState* m_state;
08461
08463 wxArrayPGProperty m_propHierarchy;
08464
08466 wxPGHashMapS2P m_dictIdChoices;
08467 };
08468
08469
08470
08471
08472
08473
08474 #ifndef __wxPG_SOURCE_FILE__
08475 #undef wxPG_FL_DESC_REFRESH_REQUIRED
08476 #undef wxPG_FL_SCROLLBAR_DETECTED
08477 #undef wxPG_FL_CREATEDSTATE
08478 #undef wxPG_FL_NOSTATUSBARHELP
08479 #undef wxPG_FL_SCROLLED
08480 #undef wxPG_FL_FOCUS_INSIDE_CHILD
08481 #undef wxPG_FL_FOCUS_INSIDE
08482 #undef wxPG_FL_MOUSE_INSIDE_CHILD
08483 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
08484 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
08485 #undef wxPG_FL_VALUE_MODIFIED
08486 #undef wxPG_FL_MOUSE_INSIDE
08487 #undef wxPG_FL_FOCUSED
08488 #undef wxPG_FL_MOUSE_CAPTURED
08489 #undef wxPG_FL_INITIALIZED
08490 #undef wxPG_FL_ACTIVATION_BY_CLICK
08491 #undef wxPG_FL_DONT_CENTER_SPLITTER
08492 #undef wxPG_SUPPORT_TOOLTIPS
08493 #undef wxPG_DOUBLE_BUFFER
08494 #undef wxPG_ICON_WIDTH
08495 #undef wxPG_USE_RENDERER_NATIVE
08496
08497
08498 #endif
08499
08500
08501 #ifdef DOXYGEN
08502 #include "editor.h"
08503 #include "manager.h"
08504 #endif
08505
08506
08507
08508 #endif // __WX_PROPGRID_PROPGRID_H__
08509