summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Tk/pTk/tixHList.h
blob: 5625f137c15dea4ed91be857c9251a873bd57c47 (plain)
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323

/*	$Id: tixHList.h,v 1.1.1.1 2000/05/17 11:08:42 idiscovery Exp $	*/

/*
 * tixHList.h --
 *
 *	Defines the data structures and functions used by the tixHList
 *	widget.
 *
 * Copyright (c) 1996, Expert Interface Technologies
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 */

#ifndef _TIX_HLIST_H_
#define _TIX_HLIST_H_

#ifndef  _TIX_INT_H_
#include "tixInt.h"
#endif

#include "tkVMacro.h"

#define HLTYPE_COLUMN 1
#define HLTYPE_HEADER 2
#define HLTYPE_ENTRY  3

/* This is used to indetify what object has caused a DItemSizeChange
 * All data structs for objects that manage DItems must have these two
 * members as the beginning of the struct.
 */
typedef struct HLItemTypeInfo {
    int type;
    char * self;
} HLItemTypeInfo;

typedef struct HListColumn {
    /* generic type info section */
    int type;
    char * self;
    struct _HListElement * chPtr;

    /* other data */
    Tix_DItem * iPtr;
    int width;
} HListColumn;

typedef struct HListHeader {
    /* generic type info section */
    int type;
    char * self;

    struct HListStruct * wPtr;
    /* other data */
    Tix_DItem * iPtr;
    int width;

    Tk_3DBorder background;	/* Used for drawing the 3d border. */
    int relief;			/* Indicates whether window as a whole is
				 * raised, sunken, or flat. */
    int borderWidth;
} HListHeader;

/*----------------------------------------------------------------------
 *  A HListElement structure contain the information about each element
 * inside the HList.
 *
 */
typedef struct _HListElement {
    /* generic type info section */
    int type;
    char * self;

    /* other data */
    struct HListStruct   * wPtr;
    struct _HListElement * parent;
    struct _HListElement * prev;
    struct _HListElement * next;
    struct _HListElement * childHead;
    struct _HListElement * childTail;

    int numSelectedChild;	/* number of childs that has selection(s) in
				 * them (either this child is selected or some
				 * of its descendants are selected */
    int numCreatedChild;	/* this var gets increment by one each
				 * time a child is created */
    char * pathName;		/* Full pathname of this element */
    char * name;		/* Name of this element */
    int height;			/* Height of this element, including padding
				 * and selBorderWidth;
				 */
    int allHeight;		/* Height of all descendants and self */
    Tk_Uid state;		/* State of Tab's for display purposes:
				 * normal or disabled. */
    Tcl_Obj * data;			/* user data field */
    /* bottom-middle position of the bitmap/image branch (offset from
     * the top-left corner of the item)
     */
    int branchX;
    int branchY;

    /*  offset of the left-middle position of the icon */
    int iconX;
    int iconY;
    /*----------------------------------*/
    /* Things to display in the element */
    /*----------------------------------*/
    HListColumn * col;		/* the multi-column display items */
    HListColumn  _oneCol;	/* If we have only one column, then this
				 * space is used (pointed to by column).
				 * This will save one Malloc */
    int indent;
    Tix_DItem * indicator;	/* indicator: little triangle on Mac */

    /*----------------------------------*/
    /* Flags			        */
    /*----------------------------------*/
    Tix_DItemInfo * diTypePtr;

    unsigned int selected : 1;
    unsigned int hidden   : 1;
    unsigned int dirty    : 1;	/* If it is dirty then its geometry needs
				 * be recalculated */
} Tix_HListElement, HListElement;

/*
 * A data structure of the following type is kept for each
 * widget managed by this file:
 */
typedef struct HListStruct {
    Tix_DispData dispData;
    Tcl_Command widgetCmd;	/* Token for button's widget command. */

    /*
     * Information used when displaying widget:
     */
    LangCallback *command;		/* Command prefix to use when invoking
				 * scrolling commands.  NULL means don't
				 * invoke commands.  Malloc'ed. */
    int width, height;		/* For app programmer to request size */

    /*
     * Information used when displaying widget:
     */

    /* Border and general drawing */
    int borderWidth;		/* Width of 3-D borders. */
    int selBorderWidth;		/* Width of 3-D borders for selected items */
    int relief;			/* Indicates whether window as a whole is
				 * raised, sunken, or flat. */
    int indent;			/* How much should the children be indented
				 * (to the right)?, in pixels */
    Tk_3DBorder border;		/* Used for drawing the 3d border. */
    Tk_3DBorder selectBorder;	/* Used for selected background. */
    XColor *normalFg;		/* Normal foreground for text. */
    XColor *normalBg;		/* Normal bachground for  text. */
    XColor *selectFg;		/* Color for drawing selected text. */
    TixFont font;		/* The default font used in the DItems. */
    GC backgroundGC;		/* GC for drawing background. */
    GC normalGC;		/* GC for drawing text in normal mode. */
    GC selectGC;		/* GC for drawing selected background. */
    GC anchorGC;		/* GC for drawing dotted anchor highlight. */
    GC dropSiteGC;		/* GC for drawing dotted anchor highlight. */

    Cursor cursor;		/* Current cursor for window, or None. */

    int topPixel;		/* Vertical offset */
    int leftPixel;		/* Horizontal offset */
    int bottomPixel;
    int wideSelect;		/* BOOL: if 1, use a wide selection: the
				 * selection background color covers the whole
				 * widget. If 0, only the "significant" part
				 * of a list entry is highlighted */
    int selectWidth;		/* Width of the selection: takes effect only
				 * if wideSelect == 1 */
    int exportSelection;	/* Do we grab X Selection */
    /* For highlights */
    int highlightWidth;		/* Width in pixels of highlight to draw
				 * around widget when it has the focus.
				 * <= 0 means don't draw a highlight. */
    XColor *highlightColorPtr;	/* Color for drawing traversal highlight. */
    GC highlightGC;		/* For drawing traversal highlight. */

    /* default pad and gap values */
    int gap, padX, padY;
    char * separator;

    Tk_Uid selectMode;		/* Selection style: single, browse, multiple,
				 * or extended.  This value isn't used in C
				 * code, but the Tcl bindings use it. */
    int drawBranch;		/* Whether to draw the "branch" lines from
				 * parent entry to children */
    Tcl_HashTable childTable;	/* Hash table to translate child names
				 * into (HListElement *) */
    HListElement * root;	/* Mother of all elements */
    HListElement * anchor;	/* The current anchor item */
    HListElement * dragSite;	/* The current drag site */
    HListElement * dropSite;	/* The current drop site */

    LangCallback *yScrollCmd;	/* Command prefix for communicating with
				 * vertical scrollbar.  NULL means no command
				 * to issue.  Malloc'ed. */
    LangCallback *xScrollCmd;	/* Command prefix for communicating with
				 * horizontal scrollbar. NULL means no command
				 * to issue.  Malloc'ed. */
    LangCallback *sizeCmd;		/* The command to call when the size of
				 * the listbox changes. E.g., when the user
				 * add/deletes elements. Useful for
				 * auto-scrollbar geometry managers */
    LangCallback *browseCmd;	/* The command to call when the selection
				 * changes. */
    LangCallback *indicatorCmd;		/* The command to call when the user touches
				 * the indicator. */
    LangCallback *dragCmd;	/* The command to call when info about a
				 * drag source is needed */
    LangCallback *dropCmd;	/* The command to call when action at a drop
				 * side needs to be performed */
    char *takeFocus;		/* Value of -takefocus option;  not used in
				 * the C code, but used by keyboard traversal
				 * scripts.  Malloc'ed, but may be NULL. */

    Tix_LinkList mappedWindows; /* Those windows that are are mapped by this
				 * widget*/
    int serial;			/* this number is incremented before each time
				 * the widget is redisplayed */

    int numColumns;		/* number of columns in the tixHList widget,
				 * cannot be changed after the widget's
				 * creation */

    int totalSize[2];

    HListColumn * reqSize;	/* Requested column sizes by the user:
				   take precedence */
    HListColumn * actualSize;	/* Actual column sizes, calculated using
				 * the sizes of the ditems */

    HListHeader ** headers;	/* Stores all the headers for a HList widget */
    int useHeader;		/* whether headers should be used */
    int headerHeight;		/* required height of the header */

    Tix_DItemInfo * diTypePtr;	/* Default item type */
    Tix_StyleTemplate stTmpl;

    int useIndicator;		/* should indicators be displayed */
    int scrollUnit[2];

    Tk_Window headerWin;	/* subwindow, used to draw the headers */
    char * elmToSee;		/* name of element to "see" the next time
				 * this widget is redrawn */
    unsigned redrawing : 1;
    unsigned redrawingFrame : 1;
    unsigned resizing  : 1;
    unsigned hasFocus  : 1;
    unsigned allDirty  : 1;
    unsigned initialized : 1;
    unsigned headerDirty : 1;
    unsigned needToRaise : 1;	/* The header subwindow needs to be raised
				 * if we add a new window item into the
				 * HList widget (either in the list or
				 * in the header */
} HList;

#define TIX_X 0
#define TIX_Y 1
#define UNINITIALIZED -1

typedef HList   WidgetRecord;
typedef HList * WidgetPtr;

EXTERN TIX_DECLARE_SUBCMD(Tix_HLColumn);
EXTERN TIX_DECLARE_SUBCMD(Tix_HLItem);

EXTERN HListColumn * 	Tix_HLAllocColumn _ANSI_ARGS_((
			    WidgetPtr wPtr, HListElement * chPtr));
EXTERN void		Tix_HLCancelResizeWhenIdle _ANSI_ARGS_((
			    WidgetPtr wPtr));
EXTERN void		Tix_HLComputeGeometry _ANSI_ARGS_((
			    ClientData clientData));
EXTERN HListElement * 	Tix_HLFindElement _ANSI_ARGS_((Tcl_Interp *interp,
			    WidgetPtr wPtr, char * pathName));
EXTERN void 		Tix_HLFreeMappedWindow _ANSI_ARGS_((WidgetPtr wPtr,
			    HListElement * chPtr));
EXTERN int	 	Tix_HLElementTopOffset _ANSI_ARGS_((
			    WidgetPtr wPtr, HListElement *chPtr));
EXTERN int	 	Tix_HLElementLeftOffset _ANSI_ARGS_((
			    WidgetPtr wPtr, HListElement *chPtr));
EXTERN int 		Tix_HLItemInfo _ANSI_ARGS_((Tcl_Interp *interp,
			    WidgetPtr wPtr, int argc, Tcl_Obj *CONST *objv));
EXTERN int		Tix_HLHeader _ANSI_ARGS_((ClientData clientData,
			    Tcl_Interp *interp, int argc, Tcl_Obj *CONST *objv));
EXTERN int		Tix_HLCreateHeaders _ANSI_ARGS_((
			    Tcl_Interp *interp, WidgetPtr wPtr));
EXTERN void		Tix_HLFreeHeaders _ANSI_ARGS_((
			    Tcl_Interp *interp, WidgetPtr wPtr));
EXTERN void		Tix_HLDrawHeader _ANSI_ARGS_((
			    WidgetPtr wPtr, Pixmap pixmap, GC gc,
			    int hdrX, int hdrY, int hdrW, int hdrH,
			    int xOffset));
EXTERN void		Tix_HLComputeHeaderGeometry _ANSI_ARGS_((
			    WidgetPtr wPtr));

EXTERN void  		Tix_HLMarkElementDirty _ANSI_ARGS_((WidgetPtr wPtr,
			    HListElement *chPtr));
EXTERN void		Tix_HLResizeWhenIdle _ANSI_ARGS_((WidgetPtr wPtr));
EXTERN void		Tix_HLResizeNow _ANSI_ARGS_((WidgetPtr wPtr));
EXTERN void		Tix_HLComputeGeometry _ANSI_ARGS_((
			    ClientData clientData));
EXTERN void		Tix_HLCancelResizeWhenIdle _ANSI_ARGS_((
			    WidgetPtr wPtr));


/* in tixHLCol.c */
EXTERN TIX_DECLARE_SUBCMD(Tix_HLColumn);
EXTERN TIX_DECLARE_SUBCMD(Tix_HLItem);

/* in tixHLInd.c */
EXTERN TIX_DECLARE_SUBCMD(Tix_HLIndicator);

#endif /*_TIX_HLIST_H_ */