# Copyright (c) 1990-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # =head1 NAME Tk::Widget - Base class of all widgets =for pm Tk/Widget.pm =for category Tk Generic Methods =head1 SYNOPSIS package Tk::Whatever; require Tk::Widget; @ISA = qw(Tk::Widget); Construct Tk::Widget 'Whatever'; sub Tk_cmd { \&Tk::whatever } S< >I<$widget>-EI(?I?) =head1 DESCRIPTION The B is an abstract base class for all Tk widgets. Generic methods available to all widgets include the methods based on core C mechanism and are used to retrieve information about windows managed by Tk. They can take any of a number of different forms, depending on the I. The legal forms are: =over 4 =item I<$widget>-EB?(I)? If I isn't specified, this method returns the name of the application (the name that may be used in B commands to communicate with the application). If I is specified, then the name of the application is changed to I. If the given name is already in use, then a suffix of the form ``B< #2>'' or ``B< #3>'' is appended in order to make the name unique. The method's result is the name actually chosen. I should not start with a capital letter. This will interfere with L processing, since names starting with capitals are assumed to be classes; as a result, Tk may not be able to find some options for the application. If sends have been disabled by deleting the B command, this command will reenable them and recreate the B command. =item I<$widget>-EB(I) Returns a decimal string giving the integer identifier for the atom whose name is I. If no atom exists with the name I then a new one is created. =item I<$widget>-EB(I) Returns the textual name for the atom whose integer identifier is I. This command is the inverse of the I<$widget>-EB command. It generates an error if no such atom exists. =item I<$widget>-EB( ?-nice? ); This command rings the bell on the display for I<$widget> and returns an empty string. The command uses the current bell-related settings for the display, which may be modified with programs such as B. If I<-nice> is not specified, this command also resets the screen saver for the screen. Some screen savers will ignore this, but others will reset so that the screen becomes visible again. =item I<$widget>-EB This command returns a list of strings suitable for printing detailing binding information for a widget. It prints a widget's bindtags. For each binding tag it prints all the bindings, comprised of the event descriptor and the callback. Callback arguments are printed, and B objects are expanded. =item I<$widget>-EB?(?-recurse => 1?,I<-option> => I?)? This method Bs a B<-cursor> option for I<$widget> and (if B<-recurse => 1> is specified) all its descendants. The cursor to be set may be passed as S => I> or defaults to 'watch'. Additional B options are applied to I<$widget> only. It also adds a special tag B<'Busy'> to the B of the widgets so configured so that B, B, B and B events are ignored (with press events generating a call to B). It then acquires a local B for I<$widget>. The state of the widgets and the grab is restored by a call to I<$widget>-EB. =item I<$widget>-EB( ?-x => I?, ?-y => I?, ?-height => I? ); Sets and queries the caret location for the display of the specified Tk window window. The caret is the per-display cursor location used for indicating global focus (e.g. to comply with Microsoft Accessibility guidelines), as well as for location of the over-the-spot XIM (X Input Methods) or Windows IME windows. If no options are specified, the last values used for setting the caret are return in option-value pair format. -x and -y represent window-relative coordinates, and -height is the height of the current cursor location, or the height of the specified window if none is given. =item I<$widget>-EB Returns a decimal string giving the number of cells in the color map for I<$widget>. =item I<$widget>-EB I<$widget->>B Returns a list containing all the children of $widget. The list is in stacking order, with the lowest window first. Top-level windows are returned as children of their logical parents. =item I<$widget>-EB Returns the class name for I<$widget>. =item I<$widget>-EB Returns 1 if the colormap for I<$widget> is known to be full, 0 otherwise. The colormap for a window is ``known'' to be full if the last attempt to allocate a new color on that window failed and this application hasn't freed any colors in the colormap since the failed allocation. =item I<$widget>-EB Used to perform delegated option configuration for a mega-widget. Returns, in Tk::Derived::ConfigSpecs notation (see L), all possible options for a widget. For example, $s = $self->Scale; $self->ConfigSpecs( $s->ConfigSpecs, .... more ConfigSpecs specifications ); returns a hash of all Tk::Scale options, delegated to $s - e.g. some representative examples: -bigincrement => [$s, bigIncrement, BigIncrement, 0, 0] -digits => [$s, digits, Digits, 0, 0] -sliderlength => [$s, sliderLength, SliderLength, 10m, 30] -troughcolor => [$s, troughColor, Background, #c3c3c3, #c3c3c3] This provides an easy means of populating a mega-widget's ConfigSpecs with initializers. =item I<$widget>-EB(I) Returns the window containing the point given by I and I. I and I are specified in screen units (i.e. any form acceptable to B) in the coordinate system of the root window (if a virtual-root window manager is in use then the coordinate system of the virtual root window is used). If no window in this application contains the point then an empty string is returned. In selecting the containing window, children are given higher priority than parents and among siblings the highest one in the stacking order is chosen. =item I<$widget>-EB Returns a decimal string giving the depth of I<$widget> (number of bits per pixel). =item I<$widget>-EB This command deletes the window related to I<$widget>, plus all its descendants. If all the B are deleted then the entire application will be destroyed. The perl object I<$widget> continues to exist while references to it still exist, e.g. until variable goes out of scope. However any attempt to use Tk methods on the object will fail. B(I<$widget>) will return false on such objects. Note however that while a window exists for I<$widget> the perl object is maintained (due to "references" in perl/Tk internals) even though original variables may have gone out of scope. (Normally this is intuitive.) =item B(I<$widget>) Returns 1 if there exists a window for I<$widget>, 0 if no such window exists. =item I<$widget>-EB(I