home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _42ed7ca2f6f1db1777948329ba16cac2 < prev    next >
Text File  |  2004-06-01  |  12KB  |  330 lines

  1. #  Copyright (c) 1990-1994 The Regents of the University of California.
  2. #  Copyright (c) 1994-1996 Sun Microsystems, Inc.
  3. #  See the file "license.terms" for information on usage and redistribution
  4. #  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  5. #
  6. #
  7.  
  8. =head1 NAME
  9.  
  10. Tk::Checkbutton - Create and manipulate Checkbutton widgets
  11.  
  12. =for category  Tk Widget Classes
  13.  
  14. =head1 SYNOPSIS
  15.  
  16. I<$checkbutton> = I<$parent>-E<gt>B<Checkbutton>(?I<options>?);
  17.  
  18. =head1 STANDARD OPTIONS
  19.  
  20. B<-activebackground>    B<-cursor>    B<-highlightthickness>    B<-takefocus>
  21. B<-activeforeground>    B<-disabledforeground>    B<-image>    B<-text>
  22. B<-anchor>    B<-font>    B<-justify>    B<-textvariable>
  23. B<-background>    B<-foreground>    B<-padx>    B<-underline>
  24. B<-bitmap>    B<-highlightbackground>    B<-pady>    B<-wraplength>
  25. B<-borderwidth>    B<-highlightcolor>    B<-relief>
  26.  
  27. See L<Tk::options> for details of the standard options.
  28.  
  29. =head1 WIDGET-SPECIFIC OPTIONS
  30.  
  31. =over 4
  32.  
  33. =item Name:    B<command>
  34.  
  35. =item Class:    B<Command>
  36.  
  37. =item Switch:    B<-command>
  38.  
  39. Specifies a L<perl/Tk callback|Tk::callbacks> to associate with the button.  This command
  40. is typically invoked when mouse button 1 is released over the button
  41. window.  The button's global variable (B<-variable> option) will
  42. be updated before the command is invoked.
  43.  
  44. =item Name:    B<height>
  45.  
  46. =item Class:    B<Height>
  47.  
  48. =item Switch:    B<-height>
  49.  
  50. Specifies a desired height for the button.
  51. If an image or bitmap is being displayed in the button then the value is in
  52. screen units (i.e. any of the forms acceptable to B<Tk_GetPixels>);
  53. for text it is in lines of text.
  54. If this option isn't specified, the button's desired height is computed
  55. from the size of the image or bitmap or text being displayed in it.
  56.  
  57. =item Name:    B<indicatorOn>
  58.  
  59. =item Class:    B<IndicatorOn>
  60.  
  61. =item Switch:    B<-indicatoron>
  62.  
  63. Specifies whether or not the indicator should be drawn.  Must be a
  64. proper boolean value.  If false, the B<relief> option is
  65. ignored and the widget's relief is always sunken if the widget is
  66. selected and raised otherwise.
  67.  
  68. =item Command-Line Name: B<-offrelief>
  69.  
  70. =item Database Name:  B<offRelief>
  71.  
  72. =item Database Class: B<OffRelief>
  73.  
  74. Specifies the relief for the checkbutton when the indicator is not
  75. drawn and the checkbutton is off.  The default value is B<raised>.  By
  76. setting this option to B<flat> and setting
  77. B<-indicatoron false -overrelief raised>, the effect is achieved of
  78. having a flat button
  79. that raises on mouse-over and which is depressed when activated.  This
  80. is the behavior typically exhibited by the Bold, Italic, and
  81. Underline checkbuttons on the toolbar of a word-processor, for
  82. example.
  83.  
  84. =item Name:    B<offValue>
  85.  
  86. =item Class:    B<Value>
  87.  
  88. =item Switch:    B<-offvalue>
  89.  
  90. Specifies value to store in the button's associated variable whenever
  91. this button is deselected.  Defaults to ``0''.
  92.  
  93. =item Name:    B<onValue>
  94.  
  95. =item Class:    B<Value>
  96.  
  97. =item Switch:    B<-onvalue>
  98.  
  99. Specifies value to store in the button's associated variable whenever
  100. this button is selected.  Defaults to ``1''.
  101.  
  102. =item Command-Line Name: B<-overrelief>
  103.  
  104. =item Database Name:  B<overRelief>
  105.  
  106. =item Database Class: B<OverRelief>
  107.  
  108. Specifies  an alternative relief for the button, to be used when
  109. the mouse cursor is over the widget.  This option can be used to
  110. make  toolbar  buttons,  by configuring B<-relief flat -overrelief
  111. raised>.  If the value of this option is the empty  string,  then
  112. no  alternative relief is used when the mouse cursor is over the
  113. button.  The empty string is the default value.
  114.  
  115. =item Name:    B<selectColor>
  116.  
  117. =item Class:    B<Background>
  118.  
  119. =item Switch:    B<-selectcolor>
  120.  
  121. Specifies a background color to use when the button is selected.
  122. If B<indicatorOn> is true then the color applies to the indicator.
  123. Under Windows, this color is used as the background for the indicator
  124. regardless of the select state.
  125. If B<indicatorOn> is false, this color is used as the background
  126. for the entire widget, in place of B<background> or B<activeBackground>,
  127. whenever the widget is selected.
  128. If specified as an empty string then no special color is used for
  129. displaying when the widget is selected.
  130.  
  131. =item Name:    B<selectImage>
  132.  
  133. =item Class:    B<SelectImage>
  134.  
  135. =item Switch:    B<-selectimage>
  136.  
  137. Specifies an image to display (in place of the B<image> option)
  138. when the checkbutton is selected.
  139. This option is ignored unless the B<image> option has been
  140. specified.
  141.  
  142. =item Name:    B<state>
  143.  
  144. =item Class:    B<State>
  145.  
  146. =item Switch:    B<-state>
  147.  
  148. Specifies one of three states for the checkbutton:  B<normal>, B<active>,
  149. or B<disabled>.  In normal state the checkbutton is displayed using the
  150. B<foreground> and B<background> options.  The active state is
  151. typically used when the pointer is over the checkbutton.  In active state
  152. the checkbutton is displayed using the B<activeForeground> and
  153. B<activeBackground> options.  Disabled state means that the checkbutton
  154. should be insensitive:  the default bindings will refuse to activate
  155. the widget and will ignore mouse button presses.
  156. In this state the B<disabledForeground> and
  157. B<background> options determine how the checkbutton is displayed.
  158.  
  159. =item Name:    B<variable>
  160.  
  161. =item Class:    B<Variable>
  162.  
  163. =item Switch:    B<-variable>
  164.  
  165. Specifies reference to a variable to set to indicate whether
  166. or not this button is selected.  Defaults to C<\$widget-E<gt>{'Value'}>
  167. member of the widget's hash. In general perl variables are C<undef> unless
  168. specifically initialized which will not match either default B<-onvalue> or
  169. default B<-offvalue>.
  170.  
  171. =item Name:    B<width>
  172.  
  173. =item Class:    B<Width>
  174.  
  175. =item Switch:    B<-width>
  176.  
  177. Specifies a desired width for the button.
  178. If an image or bitmap is being displayed in the button then the value is in
  179. screen units (i.e. any of the forms acceptable to B<Tk_GetPixels>);
  180. for text it is in characters.
  181. If this option isn't specified, the button's desired width is computed
  182. from the size of the image or bitmap or text being displayed in it.
  183.  
  184. =back
  185.  
  186. =head1 DESCRIPTION
  187.  
  188. The B<Checkbutton> method creates a new window (given by the
  189. $widget argument) and makes it into a checkbutton widget.
  190. Additional
  191. options, described above, may be specified on the command line
  192. or in the option database
  193. to configure aspects of the checkbutton such as its colors, font,
  194. text, and initial relief.  The B<checkbutton> command returns its
  195. $widget argument.  At the time this command is invoked,
  196. there must not exist a window named $widget, but
  197. $widget's parent must exist.
  198.  
  199. A checkbutton is a widget
  200. that displays a textual string, bitmap or image
  201. and a square called an I<indicator>.
  202. If text is displayed, it must all be in a single font, but it
  203. can occupy multiple lines on the screen (if it contains newlines
  204. or if wrapping occurs because of the B<wrapLength> option) and
  205. one of the characters may optionally be underlined using the
  206. B<underline> option.
  207. A checkbutton has
  208. all of the behavior of a simple button, including the
  209. following: it can display itself in either of three different
  210. ways, according to the B<state> option;
  211. it can be made to appear
  212. raised, sunken, or flat; it can be made to flash; and it invokes
  213. a L<perl/Tk callback|Tk::callbacks> whenever mouse button 1 is clicked over the
  214. checkbutton.
  215.  
  216. In addition, checkbuttons can be I<selected>.
  217. If a checkbutton is selected then the indicator is normally
  218. drawn with a selected appearance, and
  219. a Tcl variable associated with the checkbutton is set to a particular
  220. value (normally 1).
  221. Under Unix, the indicator is drawn with a sunken relief and a special
  222. color.  Under Windows, the indicator is drawn with a check mark inside.
  223. If the checkbutton is not selected, then the indicator is drawn with a
  224. deselected appearance, and the associated variable is
  225. set to a different value (typically 0).
  226. Under Unix, the indicator is drawn with a raised relief and no special
  227. color.  Under Windows, the indicator is drawn without a check mark inside.
  228. By default, the name of the variable associated with a checkbutton is the
  229. same as the I<name> used to create the checkbutton.
  230. The variable name, and the ``on'' and ``off'' values stored in it,
  231. may be modified with options on the command line or in the option
  232. database.
  233. Configuration options may also be used to modify the way the
  234. indicator is displayed (or whether it is displayed at all).
  235. By default a checkbutton is configured to select and deselect
  236. itself on alternate button clicks.
  237. In addition, each checkbutton monitors its associated variable and
  238. automatically selects and deselects itself when the variables value
  239. changes to and from the button's ``on'' value.
  240.  
  241. =head1 WIDGET METHODS
  242.  
  243. The B<Checkbutton> method creates a widget object.
  244. This object supports the B<configure> and B<cget> methods
  245. described in L<Tk::options> which can be used to enquire and
  246. modify the options described above.
  247. The widget also inherits all the methods provided by the generic
  248. L<Tk::Widget|Tk::Widget> class.
  249.  
  250. The following additional methods are available for checkbutton widgets:
  251.  
  252. =over 4
  253.  
  254. =item I<$checkbutton>-E<gt>B<deselect>
  255.  
  256. Deselects the checkbutton and sets the associated variable to its ``off''
  257. value.
  258.  
  259. =item I<$checkbutton>-E<gt>B<flash>
  260.  
  261. Flashes the checkbutton.  This is accomplished by redisplaying the checkbutton
  262. several times, alternating between active and normal colors.  At
  263. the end of the flash the checkbutton is left in the same normal/active
  264. state as when the command was invoked.
  265. This command is ignored if the checkbutton's state is B<disabled>.
  266.  
  267. =item I<$checkbutton>-E<gt>B<invoke>
  268.  
  269. Does just what would have happened if the user invoked the checkbutton
  270. with the mouse: toggle the selection state of the button and invoke
  271. the L<perl/Tk callback|Tk::callbacks> associated with the checkbutton, if there is one.
  272. The return value is the return value from the L<perl/Tk callback|Tk::callbacks>, or an
  273. empty string if there is no command associated with the checkbutton.
  274. This command is ignored if the checkbutton's state is B<disabled>.
  275.  
  276. =item I<$checkbutton>-E<gt>B<select>
  277.  
  278. Selects the checkbutton and sets the associated variable to its ``on''
  279. value.
  280.  
  281. =item I<$checkbutton>-E<gt>B<toggle>
  282.  
  283. Toggles the selection state of the button, redisplaying it and
  284. modifying its associated variable to reflect the new state.
  285.  
  286. =back
  287.  
  288. =head1 BINDINGS
  289.  
  290. Tk automatically creates class bindings for checkbuttons that give them
  291. the following default behavior:
  292.  
  293. =over 4
  294.  
  295. =item [1]
  296.  
  297. On Unix systems, a checkbutton activates whenever the mouse passes
  298. over it and deactivates whenever the mouse leaves the checkbutton.  On
  299. Mac and Windows systems, when mouse button 1 is pressed over a
  300. checkbutton, the button activates whenever the mouse pointer is inside
  301. the button, and deactivates whenever the mouse pointer leaves the
  302. button.
  303.  
  304. =item [2]
  305.  
  306. When mouse button 1 is pressed over a checkbutton, it is invoked (its
  307. selection state toggles and the command associated with the button is
  308. invoked, if there is one).
  309.  
  310. =item [3]
  311.  
  312. When a checkbutton has the input focus, the space key causes the checkbutton
  313. to be invoked.  Under Windows, there are additional key bindings; plus
  314. (+) and equal (=) select the button, and minus (-) deselects the button.
  315.  
  316. If the checkbutton's state is B<disabled> then none of the above
  317. actions occur:  the checkbutton is completely non-responsive.
  318.  
  319. The behavior of checkbuttons can be changed by defining new bindings for
  320. individual widgets or by redefining the class bindings.
  321.  
  322. =back
  323.  
  324. =head1 KEYWORDS
  325.  
  326. checkbutton, widget
  327.  
  328. =cut
  329.  
  330.