Tk::IDEpanedwindow - Subclass of Tk::Panedwindow to Control Pane Resize Behavior


    use Tk::IDEpanedwindow;

    # Create panedwindow (Just like Tk::Panedwindow)
    $panedwidnow = $widget->IDEpanedwindow( ? options ? );

    # Pack the widget
    $panedwidnow->pack(qw/-side top -expand yes -fill both /);

    # Create two frames to insert
    my $label1 = $panedwidnow->Label(-text => "This is the\nleft side", -background => 'yellow');
    my $Frame2 = $panedwidnow->Frame();
    # Insert the frames, with expand factors = 1 (both frames will grow/shrink with the size
    #       of the window)
    $pwH->add($label1, -expandfactor => 1, $Frame2, -expandfactor => 1);


This is a subclass of the Tk::Panedwindow widget that adds a expandfactors option that controls how the paned-windows are resized when the overall widget is resized.

The parent class Tk::Panedwindow only changes the last pane when the entire widget is resized. Using the -expandfactors option of this widget, you can control how each paned-window is resized when the overall widget is resized.

Note: The idea for the -expandfactors option is borrowed from the TCL/TK widget TixPanedWindow.


In addition to the options from the parent class Tk::Panedwindow, this widget provides the following options:


Array ref of expand factors to use for each pane in the widget.

Each Expand Factor must be a non-negative number. The default value is 0. The expand/shrink factor is used to calculate how much each pane should grow or shrink when the size of the PanedWindow main window is changed. When the main window expands/shrinks by n pixels, then pane i will grow/shrink by about n * factor(i) / summation(factors), where factor(i) is the expand/shrink factor of pane i and summation(factors) is the summation of the expand/shrink factors of all the panes. If summation(factors) is 0.0, however, only the last visible pane will be grown or shrunk.

Note: The behavior of this -expandfactors option is borrowed from the TCL/TK widget TixPanedWindow.


Array ref of fractional (i.e. less than one) sizes left over from the last resize of the pane frames.

Even though frame sizes are number of pixels (integers), we keep track of the fractional part of the calculated frame sizes from resize-event to resize-event. This keeps the sizes of the frames in proportion to each other better than throwing away the fractional part would.



Array ref of Tk::Widget objects in each frame of the panedwindow.



Over-ridden add method add a new widget to the collection managed by the Tk::IDEpanedwindow.

This method adds a -expandfactor option to the normal options recognized by the parent Tk::Panedwindow.


   $widget->add(?window ...? ?option value ...?);


Over-ridden forget method to delete a widget from the paned-window.

This deletes the widget from our own slaves list before calling the parent method.




Gets (and optionally sets) the slaves attribute.


        my @slaves = $self->slaves();    # Get slaves
        $self->slaves(@slaves);          # Set slaves


Internal method to get / calculate the new widget Sizes (Width or height) of a panewindow widget, based on total pw size, widget sizes, and expand factors.

This is called when the size of the panedwindow widget changes.


   @newSizes = $self->_getNewSizes($newSize, $sizes);
        where:   $newSize:   Total new size of the panewindow widget
                               (Along the paned direction)
                 $sizes:     Array ref of old sizes (i.e. not yet adjusted
                                 for the new total-size) for each window
                                 managed by the panedwindow.


Method to adjust the sizes of each pane in the paned-window direction.


        where:   $newSizes:   Array ref of new sizes  for each window
                                 managed by the panedwindow.