Defining a New Buffer
A buffer is a document that is edited in Rogue Wave® Views Studio. It uses an
IlvManager to display, edit, save, and read its contents. If you need to subclass the manager to save more information concerning your objects, for example, you have to subclass a corresponding buffer. The
IlvStBuffer class is defined to encapsulate the
IlvManager, and the
IlvStGadgetBuffer class is defined to encapsulate an
IlvGadgetManager. These classes are declared in the file
<ivstudio/stbuffer.h> and
<ivstudio/gadgets/gadbuf.h>. If you need to define a specialized manager class to edit and save your graphic objects, you have to define a corresponding buffer class.
Registering Buffer Types
When loading a
.ilv file, Rogue Wave Views Studio first reads the file
creator class information to determine the type of the buffer that must be created for editing this file. For example, when reading a file saved by an
IlvGadgetManager, Rogue Wave Views Studio sees that the creator class of that
.ilv file is
IlvGadgetManagerOutputFile and then creates an
IlvStGadgetBuffer. This is made possible by the
registerType function that allows you to associate a buffer constructor function with a file creator class. Use this function to register your own buffer types. Rogue Wave Views Studio uses an
IlvStBuffers object to manage all the buffers. You can obtain a reference to this object by calling the
buffers function:
static IlvStBuffer*
MakeMyBuffer(IlvStudio* editor, const char* name, const char*)
{
// MyGadgetBuffer is a subtype of IlvStBuffer.
return new MyGadgetBuffer(editor, name);
}
...
editor->buffers().registerType("MyGadgetManagerOutput",
MakeMyBuffer);
...
Panel Classes
An
IlvStPanelClass object is a Rogue Wave Views Studio object that describes the C++ panel class you wish to generate for a buffer. It contains all the information that Rogue Wave Views Studio requires to generate a subclass of
IlvContainer using the data edited in your buffer.
An
IlvStPanelClass object contains the class name, the base class, the base name of the file, the directories where the files are generated, and so on. Some of its properties are related to the type of the corresponding buffer, for example, the base class: a Gadgets buffer (
IlvStGadgetBuffer) is used to generate a subclass of
IlvGadgetContainer, while a 2D buffer (
IlvStBuffer) is used to generate a subclass of
IlvContainer.
Let us suppose that you have defined the class
MyContainer, a subclass of
IlvGadgetContainer that can read additional information saved by your manager. You will then want the generated class to derive from
MyContainer. You may specify the base class in the Panel Class inspector each time you create a panel class using your buffer, but the best way is to automatically set up the panel class so its base class defaults to
MyContainer.
You can do this by defining the setUpPanelClass virtual member function for your buffer. This function is called when Rogue Wave Views Studio creates a panel class from your buffer.
void
MyBuffer::setUpPanelClass(IlvStPanelClass* pclass) const
{
IlvStGadgetBuffer::setUpPanelClass(pclass);
pclass->setBaseClass("MyContainer");
}
Integrating Customized Container Classes
In many situations, Rogue Wave Views Studio creates instances of containers. For example, when you test a panel or add it to the Application buffer window. To select the appropriate classes Rogue Wave Views Studio uses a set of container information objects. An
IlvStContainerInfo object provides the information that Rogue Wave Views Studio needs about a container subclass, and creates instances of that subclass.
To integrate a class of containers, you have to define a subclass of
IlvStContainerInfo and add an instance of this class to the Rogue Wave Views Studio container information set as follows:
studio->addContainerInfo(myContainerInfo);
Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.