UI::Various::Main - general main "Window Manager" class of UI::Various
use UI::Various; my $main = UI::Various::main(); $main->window(...); $main->mainloop();
This module defines the general main "Window Manager" class of an application using UI::Various. It keeps track of active / inactive windows and / or the active dialogue. In addition it manages global attributes of the current UI, e.g. size of the display.
UI::Various's "Window Manager" is a singleton keeping track of all windows and dialogues of the application. It takes care of setting them up for the currently used UI and removing them when they are no longer needed. In addition it triggers the event loops of the current UI (aka their main loops).
In addition it holds some convenience methods to ease creating windows and some specific dialogues (see METHODS below).
The "Window Manager" holds the following attributes (besides those inherited from UI::Various::widget):
UI::Various::widget
maximum height of an application window in (approximately) characters as defined by the underlying UI system and screen / terminal size
maximum width of an application window in (approximately) characters as defined by the underlying UI system and screen / terminal size
The following attribute behave slightly different from their general description in widget. First of all (except for initialisation) they always ignore the passed object and use the internal singleton object instead. In addition they are no longer inherited but optional or mandatory, as the main "Window Manager" is the one object defining the defaults for all others that do not set them.
Note that all accessor methods can also be called via the package name itself, e.g. UI::Various::Main::max_width(). As the "Window Manager" is a singleton, it always accesses the sole existing instance anyway.
UI::Various::Main::max_width()
Besides the accessors (attributes) described above and by UI::Various::widget as well as the methods inherited from UI::Various::widget and UI::Various::container, the following additional methods are provided by the main "Window Manager" class itself:
see UI::Various::core::construct
$window = $main->window([$rh_attributes,] @ui_elements);
$main->window(UI::Various::Text->new(text => 'Hello World!'), UI::Various::Button->new(text => 'Quit', code => sub{ exit(); }));
$rh_attributes optional reference to hash with attributes @ui_elements array with possible UI elements of a window
Add a new window to the application. An optional attribute HASH is passed on to the created window while optional other UI elements are added in the specified sequence.
the new window or undef in case of an error
$dialog = $main->dialog([$rh_attributes,] @ui_elements);
$main->dialog(UI::Various::Text->new(text => 'Hello World!'), UI::Various::Button->new(text => 'Quit', code => sub{ exit(); }));
$rh_attributes optional reference to hash with attributes @ui_elements array with possible UI elements of a dialogue
Add a new dialogue to the application. An optional attribute HASH is passed on to the created dialogue while optional other UI elements are added in the specified sequence.
Note that in Curses the call blocks until the dialogue has finished! (It will therefore return undef in those cases.) The same goes for PoorTerm when the mainloop is already running.
Curses
undef
PoorTerm
the new dialogue or undef in case of an error (and always in Curses or PoorTerm with running mainloop)
mainloop
$main->mainloop();
The main event loop of the application, handling every Window and Dialog until none is left or the application exits.
Window
Dialog
UI::Various
Copyright (C) Thomas Dorner.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See LICENSE file for more details.
Thomas Dorner <dorner (at) cpan (dot) org>
To install UI::Various, copy and paste the appropriate command in to your terminal.
cpanm
cpanm UI::Various
CPAN shell
perl -MCPAN -e shell install UI::Various
For more information on module installation, please visit the detailed CPAN module installation guide.