Tk::DynaTabFrame - A NoteBook widget with orientable, dynamically stacking tabs |
Tk::DynaTabFrame - A NoteBook widget with orientable, dynamically stacking tabs
use Tk::DynaTabFrame;
$TabbedFrame = $widget->DynaTabFrame ( -font => $font, -raisecmd => \&raise_callback, -raisecolor => 'green', -tabclose => sub { my ($dtf, $caption) = @_; $dtf->delete($caption); }, -tabcolor => 'yellow', -tabcurve => 2, -tablock => undef, -tabpadx => 5, -tabpady => 5, -tabrotate => 1, -tabside => 'nw', -tabscroll => undef, -textalign => 1, -tiptime => 600, -tipcolor => 'yellow', [normal frame options...], );
[ NOTE: This module was based on Tk::TabFrame... but you probably can't tell it anymore ]
A notebook widget with orientable, dynamically rearranging tabs. When the containing window is resized, the tabs will either stack or unstack as needed to fit the enclosing widget's width(height). Likewise, when tabs are added or removed, the tabs will stack/unstack as needed.
Tabs may be placed either on the top (default), bottom, left, or right side of the widget, and may be aligned to either the left (default) or right edge for top or bottom tabs, or to the top or bottom edges for left or right tabs.
Tabs are added at the innermost row adjacent to the tabbed frame at the alignment edge, and automatically become the ``raised'' tab when added.
Separate -tabcolor and -raisecolor options may be specified for each tab. -tabcolor is used for the tab if it is not the raised tab, or if no -raisecolor is specified. -raisecolor is used when the tab is raised.
A tab can be raised by either clicking on the tab; by using left and right keyboard arrows to traverse the tabbing order; or programmatically via the raise() method.
If -tabrotate is enabled, when a tab in a row other than the innermost frame-adjacent row is raised, all rows are rotated inward, with the current frame-adjacent rows wrapping to the outside, until the raised row becomes the innermost frame adjacent row. Disabling -tabrotate will leave the raised tab in its current location (assuming the containing window has not been resized; see the -tablock option to lock down the tabs on resize events).
A small ``close'' button can be applied to the tabs via the -tabclose option. By default, clicking the close button will delete the tab and associated frame from the DynaTabFrame. If a coderef is supplied as the -tabclose value, then the coderef will be invoked instead.
Either text or images can be displayed in the tab, using either the -image or -label page options. A future release will permit both in a single tab. If neither is specified, then the page name value will be used.
A ``flash'' effect may be applied to a tab (i.e., switching between the defined background color and a flash color at a specified interval) using the flash() method. Flashing continues until either the deflash() method is called, the tab is raised manually or programmatically, or the specified flash duration expires.
A ``tabtip'' (aka balloon or tooltip) may be attached to each tab that is displayed when the mouse hovers over the tab. The number of millseconds between the mouse entering a tab, and the display of the tabtip is determined by the -tiptime option (default 450). The background color of the tabtips can be set by the -tipcolor option (default white). The text of each tabtip can be set, updated, or removed, either in the add() method, or via pageconfigure(), using the -tabtip option. Note that a the Tk::Balloon manpage widget is not created for the DynaTabFrame widget until a -tiptime, -tipcolor, or -tabtip is configured.
The widget takes all the options that a Frame does. In addition, it supports the following options:
'nw' (default) - tabs on top, aligned to the left edge 'ne' - tabs on top, aligned to the right edge 'sw' - tabs on bottom, aligned to the left edge 'se' - tabs on bottom, aligned to the right edge 'en' - tabs on right, aligned to the top edge 'es' - tabs on right, aligned to the bottom edge 'wn' - tabs on left, aligned to the top edge 'ws' - tabs on left, aligned to the bottom edge 'n' - same as 'nw' 's' - same as 'sw' 'e' - same as 'en' 'w' - same as 'wn'
Note: can only be set or changed prior to adding any pages; attempts to change the -tabside after pages have been added will be silently ignored.
The following methods may be used with a DynaTabFrame object in addition to standard methods.
Note that configuring the -tabtip option to undef
will remove the tabtip from the page.
Optional horizontal scrolled frames (ie, 'os') seem to cause some race conditions (Config events keep resizing the frame up, then down). Use mandatory scrollbars if you need horizontal scrollbars.
Support for rotated text in left or right side tabs is lacking, due to the lack of a consistent text rotation method in Perl/Tk. While the issue can be alleviated using the -textalign option, another possible solution may be either Tk::Win32RotLabel on Win32 platforms, or Tk::CanvasRottext for *nix platforms. Unfortunately, vertical text is less than aesthetically pleasing, and can consume a rather large vertical area; using images with attached balloons may be a preferable alternative.
As of v. 0.20, better compatibility with Tk::Notebook has been provided. However, DTF is not yet fully backward compatible, as some methods and options of the same name could not be changed from prior versions of DTF in order to preserve backward compatibility.
As of V 0.20, the maximum number of tab rows is 21. This arbitrary limit is imposed due to odd behavior when redrawing the tabs on a resize event. ``Pseudo'' tabs are used to provide the illusion of tabs embedded into a frame-spanning row. If these pseudotabs are destroyed and recreated during a resize event while the mouse button is still held down on the window resizer, the window will snap back to its original dimensions when the new pseudotabs are place()'d. The only solution seems to be to create a fixed number of pseudotabs at startup, and place() them as needed during the redraw. Eventually, a widget attribute may be added to specify the max number of rows to permit.
-tabclose and -tablock are mutually exclusive; if both are enabled, -tablock will be silently ignored.
Using Tk::Compound objects as tab images appears to cause sizing and layout issues due to the object not reporting its true full layout size; hence, they should be avoided.
Dean Arnold <darnold@presicient.com>
Portions of the POD derived from Tk::Notebook.
Initial code derived from Tk::TabFrame, included in Tk-DKW bundle by Damion K. Wilson.
Copyright(c)
2003-2005, Dean Arnold, Presicient Corp., USA. All rights reserved.
Portions Copyright(c)
1998-1999 Damion K. Wilson, all rights reserved.
This code and documentation may be distributed under the same conditions as Perl itself.
- added -tiptime, -tipcolor global attributes
- added -tabtip page option
- added -tabside
- added -image attribute to add()
to support images in tabs
- added -label attribute to add()
to support alternate text in tabs
- fixed -raisecolor behavior to revert color of prior raised tab
- fixed ``roaming'' tab connector frame
- code mods for performance
- added -tabcolor/-backpagecolor, -raisecolor widget level options
- added -raisecmd attribute to add()
to support event callback
- added some Tk::Notebook drop-in compatibility (pagecget(),
pageconfigure(), pages(), raised())
- POD enhancements
- added -textalign
- added -tabrotate
- added flash(), deflash()
- increased ConfigDebounce width threshold for ptk804.025beta
- added (simple) install test
- added programmatic raise button to demo app
- added flash()
- updated demo app to exersize arbitrary position removal
- fixed apparent timing issue with TabRemove and resizing that caused occasional phantom client entries
raised_name()
method/-raised_name property
to return caption of currently raised page
- fixed tab ordering on resize when raised tab gets moved to other than bottom row
- improve tab font behavior (use platform/application default when none specified)
- added tablock option
Tk::DynaTabFrame - A NoteBook widget with orientable, dynamically stacking tabs |