VSTGUI 4.5 Graphical User Interface Framework not only for VST plugins

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | List of all members
IViewCreator Class Referenceabstract
Version 4.0

View creator interface. More...

Inheritance diagram for IViewCreator:

## Public Types
enum | AttrType { kUnknownType, kBooleanType, kIntegerType, kFloatType, kStringType, kColorType, kFontType, kBitmapType, kPointType, kRectType, kTagType, kListType, kGradientType }

## Public Member Functions
virtual | ~IViewCreator () noexcept=default
virtual IdStringPtr | getViewName () const =0
virtual IdStringPtr | getBaseViewName () const =0
virtual CView * | create (const UIAttributes &attributes, const IUIDescription *description) const =0
virtual bool | apply (CView *view, const UIAttributes &attributes, const 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, const IUIDescription *desc) const =0
virtual bool | getPossibleListValues (const std::string &attributeName, std::list< const std::string * > &values) const =0
virtual bool | getAttributeValueRange (const std::string &attributeName, double &minValue, double &maxValue) const =0
virtual UTF8StringPtr | getDisplayName () const =0

## 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 ViewCreatorAdapter
{
public:
// register this class with the view factory
MyViewCreator () { UIViewFactory::registerViewCreator (*this); }
// return an unique name here
IdStringPtr getViewName () const { return "MyView"; }
// return the name here from where your custom view inherites.
// Your view automatically supports the attributes from it.
IdStringPtr getBaseViewName () const { return "CView"; }
// create your view here.
// Note you don't need to apply attributes here as the apply method will be called with this new view
CView* create (const UIAttributes& attributes, const IUIDescription* description) const { return new MyView (); }
// apply custom attributes to your view
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;
}
// add your custom attributes to the list
bool getAttributeNames (std::list<std::string>& attributeNames) const
{
attributeNames.emplace_back ("my-custom-attribute");
return true;
}
// return the type of your custom attributes
AttrType getAttributeType (const std::string& attributeName) const
{
if (attributeName == "my-custom-attribute")
return kIntegerType;
return kUnknownType;
}
// return the string value of the custom attributes of the view
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;
}
};
// create a static instance so that it registers itself with the view factory
MyViewCreator __gMyViewCreator;

## Member Enumeration Documentation

enum AttrType

Enumerator
kUnknownType |
kBooleanType |
kIntegerType |
kFloatType |
kStringType |
kColorType |
kFontType |
kBitmapType |
kPointType |
kRectType |
kTagType |
kListType |
kGradientType |

## Constructor & Destructor Documentation

virtual ~IViewCreator | ( |  | ) |
| virtual default noexcept

## Member Function Documentation

virtual bool apply | ( | CView * | view,
|  | const UIAttributes & | attributes,
|  | const IUIDescription * | description
| ) |  | const
| pure virtual

Implemented in ViewCreatorAdapter.

virtual CView* create | ( | const UIAttributes & | attributes,
|  | const IUIDescription * | description
| ) |  | const
| pure virtual

virtual bool getAttributeNames | ( | std::list< std::string > & | attributeNames | ) | const
| pure virtual

Implemented in ViewCreatorAdapter.

virtual AttrType getAttributeType | ( | const std::string & | attributeName | ) | const
| pure virtual

Implemented in ViewCreatorAdapter.

virtual bool getAttributeValue | ( | CView * | view,
|  | const std::string & | attributeName,
|  | std::string & | stringValue,
|  | const IUIDescription * | desc
| ) |  | const
| pure virtual

Implemented in ViewCreatorAdapter.

virtual bool getAttributeValueRange | ( | const std::string & | attributeName,
|  | double & | minValue,
|  | double & | maxValue
| ) |  | const
| pure virtual

Implemented in ViewCreatorAdapter.

virtual IdStringPtr getBaseViewName | ( |  | ) | const
| pure virtual

virtual UTF8StringPtr getDisplayName | ( |  | ) | const
| pure virtual

Implemented in ViewCreatorAdapter.

virtual bool getPossibleListValues | ( | const std::string & | attributeName,
|  | std::list< const std::string * > & | values
| ) |  | const
| pure virtual

Implemented in ViewCreatorAdapter.

virtual IdStringPtr getViewName | ( |  | ) | const
| pure virtual

The documentation for this class was generated from the following file:

- iviewcreator.h