class MyComponent : public IlvGadget { ... virtual void draw(IlvPort* dst, const IlvTransformer* t, const IlvRegion* clip) const; virtual IlBoolean handleEvent(IlvEvent& event) const; ... }; |
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; ... }; |
Notes: 1. Since object look-and-feel handlers are shared objects, you need to give access to MyComponent instance in each method of the object look-and-feel handler class. You can do this by using the first parameter of the methods. 2. The constructor of MyComponentLFHandler uses the MyComponent::ClassInfo method to link this object handler with MyComponent class. Thus, each subclass of MyComponentLFHandler will be dedicated to MyComponent component. |
void MyComponent::draw(IlvPort* dst, const IlvTransformer* t, const IlvRegion* clip) const { MyComponent* lfhandler = (MyComponentLFHandler*) getObjectLFHandler(MyComponent::ClassInfo()); lfhandler->draw(this, dst, t, clip); } |
IlBoolean MyComponent::handleEvent(IlvEvent& event) { MyComponentLFHandler* lfhandler = (MyComponentLFHandler*) getObjectLFHandler(ClassInfo()); return lfhandler->handleEvent(this, event); } |