Defining the Object Look-and-Feel Handler API
The object look-and-feel handler API depends on the component you are designing. As a general rule, you should provide a way to customize its look and its behavior. This can be done by adding the following methods to your object class:
class MyComponent : public IlvGadget { ... virtual void draw(IlvPort* dst, const IlvTransformer* t, const IlvRegion* clip) const; virtual IlBoolean handleEvent(IlvEvent& event) const; ...
}; |
You must also add these methods to the object look-and-feel handler class:
class MyComponentLFHandler : public IlvObjectLFHandler { MyComponentLFHandler(IlvLookFeelHandler* lfh) : IlvObjectLFHandler(MyComponent::ClassInfo(), lfh) {} ... virtual void draw(const MyComponent* object, IlvPort* dst, const IlvTransformer* t, const IlvRegion* clip) const = 0; virtual IlBoolean handleEvent(MyComponent* object, IlvEvent& event) const = 0; ... }; |
Note
|
The implementation of the MyComponent methods should be as follow:
void MyComponent::draw(IlvPort* dst, const IlvTransformer* t, const IlvRegion* clip) const { MyComponent* lfhandler = (MyComponentLFHandler*) getObjectLFHandler(MyComponent::ClassInfo()); lfhandler->draw(this, dst, t, clip); } |
and for the handleEvent method:
IlBoolean MyComponent::handleEvent(IlvEvent& event) { MyComponentLFHandler* lfhandler = (MyComponentLFHandler*) getObjectLFHandler(ClassInfo()); return lfhandler->handleEvent(this, event); } |
Of course, you can add other functionalities to your component, and make them look-and-feel dependant using the same scheme.