IViewCreator Class Reference
[Version 4.0]
View creator interface.
More...
List of all members.
Public Types |
enum | AttrType {
kUnknownType,
kBooleanType,
kIntegerType,
kFloatType,
kStringType,
kColorType,
kFontType,
kBitmapType,
kPointType,
kRectType,
kTagType,
kListType
} |
Public Member Functions |
virtual | ~IViewCreator () |
virtual IdStringPtr | getViewName () const =0 |
virtual IdStringPtr | getBaseViewName () const =0 |
virtual CView * | create (const UIAttributes &attributes, IUIDescription *description) const =0 |
virtual bool | apply (CView *view, const UIAttributes &attributes, IUIDescription *description) const =0 |
virtual bool | getAttributeNames (std::list< std::string > &attributeNames) const =0 |
virtual AttrType | getAttributeType (const std::string &attributeName) const =0 |
virtual bool | getAttributeValue (CView *view, const std::string &attributeName, std::string &stringValue, IUIDescription *desc) const =0 |
virtual bool | getPossibleListValues (const std::string &attributeName, std::list< const std::string * > &values) const |
Detailed Description
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:
MyViewCreator () { UIViewFactory::registerViewCreator (*this); }
IdStringPtr getViewName () const { return "MyView"; }
IdStringPtr getBaseViewName () const { return "CView"; }
CView* create (const UIAttributes& attributes, IUIDescription* description) const { return new MyView (); }
bool apply (CView* view, const UIAttributes& attributes, 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;
}
bool getAttributeNames (std::list<std::string>& attributeNames) const
{
attributeNames.push_back ("my-custom-attribute");
return true;
}
AttrType getAttributeType (const std::string& attributeName) const
{
if (attributeName == "my-custom-attribute")
return kIntegerType;
return kUnknownType;
}
bool getAttributeValue (CView* view, const std::string& attributeName, std::string& stringValue, 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;
Member Enumeration Documentation
- Enumerator:
kUnknownType |
|
kBooleanType |
|
kIntegerType |
|
kFloatType |
|
kStringType |
|
kColorType |
|
kFontType |
|
kBitmapType |
|
kPointType |
|
kRectType |
|
kTagType |
|
kListType |
|
Constructor & Destructor Documentation
Member Function Documentation
virtual bool getAttributeNames |
( |
std::list< std::string > & |
attributeNames |
) |
const [pure virtual] |
virtual AttrType getAttributeType |
( |
const std::string & |
attributeName |
) |
const [pure virtual] |
virtual bool getAttributeValue |
( |
CView * |
view, |
|
|
const std::string & |
attributeName, |
|
|
std::string & |
stringValue, |
|
|
IUIDescription * |
desc | |
|
) |
| | const [pure virtual] |
virtual IdStringPtr getBaseViewName |
( |
|
) |
const [pure virtual] |
virtual bool getPossibleListValues |
( |
const std::string & |
attributeName, |
|
|
std::list< const std::string * > & |
values | |
|
) |
| | const [inline, virtual] |
virtual IdStringPtr getViewName |
( |
|
) |
const [pure virtual] |
The documentation for this class was generated from the following file: