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

Framework for a manager of a command menu and dialog windows. More...

#include <GenericPluginUI.h>

Inheritance diagram for GenericPluginUI:
PluginUI

List of all members.

Classes

class  DialogEventCallbackMethod
 An instance of this class can be used as a GenericPluginUI::DialogEventCallback, in situations where the callback is a method to be invoked on a target object. More...
class  DialogSignalCallbackMethod
 An instance of this class can be used as a GenericPluginUI::DialogSignalCallback, in situations where the callback is a method to be invoked on a target object. More...

Public Types

typedef Callback3< GtkWidget
*, GdkEvent *, gpointer, gint > 
DialogEventCallback
 Type for GTK+ event callbacks.
typedef Callback2< GtkWidget
*, gpointer, void > 
DialogSignalCallback
 Type for GTK+ signal callbacks.

Public Member Functions

Setup
void RegisterMainMenu (SmartPointer< GenericMainMenu > &mainMenu)
 Register the command menu.
void RegisterDialog (SmartPointer< GenericDialog > &dialog)
 Register a dialog window.
void SetWindow (GtkWidget *window)
 Specify the main application window.
Lookup
GenericMainMenuMainMenu ()
 Get the command menu.
GenericDialogDialog (const std::string &key)
 Get the dialog identified by the specified key.
Widget dependence
void RegisterWidgetDependence (GtkWidget *controller, GtkWidget *controllee)
 Declare that the controllee widget should be active only when the controller widget is active.
void RegisterWidgetAntiDependence (GtkWidget *controller, GtkWidget *controllee)
 Declare that the controllee widget should be active only when the controller widget is inactive.
void WidgetControlCallback (GtkWidget *widget, gpointer callbackID)
 Manage the state of controllee widgets when a controller widget is clicked.

Static Public Member Functions

Message popups
static void ErrorReportDialog (const char *title, const char *message)
 Generate an error dialog.
static void WarningReportDialog (const char *title, const char *message)
 Generate a warning dialog.
static void InfoReportDialog (const char *title, const char *message)
 Generate an info dialog.

Protected Member Functions

Lifecycle
 GenericPluginUI ()
 Default constructor.
virtual ~GenericPluginUI ()
 Virtual destructor.

Private Types

typedef std::map< std::string,
SmartPointer< GenericDialog > > 
DialogMap
 Type for a map between string and reference-counted dialog window.
typedef std::map< gpointer,
DialogEventCallback
DialogEventCallbackMap
 Type for a map between gpointer (for callback ID) and event callback.
typedef std::map< gpointer,
DialogSignalCallback
DialogSignalCallbackMap
 Type for a map between gpointer (for callback ID) and signal callback.
typedef std::map< GtkWidget
*, std::vector< GtkWidget * > > 
WidgetDependenceMap
 Type for a map between a widget and a vector of widgets.

Private Member Functions

Unimplemented to prevent copy/assignment
 GenericPluginUI (const GenericPluginUI &)
const GenericPluginUIoperator= (const GenericPluginUI &)

Private Attributes

GtkWidget * _window
 The parent window.
SmartPointer< GenericMainMenu > * _mainMenu
 Reference-counted handle on the main menu object.
unsigned _callbackID
 Next ID to use when registering an event or signal callback.
const
DialogSignalCallbackMethod
< GenericPluginUI,&GenericPluginUI::WidgetControlCallback
_widgetControlCallback
 Callback to implement widget-active dependences.
DialogMap _dialogMap
 Associations between keys and dialog windows.
DialogEventCallbackMap _dialogEventCallbackMap
 Associations between callback IDs and event callbacks.
DialogSignalCallbackMap _dialogSignalCallbackMap
 Associations between callback IDs and signal callbacks.
WidgetDependenceMap _widgetControlMap
 Associations between controller and controllee widgets for all dependences and anti-dependences.
WidgetDependenceMap _widgetControlledByMap
 Associations between controller and controllee widgets for dependences only.
WidgetDependenceMap _widgetAntiControlledByMap
 Associations between controller and controllee widgets for anti- dependences only.

Related Functions

(Note that these are not member functions.)

GenericPluginUIUIInstance ()
 Get the singleton instance of the UI manager.

Event/signal dispatch

gpointer RegisterDialogEventCallback (GtkWidget *widget, const gchar *name, const DialogEventCallback &callback)
 Register a function to be invoked when a widget generates an event.
gpointer RegisterDialogSignalCallback (GtkWidget *widget, const gchar *name, const DialogSignalCallback &callback)
 Register a function to be invoked when a widget generates a signal.
static gint DialogEventCallbackDispatch (GtkWidget *widget, GdkEvent *event, gpointer data)
 Generic event callback used to invoke the specific callback functions registered with this manager.
static void DialogSignalCallbackDispatch (GtkWidget *widget, gpointer data)
 Generic signal callback used to invoke the specific callback functions registered with this manager.

Detailed Description

Framework for a manager of a command menu and dialog windows.

It is responsible for:

  • holding a reference on those objects for lifecycle management
  • providing lookup facilities for those objects
  • mapping GTK+ event/signal callbacks into method invocations on the dialog objects
  • providing automatic handling of widgets that should be active or inactive based on the active state of other widgets
  • providing utility functions for generating message popups

A subclass should handle the creation and registration of the UI objects.


Member Typedef Documentation

typedef Callback3<GtkWidget *, GdkEvent *, gpointer, gint> GenericPluginUI::DialogEventCallback

Type for GTK+ event callbacks.

The callback takes a GtkWidget* argument (widget generating the event), a GdkEvent* argument (the event), and a gpointer argument (the callback ID); it returns gint (success as TRUE or FALSE).

typedef Callback2<GtkWidget *, gpointer, void> GenericPluginUI::DialogSignalCallback

Type for GTK+ signal callbacks.

The callback takes a GtkWidget* argument (widget generating the signal) and a gpointer argument (the callback data); it has no return value.


Constructor & Destructor Documentation

GenericPluginUI::GenericPluginUI ( )
protected

Default constructor.

Initialize object state; the initial callback ID to use is 1 because 0 is reserved for "invalid". Note that as this is a protected method, GenericPluginUI objects cannot be created directly; only subclasses of GenericPluginUI can be created.

GenericPluginUI::~GenericPluginUI ( )
protectedvirtual

Virtual destructor.

Remove references to UI elements (which should trigger garbage collection).


Member Function Documentation

GenericDialog * GenericPluginUI::Dialog ( const std::string &  key)

Get the dialog identified by the specified key.

Parameters:
keyThe key.
Returns:
The dialog, or NULL if none found for that key.
gint GenericPluginUI::DialogEventCallbackDispatch ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  data 
)
static

Generic event callback used to invoke the specific callback functions registered with this manager.

Those specific callbacks are not themselves registered directly with GTK+ because they may be methods that must be invoked on objects. (Unlike this function, which is a static method.)

Parameters:
widgetThe widget generating the event.
eventThe event.
dataID of the specific callback registered with this manager.
Returns:
The return value from the specific callback.
void GenericPluginUI::DialogSignalCallbackDispatch ( GtkWidget *  widget,
gpointer  data 
)
static

Generic signal callback used to invoke the specific callback functions registered with this manager.

Those specific callbacks are not themselves registered directly with GTK+ because they may be methods that must be invoked on objects. (Unlike this function, which is a static method.)

Parameters:
widgetThe widget generating the signal.
dataID of the specific callback registered with this manager.
void GenericPluginUI::ErrorReportDialog ( const char *  title,
const char *  message 
)
static

Generate an error dialog.

Parameters:
titleThe dialog title.
messageThe error message.
void GenericPluginUI::InfoReportDialog ( const char *  title,
const char *  message 
)
static

Generate an info dialog.

Parameters:
titleThe dialog title.
messageThe info message.
GenericMainMenu * GenericPluginUI::MainMenu ( )

Get the command menu.

Returns:
The command menu, or NULL if none has been registered.
void GenericPluginUI::RegisterDialog ( SmartPointer< GenericDialog > &  dialog)

Register a dialog window.

Parameters:
dialogThe dialog.
gpointer GenericPluginUI::RegisterDialogEventCallback ( GtkWidget *  widget,
const gchar *  name,
const DialogEventCallback callback 
)

Register a function to be invoked when a widget generates an event.

Parameters:
widgetThe widget generating the event.
nameThe name of the event.
callbackThe callback function.
Returns:
The unique ID for the registered callback function.
gpointer GenericPluginUI::RegisterDialogSignalCallback ( GtkWidget *  widget,
const gchar *  name,
const DialogSignalCallback callback 
)

Register a function to be invoked when a widget generates a signal.

Parameters:
widgetThe widget generating the signal.
nameThe name of the signal.
callbackThe callback function.
Returns:
The unique ID for the registered callback function.
void GenericPluginUI::RegisterMainMenu ( SmartPointer< GenericMainMenu > &  mainMenu)

Register the command menu.

Parameters:
mainMenuThe command menu.
void GenericPluginUI::RegisterWidgetAntiDependence ( GtkWidget *  controller,
GtkWidget *  controllee 
)

Declare that the controllee widget should be active only when the controller widget is inactive.

Parameters:
controllerThe controller widget.
controlleeThe controllee widget.
void GenericPluginUI::RegisterWidgetDependence ( GtkWidget *  controller,
GtkWidget *  controllee 
)

Declare that the controllee widget should be active only when the controller widget is active.

Parameters:
controllerThe controller widget.
controlleeThe controllee widget.
void GenericPluginUI::SetWindow ( GtkWidget *  window)

Specify the main application window.

Parameters:
windowThe main window.
void GenericPluginUI::WarningReportDialog ( const char *  title,
const char *  message 
)
static

Generate a warning dialog.

Parameters:
titleThe dialog title.
messageThe warning message.
void GenericPluginUI::WidgetControlCallback ( GtkWidget *  widget,
gpointer  callbackID 
)

Manage the state of controllee widgets when a controller widget is clicked.

Parameters:
widgetThe controller widget.
callbackIDUnique numerical ID for the callback.

Friends And Related Function Documentation

GenericPluginUI & UIInstance ( )
related

Get the singleton instance of the UI manager.

Returns:
Reference to a singleton that implements GenericPluginUI.

Member Data Documentation

unsigned GenericPluginUI::_callbackID
private

Next ID to use when registering an event or signal callback.

Starts at 1; 0 is reserved to mean invalid.


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