Prima::MDI(3)
β¨ bestie, youβve landed on Prima::MDI(3) β a page from the User Contributed Perl Documentation π
π NAME π
Prima::MDI - top-level window emulation π
π¦ DESCRIPTION π¦
okay so MDI stands for Multiple Document Interface, and itβs a Microsoft Windows user interface vibe: you get multiple non-top-level windows that belong to an application window. The module contains classes that give you similar functionality; these sub-window widgets do a set of operations just like the real top-level windows do β iconize, maximize, cascade, etc. β¨
The basic classes you need to use the MDI are Prima::MDIOwner and Prima::MDI, which are, correspondingly, the sub-window owner class and the sub-window class. π«Ά Prima::MDIWindowOwner is the same as Prima::MDIOwner but itβs a Prima::Window descendant: both owner classes are different only in the class theyβre derived from. Their second ascendant is the Prima::MDIMethods package, and thatβs where all the owner class functionality lives. π
Usage of Prima::MDI extends beyond the multi-document paradigm, fr fr. 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;
π Properties π
Okay bestie, these are the knobs and dials on your MDI subwindow. Each one's got a type in ALL CAPS so you know what to feed it β¨
borderIconsINTEGER β controls the window decorations, meaning the buttons on the title bar and the title bar itself. Set it to0, or to any combo of thembi::XXXconstants β and jsyk those are a superset of thebi::XXXconstants (peep"borderIcons" in Prima::Window) and totally interchangeable with them:
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 π
borderStyleINTEGER β one of thebs::XXXconstants, which decide the whole border vibe:
bs::None - no border
bs::Single - thin border
bs::Dialog - thick border
bs::Sizeable - thick border with interactive resize capabilities
bs::Sizeable is the special one β it's a unique mode, fr. Pick it and the user can resize the window interactively with their mouse. The other border styles say no thank you to resizing, and only mess with the border width and design.
Default value: bs::Sizeable π¦
clientOBJECT β picks the client widget at run time. Heads up though: when you swap the client, the old client's children do not get reparented to the new one (rude, but that's the rules). Also you can't use this property to set the client while the MDI window is being created β useclientClassandclientProfilefor that instead.
And when you're setting a new client object, note that it has to be named MDIClient, and that the window gets automatically destroyed after the client is destroyed. π
clientClassSTRING β assigns the client widget class.
Create-only property, iykyk.
Default value: Prima::Widget
clientProfileHASH β assigns a hash of properties that get passed to the client during creation.
Create-only property too π«Ά
dragModeSCALAR β a three-state variable managing the visual feedback style while the user moves or resizes a window:- If it's
1, the window moves or resizes simultaneously with the user's mouse or keyboard actions β live, no cap. - If it's
0, a marquee rectangle gets drawn instead, and that rectangle moves or resizes as the user sends commands; the window itself only gets positioned and/or resized after the dragging session finishes successfully. - If it's
undef, you get the system-dependent dragging style (see"get_system_value" in Prima::Application).
- If it's
The dragging session can be aborted by hitting the Esc key or by calling the sizemove_cancel method. π§
Default value: undef.
iconHANDLE β picks a custom image to draw in the left corner of the toolbar. If it's0, the default image (the menu button icon) gets drawn instead.
Default value: 0
iconMinHANDLE β the minimized button image, in the normal state.iconMaxHANDLE β the maximized button image, in the normal state.iconCloseHANDLE β the close button image, in the normal state.iconRestoreHANDLE β the restore button image, in the normal state.iconMinPressedHANDLE β the minimize button image, in the pressed state.iconMaxPressedHANDLE β the maximize button image, in the pressed state.iconClosePressedHANDLE β the close button image, in the pressed state. π₯iconRestorePressedHANDLE β the restore button image, in the pressed state.tileableBOOLEAN β decides whether the window is allowed to join in on the cascading and tiling auto-arrangements, which get performed by thecascadeandtilemethods respectively. If it's0, the window position is left completely alone by those methods. π
Default value: 1
titleHeightINTEGER β sets the height of the title bar in pixels. If it's0, the default system value is used.
Default value: 0
windowStateSTATE β a three-state property running the state of a window.STATEcan be one of threews::XXXconstants:
ws::Normal
ws::Minimized
ws::Maximized
You can change this either by an explicit set-mode call or by the user doing it β either way, a WindowState notification fires off. π£
There are three convenience wrappers, because we love a shortcut: maximize(), minimize(), and restore().
Heads up! Thews::Fullscreenconstant is not supported, and there's no correspondingfullscreen()method. Don't come for me, that's just how it is. π
Default value: ws::Normal
See also: WindowState
π Methods π
arrange_iconsβ arranges the minimized sibling MDI windows geometrically. Cute little tidy-up πcascadeβ arranges sibling MDI windows so they form a cascade-like structure: the lowest window gets expanded to the full owner window inferior rectangle, the next window takes the inferior rectangle of the first one, and so on down the line. Only windows withtileableset to1get arranged, bestie.client2frame X1, Y1, X2, Y2β returns the rectangle the window would occupy if its client rectangle were assigned to theX1, Y1, X2, Y2rectangle. Math but make it fashion β¨frame2client X1, Y1, X2, Y2β the opposite direction: returns the rectangle the window client would occupy if the window rectangle were assigned toX1, Y1, X2, Y2.get_client_rect [ WIDTH, HEIGHT ]β returns a rectangle in the window coordinate system that the client would occupy if the window extensions areWIDTHandHEIGHT. IfWIDTHandHEIGHTare undefined, it just uses the current window size. π¦keyMoveβ kicks off a window-moving session, navigated by the keyboard.keySizeβ kicks off a window-resizing session, navigated by the keyboard.mdisβ returns an array of sibling MDI windows. Your little window friend group πmaximizeβ maximizes the window. A shortcut forwindowState(ws::Maximized).minimizeβ minimizes the window. A shortcut forwindowState(ws::Minimized).post_action STRINGβ posts an action to the window, and that action is deferred and executed in the next message loop. Why? So you avoid unnecessary state checks while the action-executing code is returning, that's why. The current implementation accepts these string commands:"min","max","restore","close". πrepaint_title [ STRING = "title" ]β invalidates the part of the title bar matchingSTRING, which can be one of:
left - redraws the menu button
right - redraws minimize, maximize, and close buttons
title - redraws the title
restoreβ brings the window back to the normal state from minimized or maximized. A shortcut forwindowState(ws::Normal). πsizemove_cancelβ cancels the active moving or resizing session and returns the window to its previous state. The "nvm, undo" of window dragging πtileβ arranges sibling MDI windows into a grid-like structure where all windows get equal space, if that's possible. Only windows withtileableset to1get processed.xy2part X, Yβ maps a point in the(X,Y)coordinates to a string matching the part of the window: title bar, button, or a piece of the border. That last one can only come back to you ifborderStyleis set tobs::Sizeable. The possible return values:
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
Bonus round: if the window is sizeable, these constants can come back too, telling you which bit of the border you're on:
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. That activation mark usually sits on the window holding the keyboard focus, fyi. The module does not give you a dedicated activation function, so use theselect()call for this one. βDeactivateβ triggered when the user deactivates the window. A window is normally marked inactive when it's got no keyboard focus. Again, no dedicated de-activation function from this module β usedeselect()instead.WindowState STATEβ triggered when the window state changes, whether that's from an explicitwindowState()call or from the user.STATEis the new window state, one of the threews::XXXconstants. π
π SEE ALSO π
okay bestie, when you're done here and you're like "wait, what else do I need" β go check these out, they're the whole supporting cast π
Primaβ the main character, the base module everything else lives in β¨Prima::Widgetβ the generic widget situation, your go-to for the everyday stuff πPrima::Windowβ windows themselves, top-level and all that π¦Prima::DockManagerβ for the docking/dragging-around vibe, lowkey iconic πexamples/mdi.plβ the actual working example, fr fr go read it, it's giving tutorial πΈ
and that's the whole page, bestie!! π«Ά you made it to the end, I'm so proud ππ go write something iconic with your MDI windows, no cap π
little credit where it's due before you go: this page is from perl v5.42.0, dated 2024-08-20 β that's the source and version info, keeping it π― for you πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms