Defining Callbacks without Deriving Classes
In the previous section, we derived a panel class and defined the callback methods in the derived class. For SecondPanelClass, we will now insert its callback methods in the generated source file without deriving a subclass:
1. In the Panel Class palette, select SecondPanelClass and click the Panel Class Inspector icon in the Panel Class palette tool bar.
2. In the Panel Class inspector, go to the Options notebook page and turn off the Callback Definitions toggle button.
3. Open the Source notebook page and type the following code in the section “Code for the source file”:
#include <ilviews/gadgets/appli.h>
#include <myclass1.h>
void
SecondPanelClass::ComputeCB(IlvGraphic*)
{
IlvApplication* appli = IlvApplication::GetApplication(this);
MyFirstPanelClass* pan1 =
(MyFirstPanelClass*)appli->getPanel(“FirstPanel”);
MyFirstPanelClass* pan2 =
(MyFirstPanelClass*)appli->getPanel(“SecondPanel”);
getResult()->setValue(pan1->getValue() + pan2->getValue(), IlTrue);
}
void
SecondPanelClass::QuitCB(IlvGraphic*)
{
delete IlvApplication::GetApplication(this);
IlvExit(0);
}
4. Click Apply to validate the operation, and Close to quit the inspector.
5. In the Panel Class User Code panel, click Apply.
When generating again, Rogue Wave Views Studio inserts your two callback methods in the class2.cc file.
Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.