| 1 |
|
| 2 |
=head1 NAME |
| 3 |
|
| 4 |
Tk::DialogBox - create and manipulate a dialog screen. |
| 5 |
|
| 6 |
=for pm Tixish/DialogBox.pm |
| 7 |
|
| 8 |
=for category Tix Extensions |
| 9 |
|
| 10 |
=head1 SYNOPSIS |
| 11 |
|
| 12 |
use Tk::DialogBox |
| 13 |
... |
| 14 |
$d = $top->DialogBox(-title => "Title", -buttons => ["OK", "Cancel"]); |
| 15 |
$w = $d->add(Widget, args)->pack; |
| 16 |
... |
| 17 |
$button = $d->Show; |
| 18 |
|
| 19 |
=head1 DESCRIPTION |
| 20 |
|
| 21 |
B<DialogBox> is very similar to B<Dialog> except that it allows |
| 22 |
any widget in the top Frame. B<DialogBox> creates two |
| 23 |
Frames, I<top> and I<bottom>. The bottom Frame shows all the |
| 24 |
specified Buttons, lined up from left to right. The top Frame acts |
| 25 |
as a container for all other widgets that can be added with the |
| 26 |
B<add()> method. |
| 27 |
|
| 28 |
=head1 OPTIONS |
| 29 |
|
| 30 |
The options recognized by B<DialogBox> are as follows: |
| 31 |
|
| 32 |
=over 4 |
| 33 |
|
| 34 |
=item B<-title> |
| 35 |
|
| 36 |
Specify the title of the DialogBox. If this is not set, then the |
| 37 |
name of the program is used. |
| 38 |
|
| 39 |
=item B<-buttons> |
| 40 |
|
| 41 |
The button names to display in the bottom Frame. This is a reference |
| 42 |
to an array of strings containing the text to put on each |
| 43 |
Button. There is no default value for this. If you do not specify any |
| 44 |
button names, no Buttons are displayed. |
| 45 |
|
| 46 |
=item B<-default_button> |
| 47 |
|
| 48 |
Specifies the default Button that is considered invoked when user |
| 49 |
presses <Return> on the DialogBox. This Button is highlighted. If |
| 50 |
no default Button is specified, then the first element of the |
| 51 |
array whose reference is passed to the B<-buttons> option is used |
| 52 |
as the default. |
| 53 |
|
| 54 |
=item B<-cancel_button> |
| 55 |
|
| 56 |
Specifies the Button that is considered invoked when the user closes |
| 57 |
the DialogBox using the window manager's close button. If the |
| 58 |
B<-cancel_button> option is not given, and if there's only one button |
| 59 |
configured, then this button is also used as the cancel button. |
| 60 |
Otherwise no button is considered as the cancel button; in such a case |
| 61 |
B<Show> just returns C<undef> when the user closes the DialogBox. |
| 62 |
|
| 63 |
=item B<-command> |
| 64 |
|
| 65 |
A callback which is executed after invoking an action to close the |
| 66 |
DialogBox, but before restoring focus and grab information. The |
| 67 |
selected button is passed as the first argument. |
| 68 |
|
| 69 |
=item B<-focus> |
| 70 |
|
| 71 |
Specify the widget to receive the initial focus after popping up the |
| 72 |
DialogBox. By default the B<-default_button> widget receives the |
| 73 |
initial focus. |
| 74 |
|
| 75 |
=item B<-showcommand> |
| 76 |
|
| 77 |
A callback which is executed before displaying the DialogBox and |
| 78 |
waiting for user input. The DialogBox itself is passed as the first |
| 79 |
argument. |
| 80 |
|
| 81 |
=back |
| 82 |
|
| 83 |
=head1 METHODS |
| 84 |
|
| 85 |
B<DialogBox> supports only two methods as of now: |
| 86 |
|
| 87 |
=over 4 |
| 88 |
|
| 89 |
=item B<add(>I<widget>, I<options>B<)> |
| 90 |
|
| 91 |
Add the widget indicated by I<widget>. I<Widget> can be the name |
| 92 |
of any Tk widget (standard or contributed). I<options> are the |
| 93 |
options that the widget accepts. The widget is advertized as a |
| 94 |
subwidget of B<DialogBox>. The name of I<widget> is |
| 95 |
lower-cased and used as the advertised name. If multiple instances of |
| 96 |
I<widget> are created in the B<DialogBox>, then only the last one gets |
| 97 |
the advertised name. B<add()> does not automatically B<pack()> or |
| 98 |
B<grid()> I<widget> into the B<DialogBox>. |
| 99 |
|
| 100 |
=item B<Show(>I<?-global?>B<)> |
| 101 |
|
| 102 |
Displays the Dialog until the user invokes one of the Buttons in the |
| 103 |
bottom Frame. If the grab type I<-global> is specified, then B<Show> |
| 104 |
uses that grab; otherwise it defaults to a local grab. Returns the |
| 105 |
name of the Button invoked. |
| 106 |
|
| 107 |
The actual Dialog is shown using the B<Popup> method. Any other |
| 108 |
options supplied to B<Show> are passed to B<Popup>, and can be used to |
| 109 |
position the Dialog on the screen. Please read Tk::Popup for details. |
| 110 |
|
| 111 |
=item B<Exit()> |
| 112 |
|
| 113 |
Close the dialogbox, by emulating a click on the default button. |
| 114 |
|
| 115 |
=back |
| 116 |
|
| 117 |
=head1 ADVERTISED WIDGETS |
| 118 |
|
| 119 |
=over 4 |
| 120 |
|
| 121 |
=item B<top> |
| 122 |
|
| 123 |
The subwidget reference to the top half of the DialogBox widget, the Frame |
| 124 |
containing widgets added by the B<add> method. |
| 125 |
|
| 126 |
=item B<bottom> |
| 127 |
|
| 128 |
The subwidget reference to the bottom half of the DialogBox widget, the Frame |
| 129 |
containing the Button widgets. |
| 130 |
|
| 131 |
=item B<B_"button-text"> |
| 132 |
|
| 133 |
Individual subwidget references to the Buttons in the DialogBox widget. The |
| 134 |
subwidget name is the string I<B_> concatenated with the Button's -text |
| 135 |
value. |
| 136 |
|
| 137 |
=back |
| 138 |
|
| 139 |
=head1 BUGS |
| 140 |
|
| 141 |
There is no way of removing a widget once it has been added to the |
| 142 |
top Frame, unless you access the I<top> subwidget and go through the |
| 143 |
child widgets. |
| 144 |
|
| 145 |
There is no control over the appearance of the Buttons in the |
| 146 |
bottom Frame nor is there any way to control the placement of the |
| 147 |
two Frames with respect to each other. |
| 148 |
|
| 149 |
=head1 AUTHOR |
| 150 |
|
| 151 |
B<Rajappa Iyer> [email protected] |
| 152 |
|
| 153 |
This code is distributed under the same terms as Perl. |
| 154 |
|
| 155 |
=cut |
| 156 |
|