The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tk::Multi::Toplevel - Toplevel MultiManager

SYNOPSIS

 use Tk::Multi::Toplevel ;

 my $mw = MainWindow-> new ;
 
 my $p = $mw->MultiTop();

 # If Multi::Toplevel is the only Tk window of your application
 $mw -> withdraw ; # hide the main window
 # destroy the main window when close is called
 $p -> OnDestroy(sub{$mw->destroy});

 # add a 'bar' menu with a 'foo' button on the menu bar
 $p->menuCommand(name => 'foo', menu => 'bar', 
                 sub => sub{warn "invoked  bar->foo\n";});

 # add a menu button on the 'File' menu
 $p->add(
         'command', 
         -label => 'baz', 
         -command => sub {warn "invoked  File->baz\n";}
        );

DESCRIPTION

This class is a Tk::Multi::Manager packed in a Toplevel window. It features also :

  • 'File->show internal...' button to invoke an Object Scanner (See Tk::ObjScanner)

  • A facility to manage user menus with sorted buttons

  • A help facility based on Tk::Pod

Users menus

By default the Multi::Toplevel widget comes with 3 menubuttons:

  • 'File' for the main widget commands

  • 'windows' to manage the Multi slaves widget

  • 'Help'

The user can also add its own menus and menu buttons to the main menubar. When needed the user can call the menuCommand method to add a new menu button (and as new menu if necessary) . Then the user can remove the menu button with the menuRemove command.

For instance, if the user call :

 $widget->->menuCommand(name => 'foo', menu => 'example', 
   sub => \&a_sub);
  

The menubar will feature a new 'example' menu with a 'foo' button.

Then if the user call :

 $widget->->menuCommand(name => 'bar', menu => 'example', 
   sub => \&a_sub);

The menubar will feature a new 'bar' button in the 'example' menu. Note that menu buttons are sorted alphabetically.

Then if the user call :

 $widget->menuRemove(name => 'bar', menu => 'example');

The bar button will be removed from the menu bar.

Constructor configuration options

manager

Object reference that will be scanned by the ObjScanner. Usefull when you want to debug the object that actually use the Multi::TopLevel. By default the ObjScanner will scan the Multi::TopLevel object.

podName

This the name of the pod file that will be displayed with the 'Help'->'global' button. This should be set to the pod file name of the class or the application using this widget.

By default, the help button will display the pod file of Multi::TopLevel.

podSection

This the section of the pod file that will be displayed with the 'Help'->'global' button.

By default, the help button will display the 'DESCRIPTION' pod section.

Advertised widgets

  • fileMenu: 'File' Tk::Menu (on the left of the menu bar)

  • menubar : the Tk::Frame containing the menu buttons

  • multiMgr: The Tk::Multi::Manager

Users menus are also advertised (See below)

delegated methods

  • newSlave, hide, show, destroySlave : To the Tk::Multi::Manager

  • add, delete, insert : To the 'File' Tk::Menu

Methods

Parameters are :

  • name: button_name

  • menu: menu_name

  • command: subref

Will add the 'button_name' button in the 'menu_name' menu to invoke the sub ref. If necessary, the 'menu_name' menu will be created.

  • name: button_name

  • menu: menu_name

Will remove the 'button_name' button from the 'menu_name' menu. If no buttons are left, the 'menu_name' menu will be removed from the menu bar.

showHelp (...)

Parameters are :

  • pod: pod file name (optional, defaults to the file name passed to the constructor or to 'Tk::Multi::Toplevel')

  • section: pod_section (optional, defaults to the sectione name passed to the constructor or to 'DESCRIPTION')

Will invoke the Tk::Pod documentation widget of the specified pod file and pod section.

BUGS

Users menu does not fold when you insert a lot of buttons.

Tk::Pod 0.10 does not display the specified section. Use a later version or this patch (http://www.xray.mpe.mpg.de/mailing-lists/ptk/1998-11/msg00033.html)

AUTHOR

Dominique Dumont, domi@komarr.grenoble.hp.com

Copyright (c) 1997-1998,2004 Dominique Dumont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

perl(1), Tk(3), Tk::Multi::Manager(3), Tk::Pod(3), Tk::ObjScanner(3), Tk::mega(3)