Book HomeMastering Perl/TkSearch this book

13.19. Widget Mapping and Layering

Widgets exist in one of two basic states: unmapped or mapped. When a widget is first instantiated (created), it is unmapped, meaning that it exists but has not yet been displayed. Once it is managed by a geometry manager, a widget becomes mapped: its size and position on the display have been calculated, and it has been rendered on the display.

All geometry managers have a "forget" method that removes a widget from the display without destroying it. If the widget is remanaged it reappears on the display exactly where it used to be.

You can also unceremoniously map a widget without regard to its geometry manager:

 $widget->MapWindow;

Doing this may confuse the geometry manager (pack, grid, place, form) that thinks it is managing the widget.

Similarly unceremoniously, you can yank a widget from the display:

$widget->UnmapWindow;

This unmaps the widget. It does for any widget what $widget->withdraw does for Toplevel widgets. It might confuse the geometry manager that thinks it is managing the widget.

Widgets have a stacking order (see Chapter 2, "Geometry Management" and Chapter 23, "Plethora of pTk Potpourri" for details), which you can raise or lower using the raise and lower methods.

 $widget->raise(?aboveThis?);

If the aboveThis argument is omitted, the command raises $widget so it is above all its siblings in the stacking order (it will not be obscured by any siblings and will obscure any siblings that overlap it). If aboveThis is specified, it must be a widget reference of a window that is either a sibling of $widget or the descendant of a sibling of $widget. In this case, the raise command will insert $widget into the stacking order just above aboveThis (or the ancestor of aboveThis that is a sibling of $widget); this could end up either raising or lowering $widget.

 $widget->lower(?belowThis?);

If the belowThis argument is omitted, the command lowers $widget so it is below all its siblings in the stacking order (it will be obscured by any siblings that overlap it and will not obscure any siblings). If belowThis is specified, it must be the pathname of a window that is either a sibling of $widget or the descendant of a sibling of $widget. In this case, the lower command will insert $widget into the stacking order just below belowThis (or the ancestor of belowThis that is a sibling of $widget); this could end up either raising or lowering $widget.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.