1 /*
2  * XedwList.h - XedwList widget
3  *
4  * This is the XedwList widget. It is very similar to the Athena Widget List,
5  * except it has the ability to display an icon with the string.
6  * It allows the user to select an item in a xedwList and notifies the
7  * application through a callback function.
8  *
9  *  List Created:   8/13/88
10  *  By:     Chris D. Peterson
11  *                      MIT X Consortium
12  *
13  *  Modified to XedwList: 1/26/91
14  *  By:      Edward Groenendaal
15  *                      University of Sussex, UK.
16  */
17 
18 #ifndef _XawXedwList_h
19 #define _XawXedwList_h
20 
21 /***********************************************************************
22  *
23  * XedwList Widget
24  *
25  ***********************************************************************/
26 
27 #include <X11/Intrinsic.h>
28 #include <X11/Xaw/Simple.h>
29 
30 /* Resources:
31 
32  Name               Class           RepType             Default Value
33  ----               -----           -------             -------------
34  background         Background      Pixel               XtDefaultBackground
35  border             BorderColor     Pixel               XtDefaultForeground
36  borderWidth        BorderWidth     Dimension           1
37  callback           Callback        XtCallbackXedwList  NULL       **6
38  columnSpacing      Spacing         Dimension           6
39  cursor             Cursor          Cursor              left_ptr
40  defaultColumns     Columns         int                 2          **5
41  destroyCallback    Callback        Pointer             NULL
42  font               Font            XFontStruct*        XtDefaultFont
43  forceColumns       Columns         Boolean             False      **5
44  foreground         Foreground      Pixel               XtDefaultForeground
45  height             Height          Dimension           0          **1
46  insensitiveBorder  Insensitive     Pixmap              Gray
47  internalHeight     Height          Dimension           2
48  internalWidth      Width           Dimension           4
49  xedwList           XedwList        XedwList **         NULL       **2
50  iconWidth          Width           Dimension           32
51  iconHeight         Height          Dimension           32
52  longest            Longest         int                 0          **3  **4
53  mappedWhenManaged  MappedWhenManaged   Boolean         True
54  mSelections	    Boolean         Boolean             False
55  numberStrings      NumberStrings   int                 0          **4
56  pasteBuffer        Boolean         Boolean             False
57  rowSpacing         Spacing         Dimension           4
58  sensitive          Sensitive       Boolean             True
59  showIcons          Boolean         Boolean             False
60  verticalList       Boolean         Boolean             False
61  width              Width           Dimension           0          **1
62  x                  Position        Position            0
63  y                  Position        Position            0
64 
65  **1 - If the Width or Height of the xedwList widget is zero (0) then the value
66        is set to the minimum size necessay to fit the entire list.
67 
68        If both Width and Height are zero then they are adjusted to fit the
69        entire list that is created width the number of default columns
70        specified in the defaultColumns resource.
71 
72  **2 - This is an array of strings the specify elements of the xedwList.
73        This resource must be specified.
74 
75  **3 - Longest is the length of the widest string in pixels.
76 
77  **4 - If either of these values are zero (0) then the xedwList widget calculates
78        the correct value.
79 
80        (This allows you to make startup faster if you already have
81         this information calculated)
82 
83        NOTE: If the numberStrings value is zero the xedwList must
84              be NULL terminated.
85 
86  **5 - By setting the XedwList.Columns resource you can force the application to
87        have a given number of columns.
88 
89  **6 - This returns the name and index of the item selected in an
90        XedwListReturnStruct that is pointed to by the client_data
91        in the CallbackProc.
92 
93 */
94 
95 
96 /*
97  * Value returned when there are no highlighted objects.
98  */
99 
100 #define XDTM_LIST_NONE -1
101 
102 #define XtCXedwList "XedwList"
103 #define XtCSpacing "Spacing"
104 #define XtCColumns "Columns"
105 #define XtCLongest "Longest"
106 #define XtCNumberStrings "NumberStrings"
107 
108 #define XtNcursor "cursor"
109 #define XtNcolumnSpacing "columnSpacing"
110 #define XtNdefaultColumns "defaultColumns"
111 #define XtNforceColumns "forceColumns"
112 #define XtNxedwList "xedwList"
113 #define XtNiconWidth "iconWidth"
114 #define XtNiconHeight "iconHeight"
115 #define XtNdefaultIcon "defaultIcon"
116 #define XtNlongest "longest"
117 #define XtNnumberStrings "numberStrings"
118 #define XtNpasteBuffer "pasteBuffer"
119 #define XtNrowSpacing "rowSpacing"
120 #define XtNshowIcons "showIcons"
121 #define XtNmSelections "mSelections"
122 #define XtNverticalList "verticalList"
123 
124 #define XedwSingle    1
125 #define XedwMultiple  2
126 
127 #define XedwAll			-1
128 
129 #define IconBitmapWidth       32
130 #define IconBitmapHeight      32
131 
132 /* Class record constants */
133 
134 extern WidgetClass xedwListWidgetClass;
135 
136 typedef struct _XedwListClassRec *XedwListWidgetClass;
137 typedef struct _XedwListRec      *XedwListWidget;
138 
139 /* The structure of XedwList */
140 
141 typedef struct _XedwList {
142   String string;
143   Pixmap icon;
144   Pixmap mask;
145 } XedwList;
146 
147 /* The xedwList return structure. */
148 
149 typedef struct _XedwListReturnStruct {
150   String   string;			/* String */
151   int      xedwList_index;		/* Index into list */
152   struct _XedwListReturnStruct *next;	/* Next highlighted entry */
153 } XedwListReturnStruct;
154 
155 /******************************************************************
156  *
157  * Exported Functions
158  *
159  *****************************************************************/
160 
161 /*  Function Name:  XedwListChange.
162  *  Description:    Changes the xedwList being used and shown.
163  *  Arguments:      w        -  the xedwList widget.
164  *                  xedwList -  the new xedwList.
165  *                  nitems   -  the number of items in the xedwList.
166  *                  longest  -  the length (in Pixels) of the longest element
167  *                              in the xedwList.
168  *                  resize   -  if TRUE the the xedwList widget will
169  *                              try to resize itself.
170  *  Returns: none.
171  *  NOTE:    If nitems of longest are <= 0 then they will be caluculated.
172  *           If nitems is <= 0 then the xedwList needs to be NULL terminated.
173  */
174 
175 extern void XedwListChange(
176 #if NeedFunctionPrototypes
177 Widget, XedwList**,int,int,Boolean
178 #endif
179 );
180 
181 /*  Function Name:  XedwListUnhighlight
182  *  Description:    unlights the current highlighted element.
183  *  Arguments:      w   -   the widget.
184  *  Returns: none.
185  */
186 
187 extern void XedwListUnhighlight(
188 #if NeedFunctionPrototypes
189  Widget, int
190 #endif
191 );
192 
193 /*  Function Name:  XedwListHighlight
194  *  Description:    Highlights the given item.
195  *  Arguments:      w    -  the xedwList widget.
196  *                  item -  the item to hightlight.
197  *  Returns: none.
198  */
199 
200 extern void XedwListHighlight(
201 #if NeedFunctionPrototypes
202 Widget, int
203 #endif
204 );
205 
206 
207 /*  Function Name: XedwListShowCurrent
208  *  Description: returns the currently highlighted objects.
209  *  Arguments: w - the xedwList widget.
210  *  Returns: the info about the currently highlighted object.
211  */
212 
213 extern XedwListReturnStruct *XedwListShowCurrent(
214 #if NeedFunctionPrototypes
215 Widget
216 #endif
217 );
218 
219 /*  Function Name: XedwListSelection
220  *  Description: returns true is an object is highlighted, false otherwise.
221  *  Arguments: w - the xedwList widget.
222  */
223 
224 extern Boolean XedwListSelection(
225 #if NeedFunctionPrototypes
226   Widget
227 #endif
228 );
229 
230 /*  Function Name: XedwListFreeCurrent
231  *  Description: Frees the storage allocated by a call to XedwListShowCurrent
232  *  Arguments: list - the XedwListReturnStruct list.
233  *  Returns: none.
234  */
235 extern void XedwListFreeCurrent(
236 #if NeedFunctionPrototypes
237   XedwListReturnStruct *
238 #endif
239 );
240 
241 #endif /* _XedwList_h */
242 
243