#include <win_manager.h>
Public Member Functions | |
win_manager () | |
Standard constructor. | |
~win_manager () | |
Destructor. | |
Static Public Member Functions | |
Theme and font related methods | |
static void | init (const string &font) |
Empty for now. | |
static void | cleanup () |
Delete all themes and fonts currently loaded. | |
static void | add_theme (string name) |
Load a theme from disk. | |
static bool | remove_theme (string name) |
Delete a theme. | |
static win_theme * | get_theme (string name) |
Returns a pointer to a theme. | |
static void | add_font (string name) |
Load a font from disk. | |
static bool | remove_font (string name) |
Delete a font. | |
static win_font * | get_font (string name) |
Returns a pointer to a font. | |
Window handling methods | |
static win_manager * | active = NULL |
Pointer to the active, i.e. | |
void | add (win_base *wnd) |
Add a window to the window manager. | |
void | remove (win_base *wnd) |
Remove a window from the window manager. | |
void | update () |
Update the state of all top level windows. | |
void | input_update () |
Checks for user input. | |
void | draw () |
Draws all windows. | |
void | set_focus (win_base *wnd) |
Gives the input focus to wnd. | |
void | destroy () |
Closes and deletes all windows of the current level. | |
static win_manager * | get_active () |
Use this method to get the active manger from Python. |
It also provides centralised access to fonts and themes, so that they can be used by different windows without having to load them multiple times. For something to appear on screen, it has to be passes to the window manager.
Before the window manager can be used, adonthell::main() has to be called. This instanciates a window manager object and makes it available to other classes via the static win_manager::active pointer. All windows added to that instance have access to the input focus, although only one window can own it at any given time.
Another call to adonthell::main() will create a new window manager instance that grabs the input focus. As long as it is in existance, none of the parent windows are updated, nor may they recieve the focus. A call to adonthell::main_quit() will delete the topmost window manager and return focus to the underlying windows.
That way it is possible to create a hierarchie of windows, where where only windows on the same level may share the input focus, but only those on the highest level receive input.
Definition at line 61 of file win_manager.h.
win_manager::win_manager | ( | ) |
win_manager::~win_manager | ( | ) |
void win_manager::add | ( | win_base * | wnd | ) |
Add a window to the window manager.
wnd | The window to be added |
Definition at line 101 of file win_manager.cc.
void win_manager::remove | ( | win_base * | wnd | ) |
Remove a window from the window manager.
The window is erased from the window list, but not deleted. If it had the input focus, it is passed on to the topmost window, i.e. the last one in the window list (if such a window exists).
wnd | The window to be removed |
Definition at line 119 of file win_manager.cc.
void win_manager::update | ( | ) |
Update the state of all top level windows.
Calls the update() method of all windows in the window list. If that method returns 0, it will be removed from the window list and deleted.
Definition at line 164 of file win_manager.cc.
void win_manager::input_update | ( | ) |
Checks for user input.
Calls the input_update() method of the window that has the input focus.
Definition at line 157 of file win_manager.cc.
void win_manager::draw | ( | ) |
Draws all windows.
If the window hierarchie consists of multiple levels, the lowest windows are drawn first. Within each level, windows are drawn in the order they appear in the window list.
Definition at line 146 of file win_manager.cc.
void win_manager::set_focus | ( | win_base * | wnd | ) |
Gives the input focus to wnd.
Only one window can have the focus at a time, so focus will be removed from the window that had it so far. Only the window with the focus will receive user input.
Definition at line 180 of file win_manager.cc.
void win_manager::destroy | ( | ) |
static win_manager* win_manager::get_active | ( | ) | [inline, static] |
void win_manager::init | ( | const string & | font | ) | [static] |
void win_manager::cleanup | ( | void | ) | [static] |
void win_manager::add_theme | ( | string | name | ) | [static] |
Load a theme from disk.
name | The name of the theme to load. |
Definition at line 195 of file win_manager.cc.
bool win_manager::remove_theme | ( | string | name | ) | [static] |
Delete a theme.
name | The name of the theme to delete. |
Definition at line 201 of file win_manager.cc.
win_theme * win_manager::get_theme | ( | string | name | ) | [static] |
Returns a pointer to a theme.
Loads the theme from disk if it isn't in memory yet.
name | The name of the theme to get. |
Definition at line 212 of file win_manager.cc.
void win_manager::add_font | ( | string | name | ) | [static] |
Load a font from disk.
name | The name of the font to load. |
Definition at line 226 of file win_manager.cc.
bool win_manager::remove_font | ( | string | name | ) | [static] |
Delete a font.
name | The name of the font to delete. |
Definition at line 232 of file win_manager.cc.
win_font * win_manager::get_font | ( | string | name | ) | [static] |
Returns a pointer to a font.
Loads the font from disk if it isn't in memory yet.
name | The name of the font to get. |
Definition at line 243 of file win_manager.cc.
win_manager * win_manager::active = NULL [static] |