]> git.saurik.com Git - wxWidgets.git/commitdiff
RTTI extensions
authorStefan Csomor <csomor@advancedconcepts.ch>
Tue, 19 Aug 2003 16:48:06 +0000 (16:48 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Tue, 19 Aug 2003 16:48:06 +0000 (16:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23025 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/combobox.h
include/wx/msw/listbox.h
include/wx/msw/scrolbar.h
include/wx/slider.h
include/wx/window.h
include/wx/xti.h

index a369165d75fae3812109200127966ad3b8febd31..a03308299197c329cc68fbf2d66c4ee26e196980 100644 (file)
@@ -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);
 
index ad18e8530ee97fef31327869a9852c473c9d28e1..a994417d49b4ced71c1947458fbc2cfc90f07489 100644 (file)
@@ -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;
 
index 701c61e35c7930d116e83a523bc2d5f1bc41a3cb..6cae25208da310dd15e84cbd45bc3b0986c1c038 100644 (file)
@@ -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);
index 09cd35c8b5df76d4928d2511679e987f636ed823..31fbe554bc7cc2ad95d0ae01c0e8e36f70aa5ca7 100644 (file)
@@ -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
index 2c266712cc3a3413d8909302b19f2ab124f73130..0917bae9443d400ce3316469ea759eb6bc0104da 100644 (file)
@@ -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);
index 4168b6a640891b5be51883d24d8e7157bfe40bca..4a82a413be782f3e13f9bd923fcc7a99e26dec1a 100644 (file)
@@ -538,130 +538,58 @@ private :
 } ;
 
 
-template <class Klass, typename valueType, typename retType> void wxSetterFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*setter)( valueType ) )
-{
-    Klass *obj = dynamic_cast<Klass*>(object);
-    if ( variantValue.HasData<valueType>() )
-        (obj->*(setter))(variantValue.Get<valueType>()) ;
-    else
-        (obj->*(setter))(*variantValue.Get<valueType*>()) ;
-}
-
-template <class Klass, typename valueType, typename retType> void wxSetterFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*setter)( valueType& ) )
-{
-    Klass *obj = dynamic_cast<Klass*>(object);
-    if ( variantValue.HasData<valueType>() )
-        (obj->*(setter))(variantValue.Get<valueType>()) ;
-    else
-        (obj->*(setter))(*variantValue.Get<valueType*>()) ;
-}
-
-template <class Klass, typename valueType, typename retType> void wxSetterFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*setter)( const valueType& ) )
-{
-    Klass *obj = dynamic_cast<Klass*>(object);
-    if ( variantValue.HasData<valueType>() )
-        (obj->*(setter))(variantValue.Get<valueType>()) ;
-    else
-        (obj->*(setter))(*variantValue.Get<valueType*>()) ;
-}
-
-template <class Klass, typename valueType, typename retType> void wxAdderFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*adder)( valueType ) )
-{
-    Klass *obj = dynamic_cast<Klass*>(object);
-    (obj->*(adder))(variantValue.Get<valueType>()) ;
-}
-
-template <class Klass, typename valueType, typename retType> void wxAdderFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*adder)( valueType& ) )
-{
-    Klass *obj = dynamic_cast<Klass*>(object);
-    (obj->*(adder))(variantValue.Get<valueType>()) ;
-}
-
-template <class Klass, typename valueType, typename retType> void wxAdderFunc( wxObject *object , const wxxVariant &variantValue , retType(Klass::*adder)( const valueType& ) )
-{
-    Klass *obj = dynamic_cast<Klass*>(object);
-    (obj->*(adder))(variantValue.Get<valueType>()) ;
-}
-
-/*
-template <class Klass, typename valueType> void wxxGetterFunc( const wxObject *object , wxxVariant &result, valueType& (Klass::*getter)() const )
-{
-    const Klass *obj = dynamic_cast<const Klass*>(object);
-    result = wxxVariant((obj->*(getter))()) ;
-}
-*/
-
-template <class Klass, typename valueType> void wxGetterFunc( const wxObject *object , wxxVariant &result, valueType(Klass::*getter)() const )
-{
-    const Klass *obj = dynamic_cast<const Klass*>(object);
-    result = wxxVariant((obj->*(getter))()) ;
-}
-
-template <class Klass, typename valueType> void wxGetterFunc( const wxObject *object , wxxVariant &result, const valueType&(Klass::*getter)() const)
-{
-    const Klass *obj = dynamic_cast<const Klass*>(object);
-    result = wxxVariant((obj->*(getter))()) ;
-}
 
-template <class Klass, typename valueType> void wxCollectionGetterFunc( const wxObject *object , wxxVariantArray &result, valueType& (Klass::*getter)() const )
-{
-    const Klass *obj = dynamic_cast<const Klass*>(object);
-    wxCollectionToVariantArray( (obj->*(getter))() , result ) ;
-}
-
-template <class Klass, typename valueType> void wxCollectionGetterFunc( const wxObject *object , wxxVariantArray &result, valueType(Klass::*getter)() const )
-{
-    const Klass *obj = dynamic_cast<const Klass*>(object);
-    wxCollectionToVariantArray( (obj->*(getter))() , result ) ;
-}
-
-template <class Klass, typename valueType> void wxCollectionGetterFunc( const wxObject *object , wxxVariantArray &result, const valueType&(Klass::*getter)() const)
-{
-    const Klass *obj = dynamic_cast<const Klass*>(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<Klass*>(object) ;  \
+            if ( variantValue.HasData<valueType>() ) \
+                obj->setterMethod(variantValue.Get<valueType>()) ; \
+            else \
+                obj->setterMethod(*variantValue.Get<valueType*>()) ; \
         } \
     } ;
 
-#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<const Klass*>(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<Klass*>(object) ;  \
+            if ( variantValue.HasData<valueType>() ) \
+                obj->addermethod(variantValue.Get<valueType>()) ; \
+            else \
+                obj->addermethod(*variantValue.Get<valueType*>()) ; \
         } \
     } ;
 
-#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<const Klass*>(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<typename Class,
+         typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
+struct wxConstructorBridge_7 : public wxConstructorBridge
+{
+    void Create(wxObject *o, wxxVariant *args)
+    {
+        Class *obj = dynamic_cast<Class*>(o);
+        obj->Create(
+                    args[0].Get<T0>() ,
+                    args[1].Get<T1>() ,
+                    args[2].Get<T2>() ,
+                    args[3].Get<T3>() ,
+                    args[4].Get<T4>() ,
+                    args[5].Get<T5>() ,
+                    args[6].Get<T6>()
+                  );
+    }
+};
+
+#define WX_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
+       wxConstructorBridge_7<klass,t0,t1,t2,t3,t4,t5,t6> 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<typename Class,
+         typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
+struct wxConstructorBridge_8 : public wxConstructorBridge
+{
+    void Create(wxObject *o, wxxVariant *args)
+    {
+        Class *obj = dynamic_cast<Class*>(o);
+        obj->Create(
+                    args[0].Get<T0>() ,
+                    args[1].Get<T1>() ,
+                    args[2].Get<T2>() ,
+                    args[3].Get<T3>() ,
+                    args[4].Get<T4>() ,
+                    args[5].Get<T5>() ,
+                    args[6].Get<T6>() ,
+                    args[7].Get<T7>()
+                  );
+    }
+};
+
+#define WX_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
+       wxConstructorBridge_8<klass,t0,t1,t2,t3,t4,t5,t6,t7> 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
 // ----------------------------------------------------------------------------