From a06bb527dd58cb3b0aec62d0bce0b03aade10140 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 19 Aug 2003 16:48:06 +0000 Subject: [PATCH] RTTI extensions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23025 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/combobox.h | 2 + include/wx/msw/listbox.h | 2 + include/wx/msw/scrolbar.h | 5 ++ include/wx/slider.h | 2 + include/wx/window.h | 10 --- include/wx/xti.h | 175 +++++++++++++++++--------------------- 6 files changed, 89 insertions(+), 107 deletions(-) diff --git a/include/wx/msw/combobox.h b/include/wx/msw/combobox.h index a369165d75..a033082991 100644 --- a/include/wx/msw/combobox.h +++ b/include/wx/msw/combobox.h @@ -69,6 +69,8 @@ public: virtual void Replace(long from, long to, const wxString& value); virtual void Remove(long from, long to); virtual void SetSelection(int n) { wxChoice::SetSelection(n); } + // rtti needs a function with just one signature + void SetSelectionLine(int n) { SetSelection( n ) ; } virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); diff --git a/include/wx/msw/listbox.h b/include/wx/msw/listbox.h index ad18e8530e..a994417d49 100644 --- a/include/wx/msw/listbox.h +++ b/include/wx/msw/listbox.h @@ -75,6 +75,8 @@ public: virtual bool IsSelected(int n) const; virtual void SetSelection(int n, bool select = TRUE); + // rtti needs a function with just one signature + void SetSelectionLine(int n) { SetSelection( n ) ; } virtual int GetSelection() const; virtual int GetSelections(wxArrayInt& aSelections) const; diff --git a/include/wx/msw/scrolbar.h b/include/wx/msw/scrolbar.h index 701c61e35c..6cae25208d 100644 --- a/include/wx/msw/scrolbar.h +++ b/include/wx/msw/scrolbar.h @@ -48,6 +48,11 @@ public: virtual void SetScrollbar(int position, int thumbSize, int range, int pageSize, bool refresh = TRUE); + // needed for RTTI + void SetThumbSize( int s ) { SetScrollbar( GetThumbPosition() , s , GetRange() , GetPageSize() , true ) ; } + void SetPageSize( int s ) { SetScrollbar( GetThumbPosition() , GetThumbSize() , GetRange() , s , true ) ; } + void SetRange( int s ) { SetScrollbar( GetThumbPosition() , GetThumbSize() , s , GetPageSize() , true ) ; } + void Command(wxCommandEvent& event); virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); diff --git a/include/wx/slider.h b/include/wx/slider.h index 09cd35c8b5..31fbe554bc 100644 --- a/include/wx/slider.h +++ b/include/wx/slider.h @@ -52,6 +52,8 @@ public: virtual void SetRange(int minValue, int maxValue) = 0; virtual int GetMin() const = 0; virtual int GetMax() const = 0; + void SetMin( int minValue ) { SetRange( minValue , GetMax() ) ; } + void SetMax( int maxValue ) { SetRange( GetMin() , maxValue ) ; } // the line/page size is the increment by which the slider moves when // cursor arrow key/page up or down are pressed (clicking the mouse is like diff --git a/include/wx/window.h b/include/wx/window.h index 2c266712cc..0917bae944 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -229,13 +229,6 @@ public: return wxSize(w, h); } -// the following are just helper functions to help some compiler with the extended rtti inf - void SetWindowPosition( const wxPoint &pt) { SetPosition( pt ) ; } - wxPoint GetWindowPosition() const { return GetPosition() ; } - - void SetWindowSize( const wxSize &sz ) { SetSize( sz ) ; } - wxSize GetWindowSize() const { return GetSize() ; } - wxRect GetRect() const { int x, y, w, h; @@ -646,9 +639,6 @@ public: const wxFont& GetFont() const { return m_font; } wxFont& GetFont() { return m_font; } - // for resolving RTTI conflicts - wxFont GetWindowFont() const { return GetFont() ; } - #if wxUSE_CARET // associate a caret with the window void SetCaret(wxCaret *caret); diff --git a/include/wx/xti.h b/include/wx/xti.h index 4168b6a640..4a82a413be 100644 --- a/include/wx/xti.h +++ b/include/wx/xti.h @@ -538,130 +538,58 @@ private : } ; -template void wxSetterFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*setter)( valueType ) ) -{ - Klass *obj = dynamic_cast(object); - if ( variantValue.HasData() ) - (obj->*(setter))(variantValue.Get()) ; - else - (obj->*(setter))(*variantValue.Get()) ; -} -template void wxSetterFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*setter)( valueType& ) ) -{ - Klass *obj = dynamic_cast(object); - if ( variantValue.HasData() ) - (obj->*(setter))(variantValue.Get()) ; - else - (obj->*(setter))(*variantValue.Get()) ; -} - -template void wxSetterFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*setter)( const valueType& ) ) -{ - Klass *obj = dynamic_cast(object); - if ( variantValue.HasData() ) - (obj->*(setter))(variantValue.Get()) ; - else - (obj->*(setter))(*variantValue.Get()) ; -} - -template void wxAdderFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*adder)( valueType ) ) -{ - Klass *obj = dynamic_cast(object); - (obj->*(adder))(variantValue.Get()) ; -} - -template void wxAdderFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*adder)( valueType& ) ) -{ - Klass *obj = dynamic_cast(object); - (obj->*(adder))(variantValue.Get()) ; -} - -template void wxAdderFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*adder)( const valueType& ) ) -{ - Klass *obj = dynamic_cast(object); - (obj->*(adder))(variantValue.Get()) ; -} - -/* -template void wxxGetterFunc( const wxObject *object , wxxVariant &result, valueType& (Klass::*getter)() const ) -{ - const Klass *obj = dynamic_cast(object); - result = wxxVariant((obj->*(getter))()) ; -} -*/ - -template void wxGetterFunc( const wxObject *object , wxxVariant &result, valueType(Klass::*getter)() const ) -{ - const Klass *obj = dynamic_cast(object); - result = wxxVariant((obj->*(getter))()) ; -} - -template void wxGetterFunc( const wxObject *object , wxxVariant &result, const valueType&(Klass::*getter)() const) -{ - const Klass *obj = dynamic_cast(object); - result = wxxVariant((obj->*(getter))()) ; -} - -template void wxCollectionGetterFunc( const wxObject *object , wxxVariantArray &result, valueType& (Klass::*getter)() const ) -{ - const Klass *obj = dynamic_cast(object); - wxCollectionToVariantArray( (obj->*(getter))() , result ) ; -} - -template void wxCollectionGetterFunc( const wxObject *object , wxxVariantArray &result, valueType(Klass::*getter)() const ) -{ - const Klass *obj = dynamic_cast(object); - wxCollectionToVariantArray( (obj->*(getter))() , result ) ; -} - -template void wxCollectionGetterFunc( const wxObject *object , wxxVariantArray &result, const valueType&(Klass::*getter)() const) -{ - const Klass *obj = dynamic_cast(object); - wxCollectionToVariantArray( (obj->*(getter))() , result ) ; -} - -#define WX_SETTER( property , settermethod ) \ +#define WX_SETTER( property, Klass, valueType, setterMethod ) \ class wxSetter##property : public wxSetter \ { \ public: \ - wxSetter##property() : wxSetter( #settermethod ) {} \ + wxSetter##property() : wxSetter( #setterMethod ) {} \ void Set( wxObject *object, const wxxVariant &variantValue ) const \ { \ - wxSetterFunc( object , variantValue , &class_t::settermethod ) ; \ + Klass *obj = dynamic_cast(object) ; \ + if ( variantValue.HasData() ) \ + obj->setterMethod(variantValue.Get()) ; \ + else \ + obj->setterMethod(*variantValue.Get()) ; \ } \ } ; -#define WX_GETTER( property , gettermethod ) \ +#define WX_GETTER( property, Klass, valueType , gettermethod ) \ class wxGetter##property : public wxGetter \ { \ public : \ wxGetter##property() : wxGetter( #gettermethod ) {} \ void Get( const wxObject *object , wxxVariant &result) const \ { \ - wxGetterFunc( object , result , &class_t::gettermethod ) ; \ + const Klass *obj = dynamic_cast(object) ; \ + result = wxxVariant( obj->gettermethod() ) ; \ } \ } ; -#define WX_ADDER( property , addermethod ) \ +#define WX_ADDER( property, Klass, valueType , addermethod ) \ class wxAdder##property : public wxAdder \ { \ public: \ wxAdder##property() : wxAdder( #addermethod ) {} \ void Add( wxObject *object, const wxxVariant &variantValue ) const \ { \ - wxAdderFunc( object , variantValue , &class_t::addermethod ) ; \ + Klass *obj = dynamic_cast(object) ; \ + if ( variantValue.HasData() ) \ + obj->addermethod(variantValue.Get()) ; \ + else \ + obj->addermethod(*variantValue.Get()) ; \ } \ } ; -#define WX_COLLECTION_GETTER( property , gettermethod ) \ +#define WX_COLLECTION_GETTER( property, Klass, valueType , gettermethod ) \ class wxCollectionGetter##property : public wxCollectionGetter \ { \ public : \ wxCollectionGetter##property() : wxCollectionGetter( #gettermethod ) {} \ void Get( const wxObject *object , wxxVariantArray &result) const \ { \ - wxCollectionGetterFunc( object , result , &class_t::gettermethod ) ; \ + const Klass *obj = dynamic_cast(object) ; \ + wxCollectionToVariantArray( obj->gettermethod() , result ) ; \ } \ } ; @@ -819,29 +747,29 @@ private : #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \ - WX_SETTER( name , setter ) \ + WX_SETTER( name , class_t , type , setter ) \ static wxSetter##name _setter##name ; \ - WX_GETTER( name , getter ) \ + WX_GETTER( name , class_t , type , getter ) \ static wxGetter##name _getter##name ; \ static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \ static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \ - WX_GETTER( name , getter ) \ + WX_GETTER( name , class_t , type , getter ) \ static wxGetter##name _getter##name ; \ static wxPropertyAccessor _accessor##name( NULL , &_getter##name , NULL , NULL ) ; \ static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \ - WX_ADDER( name , adder ) \ + WX_ADDER( name , class_t , addelemtype , adder ) \ static wxAdder##name _adder##name ; \ - WX_COLLECTION_GETTER( name , getter ) \ + WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \ static wxCollectionGetter##name _collectionGetter##name ; \ static wxPropertyAccessor _accessor##name( NULL , NULL ,&_adder##name , &_collectionGetter##name ) ; \ static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ; #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \ - WX_COLLECTION_GETTER( name , getter ) \ + WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \ static wxCollectionGetter##name _collectionGetter##name ; \ static wxPropertyAccessor _accessor##name( NULL , NULL , NULL , &_collectionGetter##name ) ; \ static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ; @@ -1101,7 +1029,60 @@ struct wxConstructorBridge_6 : public wxConstructorBridge const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 } ; \ const int klass::sm_constructorPropertiesCount##klass = 6; +// 7 params +template +struct wxConstructorBridge_7 : public wxConstructorBridge +{ + void Create(wxObject *o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].Get() , + args[1].Get() , + args[2].Get() , + args[3].Get() , + args[4].Get() , + args[5].Get() , + args[6].Get() + ); + } +}; + +#define WX_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ + wxConstructorBridge_7 constructor##klass ; \ + wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ + const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6} ; \ + const int klass::sm_constructorPropertiesCount##klass = 7; + +// 8 params + +template +struct wxConstructorBridge_8 : public wxConstructorBridge +{ + void Create(wxObject *o, wxxVariant *args) + { + Class *obj = dynamic_cast(o); + obj->Create( + args[0].Get() , + args[1].Get() , + args[2].Get() , + args[3].Get() , + args[4].Get() , + args[5].Get() , + args[6].Get() , + args[7].Get() + ); + } +}; + +#define WX_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \ + wxConstructorBridge_8 constructor##klass ; \ + wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ + const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6 , #v7} ; \ + const int klass::sm_constructorPropertiesCount##klass = 8; // ---------------------------------------------------------------------------- // wxClassInfo // ----------------------------------------------------------------------------