Prima::DockManager(3)
π Prima::DockManager π
okay so bestie, this is the Prima::DockManager(3) page from the User Contributed Perl Documentation π
and it is literally all about advanced dockable widgets. it's giving main-character GUI energy, no cap.
πΈ NAME πΈ
Prima::DockManager β advanced dockable widgets. periodt.
β¨ DESCRIPTION β¨
Prima::DockManager contains classes that implement additional functionality in the dockable widgets paradigm. π«Ά
The module introduces two new dockable widget classes:
Prima::DockManager::Panelbarβ a general-purpose dockable container for variable-sized widgets.Prima::DockManager::Toolbarβ a dockable container for fixed-size command widgets, mostly push buttons.
The command widgets nested in a toolbar can also be docked. π
The Prima::DockManager class is application-oriented in a way that a single of it is needed. It is derived from Prima::Component and therefore is never visualized. The class instance is stored in the instance property in all module classes to serve as a docking hierarchy root. Through the document, the instance term means the Prima::DockManager class instance. π
π«Ά real talk: the module by itself is not enough to make a docking-aware application work effectively. The reader is urged to look at the examples/dock.pl example code, which demonstrates the usage and capabilities of the module.
π Prima::DockManager::Toolbar π
A toolbar widget class. The toolbar has a dual nature; it can both dock itself and accept dockable widgets. As a dock, toolbars can host command widgets, mostly push buttons. π
The toolbar consists of two widgets. The external dockable widget is implemented in Prima::DockManager::Toolbar, and the internal dock in Prima::DockManager::ToolbarDocker classes. β¨
π Properties π
autoCloseBOOLEAN β selects the behavior of the toolbar when all of its command widgets are undocked. If1(default), the toolbar is automatically destroyed. If0it callsvisible(0). πchildDockerWIDGET β pointer to thePrima::DockManager::ToolbarDockerinstance.
See also Prima::DockManager::ToolbarDocker::parentDocker.
instanceINSTANCE βPrima::DockManagerinstance, the docking hierarchy root. π
π¦ Prima::DockManager::ToolbarDocker π¦
An internal class, implements the dock widget for command widgets, and a client in a dockable toolbar, a Prima::LinearDockerShuttle descendant. When its size is changed due to an eventual rearrangement of its docked widgets, also resizes the toolbar. π
π Properties π
instanceINSTANCE β thePrima::DockManagerinstance, the docking hierarchy root.parentDockerWIDGET β pointer to aPrima::DockManager::Toolbarinstance. When in the docked state, theparentDockervalue is always equal toowner.
See also Prima::DockManager::Toolbar::childDocker.
πΈ Methods πΈ
get_extentβ calculates the minimal rectangle that encloses all docked widgets and returns its extensions. πupdate_sizeβ called when the size is changed to resize the owner widget. If the toolbar is docked, the change might result in a change of its position or docking state.
π Prima::DockManager::Panelbar π
The class is derived from Prima::LinearDockerShuttle, and is different only in that the instance property is introduced, and the external shuttle can be resized interactively. π¦
The class is to be used as a simple host to sizeable widgets. The user can dispose of the panel bar by clicking the close button on the external shuttle. π
β Properties β
instanceINSTANCE β thePrima::DockManagerinstance, the docking hierarchy root.
π Prima::DockManager π
A binder class, contains a set of functions that groups toolbars, panels, and command widgets together under the docking hierarchy. π
The manager serves several purposes.
First, it is a command state holder: the command widgets, mostly buttons, usually are in an enabled or disabled state in different life stages of a program. The manager maintains the enabled/disabled state by assigning each command a unique scalar value, or a CLSID. The toolbars can be created using a set of command widgets, using these CLSIDs. The same is valid for the panels β although they do not host command widgets, the widgets that they do host can also be created indirectly via CLSID identifier. In addition to CLSIDs, the commands can be grouped by sections. Both CLSID and group descriptor scalars are defined by the programmer. π«Ά
Second, the create_manager method presents the standard launchpad interface that allows the rearranging of normally non-dockable command widgets, by presenting a full set of available commands to the user as icons. Dragging the icons to toolbars, dock widgets, or merely outside the configuration widget automatically creates the corresponding command widget. The notable moment here is that the command widgets are not required to know anything about dragging and docking; any Prima::Widget descendant can be used as a command widget. β¨
Third, it helps maintain the toolbars' and panels' visibility when the main window is hidden or restored. The windowState method hides or shows the toolbars and panels effectively. π
Fourth, it serves as a docking hierarchy root. All docking sessions start their protocol interactions at a Prima::DockManager object, which although does not provide docking capabilities itself (it is a Prima::Component descendant), redirects the docking requests to the children dock widgets. π
Finally, it provides several helper methods and notifications and enforces the use of the fingerprint property by all dockable widgets. The module defines the following fingerprint dmfp::XXX constants:
fdmp::Tools(0x0F000) β dock the command widgetsfdmp::Toolbar(0x10000) β dock the toolbarsfdmp::LaunchPad(0x20000) β allows widgets recycling
All this functionality is demonstrated in examples/dock.pl example. π«Ά
π Properties π
commandsHASH β a hash of boolean values with keys of CLSID scalars, where if the value is1, the command is available and is disabled otherwise. Changes to this property are reflected in the visible command widgets, which are enabled or disabled immediately. Also, theCommandChangenotification is triggered. π₯fingerprintINTEGER β the property is read-only, and always returns0xFFFFFFFF, to allow landing to all dockable widgets. In case a finer granulation is needed, the defaultfingerprintvalues of toolbars and panels can be reset. βinteractiveDragBOOLEAN β if1, the command widgets can be interactively dragged, created, and destroyed. This property is usually operated together with thecreate_managerlaunchpad widget. If0, the command widgets cannot be dragged.
Default value: 0
π§ Methods π§
activateβ brings to front all toolbars and panels. To be used inside a callback code of a main window, that has the toolbars and panels attached to:
onActivate => sub { $dock_manager-> activate }
auto_toolbar_nameβ returns a unique name for an automatically created toolbar, like"Toolbar1","Toolbar2"etc. πΈcommands_enableBOOLEAN, @CLSIDs β enables or disables commands from CLSIDs array. The changes are reflected in the visible command widgets, which are enabled or disabled immediately. Also, theCommandChangenotification is triggered. πcreate_managerOWNER, %PROFILE β inserts two widgets into OWNER with PROFILE parameters: a list box with command section groups, displayed as items, that usually correspond to the predefined toolbar names, and a notebook that displays the command icons. The notebook pages can be interactively selected by the list box navigation.
The icons dragged from the notebook, behave as dockable widgets: they can be landed on a toolbar, or any other dock widget, given it matches the fingerprint (by default dmfp::LaunchPad|dmfp::Toolbar|dmfp::Tools). dmfp::LaunchPad constant allows the recycling; if a widget is dragged back onto the notebook, it is destroyed.
Returns the two widgets created, the list box and the notebook.
PROFILE recognizes the following keys:
originX, Y β position where the widgets are to be inserted. The default value is0,0.sizeX, Y β size of the widget insertion area. By default, the widgets occupy all OWNER interiors.listboxProfilePROFILE β custom parameters passed to the list box.dockerProfilePROFILE β custom parameters passed to the notebook.
create_panelCLSID, %PROFILE β spawns a dockable panel from a previously registered CLSID. PROFILE recognizes the following keys:profileHASH β a hash of parameters passed to thenew()method of the panel widget class. Before passing it is merged with the set of parameters registered byregister_panel. Theprofilehash takes precedence.dockerProfileHASH β contains extra options passed to thePrima::DockManager::Panelbarwidget. Before passing it is merged with the set of parameters registered byregister_panel.
Note: The dock key contains a reference to the desired dock widget. If dock is set to undef, the panel is created in the non-docked state.
Example:
$dock_manager-> create_panel( $CLSID,
dockerProfile => { dock => $main_window }},
profile => { backColor => cl::Green });
create_toolOWNER, CLSID, X1, Y1, X2, Y2 β inserts a command widget, previously registered with a CLSID byregister_tool, into OWNER widget at X1 - Y2 coordinates. For automatic maintenance of enabled/disabled states of command widgets, OWNER is expected to be a toolbar. If it is not, the maintenance must be performed separately, for example, by reacting to theCommandChangeevent. πcreate_toolbar%PROFILE β creates a new toolbar of thePrima::DockManager::Toolbarclass. The following PROFILE options are recognized:autoCloseBOOLEAN β manages theautoCloseproperty of the toolbar.
The default value is 1 if the name option is set, and 0 otherwise.
dockDOCK β contains a reference to the desired DOCK widget. Ifundef, the toolbar is created in the non-docked state.dockerProfileHASH β parameters passed toPrima::DockManager::Toolbaras creation properties.
Note: The dock key contains a reference to the desired dock widget. If dock is set to undef, the panel is created in the non-docked state.
rect X1, Y1, X2, Y2β manages the geometry of thePrima::DockManager::ToolbarDockerinstance in the dock widget coordinates if itβs docked, or in the screen coordinates if itβs non-docked. πtoolbarProfile HASHβ parameters passed toPrima::DockManager::ToolbarDockeras properties. β¨vertical BOOLEANβ sets theverticalproperty of the toolbar. π¦visible BOOLEANβ selects the visibility state of the toolbar. πget_class CLSIDβ returns a class record hash registered under aCLSID, orundefif the class is not registered. The hash format contains these keys:class STRINGβ widget class.profile HASHβ creation parameters passed tonewwhen the corresponding widget is instantiated.tool BOOLEANβ if1, the class belongs to a control widget; if0, the class represents a panel client widget.lastUsedDock DOCKβ saved value of the last used dock widget.lastUsedRect X1, Y1, X2, Y2β saved coordinates of the widget.
panel_by_id CLSIDβ returns a reference to the panel widget represented by theCLSIDscalar, orundefif none is found. π«Άpanel_menuitems CALLBACKβ a helper function; maps all panel names into a structure ready to feed into thePrima::AbstractMenu::itemsproperty (seePrima::Menu). The action member of the menu item record is set to theCALLBACKscalar. πpanel_visible CLSID, BOOLEANβ sets the visibility of a panel referred to by theCLSIDscalar. IfVISIBLEis0, the panel is destroyed; if1, a new panel instance is created. πpanelsβ returns all visible panel widgets in an array. πΈpredefined_panels CLSID, DOCK, [ CLSID, DOCK, ... ]β accepts pairs of scalars, where each first item is a panelCLSIDand the second is the default dock widget. Checks for panel visibility and creates the panels that are not visible. The method is useful in program startup, when some panels have to be visible from the beginning. β¨predefined_toolbars @PROFILESβ accepts an array of hashes where each array item describes a toolbar and a default set of command widgets. Checks for toolbar visibility and creates the toolbars that are not visible. The method recognizes thesePROFILESoptions:dock DOCKβ the default dock widget.list ARRAYβ an array of CLSIDs corresponding to the command widgets to be inserted into the toolbar.name STRINGβ selects the toolbar name.origin X, Yβ selects the toolbar position relative to the dock ifdockis specified, or to the screen ifdockis not specified.
The method is useful in program startup, when some panels have to be visible from the beginning. π
register_panel CLSID, PROFILEβ registers a panel client class and set of parameters to be associated with aCLSIDscalar.PROFILEmust contain these keys:class STRINGβ client widget class.text STRINGβ a string of text displayed in the panel title bar.dockerProfile HASHβ a hash of parameters passed toPrima::DockManager::Panelbar.profileβ a hash of parameters passed to the client widget.
register_tool CLSID, PROFILEβ registers a control widget class and set of parameters to be associated with aCLSIDscalar.PROFILEmust contain these keys:class STRINGβ client widget class.profile HASHβ a hash of parameters passed to the control widget.
toolbar_by_name NAMEβ returns a reference to the toolbar ofNAME, orundefif none is found. π₯toolbar_menuitems CALLBACKβ a helper function; maps all toolbar names into a structure ready to feed into thePrima::AbstractMenu::itemsproperty (seePrima::Menu). The action member of the menu item record is set to theCALLBACKscalar. πtoolbar_visible TOOLBAR, BOOLEANβ sets the visibility of aTOOLBAR. IfVISIBLEis0, the toolbar is hidden; if1, it is shown. πtoolbarsβ returns all toolbar widgets in an array. π§windowState INTEGERβ mimics the interface ofPrima::Window::windowStateand maintains visibility of toolbars and panels. If the parameter isws::Minimized, the toolbars and panels are hidden. On any other parameter, these are shown. To be used inside callback code of a main window that has the toolbars and panels attached to:
onWindowState => sub { $dock_manager-> windowState( $_[1] ) }
β¨ Events β¨
Command CLSIDβ a generic event triggered by a command widget when the user activates it. It can also be called by other means.CLSIDis the widget identifier. π₯CommandChangeβ called when thecommandsproperty changes or thecommands_enablemethod is invoked. πPanelChangeβ triggered when a panel is created or destroyed by the user. πͺToolbarChangeβ triggered when a toolbar is created, shown, gets hidden, or destroyed by the user. π§¨
π Prima::DockManager::S::SpeedButton π
The package simplifies the creation of Prima::SpeedButton command widgets. π
β¨ Methods β¨
class IMAGE, CLSID, %PROFILEβ builds a hash with parameters ready to feed toPrima::DockManager::register_toolfor registering a combination of thePrima::SpeedButtonclass and thePROFILEparameters.IMAGEis the path to an image file, loaded and stored in the registration hash.IMAGEprovides an extended syntax for selecting the frame index if the image file is multiframed: the frame index is appended to the path name with the:character prefix. TheCLSIDscalar is not used but is returned so the method result can directly be passed into theregister_toolmethod. Returns two scalars:CLSIDand the registration hash. Example:
$dock_manager-> register_tool(
Prima::DockManager::S::SpeedButton::class( "myicon.gif:2",
q(CLSID::Logo), hint => 'Logo image' ));
π AUTHOR π
Dmitry Karasik, <dmitry@karasik.eu.org>. π«Ά
π SEE ALSO π
Prima, Prima::Widget, Prima::Docks, examples/dock.pl β go peek, bestie, iykyk. β¨
π this page came from perl v5.42.0, dated 2024-08-20, and itβs Prima::DockManager(3) β iconic, periodt. π
π¦ 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