MeshTex  3.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
GenericMainMenu Class Reference

Framework for a Radiant plugin's main menu. More...

#include <GenericMainMenu.h>

Inheritance diagram for GenericMainMenu:
RefCounted MainMenu

List of all members.

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 GenericMainMenuoperator= (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.

Detailed Description

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.


Member Typedef Documentation

typedef Callback1<const std::string&, void> GenericMainMenu::CommandCallback
protected

Function signature for a menu command callback.

The callback takes a string argument (the command token); it has no return value.


Constructor & Destructor Documentation

GenericMainMenu::GenericMainMenu ( )
protected

Default constructor.

Note that as this is a protected method, GenericMainMenu objects cannot be created directly; only subclasses of GenericMainMenu can be created.


Member Function Documentation

void GenericMainMenu::AddDialogShowEntry ( const char *  commandLabel,
const char *  command,
const SmartPointer< GenericDialog > &  dialog 
)
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.

Parameters:
commandLabelThe command label.
commandThe command token, unique for this plugin. Emptystring is interpreted as: re-use the label for the token.
dialogThe dialog this command should summon.
std::string GenericMainMenu::AddEntry ( const char *  commandLabel,
const char *  command,
const CommandCallback commandCallback 
)
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.

Parameters:
commandLabelThe command label.
commandThe command token, unique for this plugin. Emptystring is interpreted as: re-use the label for the token.
commandCallbackThe command callback function.
Returns:
The globally-unique command token: plugin name + "." + command.
void GenericMainMenu::AddSeparator ( )
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.)

void GenericMainMenu::BeginEntries ( )
protectedvirtual

Invoked before beginning construction of the command list (by subsequent Add* invocations).

In this base class, BeginEntries does nothing.

void GenericMainMenu::CommandDialogShow ( const std::string &  commandString)
virtual

Handle a command that summons a dialog window.

Parameters:
commandStringThe command token.
void GenericMainMenu::Dispatch ( const char *  command)
virtual

Invoke the handler for the given command token.

Parameters:
commandThe command token.
void GenericMainMenu::EndEntries ( )
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.

Returns:
The command label list string.
const std::string & GenericMainMenu::GetCommandList ( ) const

Get the command list for the plugin menu, as a semicolon-separated string of tokens representing each command.

Returns:
The command list string.

The documentation for this class was generated from the following files: