View creator interface.
You can register your own custom views with the UIViewFactory by inheriting from this interface and register it with UIViewFactory::registerViewCreator().
Example for an imaginary view class called MyView which directly inherites from CView:
class MyViewCreator : public IViewCreator
{
public:
CView*
create (
const UIAttributes& attributes,
const IUIDescription* description)
const {
return new MyView (); }
bool apply (CView* view,
const UIAttributes& attributes,
const IUIDescription* description)
const
{
MyView* myView = dynamic_cast<MyView*> (view);
if (myView == 0)
return false;
const std::string* attr = attributes.getAttributeValue ("my-custom-attribute");
if (attr)
{
int32_t value = (int32_t)strtol (attr->c_str (), 0, 10);
myView->setCustomAttribute (value);
}
return true;
}
{
attributeNames.push_back ("my-custom-attribute");
return true;
}
{
if (attributeName == "my-custom-attribute")
}
bool getAttributeValue (CView* view,
const std::string& attributeName, std::string& stringValue,
const IUIDescription* desc)
const
{
MyView* myView = dynamic_cast<MyView*> (view);
if (myView == 0)
return false;
if (attributeName == "my-custom-attribute")
{
std::stringstream stream;
stream << (int32_t)myView->getCustomAttribute ();
stringValue = stream.str ();
return true;
}
return false;
}
};
MyViewCreator __gMyViewCreator;