Public Member Functions
GUI::WindowManager Class Reference

The WindowManager class describes an object that manages creation and lifetime of Window objects. More...

List of all members.

Public Member Functions

Window createWindow (string type, string name="")
 Creates a new Window object of the specified type, and gives it the specified unique name.
void destroyWindow (Window window)
 Destroy the specified Window object.
void destroyWindow (string window)
 Destroy the specified Window object.
Window getWindow (string name)
 Return a pointer to the specified Window object.
bool isWindowPresent (string name)
 Examines the list of Window objects to see if one exists with the given name.
void destroyAllWindows ()
 Destroys all Window objects within the system.
Window loadWindowLayout (string filename, string name_prefix="", string resourceGroup="")
 Creates a set of windows (a Gui layout) from the information in the specified XML file.
Window loadWindowLayout (string filename, bool generateRandomPrefix)
bool isDeadPoolEmpty ()
 Return whether the window dead pool is empty.
void cleanDeadPool ()
 Permanently destroys any windows placed in the dead pool.
void renameWindow (string window, string new_name)
 Rename a window.
void renameWindow (Window window, string new_name)
 Rename a window.
string getDefaultResourceGroup ()
 Returns the default resource group currently set for layouts.
void setDefaultResourceGroup (string resourceGroup)
 Sets the default resource group to be used when loading layouts.
void lock ()
 Put WindowManager into the locked state.
void unlock ()
 Put WindowManager into the unlocked state.
bool isLocked () const
 Returns whether WindowManager is currently in the locked state.

Qualified Iterators

Window Window
 Can be used to iterate over the currently defined Windows.

Detailed Description

The WindowManager class describes an object that manages creation and lifetime of Window objects.

The WindowManager is the means by which Window objects are created and destroyed. For each sub-class of Window that is to be created, there must exist a WindowFactory object which is registered with the WindowFactoryManager. Additionally, the WindowManager tracks every Window object created, and can be used to access those Window objects by name.


Member Function Documentation

Window GUI::WindowManager::createWindow ( string  type,
string  name = "" 
)

Creates a new Window object of the specified type, and gives it the specified unique name.

Parameters:
typeString that describes the type of Window to be created. A valid WindowFactory for the specified type must be registered.
nameString that holds a unique name that is to be given to the new window. If this string is empty (""), a name will be generated for the window.
Returns:
Pointer to the newly created Window object.
Exceptions:
InvalidRequestExceptionWindowManager is locked and no Windows may be created.
AlreadyExistsExceptionA Window object with the name name already exists.
UnknownObjectExceptionNo WindowFactory is registered for type Window objects.
GenericExceptionSome other error occurred (Exception message has details).
void GUI::WindowManager::destroyWindow ( Window  window)

Destroy the specified Window object.

Parameters:
windowPointer to the Window object to be destroyed. If the window is null, or is not recognised, nothing happens.
Returns:
Nothing
Exceptions:
InvalidRequestExceptionCan be thrown if the WindowFactory for window's object type was removed.
void GUI::WindowManager::destroyWindow ( string  window)

Destroy the specified Window object.

Parameters:
windowString containing the name of the Window object to be destroyed. If window is not recognised, nothing happens.
Returns:
Nothing.
Exceptions:
InvalidRequestExceptionCan be thrown if the WindowFactory for window's object type was removed.
Window GUI::WindowManager::getWindow ( string  name)

Return a pointer to the specified Window object.

Parameters:
nameString holding the name of the Window object to be returned.
Returns:
Pointer to the Window object with the name name.
Exceptions:
UnknownObjectExceptionNo Window object with a name matching name was found.
bool GUI::WindowManager::isWindowPresent ( string  name)

Examines the list of Window objects to see if one exists with the given name.

Parameters:
nameString holding the name of the Window object to look for.
Returns:
true if a Window object was found with a name matching name. false if no matching Window object was found.
void GUI::WindowManager::destroyAllWindows ( )

Destroys all Window objects within the system.

Returns:
Nothing.
Exceptions:
InvalidRequestExceptionThrown if the WindowFactory for any Window object type has been removed.
Window GUI::WindowManager::loadWindowLayout ( string  filename,
string  name_prefix = "",
string  resourceGroup = "" 
)

Creates a set of windows (a Gui layout) from the information in the specified XML file.

Warning:
When using a C string literal as the value for the second argument name_prefix, currently (0.6.x releases) it is likely that the incorrect overload of loadWindowLayout will be invoked (possibly without immediate error or warning). To avoid the possibility of invoking the incorrect overload by mistake, it is recommended that you explicity use the CEGUI::String type when passing name_prefix.
For example, instead of this:
winMgr.loadWindowLayout("MyLayout.layout", "aPrefix/");
Do this:
winMgr.loadWindowLayout("MyLayout.layout", CEGUI::String("aPrefix/"));
Parameters:
filenameString object holding the filename of the XML file to be processed.
name_prefixString object holding the prefix that is to be used when creating the windows in the layout file, this function allows a layout to be loaded multiple times without having name clashes. Note that if you use this facility, then all windows defined within the layout must have names assigned; you currently can not use this feature in combination with automatically generated window names.
resourceGroupResource group identifier to be passed to the resource provider when loading the layout file.
Returns:
Pointer to the root Window object defined in the layout.
Exceptions:
FileIOExceptionthrown if something goes wrong while processing the file filename.
InvalidRequestExceptionthrown if filename appears to be invalid.
bool GUI::WindowManager::isDeadPoolEmpty ( )

Return whether the window dead pool is empty.

Returns:
  • true if there are no windows in the dead pool.
  • false if the dead pool contains >=1 window awaiting destruction.
void GUI::WindowManager::cleanDeadPool ( )

Permanently destroys any windows placed in the dead pool.

Note:
It is probably not a good idea to call this from a Window based event handler if the specific window has been or is being destroyed.
Returns:
Nothing.
void GUI::WindowManager::renameWindow ( string  window,
string  new_name 
)

Rename a window.

Parameters:
windowString holding the current name of the window to be renamed.
new_nameString holding the new name for the window
Exceptions:
UnknownObjectExceptionthrown if window is not known in the system.
AlreadyExistsExceptionthrown if a Window named new_name already exists.
void GUI::WindowManager::renameWindow ( Window  window,
string  new_name 
)

Rename a window.

Parameters:
windowPointer to the window to be renamed.
new_nameString holding the new name for the window
Exceptions:
AlreadyExistsExceptionthrown if a Window named new_name already exists.
string GUI::WindowManager::getDefaultResourceGroup ( )
inline

Returns the default resource group currently set for layouts.

Returns:
String describing the default resource group identifier that will be used when loading layouts.
void GUI::WindowManager::setDefaultResourceGroup ( string  resourceGroup)
inline

Sets the default resource group to be used when loading layouts.

Parameters:
resourceGroupString describing the default resource group identifier to be used.
Returns:
Nothing.
void GUI::WindowManager::lock ( )

Put WindowManager into the locked state.

While WindowManager is in the locked state all attempts to create a Window of any type will fail with an InvalidRequestException being thrown. Calls to lock/unlock are recursive; if multiple calls to lock are made, WindowManager is only unlocked after a matching number of calls to unlock.

Note:
This is primarily intended for internal use within the system.
void GUI::WindowManager::unlock ( )

Put WindowManager into the unlocked state.

While WindowManager is in the locked state all attempts to create a Window of any type will fail with an InvalidRequestException being thrown. Calls to lock/unlock are recursive; if multiple calls to lock are made, WindowManager is only unlocked after a matching number of calls to unlock.

Note:
This is primarily intended for internal use within the system.
bool GUI::WindowManager::isLocked ( ) const

Returns whether WindowManager is currently in the locked state.

While WindowManager is in the locked state all attempts to create a Window of any type will fail with an InvalidRequestException being thrown. Calls to lock/unlock are recursive; if multiple calls to lock are made, WindowManager is only unlocked after a matching number of calls to unlock.

Returns:
  • true to indicate WindowManager is locked and that any attempt to create Window objects will fail.
  • false to indicate WindowManager is unlocked and that Window objects may be created as normal.

Member Data Documentation

Window GUI::WindowManager::Window

Can be used to iterate over the currently defined Windows.

for each Window w in GUI.WindowManager {
trace(w.getName());
}