dbremner / winx

Automatically exported from code.google.com/p/winx
0 stars 0 forks source link

limitations of WINX virtual property #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
template <class T>
class CWindow
{
    WINX_THISCLASS(T);
public: 
    typedef std::string string;

    string m_strText;
public:
    DEFINE_PROPERTY(string, Text, get_Text, put_Text);
public:
    void put_Text(const std::string& value) {
        m_strText = value;
    }
    std::string get_Text() const {
        return m_strText;
    }
};

class CButton : public CWindow<CButton>
{
public:
    std::string get_Text() const {
        return "Button";
    }
}

在这个例子中使用模板完成属性的静多态机制。那么WINX_THISCL
ASS这个宏的名字看起来不是很合适,建
议改为WINX_PROPIMPLCLASS或更为贴切的名字。

Original issue reported on code.google.com by xushiweizh on 25 Feb 2008 at 12:56

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
关于1.成员变量的访问,可以做如下处理
#define _WINX_PROPERTY_READ(Type, Var, get)                 
    inline operator Type() const                                
    {                                   
        ThisClass* pThis = parent_class_ptr(ThisClass, Var);        
        return pThis->get();                        
    }                                   
    inline const Type * operator ->() const                         
    {                                   
        ThisClass* pThis = parent_class_ptr(ThisClass, Var);        
        return & pThis->get();                      
    }                                   
    _WINX_PROPERTY_BOOLOP(Type, Var)
如果这样定义的话,可以通过foo.rect->left 
的方式来访问rect结构的成员变量和成员函数

Original comment by Visua...@gmail.com on 25 Feb 2008 at 6:10