1 /*
2  * bltBind.h --
3  *
4  * Copyright 1993-1998 Lucent Technologies, Inc.
5  *
6  * Permission to use, copy, modify, and distribute this software and
7  * its documentation for any purpose and without fee is hereby
8  * granted, provided that the above copyright notice appear in all
9  * copies and that both that the copyright notice and warranty
10  * disclaimer appear in supporting documentation, and that the names
11  * of Lucent Technologies any of their entities not be used in
12  * advertising or publicity pertaining to distribution of the software
13  * without specific, written prior permission.
14  *
15  * Lucent Technologies disclaims all warranties with regard to this
16  * software, including all implied warranties of merchantability and
17  * fitness.  In no event shall Lucent Technologies be liable for any
18  * special, indirect or consequential damages or any damages
19  * whatsoever resulting from loss of use, data or profits, whether in
20  * an action of contract, negligence or other tortuous action, arising
21  * out of or in connection with the use or performance of this
22  * software.
23  */
24 
25 #ifndef _BLT_BIND_H
26 #define _BLT_BIND_H
27 
28 #include <bltList.h>
29 
30 typedef struct Blt_BindTableStruct *Blt_BindTable;
31 
32 typedef ClientData (Blt_BindPickProc) _ANSI_ARGS_((ClientData clientData,
33 	int x, int y, ClientData *contextPtr));
34 
35 typedef void (Blt_BindTagProc) _ANSI_ARGS_((Blt_BindTable bindTable,
36 	ClientData object, ClientData context, Blt_List list));
37 
38 
39 /*
40  *  Binding structure information:
41  */
42 
43 struct Blt_BindTableStruct {
44     unsigned int flags;
45     Tk_BindingTable bindingTable;
46 				/* Table of all bindings currently defined.
47 				 * NULL means that no bindings exist, so the
48 				 * table hasn't been created.  Each "object"
49 				 * used for this table is either a Tk_Uid for
50 				 * a tag or the address of an item named by
51 				 * id. */
52 
53     ClientData currentItem;	/* The item currently containing the mouse
54 				 * pointer, or NULL if none. */
55     ClientData currentContext;	/* One word indicating what kind of object
56 				 * was picked. */
57 
58     ClientData newItem;		/* The item that is about to become the
59 				 * current one, or NULL.  This field is
60 				 * used to detect deletions of the new
61 				 * current item pointer that occur during
62 				 * Leave processing of the previous current
63 				 * tab.  */
64     ClientData newContext;	/* One-word indicating what kind of object
65 				 * was just picked. */
66 
67     ClientData focusItem;
68     ClientData focusContext;
69 
70     XEvent pickEvent;		/* The event upon which the current choice
71 				 * of the current tab is based.  Must be saved
72 				 * so that if the current item is deleted,
73 				 * we can pick another. */
74     int activePick;		/* The pick event has been initialized so
75 				 * that we can repick it */
76 
77     int state;			/* Last known modifier state.  Used to
78 				 * defer picking a new current object
79 				 * while buttons are down. */
80 
81     ClientData clientData;
82     Tk_Window tkwin;
83     Blt_BindPickProc *pickProc;	/* Routine to report the item the mouse is
84 				 * currently over. */
85     Blt_BindTagProc *tagProc;	/* Routine to report tags picked items. */
86     Tcl_Interp *interp;
87 };
88 
89 EXTERN void Blt_DestroyBindingTable _ANSI_ARGS_((Blt_BindTable table));
90 
91 EXTERN Blt_BindTable Blt_CreateBindingTable _ANSI_ARGS_((Tcl_Interp *interp,
92 	Tk_Window tkwin, ClientData clientData, Blt_BindPickProc *pickProc,
93 	Blt_BindTagProc *tagProc));
94 
95 EXTERN int Blt_ConfigureBindings _ANSI_ARGS_((Tcl_Interp *interp,
96 	Blt_BindTable table, ClientData item, int argc, char **argv));
97 
98 #if (TCL_MAJOR_VERSION >= 8)
99 EXTERN int Blt_ConfigureBindingsFromObj _ANSI_ARGS_((Tcl_Interp *interp,
100 	Blt_BindTable table, ClientData item, int objc, Tcl_Obj *CONST *objv));
101 #endif
102 
103 EXTERN void Blt_PickCurrentItem _ANSI_ARGS_((Blt_BindTable table));
104 
105 EXTERN void Blt_DeleteBindings _ANSI_ARGS_((Blt_BindTable table,
106 	ClientData object));
107 
108 EXTERN void Blt_MoveBindingTable _ANSI_ARGS_((Blt_BindTable table,
109 	Tk_Window tkwin));
110 
111 #define Blt_SetFocusItem(bindPtr, object, context) \
112 	((bindPtr)->focusItem = (ClientData)(object),\
113 	 (bindPtr)->focusContext = (ClientData)(context))
114 
115 #define Blt_SetCurrentItem(bindPtr, object, context) \
116 	((bindPtr)->currentItem = (ClientData)(object),\
117 	 (bindPtr)->currentContext = (ClientData)(context))
118 
119 #define Blt_GetCurrentItem(bindPtr)  ((bindPtr)->currentItem)
120 #define Blt_GetCurrentContext(bindPtr)  ((bindPtr)->currentContext)
121 #define Blt_GetLatestItem(bindPtr)  ((bindPtr)->newItem)
122 
123 #define Blt_GetBindingData(bindPtr)  ((bindPtr)->clientData)
124 
125 #endif /*_BLT_BIND_H*/
126