-
-
21 Jan 2020 03:51:59 UTC
- Distribution: Fl
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (86 / 0 / 0)
- Kwalitee
Bus factor: 1- License: artistic_2
- Perl: v5.8.1
- Activity
24 month- Tools
- Download (122.46KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- none
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Fl::Window - Window Container for Widgets
Synopsis
use Fl; my $window = Fl::Window->new(350, 500, 'Hello, World!'); $window->show(); Fl::run();
Description
This widget produces an actual window.
This can either be a main window, with a border and title and all the window management controls, or a "subwindow" inside a window. This is controlled by whether or not the window has a
parent()
.Once you create a window, you usually add children Fl::Widgets to it by using
<$window-
add($child)>> for each new widget. See Fl::Group for more information on how to add and remove children.There are several subclasses of Fl::Window that provide double-buffering, overlay, menu, and OpenGL support.
The window's callback is done if the user tries to close a window using the window manager and Fl::modal() is zero or equal to the window. Fl::Window has a default callback that calls
<Fl::Window-
hide()>>.Methods
In addition to inheriting from Fl::Group, this widget also supports the following methods.
new(...)
The constructor creates a window of a given size and (optionally) position on screen. The upstream API has a few poorly designed options:
my $window_a = Fl::Window->new(300, 500);
This creates a window from the given size. You may also set the window's title like this:
my $window_b = Fl::Window->new(300, 500, 'Basic math');
If not provided, the window's title defaults to the filename of the current running script.
You'll notice that the above examples don't define an on screen position. The window manager is allowed to place the new window as it sees fit. To define a position yourself, use either:
my $window_c = Fl::Window->new(100, 150, 300, 500);
...or...
my $window_d = Fl::Window->new(100, 150, 300, 500, 'Math is singular');
In these examples, the new window is placed 100 pixels from the left and 150 pixels down from the top of the display area.
Again, the ($w, $h) form of the constructor creates a top-level window and asks the window manager to position the window. The ($x, $y, $w, $h) form of the constructor either creates a subwindow or a top-level window at the specified location ($x, $y), subject to window manager configuration. If you do not specify the position of the window, the window manager will pick a place to show the window or allow the user to pick a location. Use
position($x, $y)
orhotspot()
before callingshow()
to request a position on the screen. See Fl::Window-resize()/resize(...)> for more details on positioning windows.Top-level windows initially have
visible()
set to 0 and <parent()> set toundef
. Subwindows initially havevisible()
set to 1 andparent()
set to the parent window pointer.Fl::Widget->box() defaults to
FL_FLAT_BOX
. If you plan to completely fill the window with children widgets you should change this toFL_NO_BOX
. If you turn the window border off you may want to change this toFL_UP_BOX
.The destructor also deletes all children. This allows a whole tree to be deleted at once, without having to keep a pointer to all children in the user code.
show()
Puts the window on the screen.
On X, this usually has the side effect of opening the display.
If the window is already shown, it is restored and raised to the top. This is really convenient because your program can call
show()
at any time, even if the window is already up. It also means thatshow()
serves the purpose ofraise()
in other toolkits.shown()
Returns non-zero if
show()
has been called but nothide()
.You can tell if a window is iconified with
( $w-
shown() && !$w->visible() )>.hide()
Removes the window from the screen.
If the window is already hidden or has not been hsown then this does nothing and is harmless.
LICENSE
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Sanko Robinson <sanko@cpan.org>
Module Install Instructions
To install Fl, copy and paste the appropriate command in to your terminal.
cpanm Fl
perl -MCPAN -e shell install Fl
For more information on module installation, please visit the detailed CPAN module installation guide.