NAME
Prima::MDI - top-level window emulation
DESCRIPTION
MDI stands for Multiple Document Interface and is a Microsoft Windows user interface that consists of multiple non-top-level windows belonging to an application window. The module contains classes that provide similar functionality; sub-window widgets realize a set of operations similar to those of the real top-level windows, - iconize, maximize, cascade, etc.
The basic classes required to use the MDI are Prima::MDIOwner
and Prima::MDI
, which are, correspondingly, sub-window owner class and sub-window class. Prima::MDIWindowOwner
is the same as Prima::MDIOwner
but is a Prima::Window
descendant: both owner classes are different only in the class they are derived from. Their second ascendant is the Prima::MDIMethods
package that contains all the owner class functionality.
Usage of the Prima::MDI
class extends beyond the multi-document paradigm. The Prima::DockManager
module uses the class as a base of the dockable toolbar window class (see Prima::DockManager.
SYNOPSIS
use Prima qw(Application MDI Buttons);
my $owner = Prima::MDIWindowOwner-> new;
my $mdi = $owner-> insert( 'Prima::MDI');
$mdi-> client-> insert( 'Prima::Button' => centered => 1 );
run Prima;
Prima::MDI
Implements MDI window functionality. A subwindow widget consists of a title bar, title bar buttons, and a client widget. The latter must be used as an insertion target for all children widgets.
A subwindow can be moved and resized, both by mouse and keyboard. These functions, along with maximize, minimize, and restore commands are accessible via the popup menu anchored to the window toolbar. The default set of commands is as follows
Close window - Ctrl+F4
Restore window - Ctrl+F5 or double-click on the title bar
Maximize window - Ctrl+F10 or double-click on the title bar
Go to the next MDI window - Ctrl+Tab
Go to the previous MDI window - Ctrl+Shift+Tab
Invoke popup menu - Ctrl+Space
The class mimics the API of the Prima::Window
class, and to some extent, Prima::Window and this page share the same information.
Properties
- borderIcons INTEGER
-
Manages window decorations, which are buttons on the title bar and the title bar itself. Can be 0 or a combination of the following
mbi::XXX
constants that are a superset of thebi::XXX
constants ( see "borderIcons" in Prima::Window ) and are interchangeable.mbi::SystemMenu - system menu button with an icon is shown mbi::Minimize - minimize button mbi::Maximize - maximize and restore buttons mbi::TitleBar - window title mbi::Close - close button mbi::All - all of the above
Default value:
mbi::All
- borderStyle INTEGER
-
One of the
bs::XXX
constants that define the window border style:bs::None - no border bs::Single - thin border bs::Dialog - thick border bs::Sizeable - thick border with interactive resize capabilities
The
bs::Sizeable
is a unique mode. If selected, the user can resize the window interactively. The other border styles disallow resizing and affect the border width and design only.Default value:
bs::Sizeable
- client OBJECT
-
Selects the client widget at run time. When changing the client, the old client's children are not reparented to the new client. The property cannot be used to set the client during the MDI window creation; use the
clientClass
andclientProfile
properties instead.When setting a new client object, note that it has to be named
MDIClient
, and that the window will be automatically destroyed after the client is destroyed. - clientClass STRING
-
Assigns the client widget class.
Create-only property.
Default value:
Prima::Widget
- clientProfile HASH
-
Assigns a hash of properties passed to the client during the creation.
Create-only property.
- dragMode SCALAR
-
A three-state variable that manages the visual feedback style when the user moves or resizes a window. If 1, the window is moved or resized simultaneously with the user's mouse or keyboard actions. If 0, a marquee rectangle is drawn, which is moved or resized as the user sends the commands; the window is only positioned and/or resized after the dragging session is successfully finished. If
undef
, the system-dependant dragging style is used. ( See "get_system_value" in Prima::Application ).The dragging session can be aborted by hitting the Esc key or calling the
sizemove_cancel
method.Default value:
undef
. - icon HANDLE
-
Selects a custom image to be drawn in the left corner of the toolbar. If 0, the default image ( menu button icon ) is drawn.
Default value: 0
- iconMin HANDLE
-
Selects the minimized button image in the normal state.
- iconMax HANDLE
-
Selects the maximized button image in the normal state.
- iconClose HANDLE
-
Selects the close button image in the normal state.
- iconRestore HANDLE
-
Selects the restore button image in the normal state.
- iconMinPressed HANDLE
-
Selects the minimize button image in the pressed state.
- iconMaxPressed HANDLE
-
Selects the maximize button image in the pressed state.
- iconClosePressed HANDLE
-
Selects the close button image in the pressed state.
- iconRestorePressed HANDLE
-
Selects the restore button image in the pressed state.
- tileable BOOLEAN
-
Selects whether the window is allowed to participate in cascading and tiling auto-arrangements, performed correspondingly by the
cascade
andtile
methods. If 0, the window position is not affected by these methods.Default value: 1
- titleHeight INTEGER
-
Selects the height of the title bar in pixels. If 0, the default system value is used.
Default value: 0
- windowState STATE
-
A three-state property that manages the state of a window. STATE can be one of three
ws::XXX
constants:ws::Normal ws::Minimized ws::Maximized
The property can be changed either by an explicit set-mode call or by the user. In either case, a
WindowState
notification is triggered.The property has three convenience wrappers:
maximize()
,minimize()
, andrestore()
.The
ws::Fullscreen
constant is not supported, and there's no correspondingfullscreen()
method.Default value:
ws::Normal
See also:
WindowState
Methods
- arrange_icons
-
Arranges geometrically the minimized sibling MDI windows.
- cascade
-
Arranges sibling MDI windows so they form a cascade-like structure: the lowest window is expanded to the full owner window inferior rectangle, the next window occupies the inferior rectangle of the first window, etc.
Only windows with the
tileable
property set to 1 are arranged. - client2frame X1, Y1, X2, Y2
-
Returns a rectangle that the window would occupy if its client rectangle is assigned to the X1, Y1, X2, Y2 rectangle.
- frame2client X1, Y1, X2, Y2
-
Returns a rectangle that the window client would occupy if the window rectangle is assigned to the X1, Y1, X2, Y2 rectangle.
- get_client_rect [ WIDTH, HEIGHT ]
-
Returns a rectangle in the window coordinate system that the client would occupy if the window extensions are WIDTH and HEIGHT. If WIDTH and HEIGHT are undefined, the current window size is used.
- keyMove
-
Initiates window moving session, navigated by the keyboard.
- keySize
-
Initiates window resizing session, navigated by the keyboard.
- mdis
-
Returns an array of sibling MDI windows.
- maximize
-
Maximizes the window. A shortcut for
windowState(ws::Maximized)
. - minimize
-
Minimizes the window. A shortcut for
windowState(ws::Minimized)
. - post_action STRING
-
Posts an action to the window; the action is deferred and executed in the next message loop. This is used to avoid unnecessary state checks when the action-executing code returns. The current implementation accepts the following string commands:
min
,max
,restore
,close
. - repaint_title [ STRING =
title
] -
Invalidates the part of the title bar corresponding to the STRING, which can be one of the following:
left - redraws the menu button right - redraws minimize, maximize, and close buttons title - redraws the title
- restore
-
Restores the window to the normal state from the minimized or maximized state. A shortcut for
windowState(ws::Normal)
. - sizemove_cancel
-
Cancels active moving or resizing session and returns the window to the previous state
- tile
-
Arranges sibling MDI windows so they form a grid-like structure where all windows occupy equal space, if possible.
Only windows with the
tileable
property set to 1 are processed. - xy2part X, Y
-
Maps a point in the (X,Y) coordinates into a string corresponding to the part of the window: title bar, button, or a part of the border. The latter can be returned only if
borderStyle
is set tobs::Sizeable
. The possible return values are:border - window border; the window is not sizeable client - client widget caption - title bar; the window is not movable title - title bar; the window is movable close - close button min - minimize button max - maximize button restore - restore button menu - menu button desktop - the point does not belong to the window
In addition, if the window is sizeable, the following constants can be returned, indicating the part of the border:
SizeN - upper side SizeS - lower side SizeW - left side SizeE - right side SizeSW - lower left corner SizeNW - upper left corner SizeSE - lower right corner SizeNE - upper right corner
Events
- Activate
-
Triggered when the user activates the window. The activation mark usually resides on the window that has the keyboard focus.
The module does not provide a dedicated activation function; the
select()
call can be used for this. - Deactivate
-
Triggered when the user deactivates the window. A window is usually marked inactive when it contains no keyboard focus.
The module does not provide a dedicated de-activation function; the
deselect()
call can be used instead. - WindowState STATE
-
Triggered when the window state is changed, either by an explicit
windowState()
call or by the user. STATE is the new window state, one of threews::XXX
constants.
Prima::MDIMethods
Methods
The package contains methods for MDI window owners. Add Prima::MDIMethods
as a base to your class to inherit this functionality if neither Prima::MDIOwner
nor Prima::MDIWindowOwner
suit your needs.
- mdi_activate
-
Repaints window titles in all children MDI windows.
- mdis
-
Returns an array of children MDI windows.
- arrange_icons
-
The same as
Prima::MDI::arrange_icons
. - cascade
-
The same as
Prima::MDI::cascade
. - tile
-
The same as
Prima::MDI::tile
.
Prima::MDIOwner
A predeclared descendant class derived from Prima::Widget
and Prima::MDIMethods
.
Prima::MDIWindowOwner
A pre-declared descendant class derived from Prima::Window
and Prima::MDIMethods
.
AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>.
SEE ALSderived from
Prima, Prima::Widget, Prima::Window, Prima::DockManager, examples/mdi.pl