NAME
Gtk2::Ex::NoShrink -- non-shrinking container widget
SYNOPSIS
use Gtk2::Ex::NoShrink;
my $noshrink = Gtk2::Ex::NoShrink->new;
$noshrink->add ($my_child_widget);
WIDGET HIERARCHY
Gtk2::Ex::NoShrink
is a subclass of Gtk2::Bin
.
Gtk2::Widget
Gtk2::Container
Gtk2::Bin
Gtk2::Ex::NoShrink
DESCRIPTION
A Gtk2::Ex::NoShrink
container widget holds a single child widget and imposes a "no shrink" policy on its requested size. The child can grow, but any request to shrink is ignored.
When the child requests a size the NoShrink sets that as its own desired size, ie. the size it requests from its own parent in turn. But if the child later changes its request asking to be smaller, the NoShrink stays at the previous larger size, thus keeping the child's largest-ever request. This largest size is maintained separately for width and for height.
Requested sizes are of course just that: only requests. It's a matter for the NoShrink's parent how much space is actually allocated. In any case the NoShink gives its child the full actual allocated space, less the usual container border-width
amount (a Gtk2::Container
property).
FUNCTIONS
Gtk2::Ex::NoShrink->new (key=>value,...)
-
Create and return a new
Gtk2::Ex::NoShrink
container widget. Optional key/value pairs can set initial properties, as perGlib::Object->new
.my $noshrink = Gtk2::Ex::NoShrink->new;
The child widget can be set with the usual container
add
method,$noshrink->add ($my_child_widget);
Or with the usual
child
pseudo-property, either at creation time or later,my $noshrink = Gtk2::Ex::NoShrink->new (child => $my_child_widget);
PROPERTIES
minimum-width
(integer, default -1)minimum-height
(integer, default -1)-
The currently accumulated minimum width and height to impose on the size request made by the child. These are maintained as the largest width and height requested from the child so far, or -1 for no particular size requested in that direction so far.
Both sizes are for the child's space. If the
Gtk2::Container
border-width
property is set then that's added on top of these for the size requested in turn by the NoShrink.These minimums can be set initially to begin at a particular size, for example
my $noshrink = Gtk2::Ex::NoShrink->new (minimum_width => 30, minimum_height => 20);
Or they can be reduced later to reset the size. A setting of -1 means to go right down to the child's current requested size. This is good if the nature of the child's content has changed,
$noshring->set('minimum-width', -1); # reset to child size
Or a particular size in pixels can be set, to get the child's size or that new size, whichever is larger.
These minimum size properties are unaffected by any removal of the child widget or re-add of a new child. If a new widget has a completely different nature then you may want to reset both dimensions to start again from its new sizes.
shrink-width-factor
(float, default 0)shrink-height-factor
(float, default 0)-
If non-zero then these values are factors representing a point at which the NoShrink will in fact shrink to match the child's size.
If the child asks for a width which is a factor
shrink-width-factor
(or more) smaller than the existingminimum-width
imposed, then theNoShrink
will reset theminimum-width
to the child's request. Likewise likewiseshrink-height-factor
on the height.Suppose for instance
shrink-width-factor
is 2.0 and the NoShrink has over the course of successive child size requests grown to 300 pixels wide. If the child then asks to be 100 pixels the NoShrink will obey that, because it's a shrinkage by a factor of more than 2.0 times. The newminimum-width
becomes 100.These factors allow small shrinks to be ignored, but follow large ones. This can be good if the child might grow to a silly size displaying wild data for a time, and you'd like it to shrink back when normality is restored.
The usual border-width
property from Gtk2::Container
is accepted, it leaves a border of that many pixels around the child in the NoShrink
container's allocated space. The default border-width
is 0, giving the child all the allocated space.
HOME PAGE
http://www.geocities.com/user42_kevin/gtk2-ex-noshrink/index.html
LICENSE
Gtk2::Ex::NoShrink is Copyright 2007, 2008 Kevin Ryde
Gtk2::Ex::NoShrink is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Gtk2::Ex::NoShrink is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Gtk2::Ex::NoShrink. If not, see <http://www.gnu.org/licenses/>.