Creating GUI Applications with Rogue Wave Views Studio > Extending Rogue Wave Views Studio > Extending Rogue Wave Views Studio: An Example > Defining a New Panel
 
Defining a New Panel
Now you have to create a new panel to get the new property. Below are the steps to follow:
1. Create a panel using Rogue Wave® Views Studio with a line editor named file name and two buttons with the callbacks Apply and Cancel.
2. Describe a subclass of IlvStDialog to provide the constructor with the member functions Apply and Cancel.
3. Integrate the new panel into the editor.
Here is a header example:
#include <ivstudio/panel.h>
class MyPanelHandler
: public IlvStDialog {
public:
MyPanelHandler(IlvStudio* ed, const char* name,
IlvDialog* dlg = 0);
virtual void apply();
virtual void reset();
};
You provide:
*The constructor, which calls IlvStDialog constructor giving the data file you created. It initializes the panel and subscribes to the message ObjectSelected by the member function resetOnMessage. The callback passed to the subscription calls the reset member function for the panel.
*The virtual member function apply, which reads the file name object contents and associates it with the object property.
*The virtual member function reset, which initializes the file name object contents for the property of the currently selected object.
The following is a coding example:
#include <ivstudio/studio.h>
#include <mypan.h>
#include <myutil.h>
#define DATAFILE "../data/mypanel.ilv"
 
MyPanelHandler::MyPanelHandler(IlvStudio* ed, const char* name,
IlvDialog* dlg)
: IlvStDialog(ed, name, DATAFILE, IlvRect(0, 0, 254, 71))
{
IlvTextField* tf =
(IlvTextField*)getDialog()->getObject(“filename”);
tf->setLabel("", IlTrue);
resetOnMessage("ObjectSelected");
}
void
MyPanelHandler::apply()
{
IlvGraphic* obj = getEditor()->getSelection();
if (obj) {
const char* name =
((IlvTextField*)getDialog()->getObject(“filename”))->getLabel();
if (name && name[0]) {
MySetParameter(obj, IlvGetSymbol(name));
obj->setCallbackName(IlvGetSymbol(“loadilv”));
}
}
}
 
void
MyPanelHandler::reset()
{
IlvTextField* tf =
(IlvTextField*)getDialog()->getObject(“filename”);
IlvGraphic* obj = getEditor()->getSelection();
IlvSymbol* fi = 0;
if (obj)
fi = MyGetParameter(obj);
tf->setLabel(fi ? fi->name() : ““, IlTrue);
}
Once the panel class is created, it must be integrated into the editor. To do so:
1. Add the building of the panel to the editor initialization function.
2. Provide its description in the file mystudio.pnl.
The following is a coding example with a command to display the panel.
static IlvStCommand*
MkMyShowPanel(IlvStudio* editor)
{
return new IlvStShowPanel(editor->getPanel("MyPanel"));
}
 
IlBoolean
MyStudioExtension::initializePanels()
{
// ...
// Create MyPanel.
MyPanelHandler* pan = new MyPanelHandler(getEditor(), "MyPanel");
pan->connect();
// ...
return IlTrue;
}

Version 5.6
Copyright © 2012, Rogue Wave Software, Inc. All Rights Reserved.