use Prima; use Prima::Application; # this window, when closed, terminated the application my $main = Prima::MainWindow-> new( text => 'Hello world' ); # this is a modal window my $dialog = Prima::Dialog->create( size => [ 100, 100 ]); my $result = $dialog-> execute; $dialog-> destroy; run Prima;
my $w = Prima::Window-> create(
size => [300,300],
text => 'Startup window',
);
There are more about Prima::Window in areas, that it is specifically designed to - the system window management and the dialog execution.
The Prima toolkit provides simple access to buttons, title bar and borders of a window. Buttons and title bar are managed by the "::borderIcons" property, and borders by the "::borderStyle" property. These operate with set of predefined constants, "bi::XXX" and "bs::XXX", correspondingly. The button constants can be combined with each other, but not all combinations may be granted by the system. The same is valid also for the border constant, except that they can not be combined - the value of "::borderStyle" is one of the integer constants.
There are other hints that the toolkit can set for a window manager. The system can be supplied with an icon that a window is bound to; the icon dimensions are much different, and although can be requested via "sv::XIcon" and "sv::YIcon" system values, the "::icon" property scales the image automatically to the closest system-recognizable dimension. The window icon is not shown by the toolkit, it is usually resides in the window decorations and sometimes on a task bar, along with the window's name. The system can be hinted to not reflect the window on the task bar, by setting the "::taskListed" property to 0.
Another issue is the window positioning. Usually, if no explicit position was given, the window is positioned automatically by the system. The same is valid for the size. But some window managers bend it to the extreme - for example, default CDE setup force the user to set newly created windows' positions explicitly. However, there is at least one point of certainty. Typically, when the initial size and/or position of a top-level window are expected to be set by the system, the "::originDontCare" and "::sizeDontCare" properties can be set to 1 during window creation. If these set, the system is asked to size/position a window regarding its own windowing policy. The reverse is not always true, unfortunately. Either if these properties set to 0, or explicit size or positions are given, the system is hinted to use these values instead, but this does not always happen. Actually, this behavior is expected by the user and often does not get even noticed as something special. Therefore it is a good practice to test a top-level windowing code with several window managers.
There are different policies about window positioning and sizing; some window managers behave best when the position is given to the window with the system-dependent decorations. It is hardly can be called a good policy, since it is not possible to calculate the derived window coordinates with certainty. This problem results in that it is impossible to be sure about window position and size before these are set explicitly. The only, not much efficient help the toolkit can provide is the property pair "::frameOrigin" and "::frameSize", which along with "::origin" and "::size" reflect the position and size of a window, but taking into account the system-dependent decorations.
run Prima;
code. The event flow is not disrupted, but the windows and widgets that do not belong to the currently executed, the 'modal' window group can not be activated. There can be many modal windows on top of each other, but only one is accessible. As an example a message box can be depicted, a window that prevents the user to work with the application windows until dismissed. There can be other message boxes on top of each other, preventing the windows below from operation as well. This scheme is called the 'exclusive' modality.
The toolkit also provides the shared modality scheme, where there can be several stacks of modal windows, not interfering with each other. Each window stack is distinct and contains its own windows. An example analogy is when several independent applications run with modal message boxes being activated. This scheme, however, can not be achieved with single execute()-like call without creating interlocking conditions. The shared model call, "execute_shared()", inserts the window into the shared modal stack, activates the window and returns immediately.
The both kinds of modal windows can coexist, but the exclusive windows prevents the shared from operation; while there are exclusive windows, the shared have same rights as the usual windows.
The stacking order for these two models is slightly different. A window after execute() call is set on top of the last exclusive modal window, or, in other words, is added to the exclusive window stack. There can be only one exclusive window stack, but many shared window stacks; a window after execute_shared() call is added to a shared window stack, to the one the window's owner belongs to. The shared window stacks are rooted in so-called modal horizons, windows with boolean property "::modalHorizon" set to "true". The default horizon is "::application".
A window in modal state can return to the normal (non-modal) state by calling "end_modal()" method. The window is then hidden and disabled, and the windows below are accessible to the user. If the window was in the exclusive modal state, the execute() call is finished and returns the exit code, the value of "::modalResult" property. There two shortuct methods that end modal state, setting "::modalResult" to the basic 'ok' and 'not ok' code, correspondingly "ok()" and "cancel()" methods. Behavior of "cancel()" is identical to when the user closes the modal window by clicking the system close button, pressing Escape key, or otherwise cancelling the dialog execution. "ok()" sets "::modalResult" to "mb::OK", "cancel()" to "mb::Cancel", correspondingly. There are more "mb::XXX" constants, but these have no special meaning, any integer value can be passed. For example, "Prima::MsgBox::message" method uses these constants so the message window can return up to four different "mb" codes.
Only one menu at a time can be displayed in a top-level window, although a window can be an owner for many menu objects. The key property is "Prima::Menu::selected" - if a menu object is selected on a widget or a window object, it refers to the default menu actions, which, in case of Prima::Window is being displayed as menu bar.
NB: A window can be an owner for several menu objects and still do not have a menu bar displayed, if no menu objects are marked as selected.
Prima::MainWindow-> create( ... )
rather than
Prima::Window-> create( ..., onDestroy => sub { $::application-> close })
, although these lines are equivalent.
Also, the $::main_window is pointed to a newly created main window.
bi::SystemMenu - system menu button and/or close button
( usually with icon ) is shown
bi::Minimize - minimize button
bi::Maximize - maximize ( and eventual restore )
bi::TitleBar - window title
bi::All - all of the above
Not all systems respect these hints, and many systems provide more navigating decoration controls than these.
bs::None - no border bs::Single - thin border bs::Dialog - thick border bs::Sizeable - thick border with interactive resize capabilities
"bs::Sizeable" is an unique window mode. If selected, the user can resize the window, not only by dragging the window borders with the mouse but by other system-dependent means. The other border styles disallow interactive resizing.
Not all systems recognize all these hints, although many recognize interactive resizing flag.
See also: "ownerIcon"
See also: "Prima::Menu", "menuItems"
See also: "menuItems", "menuFont", "menu"
See also: "menuItems", "menuColorIndex", "menuFont", "menu"
See also: "menuItems", "menuColorIndex", "menuFont", "menu"
See also: "menuItems", "menuColorIndex", "menuFont", "menu"
See also: "menuItems", "menuColorIndex", "menuFont", "menu"
See also: "menuItems", "menuColorIndex", "menuFont", "menu"
See also: "menuItems", "menuColorIndex", "menu"
See also: "menuItems", "menuColorIndex", "menuFont", "menu"
See also: "menuItems", "menuColorIndex", "menuFont", "menu"
See also: "menu", "menuColorIndex", "menuFont"
See also: "menuItems", "menuColorIndex", "menuFont", "menu"
The property also serves as an additional grouping factor for widgets and windows. For example, default keyboard navigation by tab and arrow keys is limited to the windows and widgets of a single window stack.
mb::OK, mb::Ok mb::Cancel mb::Yes mb::No mb::Abort mb::Retry mb::Ignore mb::Help
NB: These constants are defined so they can be bitwise-or'ed, and Prima::MsgBox package uses this feature, where one of its functions parameters is a combination of "mb::" constants.
Default value: 0
Default value: 1
ws::Normal ws::Minimized ws::Maximized
There can be more or less, or other window states provided by the system, but these three were chosen as a 'least common denominator'. The property can be changed either by explicit set-mode call or by the user. In either case, a "WindowState" notification is triggered.
The property has three convenience wrappers: "maximize()", "minimize()" and "restore()".
See also: "WindowState"
See also: "ok", "modalResult", "execute", "execute_shared"
The function is returned when a window is dismissed, or if the system-dependent 'exit'-event is triggered by the user ( the latter case falls through all execute() calls and terminates "run Prima;" call, exiting gracefully).
By default, if INSERT_BEFORE object is undef, the window is also put on top of other shared-modal windows in its stack. If INSERT_BEFORE is one of the shared-modal windows in its stack, the window is placed in queue before the INSERT_BEFORE window.
The window is showed and enabled, if necessary, and "Execute" notification is triggered.
The function is returned immediately.
mt::None mt::Shared mt::Exclusive
Value of "mt::None" is 0, so result of get_modal() can be also treated as a boolean value, if only the fact of modality is needed to check.
If a window has no immediate modal relations, "undef" is returned.
See also: "cancel", "modalResult", "execute", "execute_shared"
The toolkit does not provide standalone activation functions; "select()" call is used instead.
The toolkit does not provide standalone de-activation functions; "deselect()" call is used instead.