Framework for a Radiant plugin's main menu. More...
#include <GenericMainMenu.h>
Classes | |
class | CommandCallbackMethod |
An instance of this class can be used as a GenericMainMenu::CommandCallback, in situations where the callback is a method to be invoked on a target object. More... |
Public Member Functions | |
Service the plugin interface | |
virtual void | Dispatch (const char *command) |
Invoke the handler for the given command token. | |
virtual void | CommandDialogShow (const std::string &commandString) |
Handle a command that summons a dialog window. | |
const std::string & | GetCommandList () const |
Get the command list for the plugin menu, as a semicolon-separated string of tokens representing each command. | |
const std::string & | GetCommandLabelList () const |
Get the command label list for the plugin menu, as a semicolon-separated string of labels to appear in the menu. | |
Public Member Functions inherited from RefCounted | |
RefCounted () | |
Default constructor. | |
virtual | ~RefCounted () |
Virtual destructor. | |
void | IncRef () |
Increment reference count. | |
void | DecRef () |
Decrement reference count, and self-delete if count is <= 0. |
Protected Types | |
typedef Callback1< const std::string &, void > | CommandCallback |
Function signature for a menu command callback. |
Protected Member Functions | |
Lifecycle | |
GenericMainMenu () | |
Default constructor. | |
virtual | ~GenericMainMenu () |
Virtual destructor. | |
Command list construction | |
virtual void | BeginEntries () |
Invoked before beginning construction of the command list (by subsequent Add* invocations). | |
virtual void | AddSeparator () |
Append a command-group separator to the command list. | |
virtual std::string | AddEntry (const char *commandLabel, const char *command, const CommandCallback &commandCallback) |
Append a command to the command list that will trigger a callback function when the menu entry is selected. | |
virtual void | AddDialogShowEntry (const char *commandLabel, const char *command, const SmartPointer< GenericDialog > &dialog) |
Append a command to the command list that will summon a dialog when the menu entry is selected. | |
virtual void | EndEntries () |
Invoked after ending construction of the command list. |
Private Types | |
typedef std::map< std::string, SmartPointer< GenericDialog > > | DialogMap |
Type for a map between string and reference-counted dialog window. |
Private Member Functions | |
Unimplemented to prevent copy/assignment | |
GenericMainMenu (const GenericMainMenu &) | |
const GenericMainMenu & | operator= (const GenericMainMenu &) |
Private Attributes | |
std::string | _menuCommands |
Semicolon-separated string of command tokens. | |
std::string | _menuCommandLabels |
Semicolon-separated string of command labels. | |
std::map< std::string, CommandCallback > | _dispatchMap |
Associations between command tokens and callbacks. | |
DialogMap | _dialogMap |
Associations between command tokens and dialog windows. |
Framework for a Radiant plugin's main menu.
This object handles the menu logic: what commands exist and how to execute them. The actual menu display is handled by Radiant.
A subclass should handle creating the command list.
|
protected |
Function signature for a menu command callback.
The callback takes a string argument (the command token); it has no return value.
|
protected |
Default constructor.
Note that as this is a protected method, GenericMainMenu objects cannot be created directly; only subclasses of GenericMainMenu can be created.
|
protectedvirtual |
Append a command to the command list that will summon a dialog when the menu entry is selected.
Invoking AddDialogShowEntry should be done between an invocation of BeginEntries and EndEntries.
commandLabel | The command label. |
command | The command token, unique for this plugin. Emptystring is interpreted as: re-use the label for the token. |
dialog | The dialog this command should summon. |
|
protectedvirtual |
Append a command to the command list that will trigger a callback function when the menu entry is selected.
Invoking AddEntry should be done between an invocation of BeginEntries and EndEntries.
commandLabel | The command label. |
command | The command token, unique for this plugin. Emptystring is interpreted as: re-use the label for the token. |
commandCallback | The command callback function. |
|
protectedvirtual |
Append a command-group separator to the command list.
This should be done between an invocation of BeginEntries and EndEntries. (And presumably in the neighborhood of invocations of AddEntry and/or AddDialogShowEntry.)
|
protectedvirtual |
Invoked before beginning construction of the command list (by subsequent Add* invocations).
In this base class, BeginEntries does nothing.
|
virtual |
Handle a command that summons a dialog window.
commandString | The command token. |
|
virtual |
Invoke the handler for the given command token.
command | The command token. |
|
protectedvirtual |
Invoked after ending construction of the command list.
In this base class, EndEntries only removes spurious semicolons left behind by the way we constructed the lists.
const std::string & GenericMainMenu::GetCommandLabelList | ( | ) | const |
Get the command label list for the plugin menu, as a semicolon-separated string of labels to appear in the menu.
const std::string & GenericMainMenu::GetCommandList | ( | ) | const |
Get the command list for the plugin menu, as a semicolon-separated string of tokens representing each command.