-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathwinwidgh.lisp
More file actions
155 lines (131 loc) · 4.53 KB
/
winwidgh.lisp
File metadata and controls
155 lines (131 loc) · 4.53 KB
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
;;; -*- Package: acl-clim; mode: Common-Lisp -*-
;; See the file LICENSE for the full license governing this code.
;;
(in-case-mode :local)
(in-package :acl-clim)
(deftype signed-nat ()
`(signed-byte #-64bit 32 #+64bit 64))
(deftype unsigned-nat ()
`(unsigned-byte #-64bit 32 #+64bit 64))
(ff:def-foreign-type drawitemstruct
(:struct (ctltype win:uint)
(ctlid win:uint)
(itemid win:uint)
(itemaction win:uint)
(itemstate win:uint)
(hwnditem win:hwnd)
(hdc win:hdc)
(rcitem win:rect)
(itemdata (* :void))))
(ff:def-foreign-type browseinfo
(:struct (hwndOwner win:hwnd)
(pidlRoot win:lpcitemidlist)
(pszDisplayName win:lpstr)
(lpszTitle win:lpcstr)
(ulflags win:uint)
(lpfn (* :void)) ; BFFCALLBACK
(lparam win:lparam)
(iImage :int)))
(ff:def-foreign-type toolinfo
(:struct (cbsize win:uint)
(uflags win:uint)
(hwnd win:hwnd)
(uid win:uint)
(rect win:rect)
(hinst win:hinstance)
(lpsztext win:lpstr)
(lparam win:lparam)))
(ff:def-foreign-call (SHBrowseForFolder "SHBrowseForFolder")
((info (* browseinfo)))
:returning win:pvoid ; LPITEMIDLIST
:release-heap :when-ok)
(ff:def-foreign-call (FormatMessage "FormatMessageA")
((flags :int)
(source (* :long))
(messageid :int)
(languageid :int)
(buffer (* :long))
(size :int)
(arguments (* :long)))
:arg-checking #.cl-user::*ffi-arg-checking*
:returning :int)
;; This should be equivalent to win:createpen but not cons.
(ff:def-foreign-call (CreatePen "CreatePen")
((flags :int) (source :int) (color :int))
:arg-checking #.cl-user::*ffi-arg-checking*
:call-direct #.cl-user::*ffi-call-direct*
:returning :int)
;; This should be equivalent to win:createrectrgn but not cons.
(ff:def-foreign-call (CreateRectRgn "CreateRectRgn")
((left :int) (top :int) (right :int) (bottom :int))
:arg-checking #.cl-user::*ffi-arg-checking*
:call-direct #.cl-user::*ffi-call-direct*
:returning :int)
;; This should be equivalent to win:getdc but not cons.
(ff:def-foreign-call (GetDC "GetDC")
((window win:hwnd))
:arg-checking #.cl-user::*ffi-arg-checking*
:call-direct #.cl-user::*ffi-call-direct*
:returning win:hdc)
;; This should be equivalent to win:getdc but not cons.
(ff:def-foreign-call (ReleaseDC "ReleaseDC")
((window win:hwnd) (dc win:hdc))
:arg-checking #.cl-user::*ffi-arg-checking*
:call-direct #.cl-user::*ffi-call-direct*
:returning :int)
(ff:def-foreign-call (SetBkMode "SetBkMode")
((dc win:hdc) (mode :int))
:arg-checking #.cl-user::*ffi-arg-checking*
:call-direct #.cl-user::*ffi-call-direct*
:returning :int)
(ff:def-foreign-call (SetBkColor "SetBkColor")
((dc win:hdc) (color :int))
:arg-checking #.cl-user::*ffi-arg-checking*
:call-direct #.cl-user::*ffi-call-direct*
:returning :int)
(ff:def-foreign-call (SetTextColor "SetTextColor")
((dc win:hdc) (color :int))
:arg-checking #.cl-user::*ffi-arg-checking*
:call-direct #.cl-user::*ffi-call-direct*
:returning :int)
(ff:def-foreign-call (SetROP2 "SetROP2")
((dc win:hdc) (rop2 :int))
:arg-checking #.cl-user::*ffi-arg-checking*
:call-direct #.cl-user::*ffi-call-direct*
:returning :int)
;; This should be equivalent to win:selectobject but not cons.
(ff:def-foreign-call (SelectObject "SelectObject")
((a win:hdc) (b win:hpen))
:arg-checking #.cl-user::*ffi-arg-checking*
:call-direct #.cl-user::*ffi-call-direct*
:returning win:hpen)
(ff:def-foreign-call (SetWindowsHookEx "SetWindowsHookExA")
((a :int) (b win:hookproc) (c win:hinstance) (d win:dword))
:returning win:pvoid)
(ff:def-foreign-call (CallNextHookEx "CallNextHookExA")
((a (* :nat))
(b :int)
(c win:wparam)
(d win:lparam))
:returning win:lresult)
;;; These are used only in the CreateDIBitmap code
;;;
(ff:def-foreign-call memcpy
((to (* :void)) (from (* :void)) (nbytes :int))
;; really returns (* :void) but can't hack that (why?)
:returning :int)
(ff:def-foreign-call (system-malloc "malloc")
((bytes :int))
;; really (* :void)
:returning win:pvoid)
(ff:def-foreign-call (system-free "free")
((address (* :void)))
:returning :void)
(defmacro with-malloced-space ((address-var bytes) &body body)
;; Ensure the space is freed
`(let ((,address-var (system-malloc ,bytes)))
(when (zerop ,address-var)
(error "Failed to malloc ~A bytes" ,bytes))
(unwind-protect
(progn ,@body)
(system-free ,address-var))))