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 15
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 wxPGComboCtrl wxComboCtrl
00229 #define wxPGOwnerDrawnComboBox wxOwnerDrawnComboBox
00230 #define wxPGCC_DCLICK_CYCLES wxCC_SPECIAL_DCLICK
00231 #define wxPGCC_PAINTING_CONTROL wxODCB_PAINTING_CONTROL
00232 #define wxPGCC_PAINTING_SELECTED wxODCB_PAINTING_SELECTED
00233 #define wxPGCC_PROCESS_ENTER wxTE_PROCESS_ENTER
00234 #define wxPGCC_ALT_KEYS 0
00235 #else
00236 #define wxPGComboCtrl wxPGComboControl
00237 #endif
00238
00239
00240 #if !wxCHECK_VERSION(2,7,1)
00241 #define wxPGRectContains Inside
00242 #else
00243 #define wxPGRectContains Contains
00244 #endif
00245
00246 #if wxCHECK_VERSION(2,7,0)
00247 #define wxPGIndex unsigned int
00248 #else
00249 #define wxPGIndex int
00250 #endif
00251
00252 #ifdef __WXMSW__
00253 #if wxCHECK_VERSION(2,9,0)
00254 #define wxPG_GetHDCOf(DC) ((HDC)((const wxMSWDCImpl *)DC.GetImpl())->GetHDC())
00255 #else
00256 #define wxPG_GetHDCOf(DC) ((HDC)DC.GetHDC())
00257 #endif
00258 #endif
00259
00260
00261 #if !wxCHECK_VERSION(2,8,0)
00262 #ifndef wxBORDER_THEME
00263 #define wxBORDER_THEME wxSIMPLE_BORDER
00264 #endif
00265 #endif
00266
00267 #if wxCHECK_VERSION(2,8,0)
00268 #define wxGDI_IS_OK(OBJ) ((OBJ).IsOk())
00269 #else
00270 #define wxGDI_IS_OK(OBJ) ((OBJ).Ok())
00271 #endif
00272
00273
00274
00275 #ifndef wxPG_COMPATIBILITY_1_2_0
00276 #define wxPG_COMPATIBILITY_1_2_0 1
00277 #endif
00278
00279
00280 #if wxPG_COMPATIBILITY_1_2_0
00281
00282
00283 #define wxPG_VERSION ((wxPROPGRID_MAJOR*1000)+(wxPROPGRID_MINOR*100)+(wxPROPGRID_RELEASE*10))
00284
00285 #endif
00286
00287
00288 #ifdef wxPG_COMPATIBILITY_1_0_0
00289
00290 #define wxRECURSE wxPG_RECURSE
00291 #define wxKEEP_STRUCTURE wxPG_KEEP_STRUCTURE
00292 #define wxPGConstants wxPGChoices
00293 #define wxPG_EX_CLASSIC_SPACING 0
00294
00295 #define wxPGCtrlClass wxWindow
00296 #define wxCCustomTextCtrl wxTextCtrl
00297 #define wxCCustomComboBox wxPGOwnerDrawnComboBox
00298 #define wxCCustomButton wxButton
00299
00300 #endif // #ifdef wxPG_COMPATIBILITY_1_0_0
00301
00302 #ifdef __WXPYTHON__
00303 #define wxPG_VALUETYPE_IS_STRING 0 // 1
00304 #else
00305 #define wxPG_VALUETYPE_IS_STRING 0
00306 #endif
00307
00308 #ifndef SWIG
00309 #if !wxCHECK_VERSION(2,9,0)
00310 #if !defined(wxUniChar)
00311 #define wxUniChar wxChar
00312 #endif
00313
00314 #define wxPGGetIterChar(str, i) *i
00315 #else
00316 #define wxPGGetIterChar(str, i) *i
00317 #endif
00318 #endif
00319
00320 #if wxPG_COMPATIBILITY_1_2_0
00321 #define wxPGRegisterPropertyClass(A)
00322 #endif
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 #ifndef __WXPYTHON__
00335
00336
00337
00338
00339 #define wxPG_CONST_WXCHAR_PTR const wxChar*
00340 #define wxPG_CONST_WXCHAR_DEFVAL ((const wxChar*)NULL)
00341 #define wxPG_TO_WXCHAR_PTR(A) A
00342
00343
00344 #define SetPropertyValueLong SetPropertyValue
00345 #define SetPropertyValueDouble SetPropertyValue
00346 #define SetPropertyValueBool SetPropertyValue
00347 #define SetPropertyValueString SetPropertyValue
00348 #define SetPropertyValueWxObjectPtr SetPropertyValue
00349 #define SetPropertyValuePoint SetPropertyValue
00350 #define SetPropertyValueSize SetPropertyValue
00351 #define SetPropertyValueArrint2 SetPropertyValue
00352 #define SetPropertyValueArrstr2 SetPropertyValue
00353 #define SetPropertyValueDatetime SetPropertyValue
00354 #define SetPropertyValueLongLong SetPropertyValue
00355 #define SetPropertyValueULongLong SetPropertyValue
00356
00357 #define WX_PG_NOT_PURE_IN_WXPYTHON =0
00358
00359 #else
00360
00361
00362
00363
00364 #define wxPG_CONST_WXCHAR_PTR wxString
00365 #define wxPG_CONST_WXCHAR_DEFVAL wxEmptyString
00366 #define wxPG_TO_WXCHAR_PTR(A) A //(A.c_str())
00367
00368
00369
00370
00371 #define SetPropertyValueArrstr2 _SetPropertyValueArrstr
00372 #define SetPropertyValueArrint2 _SetPropertyValueArrint
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382 class wxPGVariantAndBool
00383 {
00384 public:
00385
00386 wxPGVariantAndBool()
00387 {
00388 m_valueValid = false;
00389 m_result = false;
00390 }
00391
00392 wxPGVariantAndBool( bool result, const wxVariant& variant )
00393 {
00394 m_valueValid = true;
00395 m_result = result;
00396 m_value = variant;
00397 }
00398
00399 wxPGVariantAndBool( const wxVariant& variant )
00400 {
00401 m_valueValid = true;
00402 m_result = true;
00403 m_value = variant;
00404 }
00405
00406 wxPGVariantAndBool( bool result )
00407 {
00408 Init(result);
00409 }
00410
00411 ~wxPGVariantAndBool() { }
00412
00413 void Init( bool result = false )
00414 {
00415 m_valueValid = false;
00416 m_result = result;
00417 }
00418
00419 const wxVariant& GetValue() const
00420 {
00421 wxASSERT(m_valueValid);
00422 return m_value;
00423 }
00424
00425 public:
00426 wxVariant m_value;
00427 bool m_valueValid;
00428 bool m_result;
00429 };
00430
00431 #define WX_PG_NOT_PURE_IN_WXPYTHON
00432
00433 #endif
00434
00435
00436 #define wxPG_NO_DECL
00437
00438 #ifndef wxEMPTY_PARAMETER_VALUE
00439 #define wxEMPTY_PARAMETER_VALUE
00440 #endif
00441
00442
00443
00444 #ifdef WXMAKINGLIB_PROPGRID
00445 #define WXDLLIMPEXP_PG
00446 #elif defined(WXMAKINGDLL_PROPGRID)
00447 #define WXDLLIMPEXP_PG WXEXPORT
00448 #elif defined(WXUSINGDLL)
00449 #define WXDLLIMPEXP_PG WXIMPORT
00450 #else // not making nor using DLL
00451 #define WXDLLIMPEXP_PG wxEMPTY_PARAMETER_VALUE
00452 #endif
00453
00454
00455
00456 #ifndef SWIG
00457
00458 class WXDLLIMPEXP_PG wxPGEditor;
00459 class WXDLLIMPEXP_PG wxPGProperty;
00460 class WXDLLIMPEXP_PG wxPropertyCategory;
00461 class WXDLLIMPEXP_PG wxPGChoices;
00462 class WXDLLIMPEXP_PG wxPropertyGridState;
00463 class WXDLLIMPEXP_PG wxPGCell;
00464 class WXDLLIMPEXP_PG wxPGChoiceEntry;
00465 class WXDLLIMPEXP_PG wxPropertyGridInterface;
00466 class WXDLLIMPEXP_PG wxPropertyGrid;
00467 class WXDLLIMPEXP_PG wxPropertyGridEvent;
00468 class WXDLLIMPEXP_PG wxPropertyGridManager;
00469 class WXDLLIMPEXP_PG wxPGOwnerDrawnComboBox;
00470 class WXDLLIMPEXP_PG wxPGCustomComboControl;
00471 class WXDLLIMPEXP_PG wxPGEditorDialogAdapter;
00472
00473 class WXDLLIMPEXP_FWD_CORE wxStatusBar;
00474
00475 extern WXDLLIMPEXP_PG const wxChar *wxPropertyGridNameStr;
00476
00477 struct WXDLLIMPEXP_PG wxPGValidationInfo;
00478
00479 #endif // #ifndef SWIG
00480
00481
00482 #ifdef __WXPYTHON__
00483 class wxPGPyEditor;
00484 #endif // #ifndef __WXPYTHON__
00485
00486
00491 struct wxPGPaintData
00492 {
00494 const wxPropertyGrid* m_parent;
00495
00497 int m_choiceItem;
00498
00500 int m_drawnWidth;
00501
00503 int m_drawnHeight;
00504 };
00505
00506
00507 #ifndef SWIG
00508
00514 class WXDLLIMPEXP_PG wxPGCellRenderer
00515 {
00516 public:
00517
00518 wxPGCellRenderer( unsigned int refCount = 1 )
00519 : m_refCount(refCount) { }
00520 virtual ~wxPGCellRenderer() { }
00521
00522
00523 enum
00524 {
00525 Selected = 0x00010000,
00526 Control = 0x00020000
00527 };
00528
00529 virtual void Render( wxDC& dc,
00530 const wxRect& rect,
00531 const wxPropertyGrid* propertyGrid,
00532 wxPGProperty* property,
00533 int column,
00534 int item,
00535 int flags ) const = 0;
00536
00542 virtual wxSize GetImageSize( const wxPGProperty* property,
00543 int column,
00544 int item ) const;
00545
00548 virtual void DrawCaptionSelectionRect( wxDC& dc, int x, int y, int w, int h ) const;
00549
00552 void DrawText( wxDC& dc,
00553 const wxRect& rect,
00554 int imageWidth,
00555 const wxString& text ) const;
00556
00559 void DrawEditorValue( wxDC& dc, const wxRect& rect,
00560 int xOffset, const wxString& text,
00561 wxPGProperty* property,
00562 const wxPGEditor* editor ) const;
00563
00570 int PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell& cell,
00571 int flags ) const;
00572
00580 void PostDrawCell( wxDC& dc,
00581 const wxPropertyGrid* propGrid,
00582 const wxPGCell& cell,
00583 int flags ) const;
00584
00585 void IncRef()
00586 {
00587 m_refCount++;
00588 }
00589
00590 void DecRef()
00591 {
00592 m_refCount--;
00593 if ( !m_refCount )
00594 delete this;
00595 }
00596 protected:
00597
00598 private:
00599 unsigned int m_refCount;
00600 };
00601
00608 class WXDLLIMPEXP_PG wxPGDefaultRenderer : public wxPGCellRenderer
00609 {
00610 public:
00611 virtual void Render( wxDC& dc,
00612 const wxRect& rect,
00613 const wxPropertyGrid* propertyGrid,
00614 wxPGProperty* property,
00615 int column,
00616 int item,
00617 int flags ) const;
00618
00619 virtual wxSize GetImageSize( const wxPGProperty* property,
00620 int column,
00621 int item ) const;
00622
00623 protected:
00624 };
00625
00626 #endif // !SWIG
00627
00633 class WXDLLIMPEXP_PG wxPGCell
00634 {
00635 public:
00636 wxPGCell();
00637 wxPGCell( const wxString& text,
00638 const wxBitmap& bitmap = wxNullBitmap,
00639 const wxColour& fgCol = wxNullColour,
00640 const wxColour& bgCol = wxNullColour );
00641
00642 virtual ~wxPGCell() { }
00643
00647 void Assign(const wxPGCell& cell);
00648
00652 bool HasText() const;
00653
00654 void SetText( const wxString& text ) { m_text = text; }
00655 void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
00656 void SetFgCol( const wxColour& col ) { m_fgCol = col; }
00657 void SetBgCol( const wxColour& col ) { m_bgCol = col; }
00658 void SetFont( const wxFont& font ) { m_font = font; }
00659
00660 const wxString& GetText() const { return m_text; }
00661 const wxBitmap& GetBitmap() const { return m_bitmap; }
00662 const wxColour& GetFgCol() const { return m_fgCol; }
00663 const wxColour& GetBgCol() const { return m_bgCol; }
00664 const wxFont& GetFont() const { return m_font; }
00665
00666 protected:
00667 wxString m_text;
00668 wxBitmap m_bitmap;
00669 wxColour m_fgCol;
00670 wxColour m_bgCol;
00671 wxFont m_font;
00672 };
00673
00674
00680 #define wxPG_EMPTY_ARRAYINT wxArrayInt()
00681 #define wxPG_EMPTY_ARRAYSTRING wxArrayString()
00682
00683 #if !defined(SWIG)
00684 #define wxPG_LABEL (*((wxString*)NULL)) // Used to tell wxPGProperty to use label as name as well.
00685 #define wxPG_NULL_BITMAP wxNullBitmap
00686 #define wxPG_COLOUR_BLACK (*wxBLACK)
00687 #else
00688 #define wxPG_LABEL wxString_wxPG_LABEL
00689 #define wxPG_NULL_BITMAP wxBitmap_NULL
00690 #define wxPG_COLOUR_BLACK wxColour_BLACK
00691 #endif // #ifndef SWIG
00692
00693
00694
00695
00696 #define wxPG_INVALID_VALUE INT_MAX
00697
00698
00701 #define wxPG_COLOUR(R,G,B) ((wxUint32)(R+(G<<8)+(B<<16)))
00702
00703
00707 #define wxPG_DEFAULT_IMAGE_SIZE wxSize(-1, -1)
00708
00709
00723 typedef bool (*wxPropertyGridCallback)(wxPropertyGrid* propGrid,
00724 wxPGProperty* property,
00725 wxWindow* ctrl,
00726 int data);
00727
00733 typedef void (*wxPGPaintCallback)(wxPGProperty* property,
00734 wxDC& dc,
00735 const wxRect& rect,
00736 wxPGPaintData& paintdata);
00737
00755 typedef int (*wxPGSortCallback)(wxPropertyGrid* propGrid,
00756 wxPGProperty* p1,
00757 wxPGProperty* p2);
00758
00759
00765 #define WX_PG_CLASSINFO(NAME) (&NAME::ms_classInfo)
00766
00767
00768 typedef wxString wxPGCachedString;
00769
00773
00774
00779 enum wxPG_WINDOW_STYLES
00780 {
00781
00787 wxPG_AUTO_SORT = 0x00000010,
00788
00794 wxPG_HIDE_CATEGORIES = 0x00000020,
00795
00796
00797
00798 wxPG_ALPHABETIC_MODE = (wxPG_HIDE_CATEGORIES|wxPG_AUTO_SORT),
00799
00803 wxPG_BOLD_MODIFIED = 0x00000040,
00804
00812 wxPG_SPLITTER_AUTO_CENTER = 0x00000080,
00813
00817 wxPG_TOOLTIPS = 0x00000100,
00818
00823 wxPG_HIDE_MARGIN = 0x00000200,
00824
00827 wxPG_STATIC_SPLITTER = 0x00000400,
00828
00832 wxPG_STATIC_LAYOUT = (wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER),
00833
00838 wxPG_LIMITED_EDITING = 0x00000800,
00839
00840 #ifdef DOXYGEN
00841
00848 wxTAB_TRAVERSAL = 0x00080000,
00849
00850 #endif
00851
00853 wxPG_TOOLBAR = 0x00001000,
00854
00858 wxPG_DESCRIPTION = 0x00002000,
00859
00863 wxPG_THEME_BORDER = 0x00004000,
00864
00868 wxPG_NO_INTERNAL_BORDER = 0x00008000
00869
00870 };
00871
00872 enum wxPG_EX_WINDOW_STYLES
00873 {
00874
00887 wxPG_EX_INIT_NOCAT = 0x00001000,
00888
00892 wxPG_EX_NO_FLAT_TOOLBAR = 0x00002000,
00893
00896 wxPG_EX_MODE_BUTTONS = 0x00008000,
00897
00901 wxPG_EX_HELP_AS_TOOLTIPS = 0x00010000,
00902
00909
00910
00911 #if wxPG_COMPATIBILITY_1_2_0
00912
00913
00914 wxPG_EX_GREY_LABEL_WHEN_DISABLED = 0x00000000,
00915 #endif
00916
00919 wxPG_EX_NATIVE_DOUBLE_BUFFERING = 0x00080000,
00920
00921 #if wxPG_COMPATIBILITY_1_2_0
00922
00925 wxPG_EX_PROCESS_EVENTS_IMMEDIATELY = 0x00000000,
00926 #endif
00927
00932 wxPG_EX_AUTO_UNSPECIFIED_VALUES = 0x00200000,
00933
00939 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES = 0x00400000,
00940
00941 #if wxPG_COMPATIBILITY_1_2_0
00942
00948 wxPG_EX_TRADITIONAL_VALIDATORS = 0x00000000,
00949 #endif
00950
00953 wxPG_EX_LEGACY_VALIDATORS = 0x00800000,
00954
00957 wxPG_EX_HIDE_PAGE_BUTTONS = 0x01000000,
00958
00961 wxPG_EX_UNFOCUS_ON_ENTER = 0x02000000,
00962
00974 wxPG_EX_MULTIPLE_SELECTION = 0x04000000,
00975
00985 wxPG_EX_DISABLE_TLP_TRACKING = 0x08000000,
00986
00989 wxPG_EX_NO_TOOLBAR_DIVIDER = 0x10000000,
00990
00995 wxPG_EX_TOOLBAR_SEPARATOR = 0x20000000
00996
00997 };
00998
01002 #define wxPG_EX_ENABLE_TLP_TRACKING 0x00000000
01003
01004
01007 #define wxPG_DEFAULT_STYLE (0)
01008
01011 #define wxPGMAN_DEFAULT_STYLE (0)
01012
01016 enum wxPG_GETPROPERTYVALUES_FLAGS
01017 {
01018
01020 wxPG_KEEP_STRUCTURE = 0x00000010,
01021
01023 wxPG_RECURSE = 0x00000020,
01024
01026 wxPG_INC_ATTRIBUTES = 0x00000040,
01027
01029 wxPG_RECURSE_STARTS = 0x00000080,
01030
01032 wxPG_FORCE = 0x00000100
01033
01034 };
01035
01037 #define wxPG_DONT_RECURSE 0x00000000
01038
01039
01040
01041
01042 enum wxPG_MISC_ARG_FLAGS
01043 {
01044
01045 wxPG_FULL_VALUE = 0x00000001,
01046
01047 wxPG_REPORT_ERROR = 0x00000002,
01048
01049 wxPG_PROPERTY_SPECIFIC = 0x00000004,
01050
01051 wxPG_EDITABLE_VALUE = 0x00000008,
01052
01053
01054 wxPG_COMPOSITE_FRAGMENT = 0x00000010,
01055
01056 wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = 0x00000020,
01057
01058
01059 wxPG_PROGRAMMATIC_VALUE = 0x00000040
01060 };
01061
01062
01063
01064
01065
01066 enum wxPG_SETVALUE_FLAGS
01067 {
01068 wxPG_SETVAL_REFRESH_EDITOR = 0x0001,
01069 wxPG_SETVAL_AGGREGATED = 0x0002,
01070 wxPG_SETVAL_FROM_PARENT = 0x0004,
01071 wxPG_SETVAL_BY_USER = 0x0008
01072 };
01073
01074
01075
01076
01077 #define wxNullProperty ((wxPGProperty*)NULL)
01078
01079 #if wxPG_COMPATIBILITY_1_2_0
01080 inline bool wxPGIdIsOk(wxPGProperty* id)
01081 {
01082 return (id != NULL) ? true : false;
01083 }
01084 #endif
01085
01086 typedef wxPGProperty* wxPGId;
01087
01088 #ifndef SWIG
01089
01096 class WXDLLIMPEXP_PG wxPGPropArgCls
01097 {
01098 public:
01099 wxPGPropArgCls() { }
01100 wxPGPropArgCls( const wxPGProperty* property )
01101 {
01102 m_ptr.property = (wxPGProperty*) property;
01103 m_isName = false;
01104 }
01105 wxPGPropArgCls( const wxString& str )
01106 {
01107 m_ptr.name = &str;
01108 m_isName = 1;
01109 }
01110 wxPGPropArgCls( const wxPGPropArgCls& id )
01111 {
01112 m_ptr = id.m_ptr;
01113 m_isName = id.m_isName;
01114 }
01115 #ifdef __WXPYTHON__
01116 wxPGPropArgCls( wxString* str, bool WXUNUSED(deallocPtr) )
01117 {
01118 m_ptr.name = str;
01119 m_isName = 3;
01120 }
01121 ~wxPGPropArgCls()
01122 {
01123 if ( m_isName == 3 )
01124 delete m_ptr.name;
01125 }
01126 #endif
01127 wxPGProperty* GetPtr() const { wxCHECK( !m_isName, NULL ); return m_ptr.property; }
01128 wxPGPropArgCls( const wxChar* str )
01129 {
01130 m_ptr.rawname = str;
01131 m_isName = 2;
01132 }
01134 wxPGPropArgCls( int )
01135 {
01136 m_ptr.property = (wxPGProperty*) NULL;
01137 m_isName = false;
01138 }
01139 wxPGProperty* GetPtr( wxPropertyGridInterface* methods ) const;
01140 wxPGProperty* GetPtr( const wxPropertyGridInterface* methods ) const
01141 {
01142 return GetPtr((wxPropertyGridInterface*)methods);
01143 }
01144 wxPGProperty* GetPtr0() const { return m_ptr.property; }
01145 unsigned char HasName() const { return m_isName; }
01146 const wxString& GetName() const { return *m_ptr.name; }
01147 private:
01148 union
01149 {
01150 wxPGProperty* property;
01151 const wxChar* rawname;
01152 const wxString* name;
01153 } m_ptr;
01154 unsigned char m_isName;
01155 };
01156
01157 #else
01158
01159 class WXDLLIMPEXP_PG wxPGPropArgCls;
01160
01161 #endif
01162
01163 typedef const wxPGPropArgCls& wxPGPropArg;
01164
01165
01166
01167 WXDLLIMPEXP_PG void wxPGTypeOperationFailed( const wxPGProperty* p, const wxChar* typestr, const wxChar* op );
01168 WXDLLIMPEXP_PG void wxPGGetFailed( const wxPGProperty* p, const wxChar* typestr );
01169
01170
01171
01176 enum wxPGPropertyFlags
01177 {
01178
01181 wxPG_PROP_MODIFIED = 0x0001,
01182
01185 wxPG_PROP_DISABLED = 0x0002,
01186
01189 wxPG_PROP_HIDDEN = 0x0004,
01190
01195 wxPG_PROP_CUSTOMIMAGE = 0x0008,
01196
01200 wxPG_PROP_NOEDITOR = 0x0010,
01201
01204 wxPG_PROP_COLLAPSED = 0x0020,
01205
01212 wxPG_PROP_INVALID_VALUE = 0x0040,
01213
01214
01215
01219 wxPG_PROP_WAS_MODIFIED = 0x0200,
01220
01224 wxPG_PROP_AGGREGATE = 0x0400,
01225
01229 wxPG_PROP_CHILDREN_ARE_COPIES = 0x0800,
01230
01233 wxPG_PROP_PROPERTY = 0x1000,
01234
01237 wxPG_PROP_CATEGORY = 0x2000,
01238
01242 wxPG_PROP_MISC_PARENT = 0x4000,
01243
01248 wxPG_PROP_READONLY = 0x8000,
01249
01250
01251
01252
01253
01258 wxPG_PROP_COMPOSED_VALUE = 0x00010000,
01259
01264 wxPG_PROP_USES_COMMON_VALUE = 0x00020000,
01265
01274 wxPG_PROP_AUTO_UNSPECIFIED = 0x00040000,
01275
01278 wxPG_PROP_CLASS_SPECIFIC_1 = 0x00080000,
01279
01282 wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000,
01283
01286 wxPG_PROP_BEING_DELETED = 0x00200000
01287
01288 };
01289
01292 #define wxPG_PROP_MAX wxPG_PROP_AUTO_UNSPECIFIED
01293
01297 #define wxPG_PROP_PARENTAL_FLAGS (wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY|wxPG_PROP_MISC_PARENT)
01298
01302
01303 #define wxPG_INHERITED_PROPFLAGS (wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR)
01304
01305
01306 #define wxPG_STRING_STORED_FLAGS (wxPG_PROP_DISABLED|wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR|wxPG_PROP_COLLAPSED)
01307
01308
01309
01310 #ifndef SWIG
01311
01325 #define wxPG_ATTR_MIN wxT("Min")
01326
01329 #define wxPG_ATTR_MAX wxT("Max")
01330
01335 #define wxPG_ATTR_UNITS wxT("Units")
01336
01340 #define wxPG_ATTR_INLINE_HELP wxT("InlineHelp")
01341
01345 #define wxPG_BOOL_USE_CHECKBOX wxT("UseCheckbox")
01346
01350 #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxT("UseDClickCycling")
01351
01356 #define wxPG_FLOAT_PRECISION wxT("Precision")
01357
01360 #define wxPG_STRING_PASSWORD wxT("Password")
01361
01366 #define wxPG_UINT_BASE wxT("Base")
01367
01373 #define wxPG_UINT_PREFIX wxT("Prefix")
01374
01379 #define wxPG_FILE_WILDCARD wxT("Wildcard")
01380
01384 #define wxPG_FILE_SHOW_FULL_PATH wxT("ShowFullPath")
01385
01389 #define wxPG_FILE_SHOW_RELATIVE_PATH wxT("ShowRelativePath")
01390
01394 #define wxPG_FILE_INITIAL_PATH wxT("InitialPath")
01395
01399 #define wxPG_FILE_DIALOG_TITLE wxT("DialogTitle")
01400
01404 #define wxPG_DIR_DIALOG_MESSAGE wxT("DialogMessage")
01405
01408 #define wxPG_DATE_FORMAT wxT("DateFormat")
01409
01413 #define wxPG_DATE_PICKER_STYLE wxT("PickerStyle")
01414
01418 #define wxPG_ATTR_SPINCTRL_STEP wxT("Step")
01419
01422 #define wxPG_ATTR_SPINCTRL_WRAP wxT("Wrap")
01423
01427 #define wxPG_ATTR_SPINCTRL_MOTIONSPIN wxT("MotionSpin")
01428
01432 #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxT("UserStringMode")
01433
01434 #ifdef wxPG_COMPATIBILITY_1_0_0
01435
01441 #define wxPG_CUSTOM_EDITOR wxT("128")
01442
01447 #define wxPG_CUSTOM_IMAGE wxT("129")
01448
01452 #define wxPG_CUSTOM_CALLBACK wxT("130")
01453
01454 #endif // wxPG_COMPATIBILITY_1_0_0
01455
01464 #define wxPG_CUSTOM_PAINT_CALLBACK wxT("PaintCallback")
01465
01466
01474 #define wxPG_CUSTOM_PRIVATE_CHILDREN wxT("PrivateChildren")
01475
01476
01480 #define wxPG_COLOUR_ALLOW_CUSTOM wxT("AllowCustom")
01481
01482
01486
01487
01491 #ifndef DOXYGEN
01492
01493
01494 #undef wxPG_ATTR_DEFAULT_VALUE
01495 #define wxPG_ATTR_DEFAULT_VALUE wxPGGlobalVars->m_strDefaultValue
01496 #undef wxPG_ATTR_MIN
01497 #define wxPG_ATTR_MIN wxPGGlobalVars->m_strMin
01498 #undef wxPG_ATTR_MAX
01499 #define wxPG_ATTR_MAX wxPGGlobalVars->m_strMax
01500 #undef wxPG_ATTR_UNITS
01501 #define wxPG_ATTR_UNITS wxPGGlobalVars->m_strUnits
01502 #undef wxPG_ATTR_INLINE_HELP
01503 #define wxPG_ATTR_INLINE_HELP wxPGGlobalVars->m_strInlineHelp
01504
01505 #endif // !DOXYGEN
01506
01507 #endif // !SWIG
01508
01509
01510
01511
01512
01513 #define wxPG_BASE_OCT (long)8
01514 #define wxPG_BASE_DEC (long)10
01515 #define wxPG_BASE_HEX (long)16
01516 #define wxPG_BASE_HEXL (long)32
01517
01518
01519
01520 #define wxPG_PREFIX_NONE (long)0
01521 #define wxPG_PREFIX_0x (long)1
01522 #define wxPG_PREFIX_DOLLAR_SIGN (long)2
01523
01524
01525
01526
01527
01528
01529 #define wxPG_EDITOR(T) wxPGEditor_##T
01530
01531
01532 #define WX_PG_DECLARE_EDITOR_WITH_DECL(EDITOR,DECL) \
01533 extern DECL wxPGEditor* wxPGEditor_##EDITOR; \
01534 extern DECL wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
01535
01536
01537 #define WX_PG_DECLARE_EDITOR(EDITOR) \
01538 extern wxPGEditor* wxPGEditor_##EDITOR; \
01539 extern wxPGEditor* wxPGConstruct##EDITOR##EditorClass();
01540
01541
01542 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrl,WXDLLIMPEXP_PG)
01543 WX_PG_DECLARE_EDITOR_WITH_DECL(Choice,WXDLLIMPEXP_PG)
01544 WX_PG_DECLARE_EDITOR_WITH_DECL(ComboBox,WXDLLIMPEXP_PG)
01545 WX_PG_DECLARE_EDITOR_WITH_DECL(TextCtrlAndButton,WXDLLIMPEXP_PG)
01546 #if wxPG_INCLUDE_CHECKBOX
01547 WX_PG_DECLARE_EDITOR_WITH_DECL(CheckBox,WXDLLIMPEXP_PG)
01548 #endif
01549 WX_PG_DECLARE_EDITOR_WITH_DECL(ChoiceAndButton,WXDLLIMPEXP_PG)
01550
01551
01552
01553
01554 #ifdef SWIG
01555 #define wxVARIANT_REFCOUNTED 1
01556 #endif
01557
01558
01559
01560 #ifndef wxVARIANT_REFCOUNTED
01561 #if wxCHECK_VERSION(2,8,0)
01562 #define wxVARIANT_REFCOUNTED 1
01563 #else
01564 #define wxVARIANT_REFCOUNTED 0
01565 #error "Only supports wxWidgets 2.6 that has been patched with refcounted wxVariant"
01566 #endif
01567 #endif
01568
01569
01570 #if !defined(SWIG)
01571
01601 class WXDLLIMPEXP_PG wxPGVariantData : public wxVariantData
01602 {
01603 #if !wxCHECK_VERSION(2,9,0)
01604 DECLARE_ABSTRACT_CLASS(wxPGVariantData)
01605 #endif
01606 public:
01607 virtual void* GetValuePtr() = 0;
01608 virtual wxVariant GetDefaultValue() const = 0;
01609 protected:
01610 };
01611
01612
01613
01614
01615 #if wxCHECK_VERSION(2,9,0)
01616 #ifdef wxNO_RTTI
01617 #error "You need to enable compiler RTTI support when using wxWidgets 2.9.0 or later"
01618 #endif
01619 #define WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(A)
01620 #define WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(A, B)
01621 typedef const std::type_info* wxPGVariantDataClassInfo;
01622 #define wxPGVariantDataGetClassInfo(A) (&typeid(*A))
01623 #define wxPG_VARIANT_EQ(A, B) ( ((A).GetData() && (B).GetData() && typeid(*(A).GetData()) == typeid(*(B).GetData()) && (A == B)) || (!(A).GetData() && !(B).GetData()) )
01624 #else
01625 #define WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA DECLARE_DYNAMIC_CLASS
01626 #define WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA IMPLEMENT_DYNAMIC_CLASS
01627 typedef wxList wxVariantList;
01628 typedef wxClassInfo* wxPGVariantDataClassInfo;
01629 #define wxPGVariantDataGetClassInfo(A) (A->GetClassInfo())
01630 #define wxPG_VARIANT_EQ(A, B) ( ((A).GetData() && (B).GetData() && (A).GetData()->GetClassInfo() == (B).GetData()->GetClassInfo() && (A == B)) || (!(A).GetData() && !(B).GetData()) )
01631 #endif
01632
01633 #ifndef wxDynamicCastVariantData
01634 #define wxDynamicCastVariantData wxDynamicCast
01635 #endif
01636
01637
01638 inline void wxPGDoesNothing() {}
01639
01640
01641 #define _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, AS_ARG, AS_ARG_CONST, CTOR_CODE, DEFAULT_VALUE, SET_CODE) \
01642 WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME) \
01643 protected: \
01644 DATATYPE m_value; \
01645 public: \
01646 CLASSNAME() { CTOR_CODE; } \
01647 CLASSNAME(AS_ARG_CONST value) { CTOR_CODE; SET_CODE; m_value = value; } \
01648 DATATYPE GetValue() const { return m_value; } \
01649 AS_ARG_CONST GetValueRef() const { return m_value; } \
01650 AS_ARG GetValueRef() { return m_value; } \
01651 void SetValue(AS_ARG_CONST value) { SET_CODE; m_value = value; } \
01652 virtual wxString GetType() const { return wxT(#DATATYPE); } \
01653 virtual wxVariantData* Clone() { return new CLASSNAME; } \
01654 virtual bool Read(wxString &) { return false; } \
01655 virtual bool Write(wxString &) const { return true; } \
01656 virtual wxVariant GetDefaultValue() const { return DEFAULT_VALUE; }
01657
01658
01659 #define _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
01660 virtual bool Eq(wxVariantData& other) const \
01661 { return (this == (const wxVariantData*) &other); }
01662
01663 #define _WX_PG_IMPLEMENT_VARIANT_DATA_PROPER_EQ(CLASSNAME, DATATYPE) \
01664 virtual bool Eq(wxVariantData& other) const \
01665 { \
01666 if ( other.GetType() != wxT(#DATATYPE) ) \
01667 return false; \
01668 CLASSNAME* pOther = wxStaticCast(&other, CLASSNAME); \
01669 return (m_value == pOther->GetValueRef()); \
01670 }
01671
01672
01673
01674
01675 template<class T>
01676 wxVariant WXVARIANT( const T& value )
01677 {
01678 return wxVariant((void*)&value);
01679 }
01680
01681 template<> inline wxVariant WXVARIANT( const int& value ) { return wxVariant((long)value); }
01682 template<> inline wxVariant WXVARIANT( const long& value ) { return wxVariant(value); }
01683 template<> inline wxVariant WXVARIANT( const bool& value ) { return wxVariant(value); }
01684 template<> inline wxVariant WXVARIANT( const double& value ) { return wxVariant(value); }
01685
01686
01687
01688
01689 template<> inline wxVariant WXVARIANT( const wxArrayString& value ) { return wxVariant(value); }
01690 template<> inline wxVariant WXVARIANT( const wxString& value ) { return wxVariant(value); }
01691 #if wxUSE_DATETIME
01692 template<> inline wxVariant WXVARIANT( const wxDateTime& value ) { return wxVariant(value); }
01693 #endif
01694
01695 #if wxCHECK_VERSION(2,9,0)
01696 #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME) \
01697 extern int CLASSNAME##_d_;
01698 #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
01699 int CLASSNAME##_d_;
01700 #else
01701 #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME) \
01702 extern wxPGVariantDataClassInfo CLASSNAME##_ClassInfo
01703 #define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
01704 wxPGVariantDataClassInfo CLASSNAME##_ClassInfo = &CLASSNAME::ms_classInfo;
01705 #endif
01706
01707 #define _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, AS_ARG, AS_CONST_ARG, NULLVAL, BASECLASS) \
01708 _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
01709 WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME, BASECLASS) \
01710 AS_ARG operator <<( AS_ARG value, const wxVariant &variant ) \
01711 { \
01712 CLASSNAME *data = wxDynamicCastVariantData( variant.GetData(), CLASSNAME ); \
01713 wxASSERT( data ); \
01714 value = data->GetValue(); \
01715 return value; \
01716 } \
01717 wxVariant& operator <<( wxVariant &variant, AS_CONST_ARG value ) \
01718 { \
01719 CLASSNAME *data = new CLASSNAME( value ); \
01720 variant.SetData( data ); \
01721 return variant; \
01722 } \
01723 AS_ARG DATATYPE##FromVariant( const wxVariant& v ) \
01724 { \
01725 CLASSNAME *data = wxDynamicCastVariantData( v.GetData(), CLASSNAME ); \
01726 if ( !data ) \
01727 return NULLVAL; \
01728 return data->GetValueRef(); \
01729 } \
01730 wxVariant DATATYPE##ToVariant( AS_CONST_ARG value ) \
01731 { \
01732 wxVariant variant( new CLASSNAME( value ) ); \
01733 return variant; \
01734 }
01735
01736 #define WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE) \
01737 class CLASSNAME : public wxPGVariantData \
01738 { \
01739 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
01740 const DATATYPE&, wxPGDoesNothing(), \
01741 wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
01742 _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
01743 public: \
01744 virtual void* GetValuePtr() { return (void*)&m_value; } \
01745 }; \
01746 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
01747
01748 #define WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA(CLASSNAME, DATATYPE) \
01749 class CLASSNAME : public wxPGVariantData \
01750 { \
01751 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
01752 const DATATYPE&, wxPGDoesNothing(), \
01753 wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
01754 _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
01755 public: \
01756 virtual void* GetValuePtr() { return (void*)&m_value; } \
01757 virtual wxClassInfo* GetValueClassInfo() { return m_value.GetClassInfo(); } \
01758 }; \
01759 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
01760
01761
01762 #define WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA_WITH_PROPER_EQ(CLASSNAME, DATATYPE) \
01763 class CLASSNAME : public wxPGVariantData \
01764 { \
01765 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
01766 const DATATYPE&, wxPGDoesNothing(), \
01767 wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
01768 _WX_PG_IMPLEMENT_VARIANT_DATA_PROPER_EQ(CLASSNAME, DATATYPE) \
01769 public: \
01770 virtual void* GetValuePtr() { return (void*)&m_value; } \
01771 virtual wxClassInfo* GetValueClassInfo() { return m_value.GetClassInfo(); } \
01772 }; \
01773 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
01774
01775 #define WX_PG_IMPLEMENT_VARIANT_DATA_WITH_EQ(CLASSNAME, DATATYPE) \
01776 class CLASSNAME : public wxPGVariantData \
01777 { \
01778 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
01779 const DATATYPE&, wxPGDoesNothing(), \
01780 wxVariant(new CLASSNAME(DATATYPE())), wxPGDoesNothing()) \
01781 _WX_PG_IMPLEMENT_VARIANT_DATA_PROPER_EQ(CLASSNAME, DATATYPE) \
01782 public: \
01783 virtual void* GetValuePtr() { return (void*)&m_value; } \
01784 }; \
01785 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, const DATATYPE&, (DATATYPE&)*((DATATYPE*)NULL), wxPGVariantData)
01786
01787
01788 #define WX_PG_DECLARE_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
01789 DECL DATATYPE& operator <<( DATATYPE& value, const wxVariant &variant ); \
01790 DECL wxVariant& operator <<( wxVariant &variant, const DATATYPE& value ); \
01791 DECL DATATYPE& DATATYPE##FromVariant( const wxVariant& variant ); \
01792 DECL wxVariant DATATYPE##ToVariant( const DATATYPE& value ); \
01793 template<> inline wxVariant WXVARIANT( const DATATYPE& value ) { return DATATYPE##ToVariant(value); } \
01794 DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
01795
01796 #define WX_PG_DECLARE_WXOBJECT_VARIANT_DATA WX_PG_DECLARE_VARIANT_DATA
01797
01798 #define WX_PG_DECLARE_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
01799 DECL DATATYPE* operator <<( DATATYPE* value, const wxVariant &variant ); \
01800 DECL wxVariant& operator <<( wxVariant &variant, DATATYPE* value ); \
01801 DECL DATATYPE* DATATYPE##FromVariant( const wxVariant& variant ); \
01802 DECL wxVariant DATATYPE##ToVariant( DATATYPE* value ); \
01803 DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
01804
01805
01806 #define WX_PG_IMPLEMENT_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DEFAULT) \
01807 class CLASSNAME : public wxPGVariantData \
01808 { \
01809 _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE*, DATATYPE*, \
01810 DATATYPE*, m_value = NULL, \
01811 DEFAULT, if (m_value) Py_DECREF(m_value); if (!value) value = Py_None; Py_INCREF(value) ) \
01812 _WX_PG_IMPLEMENT_VARIANT_DATA_SHALLOW_EQ(CLASSNAME, DATATYPE) \
01813 ~CLASSNAME() { if (m_value) Py_DECREF(m_value); } \
01814 public: \
01815 virtual void* GetValuePtr() { return (void*)m_value; } \
01816 }; \
01817 _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE*, DATATYPE*, NULL, wxPGVariantData)
01818
01819
01820 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataPoint, wxPoint, WXDLLIMPEXP_PG)
01821 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataSize, wxSize, WXDLLIMPEXP_PG)
01822 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataArrayInt, wxArrayInt, WXDLLIMPEXP_PG)
01823 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataLongLong, wxLongLong, WXDLLIMPEXP_PG)
01824 WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataULongLong, wxULongLong, WXDLLIMPEXP_PG)
01825 #ifdef __WXPYTHON__
01826 WX_PG_DECLARE_PTR_VARIANT_DATA(wxPGVariantDataPyObject, PyObject, WXDLLIMPEXP_PG)
01827 #endif
01828
01829 WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataFont, wxFont, WXDLLIMPEXP_PG)
01830 #if !wxCHECK_VERSION(2,8,0)
01831 WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataColour, wxColour, WXDLLIMPEXP_PG)
01832 #else
01833 template<> inline wxVariant WXVARIANT( const wxColour& value )
01834 {
01835 wxVariant variant;
01836 variant << value;
01837 return variant;
01838 }
01839 #endif
01840
01841 #endif // !SWIG
01842
01843 #define WX_PG_VARIANT_GETVALUEREF(P, T) (*((T*)((wxPGVariantData*)(P.GetData()))->GetValuePtr()))
01844
01845
01846 WXDLLIMPEXP_PG long wxPGVariantToInt( const wxVariant& variant, long defVal = 1 );
01847
01848
01849 WXDLLIMPEXP_PG bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult );
01850
01851
01852 WXDLLIMPEXP_PG bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult );
01853
01854
01855 WXDLLIMPEXP_PG bool wxPGVariantToDouble( const wxVariant& variant, double* pResult );
01856
01857
01858 WXDLLIMPEXP_PG bool wxPGVariantToWxObjectPtr( const wxVariant& value,
01859 wxObject** result );
01860
01861
01862
01863
01864
01865 WXDLLIMPEXP_PG void wxPGInitResourceModule();
01866
01867
01868
01869
01870 #if !defined(SWIG)
01871
01872 #if wxPG_USE_STL
01873 typedef std::vector<wxPGProperty*> wxArrayPGProperty;
01874 #else
01875 WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(wxPGProperty*, wxArrayPGProperty,
01876 wxBaseArrayPtrVoid, class WXDLLIMPEXP_PG);
01877 #endif
01878
01879
01880 WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
01881 wxPGHashMapS2P,
01882 class WXDLLIMPEXP_PG);
01883
01884 #else
01885
01886 class WXDLLIMPEXP_PG wxArrayPGProperty;
01887 class WXDLLIMPEXP_PG wxPGHashMapS2P;
01888
01889 #endif
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900 #ifndef SWIG
01901 #define WX_PG_DECLARE_DOGETEDITORCLASS virtual const wxPGEditor* DoGetEditorClass() const;
01902 #else
01903 #define WX_PG_DECLARE_DOGETEDITORCLASS
01904 #endif
01905
01906 #ifndef SWIG
01907 #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
01908 public: \
01909 DECLARE_DYNAMIC_CLASS(CLASSNAME) \
01910 WX_PG_DECLARE_DOGETEDITORCLASS \
01911 private:
01912 #else
01913 #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME)
01914 #endif
01915
01916
01917 #define WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(PROPNAME,T,EDITOR) \
01918 const wxPGEditor* PROPNAME::DoGetEditorClass() const \
01919 { \
01920 return wxPGEditor_##EDITOR; \
01921 }
01922
01923
01924
01925
01926
01927
01928
01929 #define wxPG_SUBID1 2
01930 #define wxPG_SUBID2 3
01931 #define wxPG_SUBID_TEMP1 4
01932
01933
01934 #ifndef SWIG
01935
01936
01937
01938
01939 struct wxPGChoiceInfo
01940 {
01941 wxPGChoices* m_choices;
01942 };
01943
01944
01945
01951 class WXDLLIMPEXP_PG wxPGAttributeStorage
01952 {
01953 public:
01954 wxPGAttributeStorage();
01955 ~wxPGAttributeStorage();
01956
01957 void Set( const wxString& name, const wxVariant& value );
01958 unsigned int GetCount() const
01959 {
01960 return (unsigned int) m_map.size();
01961 }
01962 wxVariant FindValue( const wxString& name ) const
01963 {
01964 wxPGHashMapS2P::const_iterator it = m_map.find(name);
01965 if ( it != m_map.end() )
01966 {
01967 wxVariantData* data = (wxVariantData*) it->second;
01968 data->IncRef();
01969 return wxVariant(data, it->first);
01970 }
01971 return wxVariant();
01972 }
01973
01974 typedef wxPGHashMapS2P::const_iterator const_iterator;
01975 const_iterator StartIteration() const
01976 {
01977 return m_map.begin();
01978 }
01979 bool GetNext( const_iterator& it, wxVariant& variant ) const
01980 {
01981 if ( it == m_map.end() )
01982 return false;
01983
01984 wxVariantData* data = (wxVariantData*) it->second;
01985 data->IncRef();
01986 variant.SetData(data);
01987 variant.SetName(it->first);
01988 it++;
01989 return true;
01990 }
01991
01992 protected:
01993 wxPGHashMapS2P m_map;
01994 };
01995
01996 #endif // !SWIG
01997
01998
01999
02004 class WXDLLIMPEXP_PG wxPGProperty : public wxObject
02005 {
02006 #ifndef SWIG
02007 friend class wxPropertyGrid;
02008 friend class wxPropertyGridInterface;
02009 friend class wxPropertyGridState;
02010 friend class wxPropertyGridPopulator;
02011 friend class wxStringProperty;
02012 DECLARE_ABSTRACT_CLASS(wxPGProperty)
02013 #endif
02014 public:
02015 typedef wxUint32 FlagType;
02016 #ifndef __WXPYTHON__
02017 typedef void* ClientDataType;
02018 #else
02019 typedef PyObject* ClientDataType;
02020 #endif
02021
02022
02023
02024 #ifndef PYSWIG
02025
02027 wxPGProperty();
02028 #endif
02029
02056 wxPGProperty( const wxString& label, const wxString& name );
02057
02059 virtual ~wxPGProperty();
02060
02071 virtual void OnSetValue();
02072
02075 virtual wxVariant DoGetValue() const { return m_value; }
02076
02077 #ifndef DOXYGEN
02078 private:
02079 #else
02080 public:
02081 #endif
02082
02083
02084
02092 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
02093
02110 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
02111
02127 virtual bool IntToValue( wxVariant& value, int number, int argFlags = 0 ) const;
02128 public:
02129
02148 virtual wxString GetValueAsString( int argFlags = 0 ) const;
02149
02157 #if wxPG_COMPATIBILITY_1_2_0
02158 virtual
02159 #endif
02160 bool SetValueFromString( const wxString& text, int flags = wxPG_PROGRAMMATIC_VALUE );
02161
02171 #if wxPG_COMPATIBILITY_1_2_0
02172 virtual
02173 #endif
02174 bool SetValueFromInt( long value, int flags = 0 );
02175
02176 #if wxPG_COMPATIBILITY_1_2_0
02177
02180 virtual wxSize GetImageSize() const;
02181 #endif
02182
02193 virtual wxSize OnMeasureImage( int item = -1 ) const;
02194
02212 virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event );
02213
02249 virtual void ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const;
02250
02251 #ifdef __WXPYTHON__
02252
02253
02254 virtual wxPGVariantAndBool PyValidateValue( const wxVariant& value, wxPGValidationInfo& validationInfo ) const;
02255 virtual wxPGVariantAndBool PyStringToValue( const wxString& text, int argFlags = 0 ) const;
02256 virtual wxPGVariantAndBool PyIntToValue( int number, int argFlags = 0 ) const;
02257 virtual wxVariant PyChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const;
02258 #endif
02259
02260 void ActualChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
02261 {
02262 #ifdef __WXPYTHON__
02263 if ( m_scriptObject )
02264 {
02265 thisValue = PyChildChanged(thisValue, childIndex, childValue);
02266 return;
02267 }
02268 #endif
02269
02270 ChildChanged(thisValue, childIndex, childValue);
02271 }
02272
02273 bool ActualValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const
02274 {
02275 #ifdef __WXPYTHON__
02276 if ( m_scriptObject )
02277 {
02278 wxPGVariantAndBool vab = PyValidateValue(value, validationInfo);
02279 if ( vab.m_valueValid )
02280 value = vab.m_value;
02281 return vab.m_result;
02282 }
02283 #endif
02284
02285 return ValidateValue(value, validationInfo);
02286 }
02287
02288 bool ActualStringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const
02289 {
02290 #ifdef __WXPYTHON__
02291 if ( m_scriptObject )
02292 {
02293 wxPGVariantAndBool vab = PyStringToValue(text, argFlags);
02294 if ( vab.m_valueValid )
02295 variant = vab.m_value;
02296 return vab.m_result;
02297 }
02298 #endif
02299
02300 return StringToValue(variant, text, argFlags);
02301 }
02302
02303 bool ActualIntToValue( wxVariant& variant, int number, int argFlags = 0 ) const
02304 {
02305 #ifdef __WXPYTHON__
02306 if ( m_scriptObject )
02307 {
02308 wxPGVariantAndBool vab = PyIntToValue(number, argFlags);
02309 if ( vab.m_valueValid )
02310 variant = vab.m_value;
02311 return vab.m_result;
02312 }
02313 #endif
02314
02315 return IntToValue(variant, number, argFlags);
02316 }
02317
02318 wxString GetValueType() const
02319 {
02320 return m_value.GetType();
02321 }
02322
02323 #ifndef SWIG
02324
02326 virtual const wxPGEditor* DoGetEditorClass() const;
02327 #endif
02328
02329 #ifdef __WXPYTHON__
02330
02332 virtual wxString GetEditor() const;
02333 #endif
02334
02365 virtual wxValidator* DoGetValidator () const;
02366
02376 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
02377
02414 virtual void OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& paintdata );
02415
02420 virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
02421
02424 virtual void RefreshChildren();
02425
02433 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
02434
02441 virtual wxVariant DoGetAttribute( const wxString& name ) const;
02442
02449 virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
02450
02458 virtual void OnValidationFailure( wxVariant& pendingValue );
02459
02463 int AppendChoice( const wxString& label, int value = wxPG_INVALID_VALUE )
02464 {
02465 return InsertChoice(label,-1,value);
02466 }
02467
02471 wxPGCell* AcquireCell( unsigned int column )
02472 {
02473 if ( column >= m_cells.size() )
02474 return NULL;
02475
02476 wxPGCell* cell = (wxPGCell*) m_cells[column];
02477 m_cells[column] = NULL;
02478 return cell;
02479 }
02480
02484 bool AreChildrenComponents() const
02485 {
02486 if ( m_flags & (wxPG_PROP_COMPOSED_VALUE|wxPG_PROP_AGGREGATE) )
02487 return true;
02488
02489 return false;
02490 }
02491
02503 void AddPrivateChild( wxPGProperty* prop )
02504 {
02505 AddChild(prop);
02506 }
02507
02513 wxPGProperty* AppendChild( wxPGProperty* prop )
02514 {
02515 return InsertChild(-1, prop);
02516 }
02517
02529 wxPGProperty* InsertChild( int index, wxPGProperty* childProperty );
02530
02534 void DeleteChildren();
02535
02540 void DeleteChoice( int index );
02541
02545 void Empty()
02546 {
02547 DeleteChildren();
02548 }
02549
02555 void EnableCommonValue( bool enable = true )
02556 {
02557 if ( enable ) SetFlag( wxPG_PROP_USES_COMMON_VALUE );
02558 else ClearFlag( wxPG_PROP_USES_COMMON_VALUE );
02559 }
02560
02562 void GenerateComposedValue( wxString& text, int argFlags = 0 ) const;
02563
02565 const wxString& GetLabel() const { return m_label; }
02566
02568 wxString GetName() const;
02569
02571 const wxString& GetBaseName() const { return m_name; }
02572
02573 wxPGChoices& GetChoices();
02574
02575 const wxPGChoices& GetChoices() const;
02576
02577 const wxPGChoiceEntry* GetCurrentChoice() const;
02578
02582 int GetY() const;
02583
02584 wxVariant GetValue() const
02585 {
02586 #ifdef __WXPYTHON__
02587 wxVariant val = DoGetValue();
02588 if ( val.IsNull() )
02589 return PyObjectToVariant( Py_None );
02590 return val;
02591 #else
02592 return DoGetValue();
02593 #endif
02594 }
02595
02600 wxVariant& GetValueRef()
02601 {
02602 return m_value;
02603 }
02604
02605 const wxVariant& GetValueRef() const
02606 {
02607 return m_value;
02608 }
02609
02612 wxString GetValueString( int argFlags = 0 ) const;
02613
02622 wxPGCell* GetCell( unsigned int column ) const
02623 {
02624 if ( column >= m_cells.size() )
02625 return NULL;
02626
02627 return (wxPGCell*) m_cells[column];
02628 }
02629
02634 wxPGCell* GetOrCreateCell( unsigned int column );
02635
02636 const wxChar* GetClassName() const
02637 {
02638 return GetClassInfo()->GetClassName();
02639 }
02640
02641 unsigned int GetChoiceCount() const;
02642
02643 wxString GetChoiceString( unsigned int index );
02644
02647 int GetDisplayedCommonValueCount() const;
02648
02649 wxString GetDisplayedString() const
02650 {
02651 return GetValueString(0);
02652 }
02653
02654 #if wxPG_COMPATIBILITY_1_2_0
02655
02656 wxPGId GetId() { return this; }
02657 #endif
02658
02660 wxPropertyGrid* GetGrid() const;
02661
02664 wxPropertyGrid* GetGridIfDisplayed() const;
02665
02672 wxPGProperty* GetMainParent() const;
02673
02675 wxPGProperty* GetParent() const { return m_parent; }
02676
02677 bool IsFlagSet( FlagType flag ) const
02678 {
02679 return ( m_flags & flag ) ? true : false;
02680 }
02681
02689 bool IsTextEditable() const;
02690
02694 bool IsValueUnspecified() const
02695 {
02696 return m_value.IsNull();
02697 }
02698
02705 FlagType HasFlag( FlagType flag ) const
02706 {
02707 return ( m_flags & flag );
02708 }
02709
02713 bool CanHaveExtraChildren() const
02714 {
02715 return !IsFlagSet(wxPG_PROP_AGGREGATE);
02716 }
02717
02720 const wxPGAttributeStorage& GetAttributes() const
02721 {
02722 return m_attributes;
02723 }
02724
02727 wxVariant GetAttributesAsList() const;
02728
02729 FlagType GetFlags() const
02730 {
02731 return m_flags;
02732 }
02733
02734 const wxPGEditor* GetEditorClass() const;
02735
02738 const wxPGEditor* GetColumnEditor( int column ) const
02739 {
02740 if ( column == 1 )
02741 return GetEditorClass();
02742
02743 return NULL;
02744 }
02745
02748 int GetCommonValue() const
02749 {
02750 return m_commonValue;
02751 }
02752
02756 wxString GetType() const
02757 {
02758 return m_value.GetType();
02759 }
02760
02763 bool HasVisibleChildren() const;
02764
02768 int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
02769
02772 bool IsCategory() const { return IsFlagSet(wxPG_PROP_CATEGORY); }
02773
02776 bool IsRoot() const { return (m_parent == NULL); }
02777
02779 bool IsSubProperty() const
02780 {
02781 wxPGProperty* parent = (wxPGProperty*)m_parent;
02782 if ( parent && !parent->IsCategory() )
02783 return true;
02784 return false;
02785 }
02786
02789 const wxPGProperty* GetLastVisibleSubItem() const;
02790
02791 wxVariant GetDefaultValue() const;
02792
02793 int GetMaxLength() const
02794 {
02795 return (int) m_maxLen;
02796 }
02797
02798 #ifndef SWIG
02799 #if wxPG_COMPATIBILITY_1_2_0
02800
02804 wxVariant GetValueAsVariant() const
02805 {
02806 return GetValue();
02807 }
02808 #endif
02809 #endif
02810
02813 bool AreAllChildrenSpecified( wxVariant* pendingList = NULL ) const;
02814
02821 wxPGProperty* UpdateParentValues();
02822
02825 FlagType UsesAutoUnspecified() const
02826 {
02827 return HasFlag(wxPG_PROP_AUTO_UNSPECIFIED);
02828 }
02829
02830 wxBitmap* GetValueImage() const
02831 {
02832 return m_valueBitmap;
02833 }
02834
02835 wxVariant GetAttribute( const wxString& name ) const;
02836
02839 wxString GetAttribute( const wxString& name, const wxString& defVal ) const;
02840
02843 long GetAttributeAsLong( const wxString& name, long defVal ) const;
02844
02847 double GetAttributeAsDouble( const wxString& name, double defVal ) const;
02848
02849 inline unsigned int GetArrIndex() const { return m_arrIndex; }
02850
02851 inline unsigned int GetDepth() const { return (unsigned int)m_depth; }
02852
02858 wxString GetFlagsAsString( FlagType flagsMask ) const;
02859
02861 unsigned int GetIndexInParent() const
02862 {
02863 return m_arrIndex;
02864 }
02865
02872 bool Hide( bool hide, int flags = wxPG_RECURSE );
02873
02874 bool IsExpanded() const { return (!(m_flags & wxPG_PROP_COLLAPSED) && GetChildCount()); }
02875
02878 bool IsVisible() const;
02879
02880 bool IsEnabled() const
02881 {
02882 return ( m_flags & wxPG_PROP_DISABLED ) ? false : true;
02883 }
02884
02888 bool RecreateEditor();
02889
02892 void RefreshEditor();
02893
02901 void SetAttribute( const wxString& name, wxVariant value );
02902
02905 void SetAttributes( const wxPGAttributeStorage& attributes );
02906
02913 void SetDefaultValue( wxVariant& value )
02914 {
02915 SetAttribute(wxT("DefaultValue"), value);
02916 }
02917
02919 #ifndef SWIG
02920 void SetEditor( const wxPGEditor* editor )
02921 {
02922 m_customEditor = editor;
02923 }
02924 #endif
02925
02927 inline void SetEditor( const wxString& editorName );
02928
02933 void SetCell( int column, wxPGCell* cellObj );
02934
02937 void SetChoiceSelection( int newValue, const wxPGChoiceInfo& choiceInfo );
02938
02941 void SetCommonValue( int commonValue )
02942 {
02943 m_commonValue = commonValue;
02944 }
02945
02949 void SetFlagsFromString( const wxString& str );
02950
02958 void SetValueInEvent( wxVariant value ) const;
02959
02978 void SetValue( wxVariant value, wxVariant* pList = NULL,
02979 int flags = wxPG_SETVAL_REFRESH_EDITOR );
02980
02984 void SetValueImage( wxBitmap& bmp );
02985
02989 void SetChoicesExclusive();
02990
02991 void SetExpanded( bool expanded )
02992 {
02993 if ( !expanded ) m_flags |= wxPG_PROP_COLLAPSED;
02994 else m_flags &= ~wxPG_PROP_COLLAPSED;
02995 }
02996
03003 void SetFlag( FlagType flag ) { m_flags |= flag; }
03004
03011 void ChangeFlag( FlagType flag, bool set )
03012 {
03013 if ( set )
03014 m_flags |= flag;
03015 else
03016 m_flags &= ~flag;
03017 }
03018
03026 void SetFlagRecursively( FlagType flag, bool set );
03027
03028 void SetHelpString( const wxString& helpString )
03029 {
03030 m_helpString = helpString;
03031 }
03032
03039 void SetLabel( const wxString& label ) { m_label = label; }
03040
03041 void SetName( const wxString& newName );
03042
03046 void SetValueToUnspecified()
03047 {
03048 wxVariant val;
03049 SetValue(val, NULL, wxPG_SETVAL_REFRESH_EDITOR);
03050 }
03051
03052 #if wxUSE_VALIDATORS
03053
03054 void SetValidator( const wxValidator& validator )
03055 {
03056 m_validator = wxDynamicCast(validator.Clone(),wxValidator);
03057 }
03058
03060 wxValidator* GetValidator() const
03061 {
03062 if ( m_validator )
03063 return m_validator;
03064 return DoGetValidator();
03065 }
03066 #endif // #if wxUSE_VALIDATORS
03067
03083 bool PrepareValueForDialogEditing( wxPropertyGrid* propgrid );
03084
03085
03086
03087
03088
03089
03090
03091
03092
03093
03094
03095 ClientDataType GetClientData() const
03096 {
03097 #ifdef __WXPYTHON__
03098 if ( m_clientData )
03099 Py_INCREF( m_clientData );
03100 else
03101 Py_RETURN_NONE;
03102 #endif
03103 return m_clientData;
03104 }
03105
03110 void SetClientData( ClientDataType clientData )
03111 {
03112 #ifdef __WXPYTHON__
03113 if ( m_clientData )
03114 Py_DECREF( m_clientData );
03115
03116 if ( clientData == Py_None )
03117 {
03118 m_clientData = NULL;
03119 return;
03120 }
03121
03122 Py_INCREF( clientData );
03123 #endif
03124 m_clientData = clientData;
03125 }
03126
03137 bool SetChoices( wxPGChoices& choices );
03138
03141 inline bool SetChoices( const wxArrayString& labels,
03142 const wxArrayInt& values = wxPG_EMPTY_ARRAYINT );
03143
03146 inline bool SetMaxLength( int maxLen );
03147
03151 void SetWasModified( bool set = true )
03152 {
03153 if ( set ) m_flags |= wxPG_PROP_WAS_MODIFIED;
03154 else m_flags &= ~wxPG_PROP_WAS_MODIFIED;
03155 }
03156
03157 const wxString& GetHelpString() const
03158 {
03159 return m_helpString;
03160 }
03161
03162 void ClearFlag( FlagType flag ) { m_flags &= ~(flag); }
03163
03164
03165 bool IsSomeParent( wxPGProperty* candidate_parent ) const;
03166
03167 #if defined(__WXPYTHON__) && !defined(SWIG)
03168
03169 PyObject* m_scriptObject;
03170 wxClientData* m_OORClientData;
03171 #endif
03172
03175 void AdaptListToValue( wxVariant& list, wxVariant* value ) const;
03176
03182 int GetChildrenHeight( int lh, int iMax = -1 ) const;
03183
03185 unsigned int GetChildCount() const
03186 {
03187 return (unsigned int) m_children.GetCount();
03188 }
03189
03191 unsigned int GetCount() const
03192 {
03193 return GetChildCount();
03194 }
03195
03197 wxPGProperty* Item( unsigned int i ) const
03198 {
03199 return (wxPGProperty*)m_children.Item(i);
03200 }
03201
03204 wxPGProperty* Last() const { return (wxPGProperty*)m_children.Last(); }
03205
03207 int Index( const wxPGProperty* p ) const { return m_children.Index((wxPGProperty*)p); }
03208
03209
03210 void FixIndexesOfChildren( unsigned int starthere = 0 );
03211
03212 #ifndef SWIG
03213
03214 wxPropertyGridState* GetParentState() const { return m_parentState; }
03215 #endif
03216
03217 wxPGProperty* GetItemAtY( unsigned int y, unsigned int lh, unsigned int* nextItemY ) const;
03218
03221 wxPGProperty* GetPropertyByName( const wxString& name ) const;
03222
03226 int GetImageOffset( int imageWidth ) const;
03227
03228 protected:
03229
03246 void AddChild( wxPGProperty* prop );
03247
03248 #ifndef SWIG
03249
03252 wxString GetColumnText( unsigned int col ) const;
03253
03263 wxPGProperty* GetPropertyByNameWH( const wxString& name, unsigned int hintIndex ) const;
03264
03266 void AddChild2( wxPGProperty* prop, int index = -1, bool correct_mode = true );
03267
03268 bool DoHide( bool hide, int flags );
03269
03270 void DoSetName(const wxString& str) { m_name = str; }
03271
03273 void DoEmpty();
03274
03275
03276 void PrepareSubProperties();
03277
03278 void SetParentalType( int flag )
03279 {
03280 m_flags = (m_flags&(~(wxPG_PROP_PROPERTY|wxPG_PROP_PARENTAL_FLAGS)))|flag;
03281 }
03282
03283 void SetParentState( wxPropertyGridState* pstate ) { m_parentState = pstate; }
03284
03285
03286
03287
03288 void SubPropsChanged( int oldSelInd = -1 );
03289
03290 int GetY2( int lh ) const;
03291
03292 wxString m_label;
03293 wxString m_name;
03294 wxPGProperty* m_parent;
03295 wxPropertyGridState* m_parentState;
03296 ClientDataType m_clientData;
03297 const wxPGEditor* m_customEditor;
03298 #if wxUSE_VALIDATORS
03299 wxValidator* m_validator;
03300 #endif
03301
03302 wxBitmap* m_valueBitmap;
03303
03304 wxVariant m_value;
03305 wxPGAttributeStorage m_attributes;
03306 wxArrayPtrVoid m_children;
03307 wxArrayPtrVoid m_cells;
03308 wxString m_helpString;
03309
03310 unsigned int m_arrIndex;
03311 int m_commonValue;
03312
03313 FlagType m_flags;
03314
03315 short m_maxLen;
03316
03317
03318
03319
03320
03321 unsigned char m_depth;
03322
03323
03324
03325 unsigned char m_depthBgCol;
03326
03327 unsigned char m_bgColIndex;
03328 unsigned char m_fgColIndex;
03329
03330 private:
03331
03332 void Init();
03333 void Init( const wxString& label, const wxString& name );
03334 #endif // #ifndef SWIG
03335 };
03336
03337
03338 #if wxPG_COMPATIBILITY_1_2_0
03339 typedef wxPGProperty wxPGPropertyWithChildren;
03340 #endif
03341
03342 #define wxPGPropNameStr const wxString&
03343 #define wxPGNameConv(STR) STR
03344
03345
03346
03347
03348 #ifndef SWIG
03349
03350 WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(void*,
03351 wxPGHashMapP2P,
03352 class WXDLLIMPEXP_PG);
03353
03354 #else
03355 class WXDLLIMPEXP_PG wxPGHashMapP2P;
03356 #endif // #ifndef SWIG
03357
03358
03359
03360 #ifndef SWIG
03361
03362 WX_DECLARE_HASH_MAP_WITH_DECL(wxInt32,
03363 wxInt32,
03364 wxIntegerHash,
03365 wxIntegerEqual,
03366 wxPGHashMapI2I,
03367 class WXDLLIMPEXP_PG);
03368
03369 #else
03370 class WXDLLIMPEXP_PG wxPGHashMapI2I;
03371 #endif // #ifndef SWIG
03372
03373
03374
03375 #ifndef SWIG
03376
03381 class WXDLLIMPEXP_PG wxPGRootProperty : public wxPGProperty
03382 {
03383 public:
03384 WX_PG_DECLARE_PROPERTY_CLASS(wxPGRootProperty)
03385 public:
03386
03388 wxPGRootProperty();
03389 virtual ~wxPGRootProperty();
03390
03391 virtual bool StringToValue( wxVariant&, const wxString&, int ) const
03392 {
03393 return false;
03394 }
03395
03396 virtual void ChildChanged( wxVariant&, int, wxVariant& ) const
03397 {
03398 }
03399
03400 protected:
03401 };
03402
03403
03404
03409 class WXDLLIMPEXP_PG wxPropertyCategory : public wxPGProperty
03410 {
03411 WX_PG_DECLARE_PROPERTY_CLASS(wxPropertyCategory)
03412 public:
03413
03415 wxPropertyCategory();
03416
03424 wxPropertyCategory( const wxString& label, const wxString& name = wxPG_LABEL );
03425 ~wxPropertyCategory();
03426
03428 virtual wxString GetValueAsString( int argFlags ) const;
03429
03430 virtual void ChildChanged( wxVariant&, int, wxVariant& ) const
03431 {
03432 }
03433
03434 int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const;
03435
03436 void CalculateTextExtent( wxWindow* wnd, const wxFont& font );
03437
03438 void SetTextColIndex( unsigned int colInd ) { m_capFgColIndex = (wxByte) colInd; }
03439 unsigned int GetTextColIndex() const { return (unsigned int) m_capFgColIndex; }
03440
03441 protected:
03442 int m_textExtent;
03443 wxByte m_capFgColIndex;
03444
03445 private:
03446 void Init();
03447 };
03448
03449 #endif // !SWIG
03450
03451
03452
03458 class WXDLLIMPEXP_PG wxPGCommonValue
03459 {
03460 public:
03461
03462 wxPGCommonValue( const wxString& label, wxPGCellRenderer* renderer )
03463 {
03464 m_label = label;
03465 m_renderer = renderer;
03466 renderer->IncRef();
03467 }
03468 virtual ~wxPGCommonValue()
03469 {
03470 m_renderer->DecRef();
03471 }
03472
03473 virtual wxString GetEditableText() const { return m_label; }
03474 const wxString& GetLabel() const { return m_label; }
03475 wxPGCellRenderer* GetRenderer() const { return m_renderer; }
03476
03477 protected:
03478 wxString m_label;
03479 wxPGCellRenderer* m_renderer;
03480 };
03481
03482
03483
03484
03485 #ifndef SWIG
03486
03491 class WXDLLIMPEXP_PG wxPGChoiceEntry : public wxPGCell
03492 {
03493 public:
03494 wxPGChoiceEntry();
03495 wxPGChoiceEntry( const wxPGChoiceEntry& entry );
03496 wxPGChoiceEntry( const wxString& label,
03497 int value = wxPG_INVALID_VALUE )
03498 : wxPGCell(), m_value(value)
03499 {
03500 m_text = label;
03501 }
03502
03503 wxPGChoiceEntry( const wxString& label,
03504 int value,
03505 const wxBitmap& bitmap,
03506 const wxColour& fgCol = wxNullColour,
03507 const wxColour& bgCol = wxNullColour )
03508 : wxPGCell(label, bitmap, fgCol, bgCol), m_value(value)
03509 {
03510 }
03511
03512 virtual ~wxPGChoiceEntry()
03513 {
03514 }
03515
03516 void SetValue( int value ) { m_value = value; }
03517
03518 int GetValue() const { return m_value; }
03519
03520 protected:
03521 int m_value;
03522 };
03523
03524
03525 typedef void* wxPGChoicesId;
03526
03527 class WXDLLIMPEXP_PG wxPGChoicesData
03528 {
03529 friend class wxPGChoices;
03530 public:
03531
03532 wxPGChoicesData();
03533
03534 void CopyDataFrom( wxPGChoicesData* data );
03535
03536
03537 void Insert( int index, wxPGChoiceEntry* item )
03538 {
03539 wxArrayPtrVoid::iterator it;
03540 if ( index == -1 )
03541 {
03542 it = m_items.end();
03543 index = (int) m_items.size();
03544 }
03545 else
03546 {
03547 it = m_items.begin() + index;
03548 }
03549
03550
03551 if ( item->GetValue() == wxPG_INVALID_VALUE )
03552 item->SetValue(index);
03553
03554 m_items.insert(it, item);
03555 }
03556
03557
03558 void Clear();
03559
03560 unsigned int GetCount() const
03561 {
03562 return (unsigned int) m_items.size();
03563 }
03564
03565 wxPGChoiceEntry* Item( unsigned int i ) const
03566 {
03567 return (wxPGChoiceEntry*) m_items[i];
03568 }
03569
03570 void DecRef()
03571 {
03572 m_refCount--;
03573 wxASSERT( m_refCount >= 0 );
03574 if ( m_refCount == 0 )
03575 delete this;
03576 }
03577
03578 private:
03579 wxArrayPtrVoid m_items;
03580
03581
03582 int m_refCount;
03583
03584 virtual ~wxPGChoicesData();
03585 };
03586
03587 #define wxPGChoicesEmptyData ((wxPGChoicesData*)NULL)
03588
03589 #endif // SWIG
03590
03591
03606 class WXDLLIMPEXP_PG wxPGChoices
03607 {
03608 public:
03609
03611 wxPGChoices()
03612 {
03613 Init();
03614 }
03615
03620 wxPGChoices( const wxPGChoices& src )
03621 {
03622 if ( src.m_data != wxPGChoicesEmptyData )
03623 {
03624 m_data = src.m_data;
03625 m_data->m_refCount++;
03626 }
03627 }
03628
03638 wxPGChoices( const wxChar** labels, const long* values = NULL )
03639 {
03640 Init();
03641 Set(labels,values);
03642 }
03643
03653 wxPGChoices( const wxArrayString& labels, const wxArrayInt& values = wxPG_EMPTY_ARRAYINT )
03654 {
03655 Init();
03656 Set(labels,values);
03657 }
03658
03660 wxPGChoices( wxPGChoicesData* data )
03661 {
03662 wxASSERT(data);
03663 m_data = data;
03664 data->m_refCount++;
03665 }
03666
03668 ~wxPGChoices()
03669 {
03670 Free();
03671 }
03672
03673 void AssignData( wxPGChoicesData* data );
03674
03679 void Assign( const wxPGChoices& src )
03680 {
03681 AssignData(src.m_data);
03682 }
03683
03684 #ifndef SWIG
03685 void operator= (const wxPGChoices& a)
03686 {
03687 AssignData(a.m_data);
03688 }
03689 #endif
03690
03691 typedef long ValArrItem;
03692
03703 void Add( const wxChar** labels, const ValArrItem* values = NULL );
03704
03706 void Add( const wxArrayString& arr, const ValArrItem* values = NULL );
03707
03709 void Add( const wxArrayString& arr, const wxArrayInt& arrint );
03710
03720 wxPGChoiceEntry& Add( const wxString& label, int value = wxPG_INVALID_VALUE );
03721
03723 wxPGChoiceEntry& Add( const wxString& label, const wxBitmap& bitmap, int value = wxPG_INVALID_VALUE );
03724
03726 wxPGChoiceEntry& Add( const wxPGChoiceEntry& entry )
03727 {
03728 return Insert(entry, -1);
03729 }
03730
03732 wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE );
03733
03735 void Clear()
03736 {
03737 if ( m_data != wxPGChoicesEmptyData )
03738 m_data->Clear();
03739 }
03740
03744 wxPGChoices Copy() const
03745 {
03746 wxPGChoices dst;
03747 dst.EnsureData();
03748 dst.m_data->CopyDataFrom(m_data);
03749 return dst;
03750 }
03751
03752 void EnsureData()
03753 {
03754 if ( m_data == wxPGChoicesEmptyData )
03755 m_data = new wxPGChoicesData();
03756 }
03757
03758 const wxPGChoiceEntry& Item( unsigned int i ) const
03759 {
03760 wxASSERT( IsOk() );
03761 return *m_data->Item(i);
03762 }
03763
03764 wxPGChoiceEntry& Item( unsigned int i )
03765 {
03766 wxASSERT( IsOk() );
03767 return *m_data->Item(i);
03768 }
03769
03770 wxPGChoiceEntry& operator[](unsigned int i)
03771 {
03772 return Item(i);
03773 }
03774
03775 const wxPGChoiceEntry& operator[](unsigned int i) const
03776 {
03777 return Item(i);
03778 }
03779
03783 bool IsOk() const
03784 {
03785 return ( m_data != wxPGChoicesEmptyData );
03786 }
03787
03789 wxPGChoicesId GetId() const { return (wxPGChoicesId) m_data; };
03790
03792 void RemoveAt(size_t nIndex, size_t count = 1);
03793
03794 #ifndef SWIG
03795
03796 void Set( const wxChar** labels, const long* values = NULL )
03797 {
03798 Free();
03799 Add(labels,values);
03800 }
03801
03805 void Set( wxArrayString& arr, const long* values = (const long*) NULL )
03806 {
03807 Free();
03808 Add(arr,values);
03809 }
03810 #endif // SWIG
03811
03813 void Set( const wxArrayString& labels, const wxArrayInt& values = wxPG_EMPTY_ARRAYINT )
03814 {
03815 Free();
03816 if ( &values )
03817 Add(labels,values);
03818 else
03819 Add(labels);
03820 }
03821
03822
03823 void SetExclusive()
03824 {
03825 if ( m_data->m_refCount != 1 )
03826 {
03827 wxPGChoicesData* data = new wxPGChoicesData();
03828 data->CopyDataFrom(m_data);
03829 Free();
03830 m_data = data;
03831 }
03832 }
03833
03834 const wxString& GetLabel( unsigned int ind ) const
03835 {
03836 wxASSERT( ind >= 0 && ind < GetCount() );
03837 return Item(ind).GetText();
03838 }
03839
03840 unsigned int GetCount () const
03841 {
03842 if ( m_data )
03843 return m_data->GetCount();
03844 return 0;
03845 }
03846
03847 #if wxPG_COMPATIBILITY_1_2_0
03848
03856 wxDEPRECATED( bool HasValues() const );
03857
03865 wxDEPRECATED( bool HasValue( unsigned int i ) const );
03866 #endif
03867
03868 int GetValue( unsigned int ind ) const { return Item(ind).GetValue(); }
03869
03873 wxArrayInt GetValuesForStrings( const wxArrayString& strings ) const;
03874
03878 wxArrayInt GetIndicesForStrings( const wxArrayString& strings, wxArrayString* unmatched = NULL ) const;
03879
03880 int Index( const wxString& str ) const;
03881 int Index( int val ) const;
03882
03884 wxPGChoiceEntry& Insert( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
03885
03887 wxPGChoiceEntry& Insert( const wxPGChoiceEntry& entry, int index );
03888
03889
03890 wxPGChoicesData* GetData()
03891 {
03892 wxASSERT( m_data->m_refCount != 0xFFFFFFF );
03893 m_data->m_refCount++;
03894 return m_data;
03895 }
03896
03897
03898 wxPGChoicesData* GetDataPtr() const { return m_data; }
03899
03900
03901 wxPGChoicesData* ExtractData()
03902 {
03903 wxPGChoicesData* data = m_data;
03904 m_data = wxPGChoicesEmptyData;
03905 return data;
03906 }
03907
03908 wxArrayString GetLabels() const;
03909
03910 #ifndef SWIG
03911
03912 protected:
03913 wxPGChoicesData* m_data;
03914
03915 void Init();
03916 void Free();
03917 #endif
03918 };
03919
03920
03921
03922
03923 #ifndef SWIG
03924 #if wxMINOR_VERSION < 7 || ( wxMINOR_VERSION == 7 && wxRELEASE_NUMBER < 1 )
03925
03926
03927 WX_DECLARE_OBJARRAY_WITH_DECL(double, wxArrayDouble, class WXDLLIMPEXP_PG);
03928 #endif
03929 #endif // !SWIG
03930
03931
03932
03933
03934
03935 #define wxPG_CONSTFUNC(PROP) PROP##Create
03936 #define wxPG_PROPCLASS(PROP) PROP
03937
03938
03939 #define wxPG_NEWPROPERTY(PROP,LABEL,NAME,VALUE) wx##PROP##Property(LABEL,NAME,VALUE)
03940
03941
03942 WXDLLIMPEXP_PG wxObject* wxPG_VariantToWxObject( const wxVariant& variant, wxClassInfo* classInfo );
03943
03944
03945
03946
03947
03948 #undef wxGetVariantCast
03949 #define wxGetVariantCast(var,classname) (classname*)wxPG_VariantToWxObject(var,&classname::ms_classInfo)
03950
03951
03952 #define WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) (CLASSNAME*)wxPG_VariantToWxObject(VARIANT,&CLASSNAME::ms_classInfo)
03953
03954
03955
03956 #define wxPG_IT_CHILDREN(A) (A<<16)
03957
03965 enum wxPG_ITERATOR_FLAGS
03966 {
03967
03970 wxPG_ITERATE_PROPERTIES = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
03971 wxPG_PROP_COLLAPSED|((wxPG_PROP_MISC_PARENT|wxPG_PROP_CATEGORY)<<16)),
03972
03975 wxPG_ITERATE_HIDDEN = (wxPG_PROP_HIDDEN|wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED)),
03976
03979 wxPG_ITERATE_FIXED_CHILDREN = (wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)|wxPG_ITERATE_PROPERTIES),
03980
03984 wxPG_ITERATE_CATEGORIES = (wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY)|wxPG_PROP_COLLAPSED),
03985
03986 wxPG_ITERATE_ALL_PARENTS = (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY),
03987
03988 wxPG_ITERATE_ALL_PARENTS_RECURSIVELY = (wxPG_ITERATE_ALL_PARENTS|wxPG_IT_CHILDREN(wxPG_ITERATE_ALL_PARENTS)),
03989
03990 wxPG_ITERATOR_FLAGS_ALL = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
03991 wxPG_PROP_HIDDEN|wxPG_PROP_CATEGORY|wxPG_PROP_COLLAPSED),
03992
03993 wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL,
03994
03995 wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL,
03996
04000 wxPG_ITERATE_VISIBLE = (wxPG_ITERATE_PROPERTIES|wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)),
04001
04004 wxPG_ITERATE_ALL = (wxPG_ITERATE_VISIBLE|wxPG_ITERATE_HIDDEN),
04005
04009 wxPG_ITERATE_NORMAL = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN),
04010
04013 wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
04014
04015 };
04016
04021 #define wxPG_ITERATOR_CREATE_MASKS(FLAGS, A, B) \
04022 A = (FLAGS ^ wxPG_ITERATOR_MASK_OP_ITEM) & wxPG_ITERATOR_MASK_OP_ITEM & 0xFFFF; \
04023 B = ((FLAGS>>16) ^ wxPG_ITERATOR_MASK_OP_PARENT) & wxPG_ITERATOR_MASK_OP_PARENT & 0xFFFF;
04024
04025
04026
04027 #define wxPG_ITERATOR_PARENTEXMASK_TEST(PWC, PARENTMASK) \
04028 ( \
04029 !(PWC->GetFlags() & PARENTMASK) && \
04030 PWC->GetChildCount() \
04031 )
04032
04033
04038 class WXDLLIMPEXP_PG wxPropertyGridIteratorBase
04039 {
04040 public:
04041 wxPropertyGridIteratorBase()
04042 {
04043 }
04044
04045 void Assign( const wxPropertyGridIteratorBase& it );
04046
04047 bool AtEnd() const { return m_property == NULL; }
04048
04051 wxPGProperty* GetProperty() const { return m_property; }
04052
04053 void Init( wxPropertyGridState* state, int flags, wxPGProperty* property, int dir = 1 );
04054
04055 void Init( wxPropertyGridState* state, int flags, int startPos = wxTOP, int dir = 0 );
04056
04059 void Next( bool iterateChildren = true );
04060
04063 void Prev();
04064
04069 void SetBaseParent( wxPGProperty* baseParent ) { m_baseParent = baseParent; }
04070
04071 protected:
04072
04073 wxPGProperty* m_property;
04074
04075 private:
04076 wxPropertyGridState* m_state;
04077 wxPGProperty* m_baseParent;
04078
04079
04080 int m_itemExMask;
04081 int m_parentExMask;
04082 };
04083
04084
04085 #define wxPG_IMPLEMENT_ITERATOR(CLASS, PROPERTY, STATE) \
04086 CLASS( STATE* state, int flags = wxPG_ITERATE_DEFAULT, PROPERTY* property = NULL, int dir = 1 ) \
04087 : wxPropertyGridIteratorBase() \
04088 { Init( (wxPropertyGridState*)state, flags, (wxPGProperty*)property, dir ); } \
04089 CLASS( STATE* state, int flags, int startPos, int dir = 0 ) \
04090 : wxPropertyGridIteratorBase() \
04091 { Init( (wxPropertyGridState*)state, flags, startPos, dir ); } \
04092 CLASS() \
04093 : wxPropertyGridIteratorBase() \
04094 { \
04095 m_property = NULL; \
04096 } \
04097 CLASS( const CLASS& it ) \
04098 : wxPropertyGridIteratorBase( ) \
04099 { \
04100 Assign(it); \
04101 } \
04102 ~CLASS() \
04103 { \
04104 } \
04105 const CLASS& operator=( const CLASS& it ) \
04106 { \
04107 Assign(it); \
04108 return *this; \
04109 } \
04110 CLASS& operator++() { Next(); return *this; } \
04111 CLASS operator++(int) { CLASS it=*this;Next();return it; } \
04112 CLASS& operator--() { Prev(); return *this; } \
04113 CLASS operator--(int) { CLASS it=*this;Prev();return it; } \
04114 PROPERTY* operator *() const { return (PROPERTY*)m_property; } \
04115 static PROPERTY* OneStep( STATE* state, int flags = wxPG_ITERATE_DEFAULT, PROPERTY* property = NULL, int dir = 1 ) \
04116 { \
04117 CLASS it( state, flags, property, dir ); \
04118 if ( property ) \
04119 { \
04120 if ( dir == 1 ) it.Next(); \
04121 else it.Prev(); \
04122 } \
04123 return *it; \
04124 }
04125
04126
04134 class WXDLLIMPEXP_PG wxPropertyGridIterator : public wxPropertyGridIteratorBase
04135 {
04136 public:
04137
04138 wxPG_IMPLEMENT_ITERATOR(wxPropertyGridIterator,
04139 wxPGProperty,
04140 wxPropertyGridState)
04141
04142 protected:
04143 };
04144
04145
04150 class WXDLLIMPEXP_PG wxPropertyGridConstIterator : public wxPropertyGridIteratorBase
04151 {
04152 public:
04153 wxPG_IMPLEMENT_ITERATOR(wxPropertyGridConstIterator,
04154 const wxPGProperty,
04155 const wxPropertyGridState)
04156
04157
04160 wxPropertyGridConstIterator( const wxPropertyGridIterator& other )
04161 {
04162 Assign(other);
04163 }
04164
04168 const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it )
04169 {
04170 Assign(it);
04171 return *this;
04172 }
04173
04174 protected:
04175 };
04176
04177
04178
04181 class WXDLLIMPEXP_PG wxPGVIteratorBase
04182 {
04183 friend class wxPGVIterator;
04184 public:
04185 wxPGVIteratorBase() { m_refCount = 1; }
04186 virtual void Next() = 0;
04187 void IncRef()
04188 {
04189 m_refCount++;
04190 }
04191 void DecRef()
04192 {
04193 m_refCount--;
04194 if ( m_refCount <= 0 )
04195 delete this;
04196 }
04197 protected:
04198 virtual ~wxPGVIteratorBase() { }
04199
04200 wxPropertyGridIterator m_it;
04201 private:
04202 int m_refCount;
04203 };
04204
04212 class WXDLLIMPEXP_PG wxPGVIterator
04213 {
04214 public:
04215 wxPGVIterator() { m_pIt = NULL; }
04216 wxPGVIterator( wxPGVIteratorBase* obj ) { m_pIt = obj; }
04217 ~wxPGVIterator() { UnRef(); }
04218 void UnRef() { if (m_pIt) m_pIt->DecRef(); }
04219 wxPGVIterator( const wxPGVIterator& it )
04220 {
04221 m_pIt = it.m_pIt;
04222 m_pIt->IncRef();
04223 }
04224 #ifndef SWIG
04225 const wxPGVIterator& operator=( const wxPGVIterator& it )
04226 {
04227 UnRef();
04228 m_pIt = it.m_pIt;
04229 m_pIt->IncRef();
04230 return *this;
04231 }
04232 #endif
04233 void Next() { m_pIt->Next(); }
04234 bool AtEnd() const { return m_pIt->m_it.AtEnd(); }
04235 wxPGProperty* GetProperty() const { return m_pIt->m_it.GetProperty(); }
04236 protected:
04237 wxPGVIteratorBase* m_pIt;
04238 };
04239
04240
04241
04247 class WXDLLIMPEXP_PG wxPropertyGridHitTestResult
04248 {
04249 friend class wxPropertyGrid;
04250 public:
04251 wxPropertyGridHitTestResult()
04252 {
04253 property = NULL;
04254 column = -1;
04255 splitter = -1;
04256 splitterHitOffset = 0;
04257 }
04258
04259 ~wxPropertyGridHitTestResult()
04260 {
04261 }
04262
04266 int GetColumn() const { return column; }
04267
04272 wxPGProperty* GetProperty() const
04273 {
04274 return property;
04275 }
04276
04280 int GetSplitter() const { return splitter; }
04281
04286 int GetSplitterHitOffset() const { return splitterHitOffset; }
04287
04289 wxPGProperty* property;
04290
04292 int column;
04293
04295 int splitter;
04296
04298 int splitterHitOffset;
04299 };
04300
04301
04302
04307 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
04308 {
04309
04313 wxPG_VFB_STAY_IN_PROPERTY = 0x01,
04314
04317 wxPG_VFB_BEEP = 0x02,
04318
04321 wxPG_VFB_MARK_CELL = 0x04,
04322
04331 wxPG_VFB_SHOW_MESSAGE = 0x08,
04332
04336 wxPG_VFB_SHOW_MESSAGEBOX = 0x10,
04337
04341 wxPG_VFB_SHOW_MESSAGE_ON_STATUSBAR = 0x20,
04342
04344 wxPG_VFB_DEFAULT = wxPG_VFB_STAY_IN_PROPERTY|wxPG_VFB_BEEP,
04345
04347 wxPG_VFB_UNDEFINED = 0x80
04348
04349 };
04350
04354
04355 #define wxPGVFBFlags unsigned char
04356
04363 struct WXDLLIMPEXP_PG wxPGValidationInfo
04364 {
04367 wxVariant* m_pValue;
04368
04371 wxString m_failureMessage;
04372
04375 wxPGVFBFlags m_failureBehavior;
04376
04378 bool m_isFailing;
04379
04380 wxPGValidationInfo()
04381 {
04382 m_failureBehavior = 0;
04383 m_isFailing = false;
04384 }
04385
04386 ~wxPGValidationInfo()
04387 {
04388 }
04389
04390 wxPGVFBFlags GetFailureBehavior() const { return m_failureBehavior; }
04391
04392 void SetFailureBehavior(wxPGVFBFlags failureBehavior) { m_failureBehavior = failureBehavior; }
04393
04394 const wxString& GetFailureMessage() const { return m_failureMessage; }
04395
04396 void SetFailureMessage(const wxString& message) { m_failureMessage = message; }
04397 };
04398
04399
04400
04406 enum wxPG_KEYBOARD_ACTIONS
04407 {
04408 wxPG_ACTION_INVALID = 0,
04409 wxPG_ACTION_NEXT_PROPERTY,
04410 wxPG_ACTION_PREV_PROPERTY,
04411 wxPG_ACTION_EXPAND_PROPERTY,
04412 wxPG_ACTION_COLLAPSE_PROPERTY,
04413 wxPG_ACTION_CANCEL_EDIT,
04414 wxPG_ACTION_CUT,
04415 wxPG_ACTION_COPY,
04416 wxPG_ACTION_PASTE,
04417 wxPG_ACTION_SELECT_ALL,
04418 wxPG_ACTION_EDIT,
04419 wxPG_ACTION_MAX
04420 };
04421
04426 #ifndef SWIG
04427
04428
04436
04437 class WXDLLIMPEXP_PG wxPropertyGridState
04438 {
04439 friend class wxPGProperty;
04440 friend class wxPropertyGrid;
04441 friend class wxPGCanvas;
04442 friend class wxPropertyGridPage;
04443 friend class wxPropertyGridManager;
04444 friend class wxPropertyGridInterface;
04445 public:
04446
04448 wxPropertyGridState();
04449
04451 virtual ~wxPropertyGridState();
04452
04454 wxPGProperty* DoAppend( wxPGProperty* property );
04455
04457 wxPGProperty* BaseGetPropertyByName( wxPGPropNameStr name ) const;
04458
04460 void DoClear();
04461
04462 bool DoIsPropertySelected( wxPGProperty* prop ) const;
04463
04464 void ClearModifiedStatus( wxPGProperty* p );
04465
04466 bool DoClearSelection()
04467 {
04468 return DoSelectProperty(NULL);
04469 }
04470
04471 void DoRemoveFromSelection( wxPGProperty* prop );
04472
04473 bool DoCollapse( wxPGProperty* p );
04474
04475 bool DoExpand( wxPGProperty* p );
04476
04477 void CalculateFontAndBitmapStuff( int vspacing );
04478
04481 void CheckColumnWidths( int widthChange = 0 );
04482
04485 virtual void DoDelete( wxPGProperty* item, bool doDelete = true );
04486
04487 wxSize DoFitColumns( bool allowGridResize = false );
04488
04489 wxPGProperty* DoGetItemAtY( int y ) const;
04490
04493 virtual wxPGProperty* DoInsert( wxPGProperty* parent, int index, wxPGProperty* property );
04494
04498 virtual void DoSetSplitterPosition( int pos, int splitterColumn = 0, bool allPages = false, bool fromAutoCenter = false );
04499
04500 bool EnableCategories( bool enable );
04501
04504 void EnsureVirtualHeight()
04505 {
04506 if ( m_vhCalcPending )
04507 {
04508 RecalculateVirtualHeight();
04509 m_vhCalcPending = 0;
04510 }
04511 }
04512
04514 bool DoEnableProperty( wxPGProperty* p, bool enable );
04515
04518 unsigned int GetVirtualHeight() const
04519 {
04520 wxASSERT( !m_vhCalcPending );
04521 return m_virtualHeight;
04522 }
04523
04526 unsigned int GetVirtualHeight()
04527 {
04528 EnsureVirtualHeight();
04529 return m_virtualHeight;
04530 }
04531
04536 inline unsigned int GetActualVirtualHeight() const;
04537
04538 unsigned int GetColumnCount() const
04539 {
04540 return (unsigned int) m_colWidths.size();
04541 }
04542
04543 int GetColumnMinWidth( int column ) const;
04544
04545 int GetColumnWidth( unsigned int column ) const
04546 {
04547 return m_colWidths[column];
04548 }
04549
04550 wxPropertyGrid* GetGrid() const { return m_pPropGrid; }
04551
04556 wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT );
04557
04558 const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
04559 {
04560 return ((wxPropertyGridState*)this)->GetLastItem(flags);
04561 }
04562
04563 #if wxPG_COMPATIBILITY_1_2_0
04564 wxPGProperty* GetNextCategory( wxPGProperty* id ) const;
04565
04566 wxPGProperty* GetNextProperty( wxPGProperty* id );
04567
04568 wxPGProperty* GetNextSiblingProperty( wxPGProperty* id );
04569
04570 wxPGProperty* GetPrevSiblingProperty( wxPGProperty* id );
04571
04572 wxPGProperty* GetPrevProperty( wxPGProperty* id );
04573 #endif // wxPG_COMPATIBILITY_1_2_0
04574
04575 wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
04576
04577 wxPGProperty* GetPropertyByLabel( const wxString& name, wxPGProperty* parent = NULL ) const;
04578
04579 wxVariant DoGetPropertyValues( const wxString& listname, wxPGProperty* baseparent, long flags ) const;
04580
04581 wxPGProperty* DoGetRoot() const { return m_properties; }
04582
04583
04584 int GetVirtualWidth() const
04585 {
04586 return m_width;
04587 }
04588
04594 int GetColumnFitWidth(wxClientDC& dc, wxPGProperty* pwc, unsigned int col, bool subProps) const;
04595
04599 wxPGProperty* GetSelection() const
04600 {
04601 if ( m_selection.size() == 0 )
04602 return NULL;
04603 return m_selection[0];
04604 }
04605
04606 void DoSetSelection( wxPGProperty* prop )
04607 {
04608 m_selection.clear();
04609 if ( prop )
04610 m_selection.push_back(prop);
04611 }
04612
04613 void DoSetColumnProportion( unsigned int column, int proportion );
04614
04615 int DoGetColumnProportion( unsigned int column ) const
04616 {
04617 return m_columnProportions[column];
04618 }
04619
04620 void ResetColumnSizes( bool fromAutoCenter );
04621
04631 wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
04632
04633 inline bool IsDisplayed() const;
04634
04635 bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); }
04636
04638 void InitNonCatMode ();
04639
04640 void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true )
04641 {
04642 p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit);
04643 }
04644
04645 bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
04646
04649 void OnClientWidthChange( int newWidth, int widthChange, bool fromOnResize = false );
04650
04653 void RecalculateVirtualHeight()
04654 {
04655 m_virtualHeight = GetActualVirtualHeight();
04656 }
04657
04658 void SetColumnCount( int colCount );
04659
04660 void PropagateColSizeDec( int column, int decrease, int dir );
04661
04662 bool DoHideProperty( wxPGProperty* p, bool hide, int flags = wxPG_RECURSE );
04663
04664 bool DoSetPropertyValueString( wxPGProperty* p, const wxString& value );
04665
04666 bool DoSetPropertyValue( wxPGProperty* p, wxVariant& value );
04667
04668 bool DoSetPropertyValueWxObjectPtr( wxPGProperty* p, wxObject* value );
04669 void DoSetPropertyValues( const wxVariantList& list, wxPGProperty* default_category );
04670
04671 #ifdef wxPG_COMPATIBILITY_1_2_0
04672 #define SetPropertyUnspecified SetPropertyValueUnspecified
04673 #endif
04674
04675 void SetSplitterLeft( bool subProps = false );
04676
04678 void SetVirtualWidth( int width );
04679
04680 void Sort( wxPGProperty* p );
04681 void Sort();
04682
04685 void VirtualHeightChanged()
04686 {
04687 m_vhCalcPending = 1;
04688 }
04689
04690 protected:
04691
04692
04693 bool ArePropertiesAdjacent( wxPGProperty* prop1,
04694 wxPGProperty* prop2,
04695 int iterFlags = wxPG_ITERATE_VISIBLE ) const;
04696
04697 int DoGetSplitterPosition( int splitterIndex = 0 ) const;
04698
04705 int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const;
04706
04707 #ifndef DOXYGEN
04708 int PrepareToAddItem ( wxPGProperty* property, wxPGProperty* scheduledParent );
04709
04713 wxPropertyGrid* m_pPropGrid;
04714
04716 wxPGProperty* m_properties;
04717
04719 wxPGRootProperty m_regularArray;
04720
04722 wxPGRootProperty* m_abcArray;
04723
04725 wxPGHashMapS2P m_dictName;
04726
04728 wxArrayInt m_colWidths;
04729
04731 wxArrayInt m_editableColumns;
04732
04734 wxArrayInt m_columnProportions;
04735
04736 double m_fSplitterX;
04737
04739 wxPropertyCategory* m_currentCategory;
04740
04742 wxArrayPGProperty m_selection;
04743
04745 int m_width;
04746
04748 unsigned int m_virtualHeight;
04749
04751 unsigned char m_lastCaptionBottomnest;
04752
04757 unsigned char m_itemsAdded;
04758
04760 unsigned char m_anyModified;
04761
04762 unsigned char m_vhCalcPending;
04763
04764 #endif // #ifndef DOXYGEN
04765
04766 };
04767
04768 #endif // #ifndef SWIG
04769
04770 inline bool wxPGProperty::SetChoices( const wxArrayString& labels,
04771 const wxArrayInt& values )
04772 {
04773 wxPGChoices chs(labels,values);
04774 return SetChoices(chs);
04775 }
04776
04777
04778
04779
04780
04781 #define GetPropertyByNameI GetPropertyByNameA
04782
04783
04784 #define GetPropertyByNameWithAssert GetPropertyByNameA
04785
04786
04787
04788
04789 #define wxPG_PROP_ARG_CALL_PROLOG_0(PROPERTY) \
04790 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
04791 if ( !p ) return;
04792
04793 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(PROPERTY, RETVAL) \
04794 PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
04795 if ( !p ) return RETVAL;
04796
04797 #define wxPG_PROP_ARG_CALL_PROLOG() \
04798 wxPG_PROP_ARG_CALL_PROLOG_0(wxPGProperty)
04799
04800 #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL(RVAL) \
04801 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(wxPGProperty, RVAL)
04802
04803 #define wxPG_PROP_ID_CONST_CALL_PROLOG() \
04804 wxPG_PROP_ARG_CALL_PROLOG_0(const wxPGProperty)
04805
04806 #define wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(RVAL) \
04807 wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(const wxPGProperty, RVAL)
04808
04809
04815 class WXDLLIMPEXP_PG wxPropertyGridInterface
04816
04817 {
04818 friend class wxPropertyGrid;
04819 friend class wxPropertyGridManager;
04820 public:
04821
04823 virtual ~wxPropertyGridInterface() { };
04824
04833 void AddPropertyChoice( wxPGPropArg id, const wxString& label, int value = wxPG_INVALID_VALUE );
04834
04847 wxPGProperty* Append( wxPGProperty* property );
04848
04849 #if wxPG_COMPATIBILITY_1_2_0
04850 wxDEPRECATED( wxPGProperty* AppendCategory( const wxString& label, const wxString& name = wxPG_LABEL ) );
04851 #endif
04852
04853 wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newproperty );
04854
04858 void BeginAddChildren( wxPGPropArg id );
04859
04862 void EndAddChildren( wxPGPropArg id );
04863
04868 void InsertPropertyChoice( wxPGPropArg id, const wxString& label, int index, int value = wxPG_INVALID_VALUE );
04869
04872 virtual void Clear() = 0;
04873
04880 bool ClearSelection( bool validation = true );
04881
04885 bool Collapse( wxPGPropArg id );
04886
04892 bool CollapseAll() { return ExpandAll(false); }
04893
04900 void DeletePropertyChoice( wxPGPropArg id, int index );
04901
04909 bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
04910
04912 bool ClearPropertyValue( wxPGPropArg id )
04913 {
04914 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
04915 p->SetValue(p->GetDefaultValue());
04916 return true;
04917 }
04918
04924 static wxPGProperty* CreatePropertyByClass(const wxString &classname,
04925 const wxString &label,
04926 const wxString &name);
04927
04936 static wxPGProperty* CreatePropertyByType(const wxString &valuetype,
04937 const wxString &label,
04938 const wxString &name);
04939
04950 void DeleteProperty( wxPGPropArg id );
04951
04965 wxPGProperty* RemoveProperty( wxPGPropArg id );
04966
04967 #if wxPG_COMPATIBILITY_1_2_0
04968
04972 wxDEPRECATED( void Delete( wxPGPropArg id ) );
04973 #endif
04974
04975 #if wxPG_COMPATIBILITY_1_2_0
04976
04980 wxDEPRECATED( bool Disable( wxPGPropArg id ) );
04981 #endif
04982
04984 bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); }
04985
04987 bool EnableProperty( wxPGPropArg id, bool enable = true );
04988
04992 bool Expand( wxPGPropArg id );
04993
04996 bool ExpandAll( bool expand = true );
04997
05003 wxArrayPGProperty GetExpandedProperties() const
05004 {
05005 wxArrayPGProperty array;
05006 GetPropertiesWithFlag(&array, wxPG_PROP_COLLAPSED, true,
05007 wxPG_ITERATE_ALL_PARENTS_RECURSIVELY|wxPG_ITERATE_HIDDEN);
05008 return array;
05009 }
05010
05015 wxPGProperty* GetFirstChild( wxPGPropArg id )
05016 {
05017 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
05018
05019 if ( !p->GetChildCount() || p->IsFlagSet(wxPG_PROP_AGGREGATE) )
05020 return wxNullProperty;
05021
05022 return p->Item(0);
05023 }
05024
05033 wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL )
05034 {
05035 return wxPropertyGridIterator( m_pState, flags, firstProp );
05036 }
05037
05038 wxPropertyGridConstIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, wxPGProperty* firstProp = NULL ) const
05039 {
05040 return wxPropertyGridConstIterator( m_pState, flags, firstProp );
05041 }
05042
05053 wxPropertyGridIterator GetIterator( int flags, int startPos )
05054 {
05055 return wxPropertyGridIterator( m_pState, flags, startPos );
05056 }
05057
05058 wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const
05059 {
05060 return wxPropertyGridConstIterator( m_pState, flags, startPos );
05061 }
05062
05067 virtual wxPGVIterator GetVIterator( int flags ) const;
05068
05073 wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL )
05074 {
05075 wxPropertyGridIterator it( m_pState, flags, wxNullProperty, 1 );
05076 return *it;
05077 }
05078
05079 const wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ) const
05080 {
05081 return ((wxPropertyGridInterface*)this)->GetFirst(flags);
05082 }
05083
05084 #if wxPG_COMPATIBILITY_1_2_0
05085
05086 wxPGProperty* GetNextSiblingProperty( wxPGPropArg id )
05087 {
05088 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
05089 return m_pState->GetNextSiblingProperty(p);
05090 }
05091 #endif
05092
05098 const wxPGAttributeStorage& GetPropertyAttributes( wxPGPropArg id ) const
05099 {
05100 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(*((const wxPGAttributeStorage*)NULL));
05101 return p->GetAttributes();
05102 }
05103
05106 void SetPropertyAttributes( wxPGPropArg id, const wxPGAttributeStorage& attributes )
05107 {
05108 wxPG_PROP_ARG_CALL_PROLOG()
05109 p->SetAttributes(attributes);
05110 }
05111
05123 void GetPropertiesWithFlag( wxArrayPGProperty* targetArr,
05124 wxPGProperty::FlagType flags,
05125 bool inverse = false,
05126 int iterFlags = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES) ) const;
05127
05130 wxVariant GetPropertyAttribute( wxPGPropArg id, const wxString& attrName ) const
05131 {
05132 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant)
05133 return p->GetAttribute(attrName);
05134 }
05135
05144 wxPGProperty* GetProperty( wxPGPropNameStr name ) const
05145 {
05146 return GetPropertyByName(name);
05147 }
05148
05157 wxPGProperty* GetPropertyByName( wxPGPropNameStr name ) const;
05158
05162 wxPGProperty* GetPropertyByName( wxPGPropNameStr name, wxPGPropNameStr subname ) const;
05163
05168 wxPGChoices& GetPropertyChoices( wxPGPropArg id );
05169
05171 wxPG_CONST_WXCHAR_PTR GetPropertyClassName( wxPGPropArg id ) const
05172 {
05173 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxPG_CONST_WXCHAR_DEFVAL)
05174 return p->GetClassName();
05175 }
05176
05178 wxPGProperty::ClientDataType GetPropertyClientData( wxPGPropArg id ) const
05179 {
05180 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05181 return p->GetClientData();
05182 }
05184 const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const
05185 {
05186 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05187 return p->GetEditorClass();
05188 }
05189
05191 wxBitmap* GetPropertyImage( wxPGPropArg id ) const
05192 {
05193 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05194 return p->GetValueImage();
05195 }
05196
05198 unsigned int GetPropertyIndex( wxPGPropArg id )
05199 {
05200 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(INT_MAX)
05201 return p->GetIndexInParent();
05202 }
05203
05205 const wxString& GetPropertyLabel( wxPGPropArg id )
05206 {
05207 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
05208 return p->GetLabel();
05209 }
05211 wxString GetPropertyName( wxPGPropArg id )
05212 {
05213 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
05214 return p->GetName();
05215 }
05216
05218 wxPGProperty* GetPropertyParent( wxPGPropArg id )
05219 {
05220 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
05221 return p->GetParent();
05222 }
05223
05224 #if wxPG_COMPATIBILITY_1_2_0
05225
05227 wxPGProperty* GetPropertyPtr( wxPGPropArg id ) const
05228 {
05229 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05230 return p;
05231 }
05232 #endif
05233
05235 wxString GetPropertyHelpString( wxPGPropArg id ) const
05236 {
05237 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
05238 return p->GetHelpString();
05239 }
05240
05245 wxString GetPropertyShortClassName( wxPGPropArg id );
05246
05247 #if wxUSE_VALIDATORS
05248
05251 wxValidator* GetPropertyValidator( wxPGPropArg id )
05252 {
05253 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
05254 return p->GetValidator();
05255 }
05256 #endif
05257
05258 #ifndef SWIG
05259
05264 wxVariant GetPropertyValue( wxPGPropArg id )
05265 {
05266 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
05267 return p->GetValue();
05268 }
05269 #else
05270 %pythoncode {
05271 def GetPropertyValue(self, prop):
05272 if isinstance(prop, basestring):
05273 prop = self.GetProperty(prop)
05274 return prop.GetValue()
05275 }
05276 #endif
05277
05278 wxString GetPropertyValueAsString( wxPGPropArg id ) const;
05279 long GetPropertyValueAsLong( wxPGPropArg id ) const;
05280 unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const
05281 {
05282 return (unsigned long) GetPropertyValueAsLong(id);
05283 }
05284 #ifndef SWIG
05285 int GetPropertyValueAsInt( wxPGPropArg id ) const { return (int)GetPropertyValueAsLong(id); }
05286 #endif
05287 bool GetPropertyValueAsBool( wxPGPropArg id ) const;
05288 double GetPropertyValueAsDouble( wxPGPropArg id ) const;
05289 wxObject* GetPropertyValueAsWxObjectPtr( wxPGPropArg id ) const;
05290 void* GetPropertyValueAsVoidPtr( wxPGPropArg id ) const;
05291
05292 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
05293 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
05294 if ( p->m_value.GetType() != TYPENAME ) \
05295 { \
05296 wxPGGetFailed(p,TYPENAME); \
05297 return DEFVAL; \
05298 }
05299
05300 #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
05301 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
05302 if ( p->m_value.GetType() != TYPENAME ) \
05303 return DEFVAL; \
05304
05305 wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
05306 {
05307 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("arrstring"), wxArrayString())
05308 return p->m_value.GetArrayString();
05309 }
05310
05311 wxPoint GetPropertyValueAsPoint( wxPGPropArg id ) const
05312 {
05313 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxPoint"), wxPoint())
05314 return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxPoint);
05315 }
05316
05317 wxSize GetPropertyValueAsSize( wxPGPropArg id ) const
05318 {
05319 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxSize"), wxSize())
05320 return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxSize);
05321 }
05322
05323 wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const
05324 {
05325 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxLongLong"), (long) GetPropertyValueAsLong(id))
05326 return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxLongLong).GetValue();
05327 }
05328
05329 wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const
05330 {
05331 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxULongLong"), (unsigned long) GetPropertyValueAsULong(id))
05332 return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxULongLong).GetValue();
05333 }
05334
05335 wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const
05336 {
05337 wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxArrayInt"), wxArrayInt())
05338 wxArrayInt arr = WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxArrayInt);
05339 return arr;
05340 }
05341
05342 #if wxUSE_DATETIME
05343 wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const
05344 {
05345 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxDateTime())
05346
05347 if ( wxStrcmp(p->m_value.GetType(),wxT("datetime")) != 0 )
05348 {
05349 wxPGGetFailed(p,wxT("datetime"));
05350 return wxDateTime();
05351 }
05352 return p->m_value.GetDateTime();
05353 }
05354 #endif
05355
05356 #if defined(SWIG) || defined(__WXPYTHON__)
05357
05360 PyObject* GetPropertyValueAsPyObject( wxPGPropArg id ) const;
05361 #endif
05362
05363 #ifndef SWIG
05364
05373 wxVariant GetPropertyValues( const wxString& listname = wxEmptyString,
05374 wxPGProperty* baseparent = NULL, long flags = 0 ) const
05375 {
05376 return m_pState->DoGetPropertyValues(listname, baseparent, flags);
05377 }
05378 #endif
05379
05380 wxString GetPropertyValueType( wxPGPropArg id )
05381 {
05382 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
05383 return p->GetType();
05384 }
05385
05386 #ifdef __WXPYTHON__
05387 ptrdiff_t GetPVTI( wxPGPropArg id )
05388 {
05389 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(1)
05390
05391 wxVariant v = p->GetValue();
05392 wxVariantData* data = v.GetData();
05393 if ( !data )
05394 return 0;
05395 return (ptrdiff_t)wxPGVariantDataGetClassInfo(data);
05396 }
05397 #endif
05398
05406 wxPGProperty* GetSelection() const;
05407
05413 const wxArrayPGProperty& GetSelectedProperties() const
05414 {
05415 return m_pState->m_selection;
05416 }
05417
05418 #ifndef SWIG
05419 wxPropertyGridState* GetState() const { return m_pState; }
05420 #endif
05421
05428 bool HideProperty( wxPGPropArg id, bool hide = true, int flags = wxPG_RECURSE );
05429
05430 #if wxPG_INCLUDE_ADVPROPS
05431
05435 static void RegisterAdditionalEditors();
05436 #else
05437 static void RegisterAdditionalEditors() { }
05438 #endif
05439
05440 #if wxPG_INCLUDE_ADVPROPS
05441
05445 static void InitAllTypeHandlers();
05446 #else
05447 static void InitAllTypeHandlers() { }
05448 #endif
05449
05492 wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newproperty );
05493
05506 wxPGProperty* Insert( wxPGPropArg parent, int index, wxPGProperty* newproperty );
05507
05508 #if wxPG_COMPATIBILITY_1_2_0
05509 wxPGProperty* InsertCategory( wxPGPropArg id, int index, const wxString& label, const wxString& name = wxPG_LABEL )
05510 {
05511 return Insert( id, index, new wxPropertyCategory(label,name) );
05512 }
05513 #endif
05514
05516 bool IsPropertyEnabled( wxPGPropArg id ) const
05517 {
05518 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05519 return (!(p->GetFlags() & wxPG_PROP_DISABLED))?true:false;
05520 }
05521
05525 virtual bool IsPropertySelected( wxPGPropArg id ) const;
05526
05528 bool IsPropertyShown( wxPGPropArg id ) const
05529 {
05530 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05531 return (!(p->GetFlags() & wxPG_PROP_HIDDEN))?true:false;
05532 }
05533
05534 #if wxPG_COMPATIBILITY_1_2_0
05535
05539 wxDEPRECATED( bool IsPropertyValueType( wxPGPropArg id, const wxChar* typestr ) const );
05540 #endif
05541
05545 bool IsPropertyExpanded( wxPGPropArg id ) const;
05546
05552 bool IsPropertyKindOf( wxPGPropArg id, wxClassInfo* info ) const
05553 {
05554 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05555 return p->IsKindOf(info);
05556 }
05557
05558 #if wxPG_COMPATIBILITY_1_2_0
05559
05565 wxDEPRECATED( bool IsModified( wxPGPropArg id ) const );
05566 #endif
05567
05569 bool IsPropertyCategory( wxPGPropArg id ) const
05570 {
05571 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05572 return p->IsCategory();
05573 }
05574
05578 bool IsPropertyModified( wxPGPropArg id ) const
05579 {
05580 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05581 return ( (p->GetFlags() & wxPG_PROP_MODIFIED) ? true : false );
05582 }
05583
05586 #ifdef wxPG_COMPATIBILITY_1_0_0
05587 bool IsPropertyValueUnspecified( wxPGPropArg id ) const
05588 #else
05589 bool IsPropertyUnspecified( wxPGPropArg id ) const
05590 #endif
05591 {
05592 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
05593 return p->IsValueUnspecified();
05594 }
05595
05599 void LimitPropertyEditing( wxPGPropArg id, bool limit = true );
05600
05606 void PropertiesToNames( wxArrayString* names, const wxArrayPGProperty& properties ) const;
05607
05613 void NamesToProperties( wxArrayPGProperty* properties, const wxArrayString& names ) const;
05614
05617 virtual void RefreshGrid( wxPropertyGridState* state = NULL );
05618
05628 wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property );
05629
05635 enum EditableStateFlags
05636 {
05638 SelectionState = 0x01,
05640 ExpandedState = 0x02,
05642 ScrollPosState = 0x04,
05645 PageState = 0x08,
05647 SplitterPosState = 0x10,
05650 DescBoxState = 0x20,
05651
05655 AllStates = SelectionState |
05656 ExpandedState |
05657 ScrollPosState |
05658 PageState |
05659 SplitterPosState |
05660 DescBoxState
05661 };
05662
05685 bool RestoreEditableState( const wxString& src,
05686 int restoreStates = AllStates );
05687
05696 wxString SaveEditableState( int includedStates = AllStates ) const;
05697
05702 static void SetBoolChoices( const wxString& true_choice, const wxString& false_choice );
05703
05717 bool SetColumnProportion( unsigned int column, int proportion );
05718
05724 int GetColumnProportion( unsigned int column ) const
05725 {
05726 return m_pState->DoGetColumnProportion(column);
05727 }
05728
05736 void SetExpandedProperties( const wxArrayPGProperty& array, bool expand = true )
05737 {
05738 SetPropertiesFlag(array, wxPG_PROP_COLLAPSED, expand);
05739 }
05740
05750 void SetPropertiesFlag( const wxArrayPGProperty& srcArr, wxPGProperty::FlagType flags,
05751 bool inverse = false );
05752
05759 void SetPropertyCell( wxPGPropArg id,
05760 int column,
05761 const wxString& text = wxEmptyString,
05762 const wxBitmap& bitmap = wxNullBitmap,
05763 const wxColour& fgCol = wxNullColour,
05764 const wxColour& bgCol = wxNullColour )
05765 {
05766 wxPG_PROP_ARG_CALL_PROLOG()
05767 p->SetCell( column, new wxPGCell(text, bitmap, fgCol, bgCol) );
05768 }
05769
05780 void SetPropertyChoices( wxPGPropArg id, wxPGChoices& choices)
05781 {
05782 wxPG_PROP_ARG_CALL_PROLOG()
05783 p->SetChoices(choices);
05784 }
05785
05786
05790 void SetPropertyChoicesExclusive( wxPGPropArg id )
05791 {
05792 wxPG_PROP_ARG_CALL_PROLOG()
05793 p->SetChoicesExclusive();
05794 }
05795
05809 void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName, wxVariant value, long argFlags = 0 )
05810 {
05811 DoSetPropertyAttribute(id,attrName,value,argFlags);
05812 }
05813
05814 #ifndef SWIG
05815
05821 void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor )
05822 {
05823 wxPG_PROP_ARG_CALL_PROLOG()
05824 wxCHECK_RET( editor, wxT("unknown/NULL editor") );
05825 p->SetEditor(editor);
05826 RefreshProperty(p);
05827 }
05828 #endif // #ifndef SWIG
05829
05833 void SetPropertyEditor( wxPGPropArg id, const wxString& editorName )
05834 {
05835 SetPropertyEditor(id,GetEditorByName(editorName));
05836 }
05837
05844 void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel );
05845
05850 void SetPropertyClientData( wxPGPropArg id, wxPGProperty::ClientDataType clientData )
05851 {
05852 wxPG_PROP_ARG_CALL_PROLOG()
05853 p->SetClientData(clientData);
05854 }
05855
05859 void SetPropertyValueUnspecified( wxPGPropArg id )
05860 {
05861 wxPG_PROP_ARG_CALL_PROLOG()
05862 p->SetValueToUnspecified();
05863 }
05864
05879 void SetPropertyReadOnly( wxPGPropArg id, bool set = true,
05880 int flags = wxPG_RECURSE )
05881 {
05882 wxPG_PROP_ARG_CALL_PROLOG()
05883 if ( flags & wxPG_RECURSE )
05884 p->SetFlagRecursively(wxPG_PROP_READONLY, set);
05885 else
05886 p->ChangeFlag(wxPG_PROP_READONLY, set);
05887 }
05888
05889 #ifndef SWIG
05890
05893 void SetPropertyValues( const wxVariantList& list,
05894 wxPGPropArg defaultCategory = wxNullProperty )
05895 {
05896 wxPGProperty *p;
05897 if ( defaultCategory.HasName() ) p = defaultCategory.GetPtr(this);
05898 else p = defaultCategory.GetPtr0();
05899 m_pState->DoSetPropertyValues(list, p);
05900 }
05901
05905 void SetPropertyValues( const wxVariant& list,
05906 wxPGPropArg defaultCategory = wxNullProperty )
05907 {
05908 SetPropertyValues(list.GetList(),defaultCategory);
05909 }
05910 #endif
05911
05915 wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const
05916 {
05917 wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL)
05918 return m_pState->GetPropertyCategory(p);
05919 }
05920
05927 void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString )
05928 {
05929 wxPG_PROP_ARG_CALL_PROLOG()
05930 p->SetHelpString(helpString);
05931 }
05932
05937 void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp )
05938 {
05939 wxPG_PROP_ARG_CALL_PROLOG()
05940 p->SetValueImage(bmp);
05941 RefreshProperty(p);
05942 }
05943
05946 bool SetPropertyMaxLength( wxPGPropArg id, int maxLen );
05947
05948 #if wxUSE_VALIDATORS
05949
05951 void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator )
05952 {
05953 wxPG_PROP_ARG_CALL_PROLOG()
05954 p->SetValidator(validator);
05955 }
05956 #endif
05957
05960 void SetPropertyValueLong( wxPGPropArg id, long value )
05961 {
05962 wxVariant v(value);
05963 SetPropVal( id, v );
05964 }
05965
05966 #ifndef __WXPYTHON__
05967
05969 void SetPropertyValue( wxPGPropArg id, int value )
05970 {
05971 wxVariant v((long)value);
05972 SetPropVal( id, v );
05973 }
05974 #endif
05975
05977 void SetPropertyValueDouble( wxPGPropArg id, double value )
05978 {
05979 wxVariant v(value);
05980 SetPropVal( id, v );
05981 }
05984 void SetPropertyValueBool( wxPGPropArg id, bool value )
05985 {
05986 wxVariant v(value);
05987 SetPropVal( id, v );
05988 }
05989 #ifndef __WXPYTHON__
05990 void SetPropertyValue( wxPGPropArg id, const wxChar* value )
05991 {
05992 SetPropertyValueString( id, wxString(value) );
05993 }
05994 #endif
05995
05998 void SetPropertyValueArrstr2( wxPGPropArg id, const wxArrayString& value )
05999 {
06000 wxVariant v(value);
06001 SetPropVal( id, v );
06002 }
06003
06004
06005 #if wxUSE_DATETIME
06006 void SetPropertyValueDatetime( wxPGPropArg id, const wxDateTime& value )
06007 {
06008 wxVariant v(value);
06009 SetPropVal( id, v );
06010 }
06011 #endif
06012
06019 void SetPropertyValueString( wxPGPropArg id, const wxString& value );
06020
06023 void SetPropertyValueWxObjectPtr( wxPGPropArg id, wxObject* value )
06024 {
06025 wxVariant v(value);
06026 SetPropVal( id, v );
06027 }
06028
06029 #ifndef __WXPYTHON__
06030
06031 void SetPropertyValue( wxPGPropArg id, void* value )
06032 {
06033 wxVariant v(value);
06034 SetPropVal( id, v );
06035 }
06036 void SetPropertyValue ( wxPGPropArg id, wxObject& value )
06037 {
06038 wxVariant v(&value);
06039 SetPropVal( id, v );
06040 }
06041 #endif
06042
06049 void SetPropertyValue( wxPGPropArg id, wxVariant value )
06050 {
06051 SetPropVal( id, value );
06052 }
06053
06056 void SetPropertyValuePoint( wxPGPropArg id, const wxPoint& value )
06057 {
06058 wxVariant v = WXVARIANT(value);
06059 SetPropVal( id, v );
06060 }
06063 void SetPropertyValueSize( wxPGPropArg id, const wxSize& value )
06064 {
06065 wxVariant v = WXVARIANT(value);
06066 SetPropVal( id, v );
06067 }
06070 void SetPropertyValueLongLong( wxPGPropArg id, wxLongLong_t value )
06071 {
06072 wxVariant v = WXVARIANT(wxLongLong(value));
06073 SetPropVal( id, v );
06074 }
06077 void SetPropertyValueULongLong( wxPGPropArg id, wxULongLong_t value )
06078 {
06079 wxVariant v = WXVARIANT(wxULongLong(value));
06080 SetPropVal( id, v );
06081 }
06084 void SetPropertyValueArrint2( wxPGPropArg id, const wxArrayInt& value )
06085 {
06086 wxVariant v = WXVARIANT(value);
06087 SetPropVal( id, v );
06088 }
06091 #ifdef __WXPYTHON__
06092 void SetPropertyValuePyObject( wxPGPropArg id, PyObject* value )
06093 {
06094 wxVariant v = WXVARIANT(value);
06095 SetPropVal( id, v );
06096 }
06097 #endif
06098
06099 #ifndef SWIG
06100
06102 void SetPropVal( wxPGPropArg id, wxVariant& value );
06103 #endif
06104
06110 void SetValidationFailureBehavior( int vfbFlags );
06111
06112 #ifdef SWIG
06113 %pythoncode {
06114 def MapType(class_,factory):
06115 "Registers Python type/class to property mapping.\n\nfactory: Property builder function/class."
06116 global _type2property
06117 try:
06118 mappings = _type2property
06119 except NameError:
06120 raise AssertionError("call only after a propertygrid or manager instance constructed")
06121
06122 mappings[class_] = factory
06123
06124
06125 def DoDefaultTypeMappings(self):
06126 "Map built-in properties."
06127 global _type2property
06128 try:
06129 mappings = _type2property
06130
06131 return
06132 except NameError:
06133 mappings = {}
06134 _type2property = mappings
06135
06136 mappings[str] = StringProperty
06137 mappings[unicode] = StringProperty
06138 mappings[int] = IntProperty
06139 mappings[float] = FloatProperty
06140 mappings[bool] = BoolProperty
06141 mappings[list] = ArrayStringProperty
06142 mappings[tuple] = ArrayStringProperty
06143 mappings[wx.Font] = FontProperty
06144 mappings[wx.Colour] = ColourProperty
06145 mappings[wx.Size] = SizeProperty
06146 mappings[wx.Point] = PointProperty
06147 mappings[wx.FontData] = FontDataProperty
06148
06149
06150 def SetPropertyValueArrstr(self,p,v):
06151 "NB: We must implement this in Python because SWIG has problems combining"
06152 " conversion of list to wxArrayXXX and overloaded arguments."
06153 if not isinstance(p,basestring):
06154 self._SetPropertyValueArrstr(p,v)
06155 else:
06156 self._SetPropertyValueArrstr(self.GetPropertyByNameI(p),v)
06157
06158
06159 def SetPropertyValueArrint(self,p,v):
06160 "NB: We must implement this in Python because SWIG has problems combining"
06161 " conversion of list to wxArrayXXX and overloaded arguments."
06162 if not isinstance(p,basestring):
06163 self._SetPropertyValueArrint(p,v)
06164 else:
06165 self._SetPropertyValueArrint(self.GetPropertyByNameI(p),v)
06166
06167
06168 def DoDefaultValueTypeMappings(self):
06169 "Map pg value type ids to getter methods."
06170 global _vt2getter
06171 try:
06172 vt2getter = _vt2getter
06173
06174 return
06175 except NameError:
06176 vt2getter = {}
06177 _vt2getter = vt2getter
06178
06179
06180 def _GetValues(self,parent,fc,dict_,getter,inc_attributes):
06181 p = fc
06182
06183 while p:
06184 pfc = self.GetFirstChild(p)
06185 if pfc:
06186 self._GetValues(p,pfc,dict_,getter,inc_attributes)
06187 else:
06188 dict_[p.GetName()] = getter(p)
06189
06190 if inc_attributes:
06191 attrs = p.GetAttributes()
06192 if attrs and len(attrs):
06193 dict_['@%s@attr'%(p.GetName())] = attrs
06194
06195 p = self.GetNextSiblingProperty(p)
06196
06197
06198 def GetPropertyValues(self,dict_=None, as_strings=False, inc_attributes=False):
06199 "Returns values in the grid."
06200 ""
06201 "dict_: if not given, then a new one is created. dict_ can be"
06202 " object as well, in which case it's __dict__ is used."
06203 "as_strings: if True, then string representations of values"
06204 " are fetched instead of native types. Useful for config and such."
06205 "inc_attributes: if True, then property attributes are added"
06206 " as @<propname>@<attr>."
06207 ""
06208 "Return value: dictionary with values. It is always a dictionary,"
06209 "so if dict_ was object with __dict__ attribute, then that attribute"
06210 "is returned."
06211
06212 if dict_ is None:
06213 dict_ = {}
06214 elif hasattr(dict_,'__dict__'):
06215 dict_ = dict_.__dict__
06216
06217 if not as_strings:
06218 getter = self.GetPropertyValue
06219 else:
06220 getter = self.GetPropertyValueAsString
06221
06222 root = self.GetGrid().GetRoot()
06223 self._GetValues(root,self.GetFirstChild(root),dict_,getter,inc_attributes)
06224
06225 return dict_
06226
06227 GetValues = GetPropertyValues
06228
06229
06230 def SetPropertyValues(self,dict_):
06231 "Sets property values from dict_, which can be either\ndictionary or an object with __dict__ attribute."
06232 ""
06233 "autofill: If true, keys with not relevant properties"
06234 " are auto-created. For more info, see AutoFill."
06235 ""
06236 "Notes:"
06237 " * Keys starting with underscore are ignored."
06238 " * Attributes can be set with entries named @<propname>@<attr>."
06239 ""
06240
06241 autofill = False
06242
06243 if dict_ is None:
06244 dict_ = {}
06245 elif hasattr(dict_,'__dict__'):
06246 dict_ = dict_.__dict__
06247
06248 attr_dicts = []
06249
06250 def set_sub_obj(k0,dict_):
06251 for k,v in dict_.iteritems():
06252 if k[0] != '_':
06253 if k.endswith('@attr'):
06254 attr_dicts.append((k[1:-5],v))
06255 else:
06256 try:
06257 self.SetPropertyValue(k,v)
06258 except:
06259 try:
06260 if autofill:
06261 self._AutoFillOne(k0,k,v)
06262 continue
06263 except:
06264 if isinstance(v,dict):
06265 set_sub_obj(k,v)
06266 elif hasattr(v,'__dict__'):
06267 set_sub_obj(k,v.__dict__)
06268
06269
06270 for k,v in attr_dicts:
06271 p = GetPropertyByName(k)
06272 if not p:
06273 raise AssertionError("No such property: '%s'"%k)
06274 for an,av in v.iteritems():
06275 p.SetAttribute(an, av)
06276
06277
06278 cur_page = False
06279 is_manager = isinstance(self,PropertyGridManager)
06280
06281 try:
06282 set_sub_obj(self.GetGrid().GetRoot(),dict_)
06283 except:
06284 import traceback
06285 traceback.print_exc()
06286
06287 self.Refresh()
06288
06289
06290 SetValues = SetPropertyValues
06291
06292
06293 def _AutoFillMany(self,cat,dict_):
06294 for k,v in dict_.iteritems():
06295 self._AutoFillOne(cat,k,v)
06296
06297
06298 def _AutoFillOne(self,cat,k,v):
06299 global _type2property
06300
06301 factory = _type2property.get(v.__class__,None)
06302
06303 if factory:
06304 self.AppendIn( cat, factory(k,k,v) )
06305 elif hasattr(v,'__dict__'):
06306 cat2 = self.AppendIn( cat, PropertyCategory(k) )
06307 self._AutoFillMany(cat2,v.__dict__)
06308 elif isinstance(v,dict):
06309 cat2 = self.AppendIn( cat, PropertyCategory(k) )
06310 self._AutoFillMany(cat2,v)
06311 elif not k.startswith('_'):
06312 raise AssertionError("member '%s' is of unregisted type/class '%s'"%(k,v.__class__))
06313
06314
06315 def AutoFill(self,obj,parent=None):
06316 "Clears properties and re-fills to match members and\nvalues of given object or dictionary obj."
06317
06318 self.edited_objects[parent] = obj
06319
06320 cur_page = False
06321 is_manager = isinstance(self,PropertyGridManager)
06322
06323 if not parent:
06324 if is_manager:
06325 page = self.GetCurrentPage()
06326 page.Clear()
06327 parent = page.GetRoot()
06328 else:
06329 self.Clear()
06330 parent = self.GetGrid().GetRoot()
06331 else:
06332 p = self.GetFirstChild(parent)
06333 while p:
06334 self.Delete(p)
06335 p = self.GetNextSiblingProperty(p)
06336
06337 if not is_manager or page == self.GetCurrentPage():
06338 self.Freeze()
06339 cur_page = True
06340
06341 try:
06342 self._AutoFillMany(parent,obj.__dict__)
06343 except:
06344 import traceback
06345 traceback.print_exc()
06346
06347 if cur_page:
06348 self.Thaw()
06349
06350
06351 def RegisterEditor(self, editor, editorName=None):
06352 "Transform class into instance, if necessary."
06353 if not isinstance(editor, PGEditor):
06354 editor = editor()
06355 if not editorName:
06356 editorName = editor.__class__.__name__
06357 try:
06358 self._editor_instances.append(editor)
06359 except:
06360 self._editor_instances = [editor]
06361 RegisterEditor(editor, editorName)
06362
06363 }
06364 #endif
06365
06366
06367 wxPGProperty* GetPropertyByNameA( wxPGPropNameStr name ) const;
06368
06369 static wxPGEditor* GetEditorByName( const wxString& editorName );
06370
06371
06372
06373
06374 virtual void RefreshProperty( wxPGProperty* p ) = 0;
06375
06376 protected:
06377
06378 bool DoClearSelection( bool validation,
06379 int selFlags = 0 );
06380
06385 virtual bool SetEditableStateItem( const wxString& name, wxVariant value )
06386 {
06387 wxUnusedVar(name);
06388 wxUnusedVar(value);
06389 return false;
06390 }
06391
06396 virtual wxVariant GetEditableStateItem( const wxString& name ) const
06397 {
06398 wxUnusedVar(name);
06399 return wxNullVariant;
06400 }
06401
06402
06403 virtual wxPropertyGridState* GetPageState( int pageIndex ) const
06404 {
06405 if ( pageIndex <= 0 )
06406 return m_pState;
06407 return NULL;
06408 }
06409
06410 virtual bool DoSelectPage( int WXUNUSED(index) ) { return true; }
06411
06412
06413 virtual wxPGProperty* DoGetPropertyByName( wxPGPropNameStr name ) const;
06414
06415 #ifndef SWIG
06416
06417 wxPropertyGridState* m_pState;
06418
06419
06420 void DoSetPropertyAttribute( wxPGPropArg id, const wxString& name, wxVariant& value, long argFlags );
06421
06422
06423 wxString m_emptyString;
06424
06425 private:
06426
06427 wxPropertyGrid* GetPropertyGrid()
06428 {
06429 if ( !m_pState )
06430 return NULL;
06431 return m_pState->GetGrid();
06432 }
06433 const wxPropertyGrid* GetPropertyGrid() const
06434 {
06435 if ( !m_pState )
06436 return NULL;
06437 return (const wxPropertyGrid*) m_pState->GetGrid();
06438 }
06439 #endif // #ifndef SWIG
06440 };
06441
06442
06443 typedef wxPropertyGridInterface wxPropertyContainerMethods;
06444
06445
06446
06447
06448
06449 #define wxPG_SEL_FOCUS 0x0001 // Focuses to created editor
06450 #define wxPG_SEL_FORCE 0x0002 // Forces deletion and recreation of editor
06451 #define wxPG_SEL_NONVISIBLE 0x0004 // For example, doesn't cause EnsureVisible
06452 #define wxPG_SEL_NOVALIDATE 0x0008 // Do not validate editor's value before selecting
06453 #define wxPG_SEL_DELETING 0x0010 // Property being deselected is about to be deleted
06454 #define wxPG_SEL_SETUNSPEC 0x0020 // Property's values was set to unspecified by the user
06455 #define wxPG_SEL_DIALOGVAL 0x0040 // Property's event handler changed the value
06456
06457
06458
06459
06460 #define wxPG_SEL_DONT_SEND_EVENT 0x0080
06461
06462 #define wxPG_SEL_NO_REFRESH 0x0100 // Do not call Refresh()
06463
06464
06465
06466
06467 #ifndef SWIG
06468
06469
06470 #define wxPG_FL_INITIALIZED 0x0001
06471 #define wxPG_FL_ACTIVATION_BY_CLICK 0x0002 // Set when creating editor controls if it was clicked on.
06472 #define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
06473 #define wxPG_FL_FOCUSED 0x0008
06474 #define wxPG_FL_MOUSE_CAPTURED 0x0010
06475 #define wxPG_FL_MOUSE_INSIDE 0x0020
06476 #define wxPG_FL_VALUE_MODIFIED 0x0040
06477 #define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080 // don't clear background of m_wndEditor
06478 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100 // currently active editor uses custom image
06479 #define wxPG_FL_CELL_OVERRIDES_SEL 0x0200 // cell colours override selection colours for selected cell
06480 #define wxPG_FL_SCROLLED 0x0400
06481 #define wxPG_FL_ADDING_HIDEABLES 0x0800 // set when all added/inserted properties get hideable flag
06482 #define wxPG_FL_NOSTATUSBARHELP 0x1000 // Disables showing help strings on statusbar.
06483 #define wxPG_FL_CREATEDSTATE 0x2000 // Marks that we created the state, so we have to destroy it too.
06484 #define wxPG_FL_SCROLLBAR_DETECTED 0x4000 // Set if scrollbar's existence was detected in last onresize.
06485 #define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000 // Set if wxPGMan requires redrawing of description text box.
06486 #define wxPG_FL_IN_MANAGER 0x00020000 // Set if contained in wxPropertyGridManager
06487 #define wxPG_FL_GOOD_SIZE_SET 0x00040000 // Set after wxPropertyGrid is shown in its initial good size
06488 #define wxPG_FL_IGNORE_NEXT_NAVKEY 0x00080000 // Next navigation key event will get ignored
06489 #define wxPG_FL_IN_SELECT_PROPERTY 0x00100000 // Set when in SelectProperty.
06490 #define wxPG_FL_STRING_IN_STATUSBAR 0x00200000 // Set when help string is shown in status bar
06491 #define wxPG_FL_SPLITTER_PRE_SET 0x00400000 // Splitter position has been custom-set by the user
06492 #define wxPG_FL_VALIDATION_FAILED 0x00800000 // Validation failed. Clear on modify event.
06493 #define wxPG_FL_CATMODE_AUTO_SORT 0x01000000 // Auto sort is enabled (for categorized mode)
06494 #define wxPG_MAN_FL_PAGE_INSERTED 0x02000000 // Set after page has been inserted to manager
06495 #define wxPG_FL_ABNORMAL_EDITOR 0x04000000 // Active editor control is abnormally large
06496 #define wxPG_FL_IN_ONCUSTOMEDITOREVENT 0x08000000 // Recursion guard for OnCustomEditorEvent
06497 #define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
06498 #define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000 // Editor control width should not change on resize
06499 #define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000 // Width of panel can be different than width of grid
06500 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000 // Prevents RecalculateVirtualSize re-entrancy
06501
06502 #endif // #ifndef SWIG
06503
06504 #if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
06505
06506 #include "props.h"
06507 #endif
06508
06509
06510
06511 #define wxPG_USE_STATE m_pState
06512
06578
06579 class WXDLLIMPEXP_PG wxPropertyGrid : public wxScrolledWindow, public wxPropertyGridInterface
06580 {
06581 #ifndef SWIG
06582 friend class wxPropertyGridState;
06583 friend class wxPropertyGridInterface;
06584 friend class wxPropertyGridManager;
06585 friend class wxPGCanvas;
06586
06587 DECLARE_DYNAMIC_CLASS(wxPropertyGrid)
06588 #endif
06589
06590 public:
06595 #ifdef SWIG
06596 %pythonAppend wxPropertyGrid {
06597 self._setOORInfo(self)
06598 self.DoDefaultTypeMappings()
06599 self.edited_objects = {}
06600 self.DoDefaultValueTypeMappings()
06601 if not hasattr(self.__class__,'_vt2setter'):
06602 self.__class__._vt2setter = {}
06603 }
06604 %pythonAppend wxPropertyGrid() ""
06605
06606 wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
06607 const wxPoint& pos = wxDefaultPosition,
06608 const wxSize& size = wxDefaultSize,
06609 long style = wxPG_DEFAULT_STYLE,
06610 const wxString& name = wxPyPropertyGridNameStr );
06611 %RenameCtor(PrePropertyGrid, wxPropertyGrid());
06612
06613 #else
06614
06615 wxPropertyGrid();
06616
06621 wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
06622 const wxPoint& pos = wxDefaultPosition,
06623 const wxSize& size = wxDefaultSize,
06624 long style = wxPG_DEFAULT_STYLE,
06625 const wxString& name = wxPropertyGridNameStr );
06626
06628 virtual ~wxPropertyGrid();
06629 #endif
06630
06635 void AddActionTrigger( int action, int keycode, int modifiers = 0 );
06636
06642 static void AutoGetTranslation( bool enable );
06643
06648 bool CanClose()
06649 {
06650 return DoEditorValidate();
06651 }
06652
06657 void ClearActionTriggers( int action );
06658
06663 bool EditorValidate()
06664 {
06665 return DoEditorValidate();
06666 }
06667
06675 void CenterSplitter( bool enableAutoResizing = false );
06676
06684 bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
06685
06690 bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
06691 const wxPoint& pos = wxDefaultPosition,
06692 const wxSize& size = wxDefaultSize,
06693 long style = wxPG_DEFAULT_STYLE,
06694 const wxString& name = wxPropertyGridNameStr );
06695
06699 virtual void Clear();
06700
06703 void ClearModifiedStatus( wxPGPropArg id )
06704 {
06705 wxPG_PROP_ARG_CALL_PROLOG()
06706 m_pState->ClearModifiedStatus(p);
06707 }
06708
06711 void ClearModifiedStatus()
06712 {
06713 m_pState->ClearModifiedStatus(m_pState->m_properties);
06714 m_pState->m_anyModified = false;
06715 }
06716
06719 bool UnfocusEditor();
06720
06721 #if wxPG_COMPATIBILITY_1_2_0
06722
06727 wxDEPRECATED( void ClearTargetPage() );
06728 #endif
06729
06731 bool EnableCategories( bool enable );
06732
06736 wxPanel* GetPanel() const
06737 {
06738 return m_canvas;
06739 }
06740
06741 const wxPGCommonValue* GetCommonValue( unsigned int i ) const
06742 {
06743 return (wxPGCommonValue*) m_commonValues[i];
06744 }
06745
06748 unsigned int GetCommonValueCount() const
06749 {
06750 return (unsigned int) m_commonValues.size();
06751 }
06752
06755 wxString GetCommonValueLabel( unsigned int i ) const
06756 {
06757 wxASSERT( GetCommonValue(i) );
06758 return GetCommonValue(i)->GetLabel();
06759 }
06760
06764 bool EnsureVisible( wxPGPropArg id );
06765
06781 wxSize FitColumns()
06782 {
06783 wxSize sz = m_pState->DoFitColumns();
06784 return sz;
06785 }
06786
06787 wxFont& GetCaptionFont() { return m_captionFont; }
06788
06789 #ifndef SWIG
06790 const wxFont& GetCaptionFont() const { return m_captionFont; }
06791 #endif
06792
06794 wxColour GetCaptionBackgroundColour() const { return m_colCapBack; }
06795
06797 wxColour GetCaptionForegroundColour() const { return m_colCapFore; }
06798
06800 wxColour GetCellBackgroundColour() const { return m_colPropBack; }
06801
06803 wxColour GetCellDisabledTextColour() const { return m_colDisPropFore; }
06804
06806 wxColour GetCellTextColour() const { return m_colPropFore; }
06807
06810 unsigned int GetChildrenCount()
06811 {
06812 return GetChildrenCount( m_pState->m_properties );
06813 }
06814
06819 unsigned int GetChildrenCount( wxPGPropArg id ) const
06820 {
06821 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
06822 return p->GetChildCount();
06823 }
06824
06825 unsigned int GetColumnCount() const
06826 {
06827 return (unsigned int) m_pState->m_colWidths.size();
06828 }
06829
06831 wxColour GetEmptySpaceColour() const { return m_colEmptySpace; }
06832
06833 #if wxPG_COMPATIBILITY_1_2_0
06834
06842 const wxPGProperty* GetFirstVisible() const
06843 {
06844 return wxPropertyGridInterface::GetFirst( wxPG_ITERATE_VISIBLE );
06845 }
06846
06847 wxPGProperty* GetFirstVisible()
06848 {
06849 return wxPropertyGridInterface::GetFirst( wxPG_ITERATE_VISIBLE );
06850 }
06851 #endif
06852
06854 int GetFontHeight() const { return m_fontHeight; }
06855
06859 wxPropertyGrid* GetGrid() { return this; }
06860
06861 #if wxPG_COMPATIBILITY_1_2_0
06862
06867 wxPGProperty* GetFirstCategory() const
06868 {
06869 return (wxPGProperty*) wxPropertyGridInterface::GetFirst( wxPG_ITERATE_CATEGORIES );
06870 }
06871
06877 wxPGProperty* GetFirstProperty()
06878 {
06879 return (wxPGProperty*) wxPropertyGridInterface::GetFirst( wxPG_ITERATE_DEFAULT );
06880 }
06881 #endif
06882
06886 wxSize GetImageSize( wxPGProperty* p = NULL, int item = -1 ) const;
06887
06888 wxRect GetImageRect( wxPGProperty* p, int item ) const;
06889
06892
06893
06897 wxPGProperty* GetItemAtY( int y ) const { return DoGetItemAtY(y); }
06898
06903 wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT )
06904 {
06905 return m_pState->GetLastItem(flags);
06906 }
06907
06908 const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
06909 {
06910 return m_pState->GetLastItem(flags);
06911 }
06912
06913 #if wxPG_COMPATIBILITY_1_2_0
06914
06919 wxPGProperty* GetLastProperty()
06920 {
06921 if ( !m_pState->m_properties->GetCount() ) return NULL;
06922 wxPGProperty* p = GetLastItem(wxPG_ITERATE_DEFAULT);
06923 if ( p->IsCategory() )
06924 return GetPrevProperty(p);
06925 return p;
06926 }
06927
06935 wxPGProperty* GetLastChild( wxPGPropArg id )
06936 {
06937 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06938
06939 if ( !p->GetChildCount() ) return wxNullProperty;
06940
06941 return p->Last();
06942 }
06948 wxPGProperty* GetLastVisible()
06949 {
06950 return GetLastItem(wxPG_ITERATE_VISIBLE);
06951 }
06952 #endif // wxPG_COMPATIBILITY_1_2_0
06953
06955 wxColour GetLineColour() const { return m_colLine; }
06956
06958 wxColour GetMarginColour() const { return m_colMargin; }
06959
06960 #if wxPG_COMPATIBILITY_1_2_0
06961
06966 wxPGProperty* GetNextProperty( wxPGPropArg id )
06967 {
06968 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06969 return m_pState->GetNextProperty(p);
06970 }
06971
06976 wxPGProperty* GetNextCategory( wxPGPropArg id ) const
06977 {
06978 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06979 return m_pState->GetNextCategory(p);
06980 }
06981
06989 wxPGProperty* GetNextVisible( wxPGPropArg id ) const
06990 {
06991 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
06992 return wxPropertyGridIterator::OneStep(m_pState,wxPG_ITERATE_VISIBLE,p,1);
06993 }
06994 #endif // wxPG_COMPATIBILITY_1_2_0
06995
06996 #if wxPG_COMPATIBILITY_1_2_0
06997
07002 wxPGProperty* GetPrevProperty( wxPGPropArg id )
07003 {
07004 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
07005 return m_pState->GetPrevProperty(p);
07006 }
07011 wxPGProperty* GetPrevSiblingProperty( wxPGPropArg id )
07012 {
07013 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
07014 return m_pState->GetPrevSiblingProperty(p);
07015 }
07020 wxPGProperty* GetPrevVisible( wxPGPropArg id )
07021 {
07022 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
07023 return wxPropertyGridIterator::OneStep(m_pState,wxPG_ITERATE_VISIBLE,p,-1);
07024 }
07025 #endif // wxPG_COMPATIBILITY_1_2_0
07026
07028 wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const;
07029
07031 wxColour GetPropertyColour( wxPGPropArg id ) const
07032 {
07033 return GetPropertyBackgroundColour( id );
07034 }
07035
07037 wxColour GetPropertyTextColour( wxPGPropArg id ) const;
07038
07044 wxPGProperty* GetPropertyByLabel( const wxString& name ) const
07045 {
07046 return m_pState->GetPropertyByLabel(name);
07047 }
07048
07052 wxPGProperty* GetRoot() const { return m_pState->m_properties; }
07053
07055 int GetRowHeight() const { return m_lineHeight; }
07056
07057 wxPGProperty* GetSelectedProperty () const { return GetSelection(); }
07058
07060 wxColour GetSelectionBackgroundColour() const { return m_colSelBack; }
07061
07063 wxColour GetSelectionForegroundColour() const { return m_colSelFore; }
07064
07066 int GetSplitterPosition() const { return m_pState->DoGetSplitterPosition(0); }
07067
07071 wxTextCtrl* GetEditorTextCtrl() const;
07072
07075 int GetUnspecifiedCommonValue() const { return m_cvUnspecified; }
07076
07077 wxPGValidationInfo& GetValidationInfo()
07078 {
07079 return m_validationInfo;
07080 }
07081
07083 int GetVerticalSpacing() const { return (int)m_vspacing; }
07084
07086 bool HasSelection() const { return (m_pState->m_selection.size() > 0); }
07087
07088 bool HasVirtualWidth() const { return (m_iFlags & wxPG_FL_HAS_VIRTUAL_WIDTH)?true:false; }
07089
07092 wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
07093
07095 bool IsAnyModified() const { return (m_pState->m_anyModified>0); }
07096
07098 bool IsFrozen() const { return (m_frozen>0)?true:false; }
07099
07112 void OnTLPChanging( wxWindow* newTLP );
07113
07114 virtual void RefreshProperty( wxPGProperty* p );
07115
07119 void RefreshEditor();
07120
07123 void SetColumnCount( int colCount )
07124 {
07125 m_pState->SetColumnCount(colCount);
07126 Refresh();
07127 }
07128
07135 void SetSplitterLeft( bool subProps = false )
07136 {
07137 m_pState->SetSplitterLeft(subProps);
07138 }
07139
07140 #ifndef SWIG
07141
07145 static wxPGEditor* RegisterEditorClass( wxPGEditor* editor, const wxString& name,
07146 bool noDefCheck = false );
07147 #endif
07148
07151 void ResetColours();
07152
07162 void ResetColumnSizes( bool enableAutoResizing = false );
07163
07169 void SetButtonShortcut( int keycode, bool ctrlDown = false, bool altDown = false );
07170
07173 void SetCaptionTextColour( wxPGPropArg id, const wxColour& col );
07174
07177 void SetCurrentCategory( wxPGPropArg id )
07178 {
07179 wxPG_PROP_ARG_CALL_PROLOG()
07180 wxPropertyCategory* pc = (wxPropertyCategory*)p;
07181 wxASSERT( !pc || pc->IsCategory() );
07182 m_pState->m_currentCategory = pc;
07183 }
07184
07189 void SetPropertyAttributeAll( const wxString& attrName, wxVariant value );
07190
07201 void SetPropertyBackgroundColour( wxPGPropArg id, const wxColour& col,
07202 int flags = wxPG_RECURSE );
07203
07204 #if wxPG_COMPATIBILITY_1_2_0
07205
07212 wxDEPRECATED( void SetPropertyColour( wxPGPropArg id, const wxColour& col ) );
07213 #endif
07214
07223 void SetPropertyTextColour( wxPGPropArg id, const wxColour& col,
07224 int flags = wxPG_RECURSE );
07225
07227 void SetPropertyColourToDefault( wxPGPropArg id );
07228
07230 void SetCaptionBackgroundColour(const wxColour& col);
07231
07233 void SetCaptionForegroundColour(const wxColour& col);
07234
07238 void SetCellBackgroundColour(const wxColour& col);
07239
07242 void SetCellDisabledTextColour(const wxColour& col);
07243
07247 void SetCellTextColour(const wxColour& col);
07248
07250 void SetEmptySpaceColour(const wxColour& col);
07251
07253 void SetLineColour(const wxColour& col);
07254
07256 void SetMarginColour(const wxColour& col);
07257
07259 void SetSelectionBackground(const wxColour& col);
07260
07262 void SetSelectionForeground(const wxColour& col);
07263
07270 void SetSplitterPosition( int newxpos, bool refresh = true )
07271 {
07272 DoSetSplitterPosition_(newxpos,refresh,0);
07273 m_iFlags |= wxPG_FL_SPLITTER_PRE_SET;
07274 }
07275
07296 void SetSortFunction( wxPGSortCallback sortFunction )
07297 {
07298 m_sortFunction = sortFunction;
07299 }
07300
07304 wxPGSortCallback GetSortFunction() const
07305 {
07306 return m_sortFunction;
07307 }
07308
07316 void SetUnspecifiedValueAppearance( const wxPGCell& cell )
07317 {
07318 m_unspecifiedAppearance.Assign(cell);
07319 }
07320
07330 const wxPGCell& GetUnspecifiedValueAppearance() const
07331 {
07332 return m_unspecifiedAppearance;
07333 }
07334
07339 wxString GetUnspecifiedValueText( int argFlags = 0 ) const;
07340
07345 void SetUnspecifiedCommonValue( int index ) { m_cvUnspecified = index; }
07346
07349 void SetVirtualWidth( int width );
07350
07363 bool SelectProperty( wxPGPropArg id, bool focus = false )
07364 {
07365 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
07366 return DoSelectProperty(p, focus ? wxPG_SEL_FOCUS : 0);
07367 }
07368
07372 void SetSelection( const wxArrayPGProperty& newSelection )
07373 {
07374 DoSetSelection( newSelection, wxPG_SEL_DONT_SEND_EVENT );
07375 }
07376
07389 bool AddToSelection( wxPGPropArg id )
07390 {
07391 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
07392 return DoAddToSelection(p, wxPG_SEL_DONT_SEND_EVENT);
07393 }
07394
07399 bool RemoveFromSelection( wxPGPropArg id )
07400 {
07401 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
07402 return DoRemoveFromSelection(p, wxPG_SEL_DONT_SEND_EVENT);
07403 }
07404
07411 void MakeColumnEditable( unsigned int column, bool editable = true );
07412
07424 void BeginLabelEdit( unsigned int column = 0 )
07425 {
07426 DoBeginLabelEdit(column, wxPG_SEL_DONT_SEND_EVENT);
07427 }
07428
07436 void EndLabelEdit( bool commit = true )
07437 {
07438 DoEndLabelEdit(commit, wxPG_SEL_DONT_SEND_EVENT);
07439 }
07440
07444 wxTextCtrl* GetLabelEditor() const;
07445
07448 #ifndef SWIG
07449 void SwitchState( wxPropertyGridState* pNewState );
07450 #endif
07451
07458 void SetPropertyName( wxPGPropArg id, const wxString& newname )
07459 {
07460 wxPG_PROP_ARG_CALL_PROLOG()
07461 DoSetPropertyName( p, newname );
07462 }
07463
07470 void SetVerticalSpacing( int vspacing )
07471 {
07472 m_vspacing = (unsigned char)vspacing;
07473 CalculateFontAndBitmapStuff( vspacing );
07474 if ( !m_pState->m_itemsAdded ) Refresh();
07475 }
07476
07478 void ShowPropertyError( wxPGPropArg id, const wxString& msg )
07479 {
07480 wxPG_PROP_ARG_CALL_PROLOG()
07481 DoShowPropertyError(p, msg);
07482 }
07483
07485 void Sort();
07486
07489 void Sort( wxPGPropArg id );
07490
07494 virtual void SetWindowStyleFlag( long style );
07495
07502 void EditorsValueWasModified() { m_iFlags |= wxPG_FL_VALUE_MODIFIED; }
07503
07505 void EditorsValueWasNotModified()
07506 {
07507 m_iFlags &= ~(wxPG_FL_VALUE_MODIFIED);
07508 }
07509
07511 bool IsEditorsValueModified() const { return ( m_iFlags & wxPG_FL_VALUE_MODIFIED ) ? true : false; }
07512
07517 wxWindow* GenerateEditorButton( const wxPoint& pos, const wxSize& sz );
07518
07523 void FixPosForTextCtrl( wxWindow* ctrl,
07524 unsigned int forColumn = 1,
07525 const wxPoint& offset = wxPoint(0, 0) );
07526
07543 wxWindow* GenerateEditorTextCtrl( const wxPoint& pos,
07544 const wxSize& sz,
07545 const wxString& value,
07546 wxWindow* secondary,
07547 int extraStyle = 0,
07548 int maxLen = 0,
07549 unsigned int forColumn = 1 );
07550
07551
07552
07553 wxWindow* GenerateEditorTextCtrlAndButton( const wxPoint& pos,
07554 const wxSize& sz, wxWindow** psecondary, int limited_editing,
07555 wxPGProperty* property );
07556
07565 wxPoint GetGoodEditorDialogPosition( wxPGProperty* p,
07566 const wxSize& sz );
07567
07568
07569
07570 static wxString& ExpandEscapeSequences( wxString& dst_str, wxString& src_str );
07571
07572
07573
07574 static wxString& CreateEscapeSequences( wxString& dst_str, wxString& src_str );
07575
07578 wxRect GetPropertyRect( const wxPGProperty* p1, const wxPGProperty* p2 ) const;
07579
07584 wxWindow* GetEditorControl() const;
07585
07589 bool IsEditorFocused() const;
07590
07593 bool AdjustPosForClipperWindow( wxWindow* topCtrlWnd, int* x, int* y );
07594
07595 wxWindow* GetPrimaryEditor() const
07596 {
07597 return GetEditorControl();
07598 }
07599
07602 wxWindow* GetEditorControlSecondary() const
07603 {
07604 return m_wndEditor2;
07605 }
07606
07607 #ifdef __WXPYTHON__
07608
07609 wxRect DummywxRectTypeInit() const { return wxRect(1,2,3,4); }
07610 #endif
07611
07619 virtual bool CommitChangesFromEditor( wxUint32 flags = 0 );
07620
07621 bool HasInternalFlag( long flag ) const { return (m_iFlags & flag) ? true : false; }
07622 long GetInternalFlags() const { return m_iFlags; }
07623 void SetInternalFlag( long flag ) { m_iFlags |= flag; }
07624 void ClearInternalFlag( long flag ) { m_iFlags &= ~(flag); }
07625
07637 virtual void DoShowPropertyError( wxPGProperty* property,
07638 const wxString& msg );
07639
07646 virtual void DoHidePropertyError( wxPGProperty* property );
07647
07648 #if wxUSE_STATUSBAR
07649
07655 virtual wxStatusBar* GetStatusBar();
07656 #endif
07657
07658 #ifndef SWIG
07659
07665 static void ArrayStringToString( wxString& dst, const wxArrayString& src,
07666 wxChar preDelim, wxChar postDelim,
07667 int flags );
07668
07671 void OnCustomEditorEvent( wxCommandEvent &event );
07672
07673 bool HandleCustomEditorEvent( wxCommandEvent &event );
07674
07675 void IncFrozen() { m_frozen++; }
07676 void DecFrozen() { m_frozen--; }
07677
07678 void OnComboItemPaint( wxPGCustomComboControl* pCb,int item,wxDC& dc,
07679 wxRect& rect,int flags );
07680
07681
07682 void SendNavigationKeyEvent( int dir );
07683
07686 static void DoubleToString( wxString& target,
07687 double value,
07688 int precision,
07689 bool removeZeroes,
07690 wxString* precTemplate );
07691
07697 void ValueChangeInEvent( wxVariant variant )
07698 {
07699 m_changeInEventValue = variant;
07700 m_iFlags |= wxPG_FL_VALUE_CHANGE_IN_EVENT;
07701 }
07702
07713 bool WasValueChangedInEvent() const
07714 {
07715 return (m_iFlags & wxPG_FL_VALUE_CHANGE_IN_EVENT) ? true : false;
07716 }
07717
07721 bool IsMainButtonEvent( const wxEvent& event )
07722 {
07723 return (event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) && (m_wndSecId == event.GetId());
07724 }
07725
07728 virtual bool DoPropertyChanged( wxPGProperty* p, unsigned int selFlags = 0 );
07729
07733 virtual bool PerformValidation( wxPGProperty* p, wxVariant& pendingValue );
07734
07744 bool OnValidationFailure( wxPGProperty* property, wxVariant& invalidValue );
07745
07748 void OnValidationFailureReset( wxPGProperty* property )
07749 {
07750 if ( property && property->HasFlag(wxPG_PROP_INVALID_VALUE) )
07751 {
07752 DoOnValidationFailureReset(property);
07753 property->ClearFlag(wxPG_PROP_INVALID_VALUE);
07754 }
07755 m_validationInfo.m_failureMessage.clear();
07756 }
07757
07765 virtual bool DoOnValidationFailure( wxPGProperty* property, wxVariant& invalidValue );
07766
07771 virtual void DoOnValidationFailureReset( wxPGProperty* property );
07772
07773 int GetSpacingY() const { return m_spacingy; }
07774
07780 void SetupTextCtrlValue( const wxString text ) { m_prevTcValue = text; }
07781
07782 void DrawItem( wxPGProperty* p )
07783 {
07784 DrawItems(p,p);
07785 }
07786
07787 virtual void DrawItemAndChildren( wxPGProperty* p );
07788
07790 void DrawItemAndValueRelated( wxPGProperty* p );
07791
07792 protected:
07793
07798 virtual wxPropertyGridState* CreateState() const;
07799
07800 #ifndef DOXYGEN
07801 public:
07802
07803
07804 void SetCurControlBoldFont();
07805
07806
07807
07808
07809 bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
07810
07811
07812 virtual bool Destroy();
07813 virtual wxSize DoGetBestSize() const;
07814 virtual void Refresh( bool eraseBackground = true,
07815 const wxRect *rect = (const wxRect *) NULL );
07816 virtual bool SetFont( const wxFont& font );
07817 #if wxPG_SUPPORT_TOOLTIPS
07818 void SetToolTip( const wxString& tipString );
07819 #endif
07820 virtual void Freeze();
07821 virtual void SetExtraStyle( long exStyle );
07822 virtual void Thaw();
07823 virtual bool Reparent( wxWindowBase *newParent );
07824
07825 protected:
07826
07827 #ifndef wxPG_ICON_WIDTH
07828 wxBitmap *m_expandbmp, *m_collbmp;
07829 #endif
07830
07831 wxCursor *m_cursorSizeWE;
07832
07834 wxWindow *m_wndEditor;
07835 wxWindow *m_wndEditor2;
07836
07838 wxPanel *m_canvas;
07839
07840 #if wxPG_DOUBLE_BUFFER
07841 wxBitmap *m_doubleBuffer;
07842 #endif
07843
07844 wxArrayPtrVoid *m_windowsToDelete;
07845
07847 wxLongLong m_timeCreated;
07848
07850 wxVariant m_changeInEventValue;
07851
07853 int m_wndSecId;
07854
07856 int m_spacingy;
07857
07859 int m_width;
07860
07862 int m_height;
07863
07865 int m_ncWidth;
07866
07868
07869
07871 int m_prevVY;
07872
07875 int m_gutterWidth;
07876
07878 int m_lineHeight;
07879
07881 int m_marginWidth;
07882
07883 int m_buttonSpacingY;
07884
07886 int m_subgroup_extramargin;
07887
07889 int m_iconWidth;
07890
07891 #ifndef wxPG_ICON_WIDTH
07892
07894 int m_iconHeight;
07895 #endif
07896
07898 int m_curcursor;
07899
07902 wxFont m_captionFont;
07903
07904 int m_fontHeight;
07905
07906 int m_pushButKeyCode;
07907
07909 int m_startingSplitterX;
07910
07912 int m_draggedSplitter;
07913
07915 wxPGProperty* m_chgInfo_changedProperty;
07916
07918 wxPGProperty* m_chgInfo_baseChangedProperty;
07919
07921 wxVariant m_chgInfo_pendingValue;
07922
07924 wxVariant m_chgInfo_valueList;
07925
07927 wxPGValidationInfo m_validationInfo;
07928
07930 wxPGHashMapI2I m_actionTriggers;
07931
07933 wxPGCell m_editorAppearance;
07934
07936 wxPGCell m_unspecifiedAppearance;
07937
07939 wxArrayPGProperty m_deletedProperties;
07940 wxArrayPGProperty m_removedProperties;
07941
07942
07943
07944
07945
07947 unsigned short m_coloursCustomized;
07948
07950 signed char m_dragOffset;
07951
07953 unsigned char m_dragStatus;
07954
07956 unsigned char m_mouseSide;
07957
07959 unsigned char m_editorFocused;
07960
07962
07963
07965 unsigned char m_frozen;
07966
07967 unsigned char m_vspacing;
07968
07969 unsigned char m_pushButKeyCodeNeedsAlt;
07970
07971 unsigned char m_pushButKeyCodeNeedsCtrl;
07972
07973 unsigned char m_keyComboConsumed;
07974
07976 unsigned char m_inDoPropertyChanged;
07977
07979 unsigned char m_inCommitChangesFromEditor;
07980
07982 bool m_inDoSelectProperty;
07983
07985 bool m_inOnValidationFailure;
07986
07987 wxPGVFBFlags m_permanentValidationFailureBehavior;
07988
07990 wxUint32 m_iFlags;
07991
07993 int m_clearThisMany;
07994
07995
07996 unsigned int m_colHover;
07997
07998 wxPGProperty* m_propHover;
07999
08000
08001 wxWindow* m_labelEditor;
08002
08003
08004 wxPGProperty* m_labelEditorProperty;
08005
08006 wxWindow* m_eventObject;
08007
08008 wxWindow* m_curFocused;
08009
08010
08011
08012 wxWindow* m_tlpClosed;
08013
08014
08015 wxLongLong m_tlpClosedTime;
08016
08017 wxWindow* m_tlp;
08018
08019
08020 wxPropertyGridEvent* m_processedEvent;
08021
08022 wxPGSortCallback m_sortFunction;
08023
08024 int m_propHoverY;
08025 unsigned int m_selColumn;
08026
08027 int m_ctrlXAdjust;
08028
08029 wxColour m_colLine;
08030 wxColour m_colPropFore;
08031 wxColour m_colDisPropFore;
08032 wxColour m_colPropBack;
08033 wxColour m_colCapFore;
08034 wxColour m_colCapBack;
08035 wxColour m_colSelFore;
08036 wxColour m_colSelBack;
08037 wxColour m_colMargin;
08038 wxColour m_colEmptySpace;
08039
08040 wxArrayPtrVoid m_visPropArray;
08041
08042
08043 wxArrayPtrVoid m_arrBgBrushes;
08044 wxArrayPtrVoid m_arrFgCols;
08045
08046 wxArrayPtrVoid m_commonValues;
08047 int m_cvUnspecified;
08048
08049 wxString m_prevTcValue;
08050
08051 protected:
08052
08053
08054 void Init1();
08055
08056
08057 void Init2();
08058
08059
08060 void OnMouseMove( wxMouseEvent &event );
08061 void OnMouseMoveBottom( wxMouseEvent &event );
08062 void OnMouseClick( wxMouseEvent &event );
08063 void OnMouseRightClick( wxMouseEvent &event );
08064 void OnMouseDoubleClick( wxMouseEvent &event );
08065 void OnMouseUp( wxMouseEvent &event );
08066 void OnKey( wxKeyEvent &event );
08067 void OnKeyUp( wxKeyEvent &event );
08068 void OnNavigationKey( wxNavigationKeyEvent& event );
08069 void OnResize( wxSizeEvent &event );
08070 void OnPaint( wxPaintEvent& event );
08071
08072
08073 bool HandleMouseMove( int x, unsigned int y, wxMouseEvent &event );
08074 bool HandleMouseClick( int x, unsigned int y, wxMouseEvent &event );
08075 bool HandleMouseRightClick( int x, unsigned int y, wxMouseEvent &event );
08076 bool HandleMouseDoubleClick( int x, unsigned int y, wxMouseEvent &event );
08077 bool HandleMouseUp( int x, unsigned int y, wxMouseEvent &event );
08078 void HandleKeyEvent( wxKeyEvent &event );
08079 bool HandleChildKey( wxKeyEvent& event );
08080
08081 void OnMouseEntry( wxMouseEvent &event );
08082
08083 void OnIdle( wxIdleEvent &event );
08084 void OnFocusEvent( wxFocusEvent &event );
08085 void OnChildFocusEvent( wxChildFocusEvent& event );
08086
08087 bool OnMouseCommon( wxMouseEvent &event, int* px, int *py );
08088 bool OnMouseChildCommon( wxMouseEvent &event, int* px, int *py );
08089
08090
08091 void OnMouseClickChild( wxMouseEvent &event );
08092 void OnMouseRightClickChild( wxMouseEvent &event );
08093 void OnMouseMoveChild( wxMouseEvent &event );
08094 void OnMouseUpChild( wxMouseEvent &event );
08095 void OnChildKeyDown( wxKeyEvent &event );
08096 void OnChildKeyUp( wxKeyEvent &event );
08097
08098 void OnCaptureChange( wxMouseCaptureChangedEvent &event );
08099
08100 void OnScrollEvent( wxScrollWinEvent &event );
08101
08102 void OnSysColourChanged( wxSysColourChangedEvent &event );
08103
08104 void OnTLPClose( wxCloseEvent& event );
08105
08106 protected:
08107
08108 bool AddToSelectionFromInputEvent( wxPGProperty* prop,
08109 unsigned int colIndex,
08110 wxMouseEvent* event = NULL,
08111 int selFlags = 0 );
08112
08117 void CalculateFontAndBitmapStuff( int vspacing );
08118
08119 wxRect GetEditorWidgetRect( wxPGProperty* p, int column ) const;
08120
08121 void CorrectEditorWidgetSizeX();
08122
08126 void CorrectEditorWidgetPosY();
08127
08128 #ifdef __WXDEBUG__
08129 void _log_items();
08130 void OnScreenNote( const wxChar* format, ... );
08131 #endif
08132
08133 int DoDrawItems( wxDC& dc,
08134 const wxPGProperty* first_item,
08135 const wxPGProperty* last_item,
08136 const wxRect* clip_rect,
08137 bool isBuffered ) const;
08138
08141 virtual void DrawExpanderButton( wxDC& dc, const wxRect& rect,
08142 wxPGProperty* property ) const;
08143
08145 void DrawItems( wxDC& dc, unsigned int topitemy, unsigned int bottomitemy,
08146 const wxRect* clip_rect = (const wxRect*) NULL );
08147
08148 void DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 );
08149
08150 #if wxPG_COMPATIBILITY_1_2_0
08151
08152 wxPGProperty& GetPropertyById( wxPGPropArg id )
08153 {
08154 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(*((wxPGProperty*)NULL))
08155 return *p;
08156 }
08157 #endif
08158
08159
08160 int KeyEventToActions(wxKeyEvent &event, int* pSecond) const;
08161
08162 int KeyEventToAction(wxKeyEvent &event) const
08163 {
08164 return KeyEventToActions(event, NULL);
08165 }
08166
08167 void ImprovedClientToScreen( int* px, int* py );
08168
08169
08170 void HandleFocusChange( wxWindow* newFocused );
08171
08173 void RegainColours();
08174
08175 bool DoEditorValidate();
08176
08177
08178
08179
08180 bool DoSelectAndEdit( wxPGProperty* prop,
08181 unsigned int colIndex,
08182 unsigned int selFlags );
08183
08184 void DoSetSelection( const wxArrayPGProperty& newSelection,
08185 int selFlags = 0 );
08186
08187 bool DoAddToSelection( wxPGProperty* prop,
08188 int selFlags = 0 );
08189
08190 bool DoRemoveFromSelection( wxPGProperty* prop,
08191 int selFlags = 0 );
08192
08193 void DoBeginLabelEdit( unsigned int colIndex, int selFlags = 0 );
08194 void DoEndLabelEdit( bool commit, int selFlags = 0 );
08195 void OnLabelEditorEnterPress( wxCommandEvent& event );
08196 void OnLabelEditorKeyPress( wxKeyEvent& event );
08197
08198 wxPGProperty* DoGetItemAtY( int y ) const;
08199
08200 void DoSetSplitterPosition_( int newxpos, bool refresh = true, int splitterIndex = 0, bool allPages = false );
08201
08202 void DestroyEditorWnd( wxWindow* wnd );
08203 void FreeEditors();
08204
08205 virtual bool DoExpand( wxPGProperty* p, bool sendEvent = false );
08206
08207 virtual bool DoCollapse( wxPGProperty* p, bool sendEvent = false );
08208
08209
08210
08211
08212 wxPGProperty* GetNearestPaintVisible( wxPGProperty* p ) const;
08213
08214 static void RegisterDefaultEditors();
08215
08216
08217 void SetBackgroundColourIndex( wxPGProperty* p, int index,
08218 int flags = wxPG_RECURSE );
08219
08220
08221 void SetTextColourIndex( wxPGProperty* p, int index, int flags );
08222
08223 int CacheColour( const wxColour& colour );
08224
08225 void DoSetPropertyName( wxPGProperty* p, const wxString& newname );
08226
08227
08228 void SetupEventHandling( wxWindow* wnd, int id );
08229
08230 void CustomSetCursor( int type, bool override = false );
08231
08232 virtual bool ProcessEvent(wxEvent& event);
08233
08236 void RecalculateVirtualSize( int forceXPos = -1 );
08237
08238 void SetEditorAppearance( const wxPGCell& cell );
08239
08240 void ResetEditorAppearance()
08241 {
08242 wxPGCell cell;
08243 SetEditorAppearance(cell);
08244 }
08245
08246 void PrepareAfterItemsAdded();
08247
08248
08249 bool SendEvent( int eventType, wxPGProperty* p,
08250 wxVariant* pValue = NULL,
08251 unsigned int selFlags = wxPG_SEL_NOVALIDATE,
08252 unsigned int column = 1 );
08253
08254 void SetFocusOnCanvas()
08255 {
08256 m_canvas->SetFocusIgnoringChildren();
08257 m_editorFocused = 0;
08258 }
08259
08260 bool DoHideProperty( wxPGProperty* p, bool hide, int flags );
08261
08262 private:
08263
08264 bool ButtonTriggerKeyTest( wxKeyEvent &event );
08265
08266 #endif // DOXYGEN_SHOULD_SKIP_THIS
08267
08268 private:
08269 DECLARE_EVENT_TABLE()
08270 #endif // #ifndef SWIG
08271 };
08272
08273 #undef wxPG_USE_STATE
08274
08275
08276
08277
08278
08279
08280 #ifndef SWIG
08281 inline bool wxPropertyGridState::IsDisplayed() const
08282 {
08283 return ( this == m_pPropGrid->GetState() );
08284 }
08285
08286 inline unsigned int wxPropertyGridState::GetActualVirtualHeight() const
08287 {
08288 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
08289 }
08290 #endif
08291
08292 inline int wxPGProperty::GetDisplayedCommonValueCount() const
08293 {
08294 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE) )
08295 {
08296 wxPropertyGrid* pg = GetGrid();
08297 if ( pg )
08298 return (int) pg->GetCommonValueCount();
08299 }
08300 return 0;
08301 }
08302
08303 inline void wxPGProperty::SetEditor( const wxString& editorName )
08304 {
08305 m_customEditor = wxPropertyGridInterface::GetEditorByName(editorName);
08306 }
08307
08308 inline bool wxPGProperty::SetMaxLength( int maxLen )
08309 {
08310 return GetGrid()->SetPropertyMaxLength(this,maxLen);
08311 }
08312
08313
08314
08315
08316 #ifndef SWIG
08317
08318 #define wxPG_BASE_EVT_PRE_ID 1775
08319
08320 BEGIN_DECLARE_EVENT_TYPES()
08321 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_SELECTED, wxPG_BASE_EVT_PRE_ID)
08322 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_CHANGING, wxPG_BASE_EVT_PRE_ID+1)
08323 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_CHANGED, wxPG_BASE_EVT_PRE_ID+2)
08324 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_HIGHLIGHTED, wxPG_BASE_EVT_PRE_ID+3)
08325 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_RIGHT_CLICK, wxPG_BASE_EVT_PRE_ID+4)
08326 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_PAGE_CHANGED, wxPG_BASE_EVT_PRE_ID+5)
08327 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_ITEM_COLLAPSED, wxPG_BASE_EVT_PRE_ID+6)
08328 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_ITEM_EXPANDED, wxPG_BASE_EVT_PRE_ID+7)
08329 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_DOUBLE_CLICK, wxPG_BASE_EVT_PRE_ID+8)
08330 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_LABEL_EDIT_BEGIN, wxPG_BASE_EVT_PRE_ID+9)
08331 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_PG, wxEVT_PG_LABEL_EDIT_ENDING, wxPG_BASE_EVT_PRE_ID+10)
08332 END_DECLARE_EVENT_TYPES()
08333 #else
08334 enum {
08335 wxEVT_PG_SELECTED = wxPG_BASE_EVT_PRE_ID,
08336 wxEVT_PG_CHANGING,
08337 wxEVT_PG_CHANGED,
08338 wxEVT_PG_HIGHLIGHTED,
08339 wxEVT_PG_RIGHT_CLICK,
08340 wxEVT_PG_PAGE_CHANGED,
08341 wxEVT_PG_ITEM_COLLAPSED,
08342 wxEVT_PG_ITEM_EXPANDED,
08343 wxEVT_PG_DOUBLE_CLICK,
08344 wxEVT_PG_LABEL_EDIT_BEGIN,
08345 wxEVT_PG_LABEL_EDIT_ENDING
08346 };
08347 #endif
08348
08349
08350 #define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
08351 #define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
08352
08353
08354 #ifndef SWIG
08355 typedef void (wxEvtHandler::*wxPropertyGridEventFunction)(wxPropertyGridEvent&);
08356
08357 #define EVT_PG_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08358 #define EVT_PG_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08359 #define EVT_PG_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08360 #define EVT_PG_HIGHLIGHTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08361 #define EVT_PG_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08362 #define EVT_PG_DOUBLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08363 #define EVT_PG_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08364 #define EVT_PG_ITEM_COLLAPSED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08365 #define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
08366 #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 ),
08367 #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 ),
08368
08369 #define wxPropertyGridEventHandler(A) ((wxObjectEventFunction)(wxEventFunction)(wxPropertyGridEventFunction)&A)
08370
08371 #endif
08372
08373
08390 class WXDLLIMPEXP_PG wxPropertyGridEvent : public wxCommandEvent
08391 {
08392 public:
08393
08395 wxPropertyGridEvent(wxEventType commandType=0, int id=0);
08396 #ifndef SWIG
08397
08398 wxPropertyGridEvent(const wxPropertyGridEvent& event);
08399 #endif
08400
08401 ~wxPropertyGridEvent();
08402
08404 virtual wxEvent* Clone() const;
08405
08407 void EnableProperty( bool enable = true )
08408 {
08409 m_pg->EnableProperty(m_property,enable);
08410 }
08411
08413 void DisableProperty()
08414 {
08415 m_pg->EnableProperty(m_property,false);
08416 }
08417
08421 unsigned int GetColumn() const
08422 {
08423 return m_column;
08424 }
08425
08426 wxPGProperty* GetMainParent() const
08427 {
08428 wxASSERT(m_property);
08429 return m_property->GetMainParent();
08430 }
08431
08433 wxPGProperty* GetProperty() const
08434 {
08435 return m_property;
08436 }
08437
08438 #if wxPG_COMPATIBILITY_1_2_0
08439 #ifndef SWIG
08440
08444 wxPGProperty* GetPropertyPtr() const
08445 {
08446 return m_property;
08447 }
08448 #endif
08449 #endif
08450
08452 const wxString& GetPropertyLabel() const
08453 {
08454 wxASSERT( m_property );
08455 return m_property->GetLabel();
08456 }
08457
08459 wxString GetPropertyName() const
08460 {
08461 wxASSERT( m_property );
08462 return m_property->GetName();
08463 }
08464
08466 wxPGProperty::ClientDataType GetPropertyClientData() const
08467 {
08468 wxASSERT( m_property );
08469 return m_property->GetClientData();
08470 }
08471
08472 #ifndef SWIG
08473
08474 wxVariant GetPropertyValue() const
08475 {
08476 wxASSERT( m_property );
08477 return m_property->GetValue();
08478 }
08479
08480 wxString GetPropertyValueAsString() const
08481 {
08482 return m_pg->GetPropertyValueAsString( m_property );
08483 }
08484 long GetPropertyValueAsLong() const
08485 {
08486 return m_pg->GetPropertyValueAsLong( m_property );
08487 }
08488 int GetPropertyValueAsInt() const
08489 {
08490 return (int)GetPropertyValueAsLong();
08491 }
08492 long GetPropertyValueAsBool() const
08493 {
08494 return m_pg->GetPropertyValueAsBool( m_property );
08495 }
08496 double GetPropertyValueAsDouble() const
08497 {
08498 return m_pg->GetPropertyValueAsDouble( m_property );
08499 }
08500 const wxObject* GetPropertyValueAsWxObjectPtr() const
08501 {
08502 return m_pg->GetPropertyValueAsWxObjectPtr( m_property );
08503 }
08504 void* GetPropertyValueAsVoidPtr() const
08505 {
08506 return m_pg->GetPropertyValueAsVoidPtr( m_property );
08507 }
08508 wxArrayString GetPropertyValueAsArrayString() const
08509 {
08510 return m_pg->GetPropertyValueAsArrayString( m_property );
08511 }
08512 wxPoint GetPropertyValueAsPoint() const
08513 {
08514 return m_pg->GetPropertyValueAsPoint( m_property );
08515 }
08516 wxSize GetPropertyValueAsSize() const
08517 {
08518 return m_pg->GetPropertyValueAsSize( m_property );
08519 }
08520 wxArrayInt GetPropertyValueAsArrayInt() const
08521 {
08522 return m_pg->GetPropertyValueAsArrayInt( m_property );
08523 }
08524
08525 #else
08526 %pythoncode {
08527 def GetPropertyValue(self):
08528 return self.GetProperty().GetValue()
08529 }
08530 #endif
08531
08532 wxPGValidationInfo& GetValidationInfo()
08533 {
08534 wxASSERT(m_validationInfo);
08535 return *m_validationInfo;
08536 }
08537
08539 bool HasProperty() const { return ( m_property != (wxPGProperty*) NULL ); }
08540
08541 bool IsPropertyEnabled() const
08542 {
08543 return m_pg->IsPropertyEnabled(m_property);
08544 }
08545
08548 bool CanVeto() const { return m_canVeto; }
08549
08555 void Veto( bool veto = true ) { m_wasVetoed = veto; }
08556
08559 const wxVariant& GetValue() const
08560 {
08561 wxASSERT_MSG( m_validationInfo,
08562 wxT("Only call GetValue from a handler of event type that supports it") );
08563 return *m_validationInfo->m_pValue;
08564 }
08565
08569 void SetValidationFailureBehavior( int flags )
08570 {
08571 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
08572 m_validationInfo->m_failureBehavior = (wxPGVFBFlags) flags;
08573 }
08574
08578 void SetValidationFailureMessage( const wxString& message )
08579 {
08580 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
08581 m_validationInfo->m_failureMessage = message;
08582 }
08583
08584 #ifndef SWIG
08585 wxPGVFBFlags GetValidationFailureBehavior() const
08586 {
08587 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
08588 return m_validationInfo->m_failureBehavior;
08589 }
08590
08591 void SetCanVeto( bool canVeto ) { m_canVeto = canVeto; }
08592 bool WasVetoed() const { return m_wasVetoed; }
08593
08595 void SetProperty( wxPGProperty* p ) { m_property = p; }
08596
08597 void SetPropertyGrid( wxPropertyGrid* pg ) { m_pg = pg; }
08598
08599 void SetupValidationInfo()
08600 {
08601 wxASSERT(m_pg);
08602 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
08603 m_validationInfo = &m_pg->GetValidationInfo();
08604 }
08605
08606 void SetColumn( unsigned int column )
08607 {
08608 m_column = column;
08609 }
08610
08611 private:
08612 void Init();
08613 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent)
08614
08615 wxPGProperty* m_property;
08616 wxPropertyGrid* m_pg;
08617 wxPGValidationInfo* m_validationInfo;
08618
08619 unsigned int m_column;
08620
08621 bool m_canVeto;
08622 bool m_wasVetoed;
08623
08624 #endif
08625 };
08626
08627
08628
08629
08634 class WXDLLIMPEXP_PG wxPropertyGridPopulator
08635 {
08636 public:
08639 wxPropertyGridPopulator();
08640
08642 virtual ~wxPropertyGridPopulator();
08643
08644 void SetState( wxPropertyGridState* state );
08645
08646 void SetGrid( wxPropertyGrid* pg );
08647
08652 wxPGProperty* Add( const wxString& propClass,
08653 const wxString& propLabel,
08654 const wxString& propName,
08655 const wxString* propValue,
08656 wxPGChoices* pChoices = NULL );
08657
08662 void AddChildren( wxPGProperty* property );
08663
08669 bool AddAttribute( const wxString& name,
08670 const wxString& type,
08671 const wxString& value );
08672
08675 virtual void DoScanForChildren() = 0;
08676
08678 wxPGProperty* GetCurParent() const
08679 {
08680 return (wxPGProperty*) m_propHierarchy[m_propHierarchy.size()-1];
08681 }
08682
08683 wxPropertyGridState* GetState() { return m_state; }
08684 const wxPropertyGridState* GetState() const { return m_state; }
08685
08688 static bool ToLongPCT( const wxString& s, long* pval, long max );
08689
08695 wxPGChoices ParseChoices( const wxString& choicesString,
08696 const wxString& idString );
08697
08701 virtual void ProcessError( const wxString& msg );
08702
08703 protected:
08704
08706 wxPropertyGrid* m_pg;
08707
08709 wxPropertyGridState* m_state;
08710
08712 wxArrayPGProperty m_propHierarchy;
08713
08715 wxPGHashMapS2P m_dictIdChoices;
08716 };
08717
08718
08719
08720
08721
08722
08723 #ifndef __wxPG_SOURCE_FILE__
08724 #undef wxPG_FL_DESC_REFRESH_REQUIRED
08725 #undef wxPG_FL_SCROLLBAR_DETECTED
08726 #undef wxPG_FL_CREATEDSTATE
08727 #undef wxPG_FL_NOSTATUSBARHELP
08728 #undef wxPG_FL_SCROLLED
08729 #undef wxPG_FL_FOCUS_INSIDE_CHILD
08730 #undef wxPG_FL_FOCUS_INSIDE
08731 #undef wxPG_FL_MOUSE_INSIDE_CHILD
08732 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
08733 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
08734 #undef wxPG_FL_VALUE_MODIFIED
08735 #undef wxPG_FL_MOUSE_INSIDE
08736 #undef wxPG_FL_FOCUSED
08737 #undef wxPG_FL_MOUSE_CAPTURED
08738 #undef wxPG_FL_INITIALIZED
08739 #undef wxPG_FL_ACTIVATION_BY_CLICK
08740 #undef wxPG_FL_DONT_CENTER_SPLITTER
08741 #undef wxPG_SUPPORT_TOOLTIPS
08742 #undef wxPG_DOUBLE_BUFFER
08743 #undef wxPG_ICON_WIDTH
08744 #undef wxPG_USE_RENDERER_NATIVE
08745
08746
08747 #endif
08748
08749
08750 #ifdef DOXYGEN
08751 #include "editor.h"
08752 #include "manager.h"
08753 #endif
08754
08755
08756
08757 #endif // __WX_PROPGRID_PROPGRID_H__
08758