I have many objects which contain different properties.
I'm trying to create a properties' editor dialog where I can pass the properties as a template and then, based on the template, construct different dialog panels for representing that specific object properties.
Unfortunately, mixing the virtual functions and templates is not supported.
How can I pass the object properties and then return modified set back in order to modify the object visual representation?
One solution could be to send the object ID and construct the panels based on it with a long switch statement. But it seems ugly.
To make it more complicated, the dialog that will show with the properties and the objects are in different libraries. I'm trying to separate the code and break the linkage whenever possible.
class A
{
private:
std::string name, tag;
font labelFont, textFont;
};
class B
{
private:
std::string name, tag;
color labelColor, textColor;
};
typedef template<type T> int CallDialog(window *parent, T &options, int objectType);
int CallDialog()
{
MyDoalog dlg( parent, options, objectType );
if( dlg.OK() )
{
if( objectType == 1 )
{
options.labelFont = dlg.GetLaelFont()
options.textFnt = dlg.GetTextFont();
}
}
}
The function CallDialog() is in a different DLL (will be written by me), and I'm trying to avoid making multiple CallDialog()s passing all those properties depending on the object type.
AandBand those two UI pieces? To what extent doAandBexpected to cooperate with this machinery? If nothing else, it's impossible to set private members of the class purely from outside, without some help from the class itself. CouldAandBprovide some kind ofSaveToOptionsandPopulateFromOptionsmethods?