V
Vincent RICHOMME
Hi,
My goal is to display in a graphical application properties of my
objects. To do that I am using on windows a graphical control (MFC)
called EPropCtrl with the following definition :
Pratically when I want to display/modify properties of a simple class
defined like this :
I just need to create a new class deriving from Simple Class AND from
IPropertyHost like this :
and after to update my control by doing :
EPropCtrl objPropCtrl; // Graphical window to display/edit propertis
SimpleProp simpleProp; //Objet SimpleProp
objPropCtrl.SetPropPointer( simpleProp.GetPropPointer() );
// --------------- SO FAR EVERYTHING IS OK --------------------------
Now let's consider two objects that wrapps C structures like this :
If I am doing the same as the simple example I would do somthing like :
class BProp: public B,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{
PropList.AddPropInt(this,_T("iSizeB"),&m_refStructB.iSizeB, false);
PropList.AddPropString(this,_T("szTextB"),&m_refStructB.szTextB, false);
}
IPropertyHost* GetPropPointer() { return this; }
};
class AProp: public A,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{
PropList.AddPropInt(this,_T("iSizeA"),&m__StructA.iSizeA, false);
PropList.AddPropString(this,_T("szTextA"),&m__StructA.szTextA, false);
m_B.GetProperties( PropList ); // <----- CANNOT WORK
}
IPropertyHost* GetPropPointer() { return this; }
};
EPropCtrl objPropCtrl;
AProp objAProp;
objPropCtrl.SetPropPointer( objAProp.GetPropPointer() );
// PROBLEM : I CANNOT call m_B.GetProperties( PropList ) to display B
properties from AProp since Aprop has only a B and not a BProp.
HOw should I change my objets to display my properties ??????????????
My goal is to display in a graphical application properties of my
objects. To do that I am using on windows a graphical control (MFC)
called EPropCtrl with the following definition :
Code:
class IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList ) {}
};
// EPropCtrl : Windows control (MFC) that looks like a ListBox
class EPropCtrl
{
public:
SetPropPointer( IPropertyHost* pHost);
};
Pratically when I want to display/modify properties of a simple class
defined like this :
Code:
class Simple
{
protected:
int iValue;
};
I just need to create a new class deriving from Simple Class AND from
IPropertyHost like this :
Code:
class SimpleProp : public Simple,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{
PropList.AddPropInt(this,_T("iValue"),&iValue, false);
}
IPropertyHost* GetPropPointer() { return this; }
protected:
int iValue;
};
EPropCtrl objPropCtrl; // Graphical window to display/edit propertis
SimpleProp simpleProp; //Objet SimpleProp
objPropCtrl.SetPropPointer( simpleProp.GetPropPointer() );
// --------------- SO FAR EVERYTHING IS OK --------------------------
Now let's consider two objects that wrapps C structures like this :
Code:
typedef struct tagStructB
{
int iSizeB;
char* szTextB;
} StructB;
typedef struct tagStructA
{
int iSizeA;
char* szTextA;
StructB sStructB;
} StructA;
class B
{
public:
B(structB& refStructB) { m_refStructB = refStructB ;}
int GetSize() {return m_StructB.iSizeB;}
char* GetText() {return m_StructB.szTextB;}
protected:
structB& m_refStructB;
};
class A
{
public:
A();
int GetSize() {return m_StructA.iSizeA;}
char* GetText() {return m_StructA.szTextA;}
B& GetB() { return m_B; }
protected:
structA m_StructA;
B m_B;
};
Example of use :
A m_a;
int iSizeA = m_A.GetSize();
m_A.GetB().GetSize();
If I am doing the same as the simple example I would do somthing like :
class BProp: public B,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{
PropList.AddPropInt(this,_T("iSizeB"),&m_refStructB.iSizeB, false);
PropList.AddPropString(this,_T("szTextB"),&m_refStructB.szTextB, false);
}
IPropertyHost* GetPropPointer() { return this; }
};
class AProp: public A,
public IPropertyHost
{
public:
virtual void GetProperties( EPropList& PropList )
{
PropList.AddPropInt(this,_T("iSizeA"),&m__StructA.iSizeA, false);
PropList.AddPropString(this,_T("szTextA"),&m__StructA.szTextA, false);
m_B.GetProperties( PropList ); // <----- CANNOT WORK
}
IPropertyHost* GetPropPointer() { return this; }
};
EPropCtrl objPropCtrl;
AProp objAProp;
objPropCtrl.SetPropPointer( objAProp.GetPropPointer() );
// PROBLEM : I CANNOT call m_B.GetProperties( PropList ) to display B
properties from AProp since Aprop has only a B and not a BProp.
HOw should I change my objets to display my properties ??????????????