Gadgets > Rogue Wave Views Gadgets > Customizing the Look and Feel > Changing the Look and Feel of an Existing Component > Replacing an Object Look-and-Feel Handler
 
Replacing an Object Look-and-Feel Handler
Once you have defined the new object look-and-feel handler, you need to install it on an IlvLookFeelHandler instance.
The simplest way to install an object look-and-feel handler is to call the IlvLookFeelHandler::addObjectLFHandler method on the look-and-feel handler of the component:
IlvButton* button = ....
IlvLookFeelHandler* lfh = button->getLookFeelHandler();
MyButtonLFHandler* mylfh = new MyButtonLFHandler(lfh);
lfh->addObjectLFHandler(mylfh);
By modifying the look-and-feel handler this way will affect other buttons referencing the same look-and-feel handler. Indeed, by default, there is only one look-and-feel handler, owned by the IlvDisplay class. If you do not want to modify the default look-and-feel handler because you want to modify only the look and feel of specific components, you must do the following:
*Create a new look-and-feel handler instance using the IlvLookFeelHandler::Create method.
*Install your object look-and-feel handler using the IlvLookFeelHandler::addObjectLFHandler method.
*Install the new look-and-feel handler instance on your component using the setLookFeelHandler method.
The following code creates a new look-and-feel handler for the Motif look, and installs on it the object look-and-feel handler. Finally, the new look-and-feel handler is installed on the component:
IlvLookFeelHandler* lfh = IlvLookFeelHandler::Create(“motif”);
MyButtonLFHandler* mylfh = new MyButtonLFHandler(lfh);
lfh->addObjectLFHandler(mylfh);
IlvButton* button = ....
button->setLookFeelHandler(lfh);
Note: The first two steps can be executed through a single action by creating a subclass of the IlvLookFeelHandler. You can find more information in the section Creating a New Look-and-Feel Handler.

Version 6.0
Copyright © 2015, Rogue Wave Software, Inc. All Rights Reserved.