Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ONE::gui::GuiManager Class Reference

Inheritance diagram for ONE::gui::GuiManager:

Inheritance graph
[legend]
List of all members.

Detailed Description

the main gui management interface

It provides access to the event dispatching and the focus subsystems as well as other management facilities.
The preferred way of changing the appearance and handling of GUI components is by implementing the LookAndFeel and UIDelegate interfaces and installing the LaF via the GuiManager::setLookAndFeel() function. However, properties, delegates and suchlike may also be changed manually by calling the provided setDelegate(), setProperty() etc. These may be used to specify settings for individual gui components or for all components of the specified type.

Author:
Daniel Seibert


Public Types

typedef DelegateID ID
 component type id
typedef unsigned int Key
 property key
typedef LazyValue< BrdDSP::Type,
BrdDSP
LazyBD
 lazy BorderDelegate
typedef SmartPointer< LazyBDLazyBDSP
 smart pointer to lazy BorderDelegate
typedef LazyValue< FntSP::Type,
FntSP
LazyFont
 lazy Font
typedef SmartPointer< LazyFontLazyFontSP
 smart pointer to lazy Font
typedef LazyValue< IconSP::Type,
IconSP
LazyIcon
 lazy Icon
typedef SmartPointer< LazyIconLazyIconSP
 smart pointer to lazy Icon
typedef LazyValue< UIDSP::Type,
UIDSP
LazyUID
 lazy UIDelegate
typedef SmartPointer< LazyUIDLazyUIDSP
 smart pointer to lazy UIDelegate
typedef unsigned int Type
 color type

Public Member Functions

void clearGeneralSettings ()
 clears all general settings
void clearIndividualSettings ()
 clears all individual settings
const BrdSPgetBorder (const Bordered *obj, const BrdSP &def=0) const
 accesses the border registered for obj
Color getColor (const Displayable *obj, const Type &type, const Color &def=Color()) const
 accesses the type color for obj
ConsoleManagergetConsoleManager () const
 accesses the ConsoleManager
BrdDSP getDelegate (const ID &borderType, const BrdDSP &def=0) const
 accesses the delegate registered for the given border type
UIDSP getDelegate (const Displayable *obj, const UIDSP &def=0) const
 accesses the delegate registered for obj
FocusManagergetFocusManager () const
 accesses the FocusManager
FntSP getFont (const Displayable *obj, const FntSP &def=0) const
 accesses the font for obj
IconSP getIcon (const Displayable *obj, const IconID &iid, const IconSP &def=0) const
 accesses the icon for obj
IMSP getInputMap (const Displayable *obj, const IMSP &def=0) const
 accesses the input map for obj
LaFSP getLookAndFeel () const
 accesses the currently active LaF
EventMulticastergetMulticaster () const
 accesses the EventMulticaster
Value getProperty (const Displayable *obj, const Key &key, const Value &def=Value()) const
 accesses the value of obj 's key property
RenderStubgetRenderStub () const
 provides access to the GUI render stub
void restoreLookAndFeel ()
 resets the general settings to the ones provided by the active LaF
void setBorder (const ID &did, const BrdSP &b)
 installs a border for a class of objects
void setBorder (const Bordered *obj, const BrdSP &b)
 specifies a border for obj
void setColor (const ID &did, const Type &type, const Color &c)
 specifies a color for a class of objects
void setColor (const Displayable *obj, const Type &type, const Color &c)
 specifies a color for obj
void setDelegate (const ID &borderType, const BrdDSP &del)
 installs the delegate for a border type
void setDelegate (const ID &borderType, const LazyBDSP &del)
 installs the delegate for a border type
void setDelegate (const ID &did, const UIDSP &del)
 installs a delegate for a class of objects
void setDelegate (const ID &did, const LazyUIDSP &del)
 installs a delegate for a class of objects
void setDelegate (const Displayable *obj, const UIDSP &del)
 installs a delegate for an individual object
void setDelegate (const Displayable *obj, const LazyUIDSP &del)
 installs a delegate for an individual object
void setFont (const ID &did, const FntSP &f)
 installs a font for a class of objects
void setFont (const ID &did, const LazyFontSP &f)
 installs a font for a class of objects
void setFont (const Displayable *obj, const FntSP &f)
 installs a font for an individual object
void setFont (const Displayable *obj, const LazyFontSP &f)
 installs a font for an individual object
void setIcon (const ID &did, const IconID &iid, const IconSP &icon)
 installs an icon for a class of objects
void setIcon (const ID &did, const IconID &iid, const LazyIconSP &icon)
 installs an icon for a class of objects
void setIcon (const Displayable *obj, const IconID &iid, const IconSP &icon)
 installs an icon for an individual object
void setIcon (const Displayable *obj, const IconID &iid, const LazyIconSP &icon)
 installs an icon for an individual object
void setInputMap (const ID &did, const IMSP &map)
 specifies the input map for a class of objects.
void setInputMap (const Displayable *obj, const IMSP &map)
 specifies the input map for obj
void setLookAndFeel (const LaFSP &laf)
 changes the look and feel
void setProperty (const ID &did, const Key &key, const Value &val)
 changes the key property of a class of objects
void setProperty (const Displayable *obj, const Key &key, const Value &val)
 changes obj 's key property
void updateUI () const
 updates all user interface elements

Static Public Member Functions

static void destroyInstance ()
 may be used to manually destroy the singleton instance
static GuiManagergetInstance ()
 accesses the singleton instance
static bool isActive ()
 checks if the singleton is active
static bool isDestroyed ()
 checks if the singleton is destroyed
static bool isVirgin ()
 checks if the singleton has not been initialized
static void setPriority (unsigned short)
 sets this singleton's shutdown priority

Static Public Attributes

static const BrdSP CLEAR_BORDER
 used to remove border properties
static const Value CLEAR_VALUE
 used to remove properties
static FntSP DEFAULT_FONT
 the default font

Protected Member Functions

 Singleton ()

Static Protected Member Functions

static void destroyedError ()
static void initInstance ()

Classes

struct  Value


Member Typedef Documentation

typedef DelegateID ONE::gui::GuiManager::ID
 

component type id

typedef unsigned int ONE::gui::GuiManager::Key
 

property key

typedef LazyValue<BrdDSP::Type,BrdDSP> ONE::gui::GuiManager::LazyBD
 

lazy BorderDelegate

typedef SmartPointer<LazyBD> ONE::gui::GuiManager::LazyBDSP
 

smart pointer to lazy BorderDelegate

typedef LazyValue<FntSP::Type,FntSP> ONE::gui::GuiManager::LazyFont
 

lazy Font

typedef SmartPointer<LazyFont> ONE::gui::GuiManager::LazyFontSP
 

smart pointer to lazy Font

typedef LazyValue<IconSP::Type,IconSP> ONE::gui::GuiManager::LazyIcon
 

lazy Icon

typedef SmartPointer<LazyIcon> ONE::gui::GuiManager::LazyIconSP
 

smart pointer to lazy Icon

typedef LazyValue<UIDSP::Type,UIDSP> ONE::gui::GuiManager::LazyUID
 

lazy UIDelegate

typedef SmartPointer<LazyUID> ONE::gui::GuiManager::LazyUIDSP
 

smart pointer to lazy UIDelegate

typedef unsigned int ONE::gui::GuiManager::Type
 

color type


Member Function Documentation

void ONE::gui::GuiManager::clearGeneralSettings  ) 
 

clears all general settings

This function should not be called by client code.

void ONE::gui::GuiManager::clearIndividualSettings  ) 
 

clears all individual settings

This function leaves the general settings intact regardless of whether they were imposed by the LaF or the user. These settings may be restored to the LaF's defaults by calling GuiManager::restoreLookAndFeel()

static void ONE::util::OrderedAutomatic< GuiManager >::destroyedError  )  [static, protected, inherited]
 

static void ONE::util::OrderedAutomatic< GuiManager >::destroyInstance  )  [static, inherited]
 

may be used to manually destroy the singleton instance

If this function is not called, the instance is destroyed automatically during shutdown.

const BrdSP& ONE::gui::GuiManager::getBorder const Bordered obj,
const BrdSP def = 0
const
 

accesses the border registered for obj

If an individual border is found for obj, that border is returned. Otherwise the border for obj 's type is returned. If no border was registered for that type, this function returns the default border or def if no default was specified.

Parameters:
obj a bordered component
def an optional default value
Returns:
a border as specified above

Color ONE::gui::GuiManager::getColor const Displayable obj,
const Type type,
const Color def = Color()
const
 

accesses the type color for obj

If an individual color is set for obj, that color is returned. Otherwise this function returns the color registered for obj 's type, the default type, or def.

Parameters:
obj a gui component
type the type of the color to retrieve
def an optional default value
Returns:
the color as specified above

ConsoleManager * ONE::gui::GuiManager::getConsoleManager  )  const [inline]
 

accesses the ConsoleManager

Returns:
a pointer to the console manager

BrdDSP ONE::gui::GuiManager::getDelegate const ID borderType,
const BrdDSP def = 0
const
 

accesses the delegate registered for the given border type

This function returns the delegate registered for borderType, the default border, or def.

Parameters:
borderType the requested type
def an optional default value
Returns:
a delegate as specified above

UIDSP ONE::gui::GuiManager::getDelegate const Displayable obj,
const UIDSP def = 0
const
 

accesses the delegate registered for obj

If an individual delegate object is installed, that delegate is returned. Otherwise the delegate for obj 's type is returned. If no delegate was registered for that type, this function returns the default delegate or def if no default was specified.

Parameters:
obj a gui component
def an optional default value
Returns:
a delegate object as specified above

FocusManager * ONE::gui::GuiManager::getFocusManager  )  const [inline]
 

accesses the FocusManager

Returns:
a pointer to the focus manager

FntSP ONE::gui::GuiManager::getFont const Displayable obj,
const FntSP def = 0
const
 

accesses the font for obj

This function returns the first of the following values that is found:

  • the font registered for obj
  • the font registered for obj 's class
  • the font registered for the default component class
  • def

Parameters:
obj a gui component
def an optional default value
Returns:
a font as specified above

IconSP ONE::gui::GuiManager::getIcon const Displayable obj,
const IconID iid,
const IconSP def = 0
const
 

accesses the icon for obj

This function returns the first of the following values that is found:

  • the icon registered for obj
  • the icon registered for obj 's class
  • the icon registered for the default component class
  • def

Parameters:
obj a gui component
iid the icon type
def an optional default value
Returns:
an icon as specified above

IMSP ONE::gui::GuiManager::getInputMap const Displayable obj,
const IMSP def = 0
const
 

accesses the input map for obj

This function returns the input map for obj, obj 's class, the default component class or def, depending on which value is found first.

Returns:
an input map as specified above

static GuiManager * ONE::util::Singleton< GuiManager , util::OrderedAutomatic >::getInstance  )  [static, inherited]
 

accesses the singleton instance

The exact operation executed by calling this function is determined by the singleton policies.

Returns:
a pointer to the singleton instance

LaFSP ONE::gui::GuiManager::getLookAndFeel  )  const
 

accesses the currently active LaF

Returns:
the active LaF

EventMulticaster * ONE::gui::GuiManager::getMulticaster  )  const [inline]
 

accesses the EventMulticaster

Returns:
a pointer to the event multicaster

Value ONE::gui::GuiManager::getProperty const Displayable obj,
const Key key,
const Value &  def = Value()
const
 

accesses the value of obj 's key property

If an individual property with the given name is specified for obj it is returned. Otherwise the general property's value or def is returned. The returned value may be implicitly converted to any of the types accepted by setProperty.

Parameters:
obj a gui component
key the desired property
def an optional default value
Returns:
the value as specified above

RenderStub * ONE::gui::GuiManager::getRenderStub  )  const [inline]
 

provides access to the GUI render stub

The stub is used to render the graphical user interface.

Returns:
a pointer to the render stub

static void ONE::util::OrderedAutomatic< GuiManager >::initInstance  )  [static, protected, inherited]
 

static bool ONE::util::Singleton< GuiManager , util::OrderedAutomatic >::isActive  )  [static, inherited]
 

checks if the singleton is active

Returns:
if the singleton is instantiated

static bool ONE::util::Singleton< GuiManager , util::OrderedAutomatic >::isDestroyed  )  [static, inherited]
 

checks if the singleton is destroyed

This function returns true if an instance existed and was destroyed. Note that in some cases it is possible to revive a singleton.

Returns:
if the singleton is destroyed

static bool ONE::util::Singleton< GuiManager , util::OrderedAutomatic >::isVirgin  )  [static, inherited]
 

checks if the singleton has not been initialized

A singleton is not initialized if no instance exists and no instance has been destroyed.

Returns:
if the singleton is untouched

void ONE::gui::GuiManager::restoreLookAndFeel  ) 
 

resets the general settings to the ones provided by the active LaF

Individual settings remain untouched by this function; they may be cleared by calling GuiManager::clearIndividualSettings()

void ONE::gui::GuiManager::setBorder const ID did,
const BrdSP b
 

installs a border for a class of objects

The setting may be cleared by passing a 0 border pointer.

Parameters:
did the target type delegate ID
b the new border

void ONE::gui::GuiManager::setBorder const Bordered obj,
const BrdSP b
 

specifies a border for obj

Since components may explicitly be set to no border, this property may be cleared by passing CLEAR_BORDER as the new border value.

Parameters:
obj the target of the operation
b the new border

void ONE::gui::GuiManager::setColor const ID did,
const Type type,
const Color c
 

specifies a color for a class of objects

The setting may be cleared by passing a 0 color pointer.

Parameters:
did the target type delegate ID
type the type of color, i.e. background, foreground etc
c the new color

void ONE::gui::GuiManager::setColor const Displayable obj,
const Type type,
const Color c
 

specifies a color for obj

The setting may be cleared by passing a 0 color pointer.

Parameters:
obj the target of the operation
type the type of color, i.e. background, foreground etc
c the new color

void ONE::gui::GuiManager::setDelegate const ID borderType,
const BrdDSP del
 

installs the delegate for a border type

This function calls setDelegate(ID&,LazyBDSP&). That function should be preferred over this one as it permits lazy instantiation of potentially large delegates.
This function may be used to clear a delegate setting by passing in 0 as the new delegate pointer.

Parameters:
borderType the border's type
del the new delegate or 0 to clear the setting

void ONE::gui::GuiManager::setDelegate const ID borderType,
const LazyBDSP del
 

installs the delegate for a border type

Since Border instances are usually shared, this setting is not possible for individual borders.

This function may be used to clear a delegate setting by passing in 0 as the new delegate pointer.

Parameters:
borderType the border's type
del the new delegate or 0 to clear the setting

void ONE::gui::GuiManager::setDelegate const ID did,
const UIDSP del
 

installs a delegate for a class of objects

This function creates an initialized (i.e. non-lazy) LazyValue and passes it to setDelegate(ID&,LazyUIDSP&). That function should be preferred, as it permits lazy instantiation of large delegates.
This function may be used to remove a general setting by passing 0 as the new delegate pointer. Individual settings remain untouched by this.

Parameters:
did the target type delegate ID
del the new delegate or 0 to remove the setting

void ONE::gui::GuiManager::setDelegate const ID did,
const LazyUIDSP del
 

installs a delegate for a class of objects

If not already initialized, the passed-in value will be instantiated when it is first requested. If a value for did is already set, the old value will be overwritten.
This function may be used to remove a general setting by passing 0 as the new delegate pointer. Individual settings remain untouched by this.

Parameters:
did the target type delegate ID
del the delegate or 0 to remove the setting

void ONE::gui::GuiManager::setDelegate const Displayable obj,
const UIDSP del
 

installs a delegate for an individual object

This function creates an initialized (i.e. non-lazy) LazyValue and passes it to setDelegate(Displayable*,LazyUIDSP&). That function should be preferred, as it permits lazy instantiation of large delegates.
This function may be used to remove an individual setting by passing 0 as the new delegate pointer. General settings remain untouched by this.

Parameters:
obj the target of the operation
del the new delegate or 0 to remove the setting

void ONE::gui::GuiManager::setDelegate const Displayable obj,
const LazyUIDSP del
 

installs a delegate for an individual object

If not already initialized, the passed-in value will be instantiated when it is first requested. If a value for obj is already set, the old value will be overwritten.
This function may be used to remove an individual setting by passing 0 as the new delegate pointer. General settings remain untouched by this.

Parameters:
obj the target of the operation
del the new delegate or 0 to remove the setting

void ONE::gui::GuiManager::setFont const ID did,
const FntSP f
 

installs a font for a class of objects

This function creates an initialized (i.e. non-lazy) LazyValue and passes it to setFont(ID&,LazyFontSP&). That function should be preferred over this one as it allows the creation of large fonts to be delayed until they are actually needed.
This function may also be used to remove a general font setting by passing in 0 as the new font pointer. Individual settings remain untouched by this.

Parameters:
did the target of the operation
f the new font or 0 to remove the setting

void ONE::gui::GuiManager::setFont const ID did,
const LazyFontSP f
 

installs a font for a class of objects

If not already initialized, f will not be instantiated until it is actually needed. If a value for did is already set, the old value will be overwritten.
This function may also be used to remove a general font setting by passing in 0 as the new font pointer. Individual settings remain untouched by this.

Parameters:
did the target of the operation
f the new font or 0 to remove the setting

void ONE::gui::GuiManager::setFont const Displayable obj,
const FntSP f
 

installs a font for an individual object

This function creates an initialized (i.e. non-lazy) LazyValue and passes it to setFont(Displayable*,LazyFontSP&). That function should be preferred over this one as it allows the creation of large fonts to be delayed until they are actually needed.
This function may also be used to remove an individual font setting by passing in 0 as the new font pointer. General settings remain untouched by this.

Parameters:
obj the target of the operation
f the new font or 0 to remove the setting

void ONE::gui::GuiManager::setFont const Displayable obj,
const LazyFontSP f
 

installs a font for an individual object

If not already initialized, f will not be instantiated until it is actually needed. If a value for obj is already set, the old value will be overwritten.
This function may also be used to remove an individual font setting by passing in 0 as the new font pointer. General settings remain untouched by this.

Parameters:
obj the target of the operation
f the new font or 0 to remove the setting

void ONE::gui::GuiManager::setIcon const ID did,
const IconID iid,
const IconSP icon
 

installs an icon for a class of objects

This function creates an initialized (i.e. non-lazy) LazyValue and passes it to setIcon(ID&,IconID&,LazyIconSP&). That function should be preferred over this one as it allows the creation of large icons to be delayed until they are actually needed.
This function may also be used to remove a general icon setting by passing in 0 as the new icon pointer. Individual settings remain untouched by this.

Parameters:
did the target of the operation
iid the icon type
icon the new icon or 0 to remove the setting

void ONE::gui::GuiManager::setIcon const ID did,
const IconID iid,
const LazyIconSP icon
 

installs an icon for a class of objects

If not already initialized, icon will not be instantiated until it is actually needed. If a value for did is already set, the old value will be overwritten.
This function may also be used to remove a general icon setting by passing in 0 as the new icon pointer. Individual settings remain untouched by this.

Parameters:
did the target of the operation
iid the icon type
icon the new icon or 0 to remove the setting

void ONE::gui::GuiManager::setIcon const Displayable obj,
const IconID iid,
const IconSP icon
 

installs an icon for an individual object

This function creates an initialized (i.e. non-lazy) LazyValue and passes it to setIcon(Displayable*,IconID&,LazyIconSP&). That function should be preferred over this one as it allows the creation of large icons to be delayed until they are actually needed.
This function may also be used to remove an individual icon setting by passing in 0 as the new icon pointer. General settings remain untouched by this.

Parameters:
obj the target of the operation
iid the icon type
icon the new icon or 0 to remove the setting

void ONE::gui::GuiManager::setIcon const Displayable obj,
const IconID iid,
const LazyIconSP icon
 

installs an icon for an individual object

If not already initialized, icon will not be instantiated until it is actually needed. If a value for obj is already set, the old value will be overwritten.
This function may also be used to remove an individual icon setting by passing in 0 as the new icon pointer. General settings remain untouched by this.

Parameters:
obj the target of the operation
iid the icon type
icon the new icon or 0 to remove the setting

void ONE::gui::GuiManager::setInputMap const ID did,
const IMSP map
 

specifies the input map for a class of objects.

The setting may be cleared by passing a 0 map.

Parameters:
did the target type's delegate ID
map the new input map

void ONE::gui::GuiManager::setInputMap const Displayable obj,
const IMSP map
 

specifies the input map for obj

The setting may be removed by passing a 0 value.

Parameters:
obj the target
map the new input map

void ONE::gui::GuiManager::setLookAndFeel const LaFSP laf  ) 
 

changes the look and feel

This function installs laf and then invokes LookAndFeel::install(). The general settings are cleared before that operation. Properties that are not set by the LaF will yield the respective default values when requested. The individual settings remain untouched by this operation. They may be cleared by calling GuiManager::clearIndividualSettings(). This function may be called with a 0 pointer as the laf parameter in order to manually clear the active look and feel. This may be useful when the look's shutdown procedure relies on other objects which may no longer exist when the GUI manager is destroyed. Note, however, that most functions provided by this class will fail after the LaF was cleared.

Parameters:
laf the new look and feel or a 0 pointer to manually clear the LaF
Exceptions:
InvalidArgumentException if laf could not be installed

static void ONE::util::OrderedAutomatic< GuiManager >::setPriority unsigned  short  )  [static, inherited]
 

sets this singleton's shutdown priority

The higher the priority, the earlier the instance will be destroyed during shutdown. If the priority is changed, the highest given priority will be used.

void ONE::gui::GuiManager::setProperty const ID did,
const Key key,
const Value &  val
 

changes the key property of a class of objects

The value may be of one of the following types:

  • bool
  • char
  • int
  • float
  • void*

If val is a pointer, that pointer must be deleted manually when no longer in use. The property may be cleared by passing GuiManager::CLEAR_VALUE.

Parameters:
did the target type delegate ID
key the desired property
val the property's value

void ONE::gui::GuiManager::setProperty const Displayable obj,
const Key key,
const Value &  val
 

changes obj 's key property

The value may be of one of the following types:

  • bool
  • char
  • int
  • float
  • void*

If val is a pointer, that pointer must be deleted manually when no longer in use. The property may be cleared by passing GuiManager::CLEAR_VALUE.

Parameters:
obj the target of the operation
key the desired property
val the property's value

ONE::util::Singleton< GuiManager , util::OrderedAutomatic >::Singleton  )  [protected, inherited]
 

void ONE::gui::GuiManager::updateUI  )  const
 

updates all user interface elements

This function is comparatively slow and should only be called after all necessary changes have been made. Changes that need a call to this function in order to take effect include:

  • setLookAndFeel
  • restoreLookAndFeel
  • clearGeneralSettings
  • clearIndividualSettings
  • the general setXxxx functions

While calling this function works after calling the individual setXxxx functions, it is recommended to call Displayable::updateUI() on the affected objects as this avoids updating the whole component tree.


Member Data Documentation

const BrdSP ONE::gui::GuiManager::CLEAR_BORDER [static]
 

used to remove border properties

const Value ONE::gui::GuiManager::CLEAR_VALUE [static]
 

used to remove properties

FntSP ONE::gui::GuiManager::DEFAULT_FONT [static]
 

the default font


Generated on Wed Sep 7 19:03:17 2005 for ONEngine by  doxygen 1.4.3