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 size. The child can grow, but any request to shrink is ignored.

When the child requests a size the NoShrink sets that as the size it requests in turn from its parent. If the child later changes asks to be smaller, the NoShrink stays at the previous larger size, thus keeping the child's largest-ever request. A 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 provided. The NoShink always sets its child to the full allocated space, less the usual border-width (see Gtk2::Container) if that's set. As usual it's then a matter for the child what it does in a size perhaps bigger or perhaps smaller than what it said it wanted.

If a child is added but not shown (no $child->show) then it's treated as if there was no child. This is the same as other container classes do. For NoShrink it means a size request of the minimum-width by minimum-height, plus border-width, and nothing drawn.

FUNCTIONS

Gtk2::Ex::NoShrink->new (key=>value,...)

Create and return a new Gtk2::Ex::NoShrink container widget. Optional key/value pairs set initial properties per Glib::Object->new.

my $noshrink = Gtk2::Ex::NoShrink->new (border_width => 4);

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 0)
minimum-height (integer, default 0)

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 0 for no size requested in that direction so far.

Both sizes are for the child's space. Any border-width amount is added on top of these for the size requested in turn by the NoShrink to its parent.

These minimums can be set initially to begin at a particular size,

my $noshrink = Gtk2::Ex::NoShrink->new (minimum_width => 30,
                                        minimum_height => 20);

They can also be reduced later to reset the size. This results in the greater of the new value or the child's current requested size. Setting 0 for instance always goes to the child's current requested size. This is good if the nature of the child's content has changed,

$noshrink->set('minimum-width', 0);  # reset to child size

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 existing minimum-width imposed, then the NoShrink will reset the minimum-width to the child's request. Likewise shrink-height-factor on the height.

Suppose for instance shrink-width-factor is 2.0 and the NoShrink has over the course of successive child 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 more than 2.0 times. The new minimum-width becomes 100.

These factors allow small shrinks to be ignored but large ones obeyed. This is good if the child might grow to a silly size when displaying wild data for a while and you'd like it to shrink back when normality is restored.

The usual border-width property from Gtk2::Container is followed. It leaves a border of that many pixels around the child in the NoShrink container's allocated space. Currently nothing is drawn in the border. The default border-width is 0, giving the child all the allocated space.

SEE ALSO

Gtk2::Container, Gtk2::Bin

HOME PAGE

http://user42.tuxfamily.org/gtk2-ex-noshrink/index.html

LICENSE

Gtk2-Ex-NoShrink is Copyright 2007, 2008, 2009, 2010 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/.