1 ;; -*- mode: Lisp; Syntax: Common-Lisp; Package: cells; -*-
4 Celtk -- Cells
, Tcl
, and Tk
6 Copyright
(C) 2006 by Kenneth Tilton
8 This library is free software
; you can redistribute it and/or
9 modify it under the terms of the Lisp Lesser GNU Public License
10 (http://opensource.franz.com
/preamble.html
), known as the LLGPL.
12 This library is distributed WITHOUT ANY WARRANTY
; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the Lisp Lesser GNU Public License for more details.
22 (defctype Window
:unsigned-long
) ;; <sigh> The XWindow pointer stored in the tkwin record
23 (defctype Time
:unsigned-long
)
24 (defctype Tk_Uid
:string
)
26 (defcstruct tk-fake-win
27 "Used by macros to peek at tkwins (why use a fake window definition?)"
42 ;;; XWindowChanges changes;
43 ;;; unsigned int dummy6; /* dirtyChanges */
44 ;;; XSetWindowAttributes atts;
45 ;;; unsigned long dummy7; /* dirtyAtts */
46 ;;; unsigned int flags;
47 ;;; char *dummy8; /* handlerList */
48 ;;;#ifdef TK_USE_INPUT_METHODS
49 ;;; XIC dummy9; /* inputContext */
50 ;;;#endif /* TK_USE_INPUT_METHODS */
51 ;;; ClientData *dummy10; /* tagPtr */
52 ;;; int dummy11; /* numTags */
53 ;;; int dummy12; /* optionLevel */
54 ;;; char *dummy13; /* selHandlerList */
55 ;;; char *dummy14; /* geomMgrPtr */
56 ;;; ClientData dummy15; /* geomData */
57 ;;; int reqWidth, reqHeight;
58 ;;; int internalBorderLeft;
59 ;;; char *dummy16; /* wmInfoPtr */
60 ;;; char *dummy17; /* classProcPtr */
61 ;;; ClientData dummy18; /* instanceData */
62 ;;; char *dummy19; /* privatePtr */
63 ;;; int internalBorderRight;
64 ;;; int internalBorderTop;
65 ;;; int internalBorderBottom;
70 (defun tkwin-pathname (tkwin)
71 (foreign-slot-value tkwin
'tk-fake-win
'pathname
))
73 (defun tkwin-window (tkwin)
74 "Get the (different!) XWindow pointer from the tkwin data structure.
75 Note that the Xwindow structure is not allocated straight away, not until
76 (I guess) the XWindow server has gotten involved with the widget."
77 (foreign-slot-value tkwin
'tk-fake-win
'window
))
82 unsigned long serial
; /* # of last request processed by server */
83 Bool send_event
; /* True if this came from a SendEvent request */
84 Display
*display
; /* Display the event was read from */
85 Window event
; /* Window on which event was requested. */
86 Window root
; /* root window that the event occured on */
87 Window subwindow
; /* child window */
88 Time time
; /* milliseconds */
89 int x
, y
; /* pointer x, y coordinates in event window */
90 int x_root
, y_root
; /* coordinates relative to root */
91 unsigned int state
; /* key or button mask */
92 Tk_Uid name
; /* Name of virtual event. */
93 Bool same_screen
; /* same screen flag */
94 Tcl_Obj
*user_data
; /* application-specific data reference; Tk will
95 * decrement the reference count
*once
* when it
96 * has finished processing the event.
*/
100 (defcstruct x-virtual-event
101 "common event fields"
103 (serial :unsigned-long
)
104 (send-event :boolean
)
106 (event-window Window
)
114 (state :unsigned-int
)
116 (same-screen :boolean
)
120 (defmacro xsv
(slot-name xptr
)
121 `(foreign-slot-value ,xptr
'X-Virtual-Event
',slot-name
))
125 (defmacro xke
(slot-name xptr
)
126 `(foreign-slot-value ,xptr
'x-key-event
',slot-name
))
128 (export! xevent-type
)
129 (defun xevent-type (xe)
130 (tk-event-type (xsv type xe
)))
132 ;; -------------------------------------------
134 (defcstruct x-key-event
136 (xke-header x-virtual-event
)
140 (trans-char-3 :char
))
142 (defcstruct x-button-event
143 "common event fields"
145 (serial :unsigned-long
)
146 (send-event :boolean
)
148 (event-window Window
)
156 (state :unsigned-int
)
157 (button :unsigned-int
)
158 (same-screen :boolean
))
160 (defmacro xbe
(slot-name xptr
)
161 `(foreign-slot-value ,xptr
'x-button-event
',slot-name
))
163 (defun xbe-x (xbe) (xbe x xbe
))
164 (defun xbe-y (xbe) (xbe y xbe
))
166 ;; --------------------------------------------
168 (defcenum tcl-event-flag-values
170 (:tcl-window-events
4)
172 (:tcl-timer-events
16)
173 (:tcl-idle-events
32)
174 (:tcl-all-events -
3))
176 (defcenum tcl-variable-related-flag
177 "flags passed to getvar, setvar, tracevar, etc"
179 (:tcl-namespace-only
2)
180 (:tcl-append-value
4)
181 (:tcl-list-element
8)
182 (:tcl-trace-reads
#x10
)
183 (:tcl-trace-writes
#x20
)
184 (:tcl-trace-unsets
#x40
)
185 (:tcl-trace-destroyed
#x80
)
186 (:tcl-interp-destroyed
#x100
)
187 (:tcl-leave-err-msg
#x200
)
188 (:tcl-trace-array
#x800
)
189 ;; required to support old variable/vdelete/vinfo traces */
190 (:tcl-trace-old-style
#x1000
)
191 ;; indicate the semantics of the result of a trace */
192 (:tcl-trace-result-dynamic
#x8000
)
193 (:tcl-trace-result-object
#x10000
))
195 (defun var-flags (&rest kws
)
196 (apply '+ (loop for kw in kws
197 collecting
(foreign-enum-value 'tcl-variable-related-flag kw
))))
199 (defcstruct Tcl_ChannelType
201 (blockModeProc :pointer
)
204 (outputProc :pointer
)
206 (setOptionProc :pointer
)
207 (getOptionProc :pointer
)
208 (watchChannelProc :pointer
)
209 (channelReadyProc :pointer
)
210 (getFileProc :pointer
))