Gadgets > Creating GUI Applications with Rogue Wave Views Studio > Extending Rogue Wave Views Studio > Extending Rogue Wave Views Studio Components > Defining a New Command
 
Defining a New Command
A command is an action that the user can perform using the editor. A command is a C++ class, IlvStCommand, which is described in the file <ivstudio/command.h>. It is defined by:
*A declaration that contains information to be displayed in a menu, an icon, or a help message and a list of message names to be sent when the command has been successfully executed. Predefined commands are declared in the command description file studio.cmd. For more information on this file, see the section “Rogue Wave Views Studio Command File” in the Rogue Wave Views Studio User’s Manual.
*An action that is defined in the virtual member function doIt. It returns 0 when no error occurs; otherwise it returns the corresponding error.
Command Errors
A Rogue Wave Views Studio error is a subclass of the IlvStError class, which is declared in the file <ivstudio/error.h>. An error can be returned by the doIt member function of a command. An error is defined by a string message and a type. There are three types of errors:
*IlvStInformation
*IlvStWarning
*IlvStFatal
To add a new command, do the following:
1. Define a subclass of IlvStCommand to define the virtual member function doIt.
2. Add a descriptor in a command declaration file or directly in an option file.
3. If you use a new command declaration file, declare it in your option file using the commandFile option.
4. Register the command in the editor using the member function registerCommand, giving the command name and a function to build an instance of the command.
Predefined Command Classes
There are two subclasses for common needs:
*IlvStClickAddObject to add a new object to the current buffer.
*IlvStShowPanel to display a panel on the screen. The construction of the instance uses the panel to be displayed. If the panel is already visible, this command just hides the panel.
Executing a Command
If the editor is requested to execute a command and it fails, the corresponding error is returned by the command execution procedure and is managed by the editor. If it succeeds, the list of messages associated with the command are sent by the editor. It means that the subscriptions attached to each message are executed.

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