OSDN Git Service

*** empty log message ***
[pf3gnuchains/sourceware.git] / tk / doc / radiobutton.n
1 '\"
2 '\" Copyright (c) 1990-1994 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\" 
8 '\" RCS: @(#) $Id$
9 '\" 
10 .so man.macros
11 .TH radiobutton n 4.4 Tk "Tk Built-In Commands"
12 .BS
13 '\" Note:  do not modify the .SH NAME line immediately below!
14 .SH NAME
15 radiobutton \- Create and manipulate radiobutton widgets
16 .SH SYNOPSIS
17 \fBradiobutton\fR \fIpathName \fR?\fIoptions\fR?
18 .SO
19 \-activebackground      \-font  \-pady
20 \-activeforeground      \-foreground    \-relief
21 \-anchor        \-highlightbackground   \-takefocus
22 \-background    \-highlightcolor        \-text
23 \-bitmap        \-highlightthickness    \-textvariable
24 \-borderwidth   \-image \-underline
25 \-cursor        \-justify       \-wraplength
26 \-disabledforeground    \-padx
27 .SE
28 .SH "WIDGET-SPECIFIC OPTIONS"
29 .OP \-command command Command
30 Specifies a Tcl command to associate with the button.  This command
31 is typically invoked when mouse button 1 is released over the button
32 window.  The button's global variable (\fB\-variable\fR option) will
33 be updated before the command is invoked.
34 .OP \-height height Height
35 Specifies a desired height for the button.
36 If an image or bitmap is being displayed in the button then the value is in
37 screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
38 for text it is in lines of text.
39 If this option isn't specified, the button's desired height is computed
40 from the size of the image or bitmap or text being displayed in it.
41 .OP \-indicatoron indicatorOn IndicatorOn
42 Specifies whether or not the indicator should be drawn.  Must be a
43 proper boolean value.  If false, the \fBrelief\fR option is
44 ignored and the widget's relief is always sunken if the widget is
45 selected and raised otherwise.
46 .OP \-selectcolor selectColor Background
47 Specifies a background color to use when the button is selected.
48 If \fBindicatorOn\fR is true then the color applies to the indicator.
49 Under Windows, this color is used as the background for the indicator
50 regardless of the select state.
51 If \fBindicatorOn\fR is false, this color is used as the background
52 for the entire widget, in place of \fBbackground\fR or \fBactiveBackground\fR,
53 whenever the widget is selected.
54 If specified as an empty string then no special color is used for
55 displaying when the widget is selected.
56 .VS 8.4
57 .OP \-offrelief offRelief OffRelief
58 Specifies the relief for the checkbutton when the indicator is not drawn and
59 the checkbutton is off.  The default value is "raised".  By setting this option
60 to "flat" and setting -indicatoron to false and -overrelief to raised,
61 the effect is achieved 
62 of having a flat button that raises on mouse-over and which is
63 depressed when activated.  This is the behavior typically exhibited by
64 the Align-Left, Align-Right, and Center radiobuttons on the toolbar of a 
65 word-processor, for example.
66
67 .VE 8.4
68 .VS 8.4
69 .OP \-overrelief overRelief OverRelief
70 Specifies an alternative relief for the radiobutton, to be used when the
71 mouse cursor is over the widget.  This option can be used to make
72 toolbar buttons, by configuring \fB\-relief flat \-overrelief
73 raised\fR.  If the value of this option is the empty string, then no
74 alternative relief is used when the mouse cursor is over the radiobutton.
75 The empty string is the default value.
76 .VE 8.4
77 .OP \-selectimage selectImage SelectImage
78 Specifies an image to display (in place of the \fBimage\fR option)
79 when the radiobutton is selected.
80 This option is ignored unless the \fBimage\fR option has been
81 specified.
82 .OP \-state state State
83 Specifies one of three states for the radiobutton:  \fBnormal\fR, \fBactive\fR,
84 or \fBdisabled\fR.  In normal state the radiobutton is displayed using the
85 \fBforeground\fR and \fBbackground\fR options.  The active state is
86 typically used when the pointer is over the radiobutton.  In active state
87 the radiobutton is displayed using the \fBactiveForeground\fR and
88 \fBactiveBackground\fR options.  Disabled state means that the radiobutton
89 should be insensitive:  the default bindings will refuse to activate
90 the widget and will ignore mouse button presses.
91 In this state the \fBdisabledForeground\fR and
92 \fBbackground\fR options determine how the radiobutton is displayed.
93 .OP \-value value Value
94 Specifies value to store in the button's associated variable whenever
95 this button is selected.
96 .OP \-variable variable Variable
97 Specifies name of global variable to set whenever this button is
98 selected.  Changes in this variable also cause the button to select
99 or deselect itself.
100 Defaults to the value \fBselectedButton\fR.
101 .OP \-width width Width
102 Specifies a desired width for the button.
103 If an image or bitmap is being displayed in the button, the value is in
104 screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
105 for text it is in characters.
106 If this option isn't specified, the button's desired width is computed
107 from the size of the image or bitmap or text being displayed in it.
108 .BE
109
110 .SH DESCRIPTION
111 .PP
112 The \fBradiobutton\fR command creates a new window (given by the
113 \fIpathName\fR argument) and makes it into a radiobutton widget.
114 Additional
115 options, described above, may be specified on the command line
116 or in the option database
117 to configure aspects of the radiobutton such as its colors, font,
118 text, and initial relief.  The \fBradiobutton\fR command returns its
119 \fIpathName\fR argument.  At the time this command is invoked,
120 there must not exist a window named \fIpathName\fR, but
121 \fIpathName\fR's parent must exist.
122 .PP
123 .VS
124 A radiobutton is a widget that displays a textual string, bitmap or image
125 and a diamond or circle called an \fIindicator\fR.
126 .VE
127 If text is displayed, it must all be in a single font, but it
128 can occupy multiple lines on the screen (if it contains newlines
129 or if wrapping occurs because of the \fBwrapLength\fR option) and
130 one of the characters may optionally be underlined using the
131 \fBunderline\fR option.  A radiobutton has
132 all of the behavior of a simple button: it can display itself in either
133 of three different ways, according to the \fBstate\fR option;
134 it can be made to appear
135 raised, sunken, or flat; it can be made to flash; and it invokes
136 a Tcl command whenever mouse button 1 is clicked over the
137 check button.
138 .PP
139 In addition, radiobuttons can be \fIselected\fR.
140 If a radiobutton is selected, the indicator is normally
141 .VS
142 drawn with a selected appearance, and
143 a Tcl variable associated with the radiobutton is set to a particular
144 value (normally 1).
145 Under Unix, the indicator is drawn with a sunken relief and a special
146 color.  Under Windows, the indicator is drawn with a round mark inside.
147 If the radiobutton is not selected, then the indicator is drawn with a
148 deselected appearance, and the associated variable is
149 set to a different value (typically 0).
150 Under Unix, the indicator is drawn with a raised relief and no special
151 color.  Under Windows, the indicator is drawn without a round mark inside.
152 .VE
153 Typically, several radiobuttons share a single variable and the
154 value of the variable indicates which radiobutton is to be selected.
155 When a radiobutton is selected it sets the value of the variable to
156 indicate that fact;  each radiobutton also monitors the value of
157 the variable and automatically selects and deselects itself when the
158 variable's value changes.
159 By default the variable \fBselectedButton\fR
160 is used;  its contents give the name of the button that is
161 selected, or the empty string if no button associated with that
162 variable is selected.
163 The name of the variable for a radiobutton,
164 plus the variable to be stored into it, may be modified with options
165 on the command line or in the option database.
166 Configuration options may also be used to modify the way the
167 indicator is displayed (or whether it is displayed at all).
168 By default a radiobutton is configured to select itself on button clicks.
169
170 .SH "WIDGET COMMAND"
171 .PP
172 The \fBradiobutton\fR command creates a new Tcl command whose
173 name is \fIpathName\fR.  This
174 command may be used to invoke various
175 operations on the widget.  It has the following general form:
176 .CS
177 \fIpathName option \fR?\fIarg arg ...\fR?
178 .CE
179 \fIOption\fR and the \fIarg\fRs
180 determine the exact behavior of the command.  The following
181 commands are possible for radiobutton widgets:
182 .TP
183 \fIpathName \fBcget\fR \fIoption\fR
184 Returns the current value of the configuration option given
185 by \fIoption\fR.
186 \fIOption\fR may have any of the values accepted by the \fBradiobutton\fR
187 command.
188 .TP
189 \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
190 Query or modify the configuration options of the widget.
191 If no \fIoption\fR is specified, returns a list describing all of
192 the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
193 information on the format of this list).  If \fIoption\fR is specified
194 with no \fIvalue\fR, the command returns a list describing the
195 one named option (this list will be identical to the corresponding
196 sublist of the value returned if no \fIoption\fR is specified).  If
197 one or more \fIoption\-value\fR pairs are specified, the command
198 modifies the given widget option(s) to have the given value(s);  in
199 this case the command returns an empty string.
200 \fIOption\fR may have any of the values accepted by the \fBradiobutton\fR
201 command.
202 .TP
203 \fIpathName \fBdeselect\fR
204 Deselects the radiobutton and sets the associated variable to an
205 empty string.
206 If this radiobutton was not currently selected, the command has
207 no effect.
208 .TP
209 \fIpathName \fBflash\fR
210 Flashes the radiobutton.  This is accomplished by redisplaying the radiobutton
211 several times, alternating between active and normal colors.  At
212 the end of the flash the radiobutton is left in the same normal/active
213 state as when the command was invoked.
214 This command is ignored if the radiobutton's state is \fBdisabled\fR.
215 .TP
216 \fIpathName \fBinvoke\fR
217 Does just what would have happened if the user invoked the radiobutton
218 with the mouse: selects the button and invokes
219 its associated Tcl command, if there is one.
220 The return value is the return value from the Tcl command, or an
221 empty string if there is no command associated with the radiobutton.
222 This command is ignored if the radiobutton's state is \fBdisabled\fR.
223 .TP
224 \fIpathName \fBselect\fR
225 Selects the radiobutton and sets the associated variable to the
226 value corresponding to this widget.
227
228 .SH BINDINGS
229 .PP
230 Tk automatically creates class bindings for radiobuttons that give them
231 the following default behavior:
232 .VS
233 .IP [1]
234 On Unix systems, a radiobutton activates whenever the mouse passes
235 over it and deactivates whenever the mouse leaves the radiobutton.  On
236 Mac and Windows systems, when mouse button 1 is pressed over a
237 radiobutton, the button activates whenever the mouse pointer is inside
238 the button, and deactivates whenever the mouse pointer leaves the
239 button.
240 .VE
241 .IP [2]
242 When mouse button 1 is pressed over a radiobutton it is invoked (it
243 becomes selected and the command associated with the button is
244 invoked, if there is one).
245 .IP [3]
246 When a radiobutton has the input focus, the space key causes the radiobutton
247 to be invoked.
248 .PP
249 If the radiobutton's state is \fBdisabled\fR then none of the above
250 actions occur:  the radiobutton is completely non-responsive.
251 .PP
252 The behavior of radiobuttons can be changed by defining new bindings for
253 individual widgets or by redefining the class bindings.
254
255 .SH KEYWORDS
256 radiobutton, widget