Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * tixHList.h -- | |
3 | * | |
4 | * Defines the data structures and functions used by the tixHList | |
5 | * widget. | |
6 | * | |
7 | * Copyright (c) 1996, Expert Interface Technologies | |
8 | * | |
9 | * See the file "license.terms" for information on usage and redistribution | |
10 | * of this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
11 | * | |
12 | */ | |
13 | ||
14 | #ifndef _TIX_HLIST_H_ | |
15 | #define _TIX_HLIST_H_ | |
16 | ||
17 | #ifndef _TIX_INT_H_ | |
18 | #include "tixInt.h" | |
19 | #endif | |
20 | ||
21 | #include "tkVMacro.h" | |
22 | ||
23 | #define HLTYPE_COLUMN 1 | |
24 | #define HLTYPE_HEADER 2 | |
25 | #define HLTYPE_ENTRY 3 | |
26 | ||
27 | /* This is used to indetify what object has caused a DItemSizeChange | |
28 | * All data structs for objects that manage DItems must have these two | |
29 | * members as the beginning of the struct. | |
30 | */ | |
31 | typedef struct HLItemTypeInfo { | |
32 | int type; | |
33 | char * self; | |
34 | } HLItemTypeInfo; | |
35 | ||
36 | typedef struct HListColumn { | |
37 | /* generic type info section */ | |
38 | int type; | |
39 | char * self; | |
40 | struct _HListElement * chPtr; | |
41 | ||
42 | /* other data */ | |
43 | Tix_DItem * iPtr; | |
44 | int width; | |
45 | } HListColumn; | |
46 | ||
47 | typedef struct HListHeader { | |
48 | /* generic type info section */ | |
49 | int type; | |
50 | char * self; | |
51 | ||
52 | struct HListStruct * wPtr; | |
53 | /* other data */ | |
54 | Tix_DItem * iPtr; | |
55 | int width; | |
56 | ||
57 | Tk_3DBorder background; /* Used for drawing the 3d border. */ | |
58 | int relief; /* Indicates whether window as a whole is | |
59 | * raised, sunken, or flat. */ | |
60 | int borderWidth; | |
61 | } HListHeader; | |
62 | ||
63 | /*---------------------------------------------------------------------- | |
64 | * A HListElement structure contain the information about each element | |
65 | * inside the HList. | |
66 | * | |
67 | */ | |
68 | typedef struct _HListElement { | |
69 | /* generic type info section */ | |
70 | int type; | |
71 | char * self; | |
72 | ||
73 | /* other data */ | |
74 | struct HListStruct * wPtr; | |
75 | struct _HListElement * parent; | |
76 | struct _HListElement * prev; | |
77 | struct _HListElement * next; | |
78 | struct _HListElement * childHead; | |
79 | struct _HListElement * childTail; | |
80 | ||
81 | int numSelectedChild; /* number of childs that has selection(s) in | |
82 | * them (either this child is selected or some | |
83 | * of its descendants are selected */ | |
84 | int numCreatedChild; /* this var gets increment by one each | |
85 | * time a child is created */ | |
86 | char * pathName; /* Full pathname of this element */ | |
87 | char * name; /* Name of this element */ | |
88 | int height; /* Height of this element, including padding | |
89 | * and selBorderWidth; | |
90 | */ | |
91 | int allHeight; /* Height of all descendants and self */ | |
92 | Tk_Uid state; /* State of Tab's for display purposes: | |
93 | * normal or disabled. */ | |
94 | Arg data; /* user data field */ | |
95 | /* bottom-middle position of the bitmap/image branch (offset from | |
96 | * the top-left corner of the item) | |
97 | */ | |
98 | int branchX; | |
99 | int branchY; | |
100 | ||
101 | /* offset of the left-middle position of the icon */ | |
102 | int iconX; | |
103 | int iconY; | |
104 | /*----------------------------------*/ | |
105 | /* Things to display in the element */ | |
106 | /*----------------------------------*/ | |
107 | HListColumn * col; /* the multi-column display items */ | |
108 | HListColumn _oneCol; /* If we have only one column, then this | |
109 | * space is used (pointed to by column). | |
110 | * This will save one Malloc */ | |
111 | int indent; | |
112 | Tix_DItem * indicator; /* indicator: little triangle on Mac */ | |
113 | ||
114 | /*----------------------------------*/ | |
115 | /* Flags */ | |
116 | /*----------------------------------*/ | |
117 | Tix_DItemInfo * diTypePtr; | |
118 | ||
119 | unsigned int selected : 1; | |
120 | unsigned int hidden : 1; | |
121 | unsigned int dirty : 1; /* If it is dirty then its geometry needs | |
122 | * be recalculated */ | |
123 | } Tix_HListElement, HListElement; | |
124 | ||
125 | /* | |
126 | * A data structure of the following type is kept for each | |
127 | * widget managed by this file: | |
128 | */ | |
129 | typedef struct HListStruct { | |
130 | Tix_DispData dispData; | |
131 | Tcl_Command widgetCmd; /* Token for button's widget command. */ | |
132 | ||
133 | /* | |
134 | * Information used when displaying widget: | |
135 | */ | |
136 | LangCallback *command; /* Command prefix to use when invoking | |
137 | * scrolling commands. NULL means don't | |
138 | * invoke commands. Malloc'ed. */ | |
139 | int width, height; /* For app programmer to request size */ | |
140 | ||
141 | /* | |
142 | * Information used when displaying widget: | |
143 | */ | |
144 | ||
145 | /* Border and general drawing */ | |
146 | int borderWidth; /* Width of 3-D borders. */ | |
147 | int selBorderWidth; /* Width of 3-D borders for selected items */ | |
148 | int relief; /* Indicates whether window as a whole is | |
149 | * raised, sunken, or flat. */ | |
150 | int indent; /* How much should the children be indented | |
151 | * (to the right)?, in pixels */ | |
152 | Tk_3DBorder border; /* Used for drawing the 3d border. */ | |
153 | Tk_3DBorder selectBorder; /* Used for selected background. */ | |
154 | XColor *normalFg; /* Normal foreground for text. */ | |
155 | XColor *normalBg; /* Normal bachground for text. */ | |
156 | XColor *selectFg; /* Color for drawing selected text. */ | |
157 | TixFont font; /* The default font used in the DItems. */ | |
158 | GC backgroundGC; /* GC for drawing background. */ | |
159 | GC normalGC; /* GC for drawing text in normal mode. */ | |
160 | GC selectGC; /* GC for drawing selected background. */ | |
161 | GC anchorGC; /* GC for drawing dotted anchor highlight. */ | |
162 | GC dropSiteGC; /* GC for drawing dotted anchor highlight. */ | |
163 | ||
164 | Cursor cursor; /* Current cursor for window, or None. */ | |
165 | ||
166 | int topPixel; /* Vertical offset */ | |
167 | int leftPixel; /* Horizontal offset */ | |
168 | int bottomPixel; | |
169 | int wideSelect; /* BOOL: if 1, use a wide selection: the | |
170 | * selection background color covers the whole | |
171 | * widget. If 0, only the "significant" part | |
172 | * of a list entry is highlighted */ | |
173 | int selectWidth; /* Width of the selection: takes effect only | |
174 | * if wideSelect == 1 */ | |
175 | int exportSelection; /* Do we grab X Selection */ | |
176 | /* For highlights */ | |
177 | int highlightWidth; /* Width in pixels of highlight to draw | |
178 | * around widget when it has the focus. | |
179 | * <= 0 means don't draw a highlight. */ | |
180 | XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ | |
181 | GC highlightGC; /* For drawing traversal highlight. */ | |
182 | ||
183 | /* default pad and gap values */ | |
184 | int gap, padX, padY; | |
185 | char * separator; | |
186 | ||
187 | Tk_Uid selectMode; /* Selection style: single, browse, multiple, | |
188 | * or extended. This value isn't used in C | |
189 | * code, but the Tcl bindings use it. */ | |
190 | int drawBranch; /* Whether to draw the "branch" lines from | |
191 | * parent entry to children */ | |
192 | Tcl_HashTable childTable; /* Hash table to translate child names | |
193 | * into (HListElement *) */ | |
194 | HListElement * root; /* Mother of all elements */ | |
195 | HListElement * anchor; /* The current anchor item */ | |
196 | HListElement * dragSite; /* The current drag site */ | |
197 | HListElement * dropSite; /* The current drop site */ | |
198 | ||
199 | LangCallback *yScrollCmd; /* Command prefix for communicating with | |
200 | * vertical scrollbar. NULL means no command | |
201 | * to issue. Malloc'ed. */ | |
202 | LangCallback *xScrollCmd; /* Command prefix for communicating with | |
203 | * horizontal scrollbar. NULL means no command | |
204 | * to issue. Malloc'ed. */ | |
205 | LangCallback *sizeCmd; /* The command to call when the size of | |
206 | * the listbox changes. E.g., when the user | |
207 | * add/deletes elements. Useful for | |
208 | * auto-scrollbar geometry managers */ | |
209 | LangCallback *browseCmd; /* The command to call when the selection | |
210 | * changes. */ | |
211 | LangCallback *indicatorCmd; /* The command to call when the user touches | |
212 | * the indicator. */ | |
213 | LangCallback *dragCmd; /* The command to call when info about a | |
214 | * drag source is needed */ | |
215 | LangCallback *dropCmd; /* The command to call when action at a drop | |
216 | * side needs to be performed */ | |
217 | char *takeFocus; /* Value of -takefocus option; not used in | |
218 | * the C code, but used by keyboard traversal | |
219 | * scripts. Malloc'ed, but may be NULL. */ | |
220 | ||
221 | Tix_LinkList mappedWindows; /* Those windows that are are mapped by this | |
222 | * widget*/ | |
223 | int serial; /* this number is incremented before each time | |
224 | * the widget is redisplayed */ | |
225 | ||
226 | int numColumns; /* number of columns in the tixHList widget, | |
227 | * cannot be changed after the widget's | |
228 | * creation */ | |
229 | ||
230 | int totalSize[2]; | |
231 | ||
232 | HListColumn * reqSize; /* Requested column sizes by the user: | |
233 | take precedence */ | |
234 | HListColumn * actualSize; /* Actual column sizes, calculated using | |
235 | * the sizes of the ditems */ | |
236 | ||
237 | HListHeader ** headers; /* Stores all the headers for a HList widget */ | |
238 | int useHeader; /* whether headers should be used */ | |
239 | int headerHeight; /* required height of the header */ | |
240 | ||
241 | Tix_DItemInfo * diTypePtr; /* Default item type */ | |
242 | Tix_StyleTemplate stTmpl; | |
243 | ||
244 | int useIndicator; /* should indicators be displayed */ | |
245 | int scrollUnit[2]; | |
246 | ||
247 | Tk_Window headerWin; /* subwindow, used to draw the headers */ | |
248 | char * elmToSee; /* name of element to "see" the next time | |
249 | * this widget is redrawn */ | |
250 | unsigned redrawing : 1; | |
251 | unsigned redrawingFrame : 1; | |
252 | unsigned resizing : 1; | |
253 | unsigned hasFocus : 1; | |
254 | unsigned allDirty : 1; | |
255 | unsigned initialized : 1; | |
256 | unsigned headerDirty : 1; | |
257 | unsigned needToRaise : 1; /* The header subwindow needs to be raised | |
258 | * if we add a new window item into the | |
259 | * HList widget (either in the list or | |
260 | * in the header */ | |
261 | } HList; | |
262 | ||
263 | #define TIX_X 0 | |
264 | #define TIX_Y 1 | |
265 | #define UNINITIALIZED -1 | |
266 | ||
267 | typedef HList WidgetRecord; | |
268 | typedef HList * WidgetPtr; | |
269 | ||
270 | EXTERN TIX_DECLARE_SUBCMD(Tix_HLColumn); | |
271 | EXTERN TIX_DECLARE_SUBCMD(Tix_HLItem); | |
272 | ||
273 | EXTERN HListColumn * Tix_HLAllocColumn _ANSI_ARGS_(( | |
274 | WidgetPtr wPtr, HListElement * chPtr)); | |
275 | EXTERN void Tix_HLCancelResizeWhenIdle _ANSI_ARGS_(( | |
276 | WidgetPtr wPtr)); | |
277 | EXTERN void Tix_HLComputeGeometry _ANSI_ARGS_(( | |
278 | ClientData clientData)); | |
279 | EXTERN HListElement * Tix_HLFindElement _ANSI_ARGS_((Tcl_Interp *interp, | |
280 | WidgetPtr wPtr, char * pathName)); | |
281 | EXTERN void Tix_HLFreeMappedWindow _ANSI_ARGS_((WidgetPtr wPtr, | |
282 | HListElement * chPtr)); | |
283 | EXTERN int Tix_HLElementTopOffset _ANSI_ARGS_(( | |
284 | WidgetPtr wPtr, HListElement *chPtr)); | |
285 | EXTERN int Tix_HLElementLeftOffset _ANSI_ARGS_(( | |
286 | WidgetPtr wPtr, HListElement *chPtr)); | |
287 | EXTERN int Tix_HLItemInfo _ANSI_ARGS_((Tcl_Interp *interp, | |
288 | WidgetPtr wPtr, int argc, Tcl_Obj **objv)); | |
289 | EXTERN int Tix_HLHeader _ANSI_ARGS_((ClientData clientData, | |
290 | Tcl_Interp *interp, int argc, Tcl_Obj **objv)); | |
291 | EXTERN int Tix_HLCreateHeaders _ANSI_ARGS_(( | |
292 | Tcl_Interp *interp, WidgetPtr wPtr)); | |
293 | EXTERN void Tix_HLFreeHeaders _ANSI_ARGS_(( | |
294 | Tcl_Interp *interp, WidgetPtr wPtr)); | |
295 | EXTERN void Tix_HLDrawHeader _ANSI_ARGS_(( | |
296 | WidgetPtr wPtr, Pixmap pixmap, GC gc, | |
297 | int hdrX, int hdrY, int hdrW, int hdrH, | |
298 | int xOffset)); | |
299 | EXTERN void Tix_HLComputeHeaderGeometry _ANSI_ARGS_(( | |
300 | WidgetPtr wPtr)); | |
301 | ||
302 | EXTERN void Tix_HLMarkElementDirty _ANSI_ARGS_((WidgetPtr wPtr, | |
303 | HListElement *chPtr)); | |
304 | EXTERN void Tix_HLResizeWhenIdle _ANSI_ARGS_((WidgetPtr wPtr)); | |
305 | EXTERN void Tix_HLResizeNow _ANSI_ARGS_((WidgetPtr wPtr)); | |
306 | EXTERN void Tix_HLComputeGeometry _ANSI_ARGS_(( | |
307 | ClientData clientData)); | |
308 | EXTERN void Tix_HLCancelResizeWhenIdle _ANSI_ARGS_(( | |
309 | WidgetPtr wPtr)); | |
310 | ||
311 | ||
312 | /* in tixHLCol.c */ | |
313 | EXTERN TIX_DECLARE_SUBCMD(Tix_HLColumn); | |
314 | EXTERN TIX_DECLARE_SUBCMD(Tix_HLItem); | |
315 | ||
316 | /* in tixHLInd.c */ | |
317 | EXTERN TIX_DECLARE_SUBCMD(Tix_HLIndicator); | |
318 | ||
319 | #endif /*_TIX_HLIST_H_ */ | |
320 |