From 7eac5c531c162c1acedbe1e74d6f7001269e00e5 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Fri, 19 Sep 2008 17:13:51 +0000 Subject: [PATCH] Eliminated WX_PG_DECLARE_X_METHODS macros git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55742 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/advprops.h | 41 +++++++++------ include/wx/propgrid/props.h | 94 +++++++++++++++------------------- samples/propgrid/propgrid.h | 16 ++++-- samples/propgrid/sampleprops.h | 23 ++++++--- 4 files changed, 91 insertions(+), 83 deletions(-) diff --git a/include/wx/propgrid/advprops.h b/include/wx/propgrid/advprops.h index a73c0d3c76..cd879699d0 100644 --- a/include/wx/propgrid/advprops.h +++ b/include/wx/propgrid/advprops.h @@ -176,10 +176,11 @@ public: virtual ~wxFontProperty(); virtual void OnSetValue(); virtual wxString GetValueAsString( int argFlags = 0 ) const; - - WX_PG_DECLARE_EVENT_METHODS() - WX_PG_DECLARE_PARENTAL_METHODS() - //WX_PG_DECLARE_CUSTOM_PAINT_METHODS() + virtual bool OnEvent( wxPropertyGrid* propgrid, + wxWindow* primary, wxEvent& event ); + virtual void ChildChanged( wxVariant& thisValue, + int childIndex, wxVariant& childValue ) const; + virtual void RefreshChildren(); protected: }; @@ -225,13 +226,16 @@ public: */ virtual int GetCustomColourIndex() const; - WX_PG_DECLARE_BASIC_TYPE_METHODS() - WX_PG_DECLARE_EVENT_METHODS() - WX_PG_DECLARE_ATTRIBUTE_METHODS() - - WX_PG_DECLARE_CUSTOM_PAINT_METHODS() - //virtual wxSize GetImageSize( int item ) const; - //virtual wxPGCellRenderer* GetCellRenderer( int column ) const; + virtual wxString GetValueAsString( int argFlags = 0 ) const; + virtual bool StringToValue( wxVariant& variant, + const wxString& text, + int argFlags = 0 ) const; + virtual bool OnEvent( wxPropertyGrid* propgrid, + wxWindow* primary, wxEvent& event ); + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); + virtual wxSize OnMeasureImage( int item ) const; + virtual void OnCustomPaint( wxDC& dc, + const wxRect& rect, wxPGPaintData& paintdata ); // Helper function to show the colour dialog bool QueryColourFromUser( wxVariant& variant ) const; @@ -294,9 +298,9 @@ class WXDLLIMPEXP_PROPGRID wxCursorProperty : public wxEnumProperty int value = 0 ); virtual ~wxCursorProperty(); - WX_PG_DECLARE_CUSTOM_PAINT_METHODS() - //virtual wxSize GetImageSize( int item ) const; - //virtual wxPGCellRenderer* GetCellRenderer( int column ) const; + virtual wxSize OnMeasureImage( int item ) const; + virtual void OnCustomPaint( wxDC& dc, + const wxRect& rect, wxPGPaintData& paintdata ); }; // ----------------------------------------------------------------------- @@ -321,7 +325,9 @@ public: virtual void OnSetValue(); - WX_PG_DECLARE_CUSTOM_PAINT_METHODS() + virtual wxSize OnMeasureImage( int item ) const; + virtual void OnCustomPaint( wxDC& dc, + const wxRect& rect, wxPGPaintData& paintdata ); protected: wxBitmap* m_pBitmap; // final thumbnail area @@ -370,7 +376,8 @@ public: virtual bool StringToValue(wxVariant& variant, const wxString& text, int argFlags = 0) const; - WX_PG_DECLARE_EVENT_METHODS() + virtual bool OnEvent( wxPropertyGrid* propgrid, + wxWindow* primary, wxEvent& event ); wxArrayInt GetValueAsArrayInt() const { @@ -420,7 +427,7 @@ public: const wxString& text, int argFlags = 0) const; - WX_PG_DECLARE_ATTRIBUTE_METHODS() + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); void SetFormat( const wxString& format ) { diff --git a/include/wx/propgrid/props.h b/include/wx/propgrid/props.h index 6e42c2813a..08c1d9228f 100644 --- a/include/wx/propgrid/props.h +++ b/include/wx/propgrid/props.h @@ -22,44 +22,10 @@ class wxArrayEditorDialog; // ----------------------------------------------------------------------- -// -// Additional property class declaration helper macros -// - // // Property class implementation helper macros. // -#define WX_PG_DECLARE_BASIC_TYPE_METHODS() \ - virtual wxString GetValueAsString( int argFlags = 0 ) const; \ - virtual bool StringToValue( wxVariant& variant, \ - const wxString& text, \ - int argFlags = 0 ) const; - -#define WX_PG_DECLARE_CHOICE_METHODS() \ - virtual bool IntToValue( wxVariant& variant, \ - int number, int argFlags = 0 ) const; \ - -#define WX_PG_DECLARE_EVENT_METHODS() \ - virtual bool OnEvent( wxPropertyGrid* propgrid, \ - wxWindow* primary, wxEvent& event ); - -#define WX_PG_DECLARE_PARENTAL_METHODS() \ - virtual void ChildChanged( wxVariant& thisValue, \ - int childIndex, wxVariant& childValue ) const; \ - virtual void RefreshChildren(); - -#define WX_PG_DECLARE_CUSTOM_PAINT_METHODS() \ - virtual wxSize OnMeasureImage( int item ) const; \ - virtual void OnCustomPaint( wxDC& dc, \ - const wxRect& rect, wxPGPaintData& paintdata ); - -#define WX_PG_DECLARE_ATTRIBUTE_METHODS() \ - virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); - -#define WX_PG_DECLARE_VALIDATOR_METHODS() \ - virtual wxValidator* DoGetValidator() const; - // Adds constructor function as well. #define WX_PG_IMPLEMENT_PROPERTY_CLASS2(NAME,CLASSNAME,\ UPCLASS,T,T_AS_ARG,EDITOR) \ @@ -93,7 +59,7 @@ public: \ const wxString& value = wxEmptyString); \ virtual ~NAME(); \ virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxString& value ); \ - WX_PG_DECLARE_VALIDATOR_METHODS() \ + virtual wxValidator* DoGetValidator() const; \ }; #define WX_PG_DECLARE_STRING_PROPERTY(NAME) \ @@ -378,8 +344,12 @@ public: const wxString& value = wxEmptyString ); virtual ~wxStringProperty(); - WX_PG_DECLARE_BASIC_TYPE_METHODS() - WX_PG_DECLARE_ATTRIBUTE_METHODS() + virtual wxString GetValueAsString( int argFlags = 0 ) const; + virtual bool StringToValue( wxVariant& variant, + const wxString& text, + int argFlags = 0 ) const; + + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); /** This is updated so "" special value can be handled. */ @@ -464,7 +434,10 @@ public: wxIntProperty( const wxString& label, const wxString& name, const wxLongLong& value ); - WX_PG_DECLARE_BASIC_TYPE_METHODS() + virtual wxString GetValueAsString( int argFlags = 0 ) const; + virtual bool StringToValue( wxVariant& variant, + const wxString& text, + int argFlags = 0 ) const; virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const; virtual bool IntToValue( wxVariant& variant, @@ -515,8 +488,11 @@ public: wxUIntProperty( const wxString& label, const wxString& name, const wxULongLong& value ); - WX_PG_DECLARE_BASIC_TYPE_METHODS() - WX_PG_DECLARE_ATTRIBUTE_METHODS() + virtual wxString GetValueAsString( int argFlags = 0 ) const; + virtual bool StringToValue( wxVariant& variant, + const wxString& text, + int argFlags = 0 ) const; + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const; virtual bool IntToValue( wxVariant& variant, @@ -549,8 +525,11 @@ public: double value = 0.0 ); virtual ~wxFloatProperty(); - WX_PG_DECLARE_BASIC_TYPE_METHODS() - WX_PG_DECLARE_ATTRIBUTE_METHODS() + virtual wxString GetValueAsString( int argFlags = 0 ) const; + virtual bool StringToValue( wxVariant& variant, + const wxString& text, + int argFlags = 0 ) const; + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const; @@ -589,9 +568,13 @@ public: bool value = false ); virtual ~wxBoolProperty(); - WX_PG_DECLARE_BASIC_TYPE_METHODS() - WX_PG_DECLARE_CHOICE_METHODS() - WX_PG_DECLARE_ATTRIBUTE_METHODS() + virtual wxString GetValueAsString( int argFlags = 0 ) const; + virtual bool StringToValue( wxVariant& variant, + const wxString& text, + int argFlags = 0 ) const; + virtual bool IntToValue( wxVariant& variant, + int number, int argFlags = 0 ) const; + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); }; #endif // !SWIG @@ -891,8 +874,7 @@ public: const wxString& text, int argFlags = 0 ) const; virtual wxPGEditorDialogAdapter* GetEditorDialog() const; - - WX_PG_DECLARE_ATTRIBUTE_METHODS() + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); static wxValidator* GetClassValidator(); virtual wxValidator* DoGetValidator() const; @@ -942,8 +924,8 @@ public: virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const; - - WX_PG_DECLARE_EVENT_METHODS() + virtual bool OnEvent( wxPropertyGrid* propgrid, + wxWindow* primary, wxEvent& event ); // Shows string editor dialog. Value to be edited should be read from // value, and if dialog is not cancelled, it should be stored back and true @@ -981,8 +963,8 @@ public: const wxString& value = wxEmptyString ); virtual ~wxDirProperty(); - WX_PG_DECLARE_ATTRIBUTE_METHODS() - WX_PG_DECLARE_VALIDATOR_METHODS() + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); + virtual wxValidator* DoGetValidator() const; virtual bool OnButtonClick ( wxPropertyGrid* propGrid, wxString& value ); @@ -1017,8 +999,12 @@ public: virtual ~wxArrayStringProperty(); virtual void OnSetValue(); - WX_PG_DECLARE_BASIC_TYPE_METHODS() - WX_PG_DECLARE_EVENT_METHODS() + virtual wxString GetValueAsString( int argFlags = 0 ) const; + virtual bool StringToValue( wxVariant& variant, + const wxString& text, + int argFlags = 0 ) const; + virtual bool OnEvent( wxPropertyGrid* propgrid, + wxWindow* primary, wxEvent& event ); virtual void GenerateValueAsString(); @@ -1059,7 +1045,7 @@ public: \ virtual bool OnEvent( wxPropertyGrid* propgrid, \ wxWindow* primary, wxEvent& event ); \ virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \ - WX_PG_DECLARE_VALIDATOR_METHODS() \ + virtual wxValidator* DoGetValidator() const; \ }; #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \ diff --git a/samples/propgrid/propgrid.h b/samples/propgrid/propgrid.h index ffe6c04808..e0e44a0993 100644 --- a/samples/propgrid/propgrid.h +++ b/samples/propgrid/propgrid.h @@ -26,9 +26,11 @@ public: virtual void OnSetValue(); // Override to allow image loading. - WX_PG_DECLARE_CHOICE_METHODS() - WX_PG_DECLARE_EVENT_METHODS() - WX_PG_DECLARE_CUSTOM_PAINT_METHODS() + virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const; + virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event ); + virtual wxSize OnMeasureImage( int item ) const; + virtual void OnCustomPaint( wxDC& dc, + const wxRect& rect, wxPGPaintData& paintdata ); void LoadThumbnails( size_t n ); @@ -74,7 +76,9 @@ public: const wxVector3f& value = wxVector3f() ); virtual ~wxVectorProperty(); - WX_PG_DECLARE_PARENTAL_METHODS() + virtual void ChildChanged( wxVariant& thisValue, + int childIndex, wxVariant& childValue ) const; + virtual void RefreshChildren(); protected: }; @@ -104,7 +108,9 @@ public: const wxTriangle& value = wxTriangle() ); virtual ~wxTriangleProperty(); - WX_PG_DECLARE_PARENTAL_METHODS() + virtual void ChildChanged( wxVariant& thisValue, + int childIndex, wxVariant& childValue ) const; + virtual void RefreshChildren(); protected: }; diff --git a/samples/propgrid/sampleprops.h b/samples/propgrid/sampleprops.h index 6d7166901a..28244dd7c5 100644 --- a/samples/propgrid/sampleprops.h +++ b/samples/propgrid/sampleprops.h @@ -34,8 +34,10 @@ public: // in base class to function properly. virtual wxVariant DoGetValue() const; - WX_PG_DECLARE_PARENTAL_METHODS() - WX_PG_DECLARE_EVENT_METHODS() + virtual void ChildChanged( wxVariant& thisValue, + int childIndex, wxVariant& childValue ) const; + virtual void RefreshChildren(); + virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event ); protected: // Value must be stored as variant - otherwise it will be @@ -54,7 +56,9 @@ public: const wxSize& value = wxSize() ); virtual ~wxSizeProperty(); - WX_PG_DECLARE_PARENTAL_METHODS() + virtual void ChildChanged( wxVariant& thisValue, + int childIndex, wxVariant& childValue ) const; + virtual void RefreshChildren(); protected: @@ -76,7 +80,9 @@ public: const wxPoint& value = wxPoint() ); virtual ~wxPointProperty(); - WX_PG_DECLARE_PARENTAL_METHODS() + virtual void ChildChanged( wxVariant& thisValue, + int childIndex, wxVariant& childValue ) const; + virtual void RefreshChildren(); protected: @@ -107,9 +113,12 @@ public: virtual ~wxArrayDoubleProperty (); virtual void OnSetValue(); - WX_PG_DECLARE_BASIC_TYPE_METHODS() - WX_PG_DECLARE_EVENT_METHODS() - WX_PG_DECLARE_ATTRIBUTE_METHODS() + virtual wxString GetValueAsString( int argFlags = 0 ) const; + virtual bool StringToValue( wxVariant& variant, + const wxString& text, + int argFlags = 0 ) const; + virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event ); + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); // Generates cache for displayed text virtual void GenerateValueAsString ( wxString& target, int prec, bool removeZeroes ) const; -- 2.45.2