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

  1. .NH 2
  2. List Widget
  3. .LP
  4. .XS
  5.     List Widget
  6. .XE
  7. .IN "List widget" "" "@DEF@"
  8. .Ds 0
  9. .TA 2.0i
  10. .ta 2.0i
  11. .sp
  12. Application header file    <X11/Xaw/List.h>
  13. .IN "List.h" ""
  14. Class header file    <X11/Xaw/ListP.h>
  15. .IN "ListP.h" ""
  16. Class    listWidgetClass
  17. .IN "listWidgetClass" ""
  18. Class Name    List
  19. .IN "List widget" "class name"
  20. Superclass    Simple
  21. .sp
  22. .De
  23. .LP
  24.  
  25. The List widget contains a list of strings formatted into rows and
  26. columns. When one of the strings is selected, it is highlighted, and the
  27. List widget's \fBNotify\fP action is invoked, calling all routines on
  28. its callback list.  Only one string may be selected at a time.
  29. .NH 3
  30. Resources
  31. .LP
  32. When creating a List widget instance, the following resources are
  33. retrieved from the argument list or from the resource database:
  34. .LP
  35. .IN "List widget" "resources"
  36. .ps 9
  37. .nr PS 9
  38. .vs 11
  39. .nr VS 11
  40. .TS H
  41. expand;
  42. lw(1i) lw(1i) lw(1i) lw(.5i) lw(2i).
  43. _
  44. .sp 3p
  45. .TB
  46. Name    Class    Type    Notes    Default Value
  47. .sp 3p
  48. _
  49. .TH
  50. .R
  51. .sp 3p
  52. accelerators    Accelerators    AcceleratorTable        NULL
  53. ancestorSensitive    AncestorSensitive    Boolean    D    True
  54. background    Background    Pixel        XtDefaultBackground
  55. backgroundPixmap    Pixmap    Pixmap        XtUnspecifiedPixmap
  56. borderColor    BorderColor    Pixel        XtDefaultForeground
  57. borderPixmap    Pixmap    Pixmap        XtUnspecifiedPixmap
  58. borderWidth    BorderWidth    Dimension        1
  59. callback    Callback    Callback        NULL
  60. colormap    Colormap    Colormap        Parent's Colormap
  61. columnSpacing    Spacing    Dimension        6
  62. cursor    Cursor    Cursor        XC_left_ptr
  63. cursorName    Cursor    String        NULL
  64. defaultColumns    Columns    int        2
  65. depth    Depth    int    C    Parent's Depth
  66. destroyCallback    Callback    XtCallbackList        NULL
  67. font    Font    FontStruct        XtDefaultFont
  68. forceColumns    Columns    Boolean        False
  69. foreground    Foreground    Pixel        XtDefaultForeground
  70. height    Height    Dimension    A    Enough space to contain the list
  71. insensitiveBorder    Insensitive    Pixmap        GreyPixmap
  72. internalHeight    Height    Dimension        2
  73. internalWidth    Width    Dimension        4
  74. list    List    Pointer        name of widget
  75. longest    Longest    int    A    0
  76. mappedWhenManaged    MappedWhenManaged    Boolean        True
  77. numberStrings    NumberStrings    int    A    computed for NULL terminated list
  78. pasteBuffer    Boolean    Boolean        False
  79. pointerColor    Foreground    Pixel        XtDefaultForeground
  80. pointerColorBackground    Background    Pixel        XtDefaultBackground
  81. rowSpacing    Spacing    Dimension        2
  82. screen    Screen    Screen    R    Parent's Screen
  83. sensitive    Sensitive    Boolean        True
  84. translations    Translations    TranslationTable        See below
  85. verticalList    Boolean    Boolean        False
  86. width    Width    Dimension    A    Enough space to contain the list
  87. x    Position    Position        0
  88. y    Position    Position        0
  89. .sp 3p
  90. _
  91. .TE
  92. .ps 11
  93. .nr PS 11
  94. .vs 13
  95. .nr VS 13
  96. .Ac
  97. .As
  98. .Bg
  99. .Gp
  100. .Bc
  101. .Bp
  102. .Bw
  103. .IP \fBcallback\fP 1.5i
  104. All functions on this list are called whenever the \fBnotify\fP action is
  105. invoked.  The \fIcall_data\fP argument contains information about the element
  106. selected and is described in detail in the \fBList Callbacks\fP section.
  107. .Cm
  108. .IP \fBcolumnSpacing\fP 1.5i
  109. .br
  110. .ns
  111. .IP \fBrowSpacing\fP 1.5i
  112. The amount of space, in pixels, between each of the rows and columns
  113. in the list. 
  114. .Cu
  115. .Pn
  116. .IP \fBdefaultColumns\fP 1.5i
  117. The default number of columns.  This value is used when neither the
  118. width nor the height of the List widget is specified or when
  119. \fBforceColumns\fP is \fBTrue\fP.
  120. .Dp
  121. .Dc
  122. .IP \fBforceColumns\fP
  123. Forces the default number of columns to be used regardless of the
  124. List widget's current size. 
  125. .IP \fBforeground\fP 1.5i
  126. A pixel value which indexes the widget's colormap to derive the color
  127. used to paint the text of the list elements.
  128. .Hw
  129. .Ib
  130. .IP \fPinternalHeight\fP 1.5i
  131. .br
  132. .ns
  133. .IP \fPinternalWidth\fP 1.5i
  134. The margin, in pixels, between the edges of the list and the
  135. corresponding edge of the List widget's window.
  136. .IP \fBlist\fP 1.5i
  137. An array of text strings displayed in the List widget.  If
  138. \fBnumberStrings\fP is zero (the default) then the \fBlist\fP must be
  139. NULL terminated.  If a value is not specified for the \fBlist\fP, then
  140. \fBnumberStrings\fP is set to 1, and the name of the widget is used as
  141. the \fBlist\fP, and \fBlongest\fP is set to the length of the name of the
  142. widget.  The \fBlist\fP is used in place, and must be available
  143. to the List widget for the lifetime of this widget, or until it is
  144. changed with \fBXtSetValues\fP or \fBXawListChange\fP.
  145. .IP \fBlongest\fP
  146. Specifies the width, in pixels, of the longest string in the current
  147. list.  The List widget will compute this value if zero (the default)
  148. is specified.  If this resource is not correctly specified, selection of
  149. list items may not work properly.
  150. .Mm
  151. .IP \fBnumberStrings\fP 1.5i
  152. The number of strings in the current list.  If a value of zero (the
  153. default) is specified, the List widget will compute it.  When computing
  154. the number of strings the List widget assumes that the \fBlist\fP is NULL
  155. terminated. 
  156. .IP \fBpasteBuffer\fP 1.5i
  157. If this resource is set to \fBTrue\fP then the name of the currently
  158. selected list element will be put into \fBCUT_BUFFER_0\fP.
  159. .Pf
  160. .Pb
  161. .Sc
  162. .Se
  163. .Tr
  164. .IP \fBverticalList\fP 1.5i
  165. If this resource is set to \fBTrue\fP then the list elements will be 
  166. presented in column major order.
  167. .Xy
  168. .NH 3
  169. List Actions
  170. .IN "List widget" "actions"
  171. .LP
  172. The List widget supports the following actions:
  173. .IP \(bu 5
  174. Highlighting and unhighlighting the list element under the
  175. pointer with \fBSet\fP and \fBUnset\fP
  176. .IP \(bu 5
  177. Processing application callbacks with \fBNotify\fP
  178. .LP
  179. The following is the default translation table used by the List Widget:
  180. .IN "List widget" "default translation table"
  181. .LP
  182. .Ds 
  183. .TA .5i 2.25i
  184. .ta .5i 2.25i
  185. <Btn1Down>,<Btn1Up>:    Set(\|) Notify(\|)
  186. .sp
  187. .De
  188. .LP
  189. The full list of actions supported by List widget is:
  190. .IP \fBSet\fP(\|) 1.5i
  191. \fISets\fP the list element that is currently under the pointer.  To
  192. inform the user that this element is currently set, it is drawn with is
  193. foreground and background colors reversed.  If this action is called when
  194. there is no list element under the cursor, the currently \fIset\fP
  195. element will be \fIunset\fP.
  196. .IP \fBUnset\fP(\|) 1.5i
  197. Cancels the \fIset\fP state of the element under the pointer,
  198. and redraws it with normal foreground and background colors.
  199. .IP \fBNotify\fP(\|) 1.5i
  200. Calls all callbacks on the List widget's callback list.  Information
  201. about the currently selected list element is passed in the
  202. \fIcall_data\fP argument (see \fBList Callbacks\fP below).
  203. .NH 3
  204. List Callbacks
  205. .IN "List widget" "callbacks"
  206. .LP
  207. All procedures on the List widget's callback list will have a
  208. \fBXawListReturnStruct\fP passed to them as \fIcall_data\fP.  The
  209. structure is defined in the List widget's application header file.
  210. .LP
  211. .Ds 0
  212. .TA .5i 2.25i
  213. .ta .5i 2.25i
  214. .IN "XawListReturnStruct" "" "@DEF@"
  215. typedef struct _XawListReturnStruct {
  216.     String string;    /* string shown in the list. */
  217.     int list_index;    /* index of the item selected. */
  218. } XawListReturnStruct;
  219. .IN "XawListReturnStruct" ""
  220. .NT
  221. The \fIlist_index\fP item used to be called simply \fIindex\fP.
  222. Unfortunately, this name collided with a global name defined on some
  223. operating systems, and had to be changed.
  224. .NE
  225. .De
  226. .NH 3
  227. Changing the List
  228. .LP
  229. To change the list that is displayed, use
  230. .PN XawListChange .
  231. .IN "XawListChange" "" "@DEF@"
  232. .FD 0
  233. void XawListChange(\fIw\fP, \fIlist\fP, \fInitems\fP, \fIlongest\fP, \fIresize\fP)
  234. .br
  235.      Widget \fIw\fP;
  236. .br
  237.      String * \fIlist\fP;
  238. .br
  239.      int \fInitems\fP, \fIlongest\fP;
  240. .br
  241.      Boolean \fIresize\fP;
  242. .FN
  243. .IP \fIw\fP 1i
  244. Specifies the List widget.
  245. .IP \fIlist\fP 1i
  246. Specifies the new list for the List widget to display.
  247. .IP \fInitems\fP 1i
  248. Specifies the number of items in the \fIlist\fP.  If a value less than 1
  249. is specified, \fIlist\fP must be NULL terminated, and the number of
  250. items will be calculated by the List widget.
  251. .IP \fIlongest\fP 1i
  252. Specifies the length of the longest item in the \fIlist\fP in pixels.
  253. If a value less than 1 is specified, the List widget will calculate the
  254. value.
  255. .IP \fIresize\fP 1i
  256. Specifies a Boolean value that if \fBTrue\fP indicates that the
  257. List widget should try to resize itself after making the change.
  258. The constraints of the List widget's parent are always enforced,
  259. regardless of the value specified here.
  260. .LP
  261. .PN XawListChange
  262. will \fIunset\fP all list elements that are currently \fBset\fP before
  263. the list is actually changed.  The \fIlist\fP is used in place, and must
  264. remain usable for the lifetime of the List widget, or until \fIlist\fP
  265. has been changed again with this function or with \fBXtSetValues\fP.
  266. .NH 3
  267. Highlighting an Item
  268. .LP
  269. To highlight an item in the list, use
  270. .PN XawListHighlight .
  271. .IN "XawListHighlight" "" "@DEF@"
  272. .FD 0
  273. void XawListHighlight(\fIw\fP, \fIitem\fP)
  274. .br
  275.      Widget \fIw\fP;
  276. .br
  277.      int \fIitem\fP;
  278. .FN
  279. .IP \fIw\fP 1i
  280. Specifies the List widget.
  281. .IP \fIitem\fP 1i
  282. Specifies an index into the current list that indicates the item to be
  283. highlighted.
  284. .LP
  285. Only one item can be highlighted at a time.
  286. If an item is already highlighted when
  287. .PN XawListHighlight 
  288. is called,
  289. the highlighted item is unhighlighted before the new item is highlighted.
  290. .NH 3
  291. Unhighlighting an Item
  292. .LP
  293. To unhighlight the currently highlighted item in the list, use
  294. .PN XawListUnhighlight .
  295. .IN "XawListUnhighlight" "" "@DEF@"
  296. .FD 0
  297. void XawListUnhighlight(\fIw\fP)
  298. .br
  299.      Widget \fIw\fP;
  300. .FN
  301. .IP \fIw\fP 1i
  302. Specifies the List widget.
  303. .NH 3
  304. Retrieving the Currently Selected Item
  305. .LP
  306. To retrieve the list element that is currently \fIset\fP, use
  307. .PN XawListShowCurrent .
  308. .IN "XawListShowCurrent" "" "@DEF@"
  309. .FD 0
  310. XawListReturnStruct *XawListShowCurrent(\fIw\fP)
  311. .br
  312.      Widget \fIw\fP;
  313. .FN
  314. .IP \fIw\fP 1i
  315. Specifies the List widget.
  316. .LP
  317. .PN XawListShowCurrent
  318. returns a pointer to an
  319. .PN XawListReturnStruct
  320. structure,
  321. containing the currently highlighted item.
  322. If the value of the index member is XAW_LIST_NONE,
  323. .IN "XAW_LIST_NONE"
  324. the string member is undefined, and no item is currently selected.
  325.