home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / doc / Xaw / Toggle < prev    next >
Encoding:
Text File  |  1991-07-29  |  12.0 KB  |  368 lines

  1. .NH 2
  2. Toggle Widget
  3. .XS
  4.     Toggle Widget
  5. .XE
  6. .IN "Toggle widget" "" "@DEF@"
  7. .Ds 0
  8. .TA 2.0i
  9. .ta 2.0i
  10. .sp
  11. Application Header file    <Xaw/Toggle.h>
  12. .IN "Toggle.h" ""
  13. Class Header file    <Xaw/ToggleP.h>
  14. .IN "ToggleP.h" ""
  15. Class        toggleWidgetClass
  16. .IN "toggleWidgetClass" ""
  17. Class Name    Toggle
  18. .IN "Toggle widget" "class name"
  19. Superclass     Command
  20. .sp
  21. .De
  22. .LP
  23. The Toggle widget is an area, often rectangular, containing a text label
  24. or bitmap image.  This widget maintains a Boolean state (e.g.
  25. True/False or On/Off) and changes state whenever it is selected.  When
  26. the pointer is on the button, the button may become highlighted by
  27. drawing a rectangle around its perimeter.  This highlighting indicates
  28. that the button is ready for selection.  When pointer button 1 is
  29. pressed and released, the Toggle widget indicates that it has changed
  30. state by reversing its foreground and background colors, and its
  31. \fBnotify\fP action is invoked, calling all functions on its callback
  32. list.  If the pointer is moved out of the widget before the button is
  33. released, the widget reverts to its normal foreground and background
  34. colors, and releasing the button has no effect.  This behavior allows
  35. the user to cancel an action.
  36. .LP
  37. Toggle buttons may also be part of a radio group.  A radio group is a
  38. .IN "Radio groups" ""
  39. .IN "Radio button" ""
  40. .IN "Toggle widget" "used in radio groups"
  41. list of at least two Toggle buttons in which no more than one Toggle may 
  42. be set at
  43. any time.  A radio group is identified by the widget ID of any one of
  44. its members.  The convenience routine \fBXawToggleGetCurrent\fP will
  45. return information about the Toggle button in the radio group.
  46. .LP
  47. Toggle widget state is preserved across changes in sensitivity.
  48. .NH 3
  49. Resources
  50. .LP
  51. When creating a Toggle widget instance, the following resources are
  52. retrieved from the argument list or from the resource database:
  53. .LP
  54. .IN "Toggle widget" "resources"
  55. .ps 9
  56. .nr PS 9
  57. .vs 11
  58. .nr VS 11
  59. .TS H
  60. expand;
  61. lw(1i) lw(1i) lw(1i) lw(.5i) lw(2i).
  62. _
  63. .sp 3p
  64. .TB
  65. Name    Class    Type    Notes    Default Value
  66. .sp 3p
  67. _
  68. .TH
  69. .R
  70. .sp 3p
  71. accelerators    Accelerators    AcceleratorTable        NULL
  72. ancestorSensitive    AncestorSensitive    Boolean    D    True
  73. background    Background    Pixel        XtDefaultBackground
  74. backgroundPixmap    Pixmap    Pixmap        XtUnspecifiedPixmap
  75. bitmap    Bitmap    Pixmap        None
  76. borderColor    BorderColor    Pixel        XtDefaultForeground
  77. borderPixmap    Pixmap    Pixmap        XtUnspecifiedPixmap
  78. borderWidth    BorderWidth    Dimension        1
  79. callback    Callback    XtCallbackList        NULL
  80. colormap    Colormap    Colormap        Parent's Colormap
  81. cornerRoundPercent    CornerRoundPercent    Dimension        25
  82. cursor    Cursor    Cursor        None
  83. cursorName    Cursor    String        NULL
  84. depth    Depth    int    C    Parent's Depth
  85. destroyCallback    Callback    XtCallbackList        NULL
  86. encoding    Encoding    UnsignedChar        XawTextEncoding8bit
  87. font    Font    XFontStruct        XtDefaultFont
  88. foreground    Foreground    Pixel        XtDefaultForeground
  89. height    Height    Dimension    A    Font height + 2 * \fBinternalHeight\fP
  90. highlightThickness    Thickness    Dimension    A    2 (0 if Shaped)
  91. insensitiveBorder    Insensitive    Pixmap        GreyPixmap
  92. internalHeight    Height    Dimension        2
  93. internalWidth    Width    Dimension        4
  94. justify    Justify    Justify        XtJustifyCenter (center)
  95. label    Label    String        name of widget
  96. leftBitmap    LeftBitmap    Bitmap        None
  97. mappedWhenManaged    MappedWhenManaged    Boolean        True
  98. pointerColor    Foreground    Pixel        XtDefaultForeground
  99. pointerColorBackground    Background    Pixel        XtDefaultBackground
  100. radioData    RadioData    Pointer        Name of widget
  101. radioGroup    Widget    Widget        No radio group
  102. resize    Resize    Boolean        True
  103. screen    Screen    Screen    R    Parent's Screen
  104. sensitive    Sensitive    Boolean        True
  105. shapeStype    ShapeStyle    ShapeStyle        Rectangle
  106. state    State    Boolean        Off
  107. translations    Translations    TranslationTable        See below
  108. width    Width    Dimension    A    \fBlabel\fP width + 2 * \fBinternalWidth\fP
  109. x    Position    Position        0
  110. y    Position    Position        0
  111. .sp 3p
  112. _
  113. .TE
  114. .ps 11
  115. .nr PS 11
  116. .vs 13
  117. .nr VS 13
  118. .Ac
  119. .As
  120. .Bg
  121. .Gp
  122. .Bm
  123. .Bc
  124. .Bp
  125. .Bw
  126. .Cb
  127. .Cm
  128. .Cr
  129. .Cu
  130. .Pn
  131. .Dp
  132. .Dc
  133. .Le
  134. .Lf
  135. .Lg
  136. .Hw
  137. .Ht 
  138. .Ib
  139. .Ih
  140. .Ju
  141. .La
  142. .Ll
  143. .Mm
  144. .Pf
  145. .Pb
  146. .IP \fBradioData\fP 1.5i
  147. Specifies the data that will be returned by \fBXawToggleGetCurrent\fP
  148. when this is the currently \fIset\fP widget in the radio group.  This
  149. value is also used to identify the Toggle that will be set by a call to
  150. \fBXawToggleSetCurrent\fP.  The value NULL will be returned by
  151. \fBXawToggleGetCurrent\fP if no widget in a radio group is currently
  152. set.  Programmers must not specify NULL (or Zero) as \fBradioData\fP.
  153. .IP \fBradioGroup\fP 1.5i
  154. Specifies another Toggle widget that is in the radio group to which this
  155. Toggle widget should be added.  A radio group is a group of at least two Toggle
  156. widgets, only one of which may be \fIset\fP at a time.  If this value is
  157. NULL (the default) then the Toggle will not be part of any radio group
  158. and can change state without affecting any other Toggle widgets.  If the
  159. widget specified in this resource is not already in a radio group then a
  160. new radio group will be created containing these two Toggle widgets.  No
  161. Toggle widget can be in multiple radio groups.  The behavior of a radio
  162. group of one toggle is undefined.  A converter is registered which will
  163. convert widget names to widgets without caching.
  164. .Re
  165. .Sc
  166. .Se
  167. .Ss 
  168. .IP \fBstate\fP
  169. Specifies whether the Toggle widget is set (\fBTrue\fP) or unset
  170. (\fBFalse\fP).
  171. .Tr
  172. .Xy
  173. .NH 3
  174. Toggle Actions
  175. .IN "Toggle widget" "actions"
  176. .LP
  177. The Toggle widget supports the following actions:
  178. .IP \(bu 5
  179. Switching the button between the foreground and background
  180. colors with \fBset\fP and \fBunset\fP and \fBtoggle\fP
  181. .IP \(bu 5
  182. Processing application callbacks with \fBnotify\fP
  183. .IP \(bu 5
  184. Switching the internal border between highlighted
  185. and unhighlighted states with \fBhighlight\fP and \fBunhighlight\fP
  186. .LE
  187. .LP
  188. The following are the default translation bindings used by the
  189. Toggle widget:
  190. .IN "Toggle widget" "default translation table"
  191. .LP
  192. .sp
  193. .Ds 0
  194. .TA .5i 2.25i
  195. .ta .5i 2.25i
  196.     <EnterWindow>:    highlight(Always)
  197.     <LeaveWindow>:    unhighlight(\|)
  198.     <Btn1Down>,<Btn1Up>:    toggle(\|) notify(\|)
  199. .De
  200. .NH 3
  201. Toggle Actions
  202. .LP
  203. The full list of actions supported by Toggle is:
  204. .IP \fBhighlight\fP(\fIcondition\fP) 1.5i
  205. Displays the internal highlight border in the color (\fBforeground\fP
  206. or \fBbackground\fP ) that contrasts with the interior color of the
  207. Toggle widget.  The conditions \fBWhenUnset\fP and \fBAlways\fP are
  208. understood by this action procedure.  If no argument is passed then
  209. \fBWhenUnset\fP is assumed.
  210. .IP \fBunhighlight\fP(\|) 1.5i
  211. Displays the internal highlight border in the color (\fBforeground\fP
  212. or \fBbackground\fP ) that matches the interior color of the
  213. Toggle widget.  
  214. .IP \fBset\fP(\|) 1.5i
  215. Enters the \fIset\fP state, in which \fBnotify\fP is possible.  This
  216. action causes the button to display its interior in the
  217. \fBforeground\fP color.  The label or bitmap is displayed in the
  218. \fBbackground\fP color. 
  219. .IP \fBunset\fP(\|) 1.5i
  220. Cancels the \fIset\fP state and displays the interior of the button in the
  221. \fBbackground\fP color.  The label or bitmap is displayed in the
  222. \fBforeground\fP color.
  223. .IP \fBtoggle\fP(\|) 1.5i
  224. Changes the current state of the Toggle widget, causing to be set
  225. if it was previously unset, and unset if it was previously set.
  226. If the widget is to be set, and is in a radio group then this procedure may 
  227. unset another Toggle widget causing all routines on its callback list
  228. to be invoked.  The callback routines for the Toggle that
  229. is to be unset will be called before the one that is to be set.
  230. .IP \fBreset\fP(\|) 1.5i
  231. Cancels any \fBset\fP or \fBhighlight\fP and displays the interior of the
  232. button in the \fBbackground\fP color, with the label displayed in the 
  233. \fBforeground\fP color.
  234. .IP \fBnotify\fP(\|) 1.5i
  235. When the button is in the \fBset\fP state this action calls all functions in
  236. the callback list named by the \fBcallback\fP resource.  The value of
  237. the call_data argument in these callback functions is undefined. 
  238. .LP
  239. .NT
  240. When a bitmap of depth greater that one (1) is specified the
  241. \fIset\fP(), \fIunset\fP(), and \fIreset\fP() actions have no effect,
  242. since there are no foreground and background colors used in a 
  243. multi-plane pixmap.
  244. .NE
  245. .NH 3
  246. Radio Groups
  247. .IN "Radio groups"
  248. .LP
  249. There are typically two types of radio groups desired by applications.
  250. The default translations for the Toggle widget implement a "zero or one
  251. .IN "Radio groups" "zero or one of many"
  252. of many" radio group.  This means that there may be no more than one
  253. button active, but there need not be any buttons active.
  254. .LP
  255. The other type of radio group is "one of many" and has the more strict
  256. .IN "Radio groups" "one of many"
  257. policy that there will always be exactly one radio button active.
  258. Toggle widgets can be used to provide this interface with a slight
  259. modification to the translation table of each Toggle in the group.
  260. .Ds 0
  261. .TA .5i 2.25i
  262. .ta .5i 2.25i
  263. .sp
  264.     <EnterWindow>:    highlight(Always)
  265.     <LeaveWindow>:    unhighlight(\|)
  266.     <Btn1Down>,<Btn1Up>:    set(\|) notify(\|)
  267. .sp
  268. .De
  269. This translation table will not allow any Toggle to be \fIunset\fP
  270. except as a result of another Toggle becoming \fIset\fP.  It is
  271. the application programmer's responsibility to choose an initial
  272. state for the radio group by setting the \fBstate\fP resource of one of
  273. its member widgets to \fBTrue\fP.
  274. .NH 3
  275. Convenience Routines
  276. .LP
  277. The following functions allow easy access to the Toggle widget's radio
  278. group functionality.
  279. .NH 4
  280. Changing the Toggle's Radio Group.
  281. .LP
  282. To enable an application to change the Toggle's radio group, add
  283. the Toggle to a radio group, or remove the Toggle from a radio group, use 
  284. \fBXawToggleChangeRadioGroup\fP.
  285. .IN "XawToggleChangeRadioGroup" "" "@DEF@"
  286. .sp 6p
  287. void XawToggleChangeRadioGroup(\fIw\fP, \fIradio_group\fP)
  288. .br
  289.      Widget \fIw\fP, \fIradio_group\fP;
  290. .FN
  291. .IP \fIw\fP 1i
  292. Specifies the Toggle widget.
  293. .IP \fIradio_group\fP 1i
  294. Specifies any Toggle in the new radio group.  If NULL then the Toggle
  295. will be removed from any radio group of which it is a member.
  296. .LP
  297. If a Toggle is already \fIset\fP in the new radio group,
  298. and the Toggle to be added is also \fIset\fP then the previously
  299. \fIset\fP Toggle in the radio group is \fIunset\fP and its callback
  300. procedures are invoked.
  301. .SH
  302. Finding the Currently selected Toggle in a radio group of Toggles
  303. .LP
  304. To find the currently selected Toggle in a radio group of Toggle widgets
  305. use 
  306. \fBXawToggleGetCurrent\fP.
  307. .IN "XawToggleGetCurrent" "" "@DEF@"
  308. .sp 6p
  309. XtPointer XawToggleGetCurrent(\fIradio_group\fP);
  310. .br
  311.      Widget \fIradio_group\fP;
  312. .FN
  313. .IP \fIradio_group\fP 1i
  314. Specifies any Toggle widget in the radio group.
  315. .LP
  316. The value returned by this function is the
  317. .PN radioData
  318. of the Toggle in this radio group that is currently set.  The default
  319. value for
  320. .PN radioData 
  321. is the name of that Toggle widget.  If no Toggle is set in the radio
  322. group specified then NULL is returned.
  323. .SH
  324. Changing the Toggle that is set in a radio group.
  325. .LP
  326. To change the Toggle that is currently set in a radio group use 
  327. \fBXawToggleSetCurrent\fP.
  328. .IN "XawToggleSetCurrent" "" "@DEF@"
  329. .sp 6p
  330. void XawToggleSetCurrent(\fIradio_group\fP, \fIradio_data\fP);
  331. .br
  332.      Widget \fIradio_group\fP;
  333.      XtPointer \fIradio_data\fP;
  334. .FN
  335. .IP \fIradio_group\fP 1i
  336. Specifies any Toggle widget in the radio group.
  337. .IP \fIradio_data\fP 1i
  338. Specifies the 
  339. .PN radioData
  340. identifying the Toggle that should be set in the radio group specified
  341. by the \fIradio_group\fP argument.
  342. .LP
  343. \fBXawToggleSetCurrent\fP locates the Toggle widget to be set by
  344. matching \fIradio_data\fP against the \fBradioData\fP for each Toggle in
  345. the radio group.  If none match, \fBXawToggleSetCurrent\fP returns
  346. without making any changes.  If more than one Toggle matches,
  347. \fBXawToggleSetCurrent\fP will choose a Toggle to set arbitrarily.  If
  348. this causes any Toggle widgets to change state, all routines in their
  349. callback lists will be invoked.  The callback routines for a Toggle that
  350. is to be unset will be called before the one that is to be set.
  351. .SH
  352. Unsetting all Toggles in a radio group.
  353. .LP
  354. To unset all Toggle widgets in a radio group use
  355. \fBXawToggleUnsetCurrent\fP.
  356. .IN "XawToggleUnsetCurrent" "" "@DEF@"
  357. .sp 6p
  358. void XawToggleUnsetCurrent(\fIradio_group\fP);
  359. .br
  360.      Widget \fIradio_group\fP;
  361. .FN
  362. .IP \fIradio_group\fP 1i
  363. Specifies any Toggle widget in the radio group.
  364. .LP
  365. If this causes a Toggle widget to change state, all routines on its
  366. callback list will be invoked.
  367.  
  368.