Gadgets > Creating GUI Applications with Rogue Wave Views Studio > Extending Rogue Wave Views Studio > Extending Rogue Wave Views Studio: An Example > Defining a New Buffer Class
 
Defining a New Buffer Class
Define a subclass MyGadgetBuffer from IlvStGadgetBuffer. Below is a header example:
class MyGadgetBuffer
: public IlvStGadgetBuffer {
public:
MyGadgetBuffer(IlvStudio*, const char* name, IlvManager* = 0);
virtual const char* getType () const;
virtual const char* getTypeLabel() const;
virtual void setUpPanelClass(IlvStPanelClass*) const;
};
You provide:
*The constructor, which calls the IlvStGadgetBuffer constructor. If the manager parameter is not yet created, it creates a MyManager instance.
*The virtual member function getType, which returns the class name MyGadgetBuffer.
*The virtual member function getTypeLabel, which returns the class name label. This label is used by Rogue Wave Views Studio to display the type of the buffer in the Main window. It may be different from the label returned by the getType member function that is used as the identifier of the buffer type.
*The virtual member function setUpPanelClass, which is called when a Rogue Wave Views Studio panel class is made for your buffer.
The MyGadgetBuffer class can be defined like this:
#include <ivstudio/studio.h>
#include <ivstudio/stdesc.h>
 
#include <mybuf.h>
#include <myman.h>
#include <mycont.h>
 
MyGadgetBuffer::MyGadgetBuffer(IlvStudio* editor,
const char* name,
IlvManager* mgr)
: IlvStGadgetBuffer(editor,
name,
mgr ? mgr : new MyManager(editor->getDisplay()))
{
}
 
const char*
MyGadgetBuffer::getType () const
{
return "MyGadgetBuffer";
}
 
const char*
MyGadgetBuffer::getTypeLabel () const
{
return "Mine";
}
 
void
MyGadgetBuffer::setUpPanelClass(IlvStPanelClass* pclass) const
{
IlvStGadgetBuffer::setUpPanelClass(pclass);
pclass->setBaseClass(“MyContainer”);
}
Once you have the new class, you have to integrate it into the editor; that is, tell the editor that the file saved with the new descriptor needs to be loaded in the new buffer type.
To do so, add a call to registerType in your initializeBuffers method of your extension class. The following is an example:
#include <mybuf.h>
 
static IlvStBuffer*
MakeMyBuffer(IlvStudio* editor, const char* name, const char*)
{
return new MyGadgetBuffer(editor, name);
}
 
IlBoolean
MyStudioExtension::initializeBuffers()
{
IlvStudio* editor = getEditor();
// ...
editor->buffers().registerType("MyGadgetManagerOutput",
MakeMyBuffer);
// ...
return IlTrue;
}

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.