-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultiList.h
301 lines (239 loc) · 12.3 KB
/
MultiList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/****************************************************************************
MultiList.h
This file is the public header file for the MultiList widget, an
extension to the Athena List widget.
This code is loosely based on the Athena List source which
is why the MIT copyright notice appears below.
The code was changed substantially in V3.4 to change the
action/callback interface which was unnecessarily ugly. Code
using some features of the old interface may need to be changed.
Hope the changes don't make people's lives too miserable.
****************************************************************************/
/*
* Author:
* Brian Totty
* Department of Computer Science
* University Of Illinois at Urbana-Champaign
* 1304 West Springfield Avenue
* Urbana, IL 61801
*
* totty@cs.uiuc.edu
*
*/
/*
* Copyright 1989 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Original Athena Author: Chris D. Peterson, MIT X Consortium
*/
#ifndef _MULTILIST_H_
#define _MULTILIST_H_
#include <X11/Xaw/Simple.h>
/*---------------------------------------------------------------------------*
R E S O U R C E D E S C R I P T I O N S A N D N O T E S
*---------------------------------------------------------------------------*/
/*
Name Class RepType Default Value
---- ----- ------- -------------
background Background Pixel XtDefaultBackground
border BorderColor Pixel XtDefaultForeground
borderWidth BorderWidth Dimension 1
callback Callback XtCallbackList NULL *1
columnWidth Width Dimension 0 *9
columnSpacing Spacing Dimension 8
cursor Cursor Cursor left_ptr
defaultColumns Columns int 1 *2
destroyCallback Callback Pointer NULL
font Font XFontStruct* XtDefaultFont
forceColumns Columns Boolean False *2
foreground Foreground Pixel XtDefaultForeground
height Height Dimension 0 *3
highlightBackground HBackground Pixel XtDefaultForeground *4
highlightForeground HForeground Pixel XtDefaultBackground *4
insensitiveBorder Insensitive Pixmap Gray
list List String * NULL *5
longest Longest int 0 *6
mappedWhenManaged MappedWhenManaged Boolean True
maxSelectable Value int 1 *7
numberStrings NumberStrings int 0 *5
pasteBuffer Boolean Boolean False
rowHeight Height Dimension 0 *9
rowSpacing Spacing Dimension 2
sensitive Sensitive Boolean True
sensitiveArray List Boolean * NULL *8
shadeSurplus Boolean Boolean True *10 verticalList
Boolean Boolean False width Width Dimension 0
x Position Position 0
y Position Position 0
* 1 - The callback functions are called whenever a highlight or unhighlight
takes place. More precisely, a callback occurs whenever the Notify()
action is triggered. By default, this occurs when the mouse button is
lifted after a selection or deselection occurred. The callback returns
an XfwfMultiListReturnStruct data structure which contains numerous
fields describing the selection state. The most important fields
indicate the total number of items selected, and a list of those items.
* 2 - The defaultColumns resource is used in two cases. If forceColumns
is true, the widget will set the number of columns to the value of
default columns. If the widget width is unconstrained by the parent
widgets, the defaultColumns is also used to determine the number of
columns and the resulting width. Otherwise, the number of columns
will be calcultaed based on the current width and will be changed to
an appropriate value.
* 3 - If the width or height is set to zero (0), which is the default case,
then the widget will calculate the size of that dimension to be just
large enough to hold the contents of the widget.
* 4 - The highlightForeground and highlightBackground colors specify the
colors used to highlight the text (foreground) and the surrounding
background space of a list item when it is selected (highlighted).
The default is the reverse of the default foreground and background
colors.
* 5 - The list resource is an array of strings (char * array) which tell
the names of each item of the list. The number of elements of this
array are indicated by the resource numberStrings. If numberStrings
is set to 0 (the default), then the MultiList widget will count the
number of strings in the list. This requires that the list be
NULL terminated. If list is NULL, then the widget treats it as an
empty list. Once the list is set the list resource is set to NULL,
so you won't be able to read back the list after it has been set. The
widgets copies the strings internally, so the user can free the list
storage after setting it.
* 6 - This resource represent the longest string in pixels. If this
resource is zero (0), which is the default and probably the value
most people should use, the longest string length is calculated
and the resource is updated.
* 7 - The maxSelectable resource indicates the maximum number of items
which can be selected at any one time. In the original Athena
widget, you could have at most one item selected at a time. In
this widget, you can choose how many will be selected at a time.
* 8 - Each item in the MultiList can be made insensitive, so it is printed in
gray shading and can not be highlighted. This can be done by
setting the sensitivity list, which is an array of Booleans which
indicate whether or not the corresponding item is sensitive (can be
selected). If sensitivity list is NULL, all items are sensitive. The
widget copies the sensitivity information, so the user can delete the
sensitivity array storage after setting it. The widget sets the
resource to NULL after it has been set, so the user cannot read the
old list back.
* 9 - These values are intended for reading only. They indicate the pixel
width/height of the column/row.
* 10 - If the list height is made larger than the sum of the list entry
heights, the surplus space is shaded in the background color if
shadeSurplus is False, or in a gray stipple pattern if shadeSurplus
is True.
*/
/*---------------------------------------------------------------------------*
S T R I N G D E F I N I T I O N S
*---------------------------------------------------------------------------*/
#ifndef XtCList
#define XtCList "List"
#endif
#ifndef XtCSpacing
#define XtCSpacing "Spacing"
#endif
#ifndef XtCColumns
#define XtCColumns "Columns"
#endif
#ifndef XtCLongest
#define XtCLongest "Longest"
#endif
#define XtCNumberStrings "NumberStrings"
#define XtCHForeground "HForeground"
#define XtCHBackground "HBackground"
#ifndef XtNcursor
#define XtNcursor "cursor"
#endif
#define XtNhighlightForeground "highlightForeground"
#define XtNhighlightBackground "highlightBackground"
#define XtNcolumnSpacing "columnSpacing"
#ifndef XtNrowSpacing
#define XtNrowSpacing "rowSpacing"
#endif
#define XtNdefaultColumns "defaultColumns"
#ifndef XtNforceColumns
#define XtNforceColumns "forceColumns"
#endif
#ifndef XtNpasteBuffer
#define XtNpasteBuffer "pasteBuffer"
#endif
#ifndef XtNverticalList
#define XtNverticalList "verticalList"
#endif
#ifndef XtNlongest
#define XtNlongest "longest"
#endif
#define XtNnumberStrings "numberStrings"
#ifndef XtNlist
#define XtNlist "list"
#endif
#define XtNsensitiveArray "sensitiveArray"
#define XtNmaxSelectable "maxSelectable"
#define XtNshadeSurplus "shadeSurplus"
#define XtNrowHeight "rowHeight"
#define XtNcolumnWidth "columnWidth"
/* Class Record Constants */
extern WidgetClass xfwfMultiListWidgetClass;
typedef struct _XfwfMultiListClassRec *XfwfMultiListWidgetClass;
typedef struct _XfwfMultiListRec *XfwfMultiListWidget;
/*---------------------------------------------------------------------------*
R E T U R N S T R U C T U R E
*---------------------------------------------------------------------------*/
#define XfwfMultiListActionNothing 0
#define XfwfMultiListActionHighlight 1
#define XfwfMultiListActionUnhighlight 2
#define XfwfMultiListActionStatus 3
typedef struct _XfwfMultiListReturnStruct {
int num_selected; /* Number Of Items Now Selected */
int *selected_items; /* Indexes Of Selected Items */
int action; /* Last Action Performed */
int item; /* Last Item Index Modified */
String string; /* String Of Last Index Modified */
} XfwfMultiListReturnStruct;
/*---------------------------------------------------------------------------*
U T I L I T Y R O U T I N E S
*---------------------------------------------------------------------------*/
#if (!NeedFunctionPrototypes)
extern Boolean XfwfMultiListHighlightItem();
extern void XfwfMultiListHighlightAll();
extern void XfwfMultiListUnhighlightItem();
extern void XfwfMultiListUnhighlightAll();
extern int XfwfMultiListToggleItem();
extern XfwfMultiListReturnStruct *XfwfMultiListGetHighlighted();
extern Boolean XfwfMultiListIsHighlighted();
extern Boolean XfwfMultiListGetItemInfo();
extern void XfwfMultiListSetNewData();
#else
extern Boolean XfwfMultiListHighlightItem(XfwfMultiListWidget mlw,
int item_index);
extern void XfwfMultiListHighlightAll(XfwfMultiListWidget mlw);
extern void XfwfMultiListUnhighlightItem(XfwfMultiListWidget mlw,
int item_index);
extern void XfwfMultiListUnhighlightAll(XfwfMultiListWidget mlw);
extern int XfwfMultiListToggleItem(XfwfMultiListWidget mlw, int item_index);
extern XfwfMultiListReturnStruct *
XfwfMultiListGetHighlighted(XfwfMultiListWidget mlw);
extern Boolean XfwfMultiListIsHighlighted(XfwfMultiListWidget mlw,
int item_index);
extern Boolean XfwfMultiListGetItemInfo(XfwfMultiListWidget mlw, int item_index,
String *str_ptr, Boolean *h_ptr,
Boolean *s_ptr);
extern void XfwfMultiListSetNewData(XfwfMultiListWidget mlw, String *list,
int nitems, int longest, int resize,
Boolean *sensitivity_array);
#endif
#endif