author | Claus Gittinger <cg@exept.de> |
Tue, 27 Feb 1996 02:10:42 +0100 | |
changeset 466 | 257f4414a176 |
parent 463 | cb4731ced6b5 |
child 480 | 07ab9bbaea5f |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
70 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
DeviceWorkstation subclass:#XWorkstation |
|
341 | 14 |
instanceVariableNames:'screen hasShapeExtension hasFaxExtension hasShmExtension |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
15 |
hasDPSExtension hasMbufExtension hasXVideoExtension hasSaveUnder |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
16 |
hasPEXExtension hasImageExtension hasInputExtension |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
17 |
ignoreBackingStore blackpixel whitepixel protocolsAtom |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
18 |
deleteWindowAtom saveYourselfAtom quitAppAtom primaryAtom |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
19 |
secondaryAtom cutBuffer0Atom stringAtom lengthAtom listOfXFonts |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
20 |
buttonsPressed eventRootX eventRootY displayName eventTrace |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
21 |
dispatchingExpose rgbVisual virtualRootId rootId eventBuffer |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
22 |
altModifierMask metaModifierMask' |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
23 |
classVariableNames:'RawKeysymTranslation ConservativeSync' |
341 | 24 |
poolDictionaries:'' |
25 |
category:'Interface-Graphics' |
|
295 | 26 |
! |
0 | 27 |
|
78 | 28 |
!XWorkstation primitiveDefinitions! |
0 | 29 |
%{ |
46 | 30 |
/* |
31 |
* x does a typedef Time - I need Object Time ... |
|
32 |
*/ |
|
0 | 33 |
#define Time XTime |
34 |
||
391
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
35 |
/* |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
36 |
* x does a #define True / False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
37 |
* we are lucky - the ST/X True/False are not needed |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
38 |
*/ |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
39 |
#undef True |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
40 |
#undef False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
41 |
|
37 | 42 |
#ifdef memset |
43 |
# undef memset |
|
44 |
#endif |
|
45 |
||
0 | 46 |
#include <stdio.h> |
47 |
#include <X11/Xlib.h> |
|
48 |
#include <X11/Xutil.h> |
|
49 |
#include <X11/Xatom.h> |
|
50 |
||
150 | 51 |
#define XK_MISCELLANY |
52 |
#include <X11/keysymdef.h> |
|
53 |
||
277
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
54 |
#include <X11/cursorfont.h> |
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
55 |
|
90 | 56 |
/* |
57 |
* this define adds support for two-byte-strings. |
|
58 |
* leaving it undefined does not really save you much |
|
59 |
* (the define will vanish) |
|
60 |
*/ |
|
36 | 61 |
#define TWOBYTESTRINGS |
62 |
||
0 | 63 |
/* |
64 |
* shape support works; enabled by -DSHAPE in makefile |
|
65 |
* see RoundClock and RoundGlobe examples |
|
66 |
*/ |
|
67 |
#ifdef SHAPE |
|
68 |
# include <X11/extensions/shape.h> |
|
69 |
#endif |
|
70 |
||
71 |
/* |
|
150 | 72 |
* shared memory extension access is currently not supported |
0 | 73 |
* (only query is implemented) |
74 |
*/ |
|
75 |
#ifdef SHM |
|
76 |
# include <X11/extensions/XShm.h> |
|
77 |
#endif |
|
78 |
||
79 |
/* |
|
150 | 80 |
* multiBuffer extension access is currently not supported |
81 |
* (only query is implemented) |
|
82 |
*/ |
|
83 |
#ifdef MBUF |
|
84 |
# include <X11/extensions/multibuf.h> |
|
85 |
#endif |
|
86 |
||
87 |
/* |
|
88 |
* XVideo extension access is currently not supported |
|
89 |
* (only query is implemented) |
|
90 |
*/ |
|
91 |
#ifdef XVIDEO |
|
92 |
# include <X11/extensions/Xv.h> |
|
93 |
#endif |
|
94 |
||
95 |
/* |
|
0 | 96 |
* this is a non-standard fax-image decompression extension |
97 |
* (only found in megascan servers ported by myself) |
|
98 |
*/ |
|
99 |
#ifdef FAX |
|
100 |
# include <X11/extensions/XFAXImage.h> |
|
101 |
#endif |
|
102 |
||
103 |
/* |
|
186 | 104 |
* PEX extension - if available |
105 |
*/ |
|
106 |
#ifdef PEX5 |
|
107 |
# include <PEX5/PEX.h> |
|
108 |
#endif |
|
109 |
||
110 |
/* |
|
111 |
* XImage extension - if available |
|
112 |
*/ |
|
113 |
#ifdef XIE |
|
114 |
# include <X11/extensions/XIE.h> |
|
115 |
#endif |
|
116 |
||
117 |
/* |
|
90 | 118 |
* when I have more time to check it out, I will support display-PS |
0 | 119 |
*/ |
120 |
#ifdef DPS |
|
121 |
# ifdef sgi |
|
122 |
# include <X11/extensions/XDPS.h> |
|
123 |
# include <X11/extensions/XDPSlib.h> |
|
124 |
# include <X11/extensions/dpsXclient.h> |
|
125 |
# else |
|
126 |
# include <DPS/XDPS.h> |
|
127 |
# include <DPS/XDPSlib.h> |
|
128 |
# include <DPS/dpsXclient.h> |
|
129 |
# endif |
|
130 |
#endif |
|
131 |
||
90 | 132 |
#if defined(IRIX5) || (XlibSpecificationRelease == 6) |
133 |
/* |
|
134 |
* accessing private data in Display ... sorry |
|
135 |
*/ |
|
136 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
137 |
#else |
|
138 |
# define DISPLAYACCESS(d) d |
|
139 |
#endif |
|
140 |
||
78 | 141 |
/* |
142 |
* some defines - tired of typing ... |
|
143 |
*/ |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
144 |
#define _DisplayVal(o) (Display *)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
145 |
#define _WindowVal(o) (Window)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
146 |
#define _PixmapVal(o) (Pixmap)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
147 |
#define _GCVal(o) (GC)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
148 |
#define _CursorVal(o) (Cursor)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
149 |
#define _FontVal(o) (XFontStruct *)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
150 |
#define _DPSContextVal(o) (DPSContext)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
151 |
|
211 | 152 |
#define __MKATOMOBJ(a) __MKSMALLINT(a) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
153 |
#define _AtomVal(o) __intVal(o) |
211 | 154 |
#define __isAtomID(o) __isSmallInteger(o) |
155 |
||
156 |
#define myDpy _DisplayVal(_INST(displayId)) |
|
157 |
#define ISCONNECTED (_INST(displayId) != nil) |
|
78 | 158 |
|
159 |
#ifndef THISCONTEXT_IN_REGISTER |
|
160 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
|
161 |
# define END_INTERRUPTSBLOCKED /* */ |
|
162 |
#else |
|
163 |
extern int __interruptsBlocked; |
|
164 |
# define BEGIN_INTERRUPTSBLOCKED \ |
|
165 |
{ \ |
|
166 |
int needUnblock = 0; \ |
|
167 |
extern OBJ __thisContext__; \ |
|
168 |
\ |
|
169 |
__thisContext__ = __thisContext;\ |
|
170 |
if (!__interruptsBlocked) { \ |
|
150 | 171 |
__BLOCKINTERRUPTS(); \ |
78 | 172 |
needUnblock = 1; \ |
173 |
} |
|
174 |
||
175 |
# define END_INTERRUPTSBLOCKED \ |
|
158 | 176 |
__thisContext = __thisContext; \ |
177 |
__thisContext__ = 0; \ |
|
78 | 178 |
if (needUnblock) { \ |
150 | 179 |
__UNBLOCKINTERRUPTS(); \ |
78 | 180 |
} \ |
181 |
} |
|
182 |
||
183 |
#endif |
|
184 |
%} |
|
185 |
! ! |
|
186 |
||
187 |
!XWorkstation primitiveVariables! |
|
188 |
%{ |
|
0 | 189 |
/* |
146 | 190 |
* remembered info from private error handler |
0 | 191 |
*/ |
2 | 192 |
static char lastErrorMsg[80] = ""; |
193 |
static unsigned lastRequestCode = 0; |
|
194 |
static unsigned lastMinorCode = 0; |
|
195 |
static unsigned lastResource = 0; |
|
129 | 196 |
|
197 |
static int __debug__ = 0; |
|
198 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 199 |
%} |
200 |
! ! |
|
201 |
||
202 |
!XWorkstation primitiveFunctions! |
|
203 |
%{ |
|
18 | 204 |
/* |
144 | 205 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
206 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 207 |
* the implementation below is somewhat wrong: it will |
78 | 208 |
* report all errors for Display, even though there could be |
162 | 209 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
210 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 211 |
*/ |
168 | 212 |
static |
12 | 213 |
__XErrorHandler__(dpy, event) |
0 | 214 |
Display *dpy; |
215 |
XErrorEvent *event; |
|
216 |
{ |
|
163 | 217 |
#ifdef _AIX |
218 |
printf("XError\n"); fflush(stdout); |
|
219 |
#endif |
|
0 | 220 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); |
221 |
if (lastErrorMsg[0] == '\0') { |
|
70 | 222 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 223 |
} |
2 | 224 |
lastRequestCode = event->request_code; |
225 |
lastMinorCode = event->minor_code; |
|
226 |
lastResource = event->resourceid; |
|
227 |
||
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
228 |
if (@global(ErrorPrinting) == true) { |
219
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
229 |
fprintf(stderr, "XWORKSTAT: x-error cought maj=%d (0x%x) min=%d (0x%x) resource=%x\n", |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
230 |
event->request_code, event->request_code, |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
231 |
event->minor_code, event->minor_code, event->resourceid); |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
232 |
fprintf(stderr, "XWORKSTAT: x-error message is '%s'\n", lastErrorMsg); |
218
10072d9beba5
can now turn off Xlib error messages from the errorHandler
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
233 |
} |
43 | 234 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
235 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 236 |
return 0; |
237 |
} |
|
238 |
||
90 | 239 |
#ifdef VIRTUAL_ROOT |
0 | 240 |
/* |
18 | 241 |
* added since RootWindow-macro is not suficient |
242 |
* when virtual root-windows are involved (i.e. tvtwm) |
|
243 |
*/ |
|
244 |
static Window |
|
245 |
getRootWindow(dpy, screen) |
|
246 |
Display *dpy; |
|
247 |
{ |
|
248 |
Window root; |
|
249 |
Atom vRootAtom = None; |
|
250 |
int i; |
|
251 |
Window rootReturn, parentReturn; |
|
252 |
Window* children; |
|
253 |
unsigned int numChildren; |
|
254 |
||
255 |
root = RootWindow(dpy, screen); |
|
256 |
/* |
|
257 |
* on IRIS, this creates a badwindow error - why ? |
|
258 |
* children contains a funny window (000034) |
|
259 |
*/ |
|
90 | 260 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 261 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
70 | 262 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
263 |
if (vRootAtom != None) { |
|
264 |
for (i=0; i < numChildren; i++) { |
|
265 |
Atom actual_type; |
|
266 |
int actual_format; |
|
267 |
unsigned long nitems, bytesafter; |
|
268 |
Window* newRoot = (Window*) 0; |
|
269 |
||
270 |
if (children[i]) { |
|
271 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
272 |
0L, 1L, False, XA_WINDOW, |
|
273 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
274 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
275 |
root = *newRoot; |
|
276 |
break; |
|
277 |
} |
|
278 |
} |
|
279 |
} |
|
280 |
if (children) XFree( children ); |
|
281 |
} |
|
18 | 282 |
} |
90 | 283 |
# endif |
18 | 284 |
return root; |
285 |
} |
|
90 | 286 |
#endif |
0 | 287 |
%} |
78 | 288 |
! ! |
0 | 289 |
|
295 | 290 |
!XWorkstation class methodsFor:'documentation'! |
291 |
||
292 |
copyright |
|
293 |
" |
|
294 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
295 |
All Rights Reserved |
|
296 |
||
297 |
This software is furnished under a license and may be used |
|
298 |
only in accordance with the terms of that license and with the |
|
299 |
inclusion of the above copyright notice. This software may not |
|
300 |
be provided or otherwise made available to, or used by, any |
|
301 |
other person. No title to or ownership of the software is |
|
302 |
hereby transferred. |
|
303 |
" |
|
304 |
! |
|
305 |
||
306 |
documentation |
|
307 |
" |
|
308 |
this class provides the interface to X11. It redefines all required methods |
|
309 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
310 |
limited to one display - in theory, you can create Views on many displays |
|
311 |
simultanously. However, the default setup is for one display only. |
|
312 |
To support multiple displays, you will have to start another event dispatcher |
|
313 |
process for the other display(s) and create the other views with a slightly |
|
314 |
different protocol. However, 'normal' applications do not have to care for |
|
315 |
all of this ... |
|
316 |
||
317 |
See more documentation in my superclass, DeviceWorkstation. |
|
318 |
" |
|
319 |
! ! |
|
320 |
||
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
321 |
!XWorkstation class methodsFor:'initialization'! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
322 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
323 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
324 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
325 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
326 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
327 |
|
386 | 328 |
RawKeysymTranslation isNil ifTrue:[ |
329 |
"/ the following table maps X-keyevents to ST/X |
|
330 |
"/ device independed events. |
|
331 |
"/ It is NOT meant as a keyboardMap replacement. |
|
332 |
||
333 |
RawKeysymTranslation := d := Dictionary new. |
|
334 |
d at:'Delete_line' put:#DeleteLine. |
|
335 |
d at:'Delete_word' put:#DeleteWord. |
|
336 |
d at:'Down' put:#CursorDown. |
|
337 |
d at:'Up' put:#CursorUp. |
|
338 |
d at:'Left' put:#CursorLeft. |
|
339 |
d at:'Right' put:#CursorRight. |
|
340 |
] |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
341 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
342 |
|
2 | 343 |
!XWorkstation class methodsFor:'error handling'! |
344 |
||
129 | 345 |
debug:aBoolean |
346 |
%{ /* NOCONTEXT */ |
|
347 |
||
348 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
349 |
%} |
|
350 |
! |
|
351 |
||
78 | 352 |
errorStringOfLastError |
353 |
%{ |
|
216 | 354 |
RETURN ( __MKSTRING(lastErrorMsg COMMA_CON) ); |
78 | 355 |
%} |
356 |
! |
|
357 |
||
135 | 358 |
lastErrorString |
2 | 359 |
"return the last X-error string - |
360 |
when buffering is on, this may be |
|
361 |
an error for a long-ago operation" |
|
78 | 362 |
|
363 |
|string requestCode s match line| |
|
364 |
||
365 |
string := self errorStringOfLastError. |
|
366 |
requestCode := self requestCodeOfLastError. |
|
367 |
" |
|
368 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
369 |
and append the name of the corresponding X-request |
|
370 |
" |
|
371 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
372 |
s notNil ifTrue:[ |
|
373 |
match := 'XRequest.' , requestCode printString. |
|
374 |
line := s peekForLineStartingWith:match. |
|
375 |
line notNil ifTrue:[ |
|
376 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
377 |
]. |
|
378 |
s close. |
|
379 |
]. |
|
380 |
^ string |
|
295 | 381 |
! |
382 |
||
383 |
minorCodeOfLastError |
|
384 |
%{ /* NOCONTEXT */ |
|
385 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
386 |
RETURN ( __MKSMALLINT(lastMinorCode) ); |
295 | 387 |
%} |
388 |
! |
|
389 |
||
390 |
requestCodeOfLastError |
|
152 | 391 |
%{ /* NOCONTEXT */ |
392 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
393 |
RETURN ( __MKSMALLINT(lastRequestCode) ); |
0 | 394 |
%} |
135 | 395 |
! |
396 |
||
295 | 397 |
resourceIdOfLastError |
0 | 398 |
%{ /* NOCONTEXT */ |
295 | 399 |
|
400 |
RETURN ( __MKOBJ(lastResource) ); |
|
0 | 401 |
%} |
402 |
! ! |
|
403 |
||
104 | 404 |
!XWorkstation class methodsFor:'queries'! |
405 |
||
406 |
platformName |
|
133 | 407 |
"ST-80 compatibility. |
408 |
Return a string describing the display systems platform." |
|
409 |
||
410 |
^ 'X' "I don't know what ST-80 returns for X ..." |
|
104 | 411 |
! ! |
412 |
||
0 | 413 |
!XWorkstation methodsFor:'accessing & queries'! |
414 |
||
295 | 415 |
blackpixel |
416 |
"return the colornumber of black" |
|
417 |
||
418 |
^ blackpixel |
|
419 |
! |
|
420 |
||
421 |
button1MotionMask |
|
422 |
"return the state-mask for button1 in motion events state-field. |
|
423 |
For backward compatibility." |
|
424 |
||
425 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
426 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 427 |
%} |
428 |
! |
|
429 |
||
430 |
button2MotionMask |
|
431 |
"return the state-mask for button2 in motion events state-field |
|
432 |
For backward compatibility." |
|
433 |
||
434 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
435 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 436 |
%} |
437 |
! |
|
438 |
||
439 |
button3MotionMask |
|
440 |
"return the state-mask for button3 in motion events state-field |
|
441 |
For backward compatibility." |
|
442 |
||
443 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
444 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 445 |
%} |
446 |
! |
|
447 |
||
448 |
buttonMotionMask:aButton |
|
449 |
"return the state-mask for button1 in motion events state-field. |
|
450 |
This is the devices mask." |
|
451 |
||
452 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
453 |
if (aButton == __MKSMALLINT(1)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
454 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
455 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
456 |
if (aButton == __MKSMALLINT(2)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
457 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
458 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
459 |
if (aButton == __MKSMALLINT(3)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
460 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 461 |
} |
462 |
%}. |
|
463 |
^ nil |
|
464 |
! |
|
465 |
||
382 | 466 |
controlMask |
467 |
%{ /* NOCONTEXT */ |
|
468 |
RETURN (__MKSMALLINT(ControlMask)); |
|
469 |
%} |
|
470 |
! |
|
471 |
||
295 | 472 |
defaultEventMask |
473 |
"return a mask to enable some events by default." |
|
474 |
||
475 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
476 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
295 | 477 |
KeyPressMask | KeyReleaseMask | |
478 |
EnterWindowMask | LeaveWindowMask | |
|
479 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
480 |
%} |
|
481 |
! |
|
482 |
||
0 | 483 |
displayFileDescriptor |
484 |
"return the displays fileNumber - for select" |
|
485 |
||
486 |
%{ /* NOCONTEXT */ |
|
487 |
||
150 | 488 |
if (ISCONNECTED) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
489 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 490 |
} |
491 |
RETURN (nil); |
|
0 | 492 |
%} |
493 |
! |
|
494 |
||
133 | 495 |
displayName |
496 |
"return the X-connections display name. |
|
497 |
This is (currently) nil for the default display, |
|
498 |
something like foo:0 for any other remote display. |
|
499 |
Future versions may return non-nil strings for the default display as well." |
|
500 |
||
501 |
^ displayName |
|
502 |
! |
|
503 |
||
341 | 504 |
protocolVersion |
505 |
"return the X-servers protocol version - should normally not be of |
|
506 |
any interest" |
|
507 |
||
508 |
%{ /* NOCONTEXT */ |
|
509 |
if (ISCONNECTED) { |
|
510 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
|
511 |
} |
|
512 |
RETURN (nil); |
|
513 |
%} |
|
514 |
||
515 |
" |
|
516 |
Display protocolVersion |
|
517 |
" |
|
518 |
! |
|
519 |
||
520 |
rootView |
|
521 |
rootView isNil ifTrue:[ |
|
522 |
rootView := DisplayRootView on:self |
|
523 |
]. |
|
524 |
^ rootView |
|
525 |
||
526 |
" |
|
527 |
|v| |
|
528 |
v := Display rootView. |
|
529 |
v paint:Color red. |
|
530 |
v noClipByChildren. |
|
531 |
v fillRectangleX:10 y:10 width:100 height:100. |
|
532 |
" |
|
533 |
! |
|
534 |
||
535 |
serverVendor |
|
536 |
"return the X-server vendor string - this should normally not be of |
|
537 |
any interest, but can be for special cases |
|
538 |
(to avoid bugs in certain implementations)" |
|
539 |
%{ |
|
540 |
if (ISCONNECTED) { |
|
541 |
RETURN ( __MKSTRING(XServerVendor(myDpy) COMMA_CON) ); |
|
542 |
} |
|
543 |
RETURN (nil); |
|
544 |
%} |
|
545 |
||
546 |
" |
|
547 |
Display serverVendor |
|
548 |
" |
|
549 |
! |
|
550 |
||
382 | 551 |
shiftMask |
552 |
%{ /* NOCONTEXT */ |
|
553 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
554 |
%} |
|
555 |
! |
|
556 |
||
341 | 557 |
translatePoint:aPoint from:windowId1 to:windowId2 |
558 |
"given a point in window1, return the coordinate in window2. |
|
559 |
This expects a device coordinate (relative to the first views origin) |
|
560 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
561 |
- use to xlate points from a window to rootwindow" |
|
562 |
||
563 |
|x1 y1 x2 y2| |
|
564 |
||
565 |
x1 := x2 := aPoint x truncated. |
|
566 |
y1 := y2 := aPoint y truncated. |
|
567 |
%{ |
|
568 |
int xpos, ypos; |
|
569 |
Window w1, w2, child_return; |
|
570 |
int screen = _intVal(_INST(screen)); |
|
571 |
Display *dpy = myDpy; |
|
572 |
||
573 |
if (__isExternalAddress(windowId1) |
|
574 |
&& __isExternalAddress(windowId2) |
|
575 |
&& __bothSmallInteger(x1, y1)) { |
|
576 |
w1 = _WindowVal(windowId1); |
|
577 |
w2 = _WindowVal(windowId2); |
|
578 |
#ifdef VIRTUAL_ROOT |
|
579 |
if ((w1 == RootWindow(dpy, screen)) |
|
580 |
|| (w2 == RootWindow(dpy, screen))) { |
|
581 |
if (w1 == RootWindow(dpy, screen)) { |
|
582 |
w1 = getRootWindow(dpy, screen); |
|
583 |
} |
|
584 |
if (w2 == RootWindow(dpy, screen)) { |
|
585 |
w2 = getRootWindow(dpy, screen); |
|
586 |
} |
|
587 |
} |
|
588 |
#endif |
|
589 |
BEGIN_INTERRUPTSBLOCKED |
|
590 |
XTranslateCoordinates(dpy, w1, w2, |
|
591 |
_intVal(x1), _intVal(y1), |
|
592 |
&xpos, &ypos, &child_return); |
|
593 |
END_INTERRUPTSBLOCKED |
|
594 |
x2 = __MKSMALLINT(xpos); |
|
595 |
y2 = __MKSMALLINT(ypos); |
|
596 |
} |
|
597 |
%}. |
|
598 |
||
599 |
^ (x2 @ y2) |
|
600 |
! |
|
601 |
||
602 |
vendorRelease |
|
603 |
"return the X-servers vendor release - should normally not be of |
|
604 |
any interest, but can be for special cases. |
|
605 |
(to avoid bugs in certain implementations)" |
|
606 |
||
607 |
%{ /* NOCONTEXT */ |
|
608 |
if (ISCONNECTED) { |
|
609 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
|
610 |
} |
|
611 |
RETURN (nil); |
|
612 |
%} |
|
613 |
||
614 |
" |
|
615 |
Display vendorRelease |
|
616 |
" |
|
617 |
! |
|
618 |
||
619 |
viewIdFromPoint:aPoint in:windowId |
|
620 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
621 |
hit by this coordinate. Return nil if no view was hit. |
|
622 |
The returned id may be the id of a non ST view. |
|
623 |
- used to find the window to drop objects after a cross-view drag." |
|
624 |
||
625 |
%{ /* NOCONTEXT */ |
|
626 |
||
627 |
Display *dpy = myDpy; |
|
628 |
int screen = _intVal(_INST(screen)); |
|
629 |
OBJ xp, yp; |
|
630 |
int xpos, ypos; |
|
631 |
Window child_return; |
|
632 |
||
633 |
if (__isExternalAddress(windowId) |
|
634 |
&& __isPoint(aPoint)) { |
|
635 |
xp = _point_X(aPoint); |
|
636 |
yp = _point_Y(aPoint); |
|
637 |
if (__bothSmallInteger(xp, yp)) { |
|
638 |
BEGIN_INTERRUPTSBLOCKED |
|
639 |
XTranslateCoordinates(dpy, |
|
640 |
RootWindow(dpy, screen), |
|
641 |
_WindowVal(windowId), |
|
642 |
_intVal(xp), _intVal(yp), |
|
643 |
&xpos, &ypos, &child_return); |
|
644 |
END_INTERRUPTSBLOCKED |
|
645 |
if (child_return) { |
|
646 |
RETURN ( __MKOBJ(child_return) ); |
|
647 |
} |
|
648 |
RETURN ( nil ); |
|
649 |
} |
|
650 |
} |
|
651 |
%}. |
|
652 |
windowId notNil ifTrue:[ |
|
653 |
aPoint isPoint ifTrue:[ |
|
654 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
655 |
] |
|
656 |
]. |
|
657 |
||
658 |
^ nil |
|
659 |
! |
|
660 |
||
661 |
virtualExtent |
|
662 |
"return the virtual extent of the display (in pixels). |
|
663 |
On most systems, this is the same as the physical width; |
|
664 |
except, if a window manager with a virtual desktop like olvwm |
|
665 |
(simulating a bigger screen) is running." |
|
666 |
||
667 |
%{ |
|
668 |
if ((_INST(rootId) != _INST(virtualRootId)) |
|
669 |
&& __isExternalAddress(_INST(virtualRootId))) { |
|
670 |
Window vRootWin; |
|
671 |
Window root; |
|
672 |
int x, y; |
|
673 |
unsigned int width, height; |
|
674 |
unsigned int dummy; |
|
675 |
||
676 |
vRootWin = _WindowVal(_INST(virtualRootId)); |
|
677 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
|
678 |
&dummy, &dummy)) { |
|
679 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
680 |
} |
|
681 |
} |
|
682 |
%}. |
|
683 |
^ width @ height |
|
684 |
! |
|
685 |
||
686 |
whitepixel |
|
687 |
"return the colornumber of white" |
|
688 |
||
689 |
^ whitepixel |
|
690 |
! ! |
|
691 |
||
692 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
693 |
||
0 | 694 |
hasDPS |
186 | 695 |
"return true, if this workstation supports display postscript. |
696 |
Both the server must support it, and the feature must have been |
|
697 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 698 |
|
699 |
^ hasDPSExtension |
|
186 | 700 |
|
701 |
" |
|
702 |
Display hasDPS |
|
703 |
" |
|
704 |
! |
|
705 |
||
150 | 706 |
hasExtension:extensionString |
707 |
"query for an X extension. The argument, extensionString |
|
708 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 709 |
Return true, if that extension is available in the server. |
710 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 711 |
|
712 |
%{ |
|
713 |
int dummy; |
|
714 |
||
715 |
if (__isString(extensionString) && ISCONNECTED) { |
|
716 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
|
717 |
RETURN ( true ); |
|
718 |
} |
|
719 |
} |
|
720 |
%}. |
|
721 |
^ false |
|
186 | 722 |
|
723 |
" |
|
724 |
Display hasExtension:'XVideo' |
|
725 |
Display hasExtension:'Input' |
|
726 |
Display hasExtension:'GLX' |
|
727 |
Display hasExtension:'X3D-PEX' |
|
728 |
Display hasExtension:'XInputExtension' |
|
729 |
Display hasExtension:'SHAPE' |
|
730 |
Display hasExtension:'MIT-SHM' |
|
731 |
Display hasExtension:'SGIFullScreenStereo' |
|
732 |
" |
|
150 | 733 |
! |
734 |
||
295 | 735 |
hasFax |
736 |
"return true, if this workstation supports decompression of fax images. |
|
737 |
Both the server must support it, and the feature must have been |
|
738 |
enabled in the smalltalk system, for true to be returned." |
|
739 |
||
740 |
^ hasFaxExtension |
|
741 |
||
742 |
" |
|
743 |
Display hasFaxExtension |
|
744 |
" |
|
745 |
! |
|
746 |
||
747 |
hasImageExtension |
|
748 |
"return true, if this workstation supports the X image extension. |
|
749 |
Both the server must support it, and the feature must have been |
|
750 |
enabled in the smalltalk system, for true to be returned." |
|
751 |
||
752 |
^ hasImageExtension |
|
753 |
||
754 |
" |
|
755 |
Display hasImageExtension |
|
756 |
" |
|
757 |
! |
|
758 |
||
759 |
hasInputExtension |
|
760 |
"return true, if this workstation supports the X input extension. |
|
761 |
Both the server must support it, and the feature must have been |
|
762 |
enabled in the smalltalk system, for true to be returned." |
|
763 |
||
764 |
^ hasInputExtension |
|
765 |
||
766 |
" |
|
767 |
Display hasInputExtension |
|
768 |
" |
|
769 |
! |
|
770 |
||
771 |
hasMultibuffer |
|
772 |
"return true, if this workstation supports the multibuffer extension. |
|
773 |
Both the server must support it, and the feature must have been |
|
774 |
enabled in the smalltalk system, for true to be returned." |
|
775 |
||
776 |
^ hasMbufExtension |
|
777 |
||
778 |
" |
|
779 |
Display hasMultibuffer |
|
780 |
" |
|
781 |
! |
|
782 |
||
783 |
hasPEX |
|
784 |
"return true, if this workstation supports PEX 3D graphics. |
|
785 |
Both the server must support it, and the feature must have been |
|
786 |
enabled in the smalltalk system, for true to be returned." |
|
787 |
||
788 |
^ hasPEXExtension |
|
789 |
||
790 |
" |
|
791 |
Display hasPEX |
|
792 |
" |
|
793 |
! |
|
794 |
||
795 |
hasShape |
|
796 |
"return true, if this workstation supports non-rectangular windows. |
|
797 |
Both the server must support it, and the feature must have been |
|
798 |
enabled in the smalltalk system, for true to be returned." |
|
799 |
||
800 |
^ hasShapeExtension |
|
801 |
||
802 |
" |
|
803 |
Display hasShape |
|
804 |
" |
|
805 |
! |
|
806 |
||
807 |
hasShm |
|
808 |
"return true, if this workstation supports the shared pixmap extension. |
|
809 |
Both the server must support it, and the feature must have been |
|
810 |
enabled in the smalltalk system, for true to be returned." |
|
811 |
||
812 |
^ hasShmExtension |
|
813 |
||
814 |
" |
|
815 |
Display hasShm |
|
816 |
" |
|
817 |
! |
|
818 |
||
819 |
hasXVideo |
|
820 |
"return true, if this workstation supports the XVideo extension. |
|
821 |
Both the server must support it, and the feature must have been |
|
822 |
enabled in the smalltalk system, for true to be returned." |
|
823 |
||
824 |
^ hasXVideoExtension |
|
825 |
||
826 |
" |
|
827 |
Display hasXVideo |
|
828 |
" |
|
829 |
! |
|
830 |
||
831 |
iconSizes |
|
832 |
"Get the preferrer icon sizes. These are set by the window manager. |
|
833 |
We return nil (if not set) or an OrderedCollection of Intervals." |
|
834 |
||
835 |
|xIconSizes count ret| |
|
836 |
||
837 |
%{ |
|
838 |
Display *dpy = myDpy; |
|
839 |
int screen = _intVal(_INST(screen)); |
|
840 |
XIconSize *sizeList; |
|
841 |
int cnt; |
|
842 |
||
843 |
if (ISCONNECTED) { |
|
844 |
if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) { |
|
845 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
|
846 |
count = __MKSMALLINT(cnt); |
|
847 |
} |
|
848 |
} |
|
849 |
%}. |
|
850 |
xIconSizes isNil ifTrue:[^ nil]. |
|
851 |
||
852 |
ret := OrderedCollection new:count. |
|
853 |
1 to:count do:[ :i | |
|
854 |
| startX startY stopX stopY stepX stepY| |
|
855 |
||
856 |
%{ |
|
857 |
XIconSize *slp; |
|
858 |
||
859 |
slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1]; |
|
860 |
startX = __MKSMALLINT(slp->min_width); |
|
861 |
startY = __MKSMALLINT(slp->min_height); |
|
862 |
stopX = __MKSMALLINT(slp->max_width); |
|
863 |
stopY = __MKSMALLINT(slp->max_height); |
|
864 |
stepX = __MKSMALLINT(slp->width_inc); |
|
865 |
stepY = __MKSMALLINT(slp->height_inc); |
|
866 |
%}. |
|
867 |
ret add:(Interval from:startX@startY to:stopX@stopY by:stepX@stepY) |
|
868 |
]. |
|
869 |
||
870 |
xIconSizes free. |
|
871 |
^ ret |
|
872 |
||
873 |
" |
|
874 |
Display iconSizes |
|
875 |
" |
|
876 |
! |
|
877 |
||
341 | 878 |
ignoreBackingStore:aBoolean |
879 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
880 |
no backing store used - this can be used on servers where backing store is |
|
881 |
very slow or is broken (can be put into display-rc-file)" |
|
882 |
||
883 |
ignoreBackingStore := aBoolean |
|
295 | 884 |
! |
885 |
||
43 | 886 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
887 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
888 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
889 |
depth, bitsPerPixel and padding values." |
43 | 890 |
|
150 | 891 |
|nFormats "{ Class: SmallInteger }" |
892 |
formatArray| |
|
43 | 893 |
%{ |
894 |
Display *dpy = myDpy; |
|
150 | 895 |
|
896 |
if (! ISCONNECTED) { |
|
897 |
RETURN (nil); |
|
898 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
899 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 900 |
%}. |
901 |
formatArray := Array new:nFormats. |
|
150 | 902 |
1 to:nFormats do:[:index | |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
903 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
150 | 904 |
|
905 |
i := index. |
|
43 | 906 |
%{ |
70 | 907 |
ScreenFormat *format; |
908 |
Display *dpy = myDpy; |
|
909 |
||
90 | 910 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
70 | 911 |
format += (_intVal(i)-1); |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
912 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
913 |
depthInfo = __MKSMALLINT(format->depth); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
914 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
43 | 915 |
%}. |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
916 |
info := IdentityDictionary new. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
917 |
info at:#depth put:depthInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
918 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
919 |
info at:#padding put:paddingInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
920 |
formatArray at:index put:info. |
43 | 921 |
]. |
922 |
^ formatArray |
|
923 |
||
924 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
925 |
Display supportedImageFormats |
43 | 926 |
" |
927 |
! |
|
928 |
||
81 | 929 |
supportsDeepIcons |
930 |
"return true, if this device supports non b&w (i.e. greyScale |
|
931 |
or colored icons). Many Xservers (and/or windowManagers) crash, |
|
186 | 932 |
if you pass them a deep form as icon; therefore, we return false. |
933 |
It may be a good idea to check for the server vendor/release and |
|
934 |
return trie sometimes." |
|
81 | 935 |
|
936 |
^ false |
|
937 |
! |
|
938 |
||
939 |
supportsViewGravity |
|
940 |
"return true, if this device supports gravity attributes. |
|
82 | 941 |
We do not depend on it being implemented, but some resizing operations |
81 | 942 |
are faster, it is is." |
943 |
||
944 |
^ true |
|
0 | 945 |
! ! |
946 |
||
947 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
948 |
||
295 | 949 |
createBitmapFromArray:anArray width:w height:h |
950 |
|bitmapId| |
|
951 |
||
952 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
953 |
bitmapId isNil ifTrue:[ |
|
954 |
self primitiveFailed |
|
955 |
]. |
|
956 |
^ bitmapId |
|
957 |
! |
|
958 |
||
959 |
createBitmapFromFile:aString for:aForm |
|
960 |
|id w h| |
|
961 |
||
962 |
%{ |
|
963 |
Display *dpy = myDpy; |
|
964 |
int screen = _intVal(_INST(screen)); |
|
965 |
Pixmap newBitmap; |
|
966 |
char *filename; |
|
967 |
unsigned b_width, b_height; |
|
968 |
int b_x_hot, b_y_hot; |
|
969 |
int status; |
|
970 |
||
971 |
if (ISCONNECTED) { |
|
972 |
if (__isString(aString) || __isSymbol(aString)) { |
|
973 |
filename = (char *)_stringVal(aString); |
|
974 |
||
975 |
BEGIN_INTERRUPTSBLOCKED |
|
976 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
977 |
filename, &b_width, &b_height, &newBitmap, |
|
978 |
&b_x_hot, &b_y_hot); |
|
979 |
END_INTERRUPTSBLOCKED |
|
980 |
||
981 |
if (status == BitmapSuccess) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
982 |
w = __MKSMALLINT(b_width); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
983 |
h = __MKSMALLINT(b_height); |
295 | 984 |
id = __MKOBJ(newBitmap); |
985 |
} |
|
986 |
} |
|
987 |
} |
|
988 |
%}. |
|
989 |
id notNil ifTrue:[ |
|
990 |
aForm setWidth:w height:h |
|
991 |
]. |
|
992 |
^ id |
|
993 |
! |
|
994 |
||
995 |
createBitmapWidth:w height:h |
|
996 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
997 |
(i.e. random). Return a bitmap id or nil" |
|
998 |
||
999 |
%{ /* NOCONTEXT */ |
|
1000 |
||
1001 |
Display *dpy = myDpy; |
|
1002 |
int screen = _intVal(_INST(screen)); |
|
1003 |
Pixmap newBitmap; |
|
1004 |
||
1005 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1006 |
BEGIN_INTERRUPTSBLOCKED |
|
1007 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1008 |
_intVal(w), _intVal(h), 1); |
|
1009 |
END_INTERRUPTSBLOCKED |
|
1010 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
1011 |
} |
|
1012 |
%} |
|
1013 |
. |
|
1014 |
self primitiveFailed. |
|
1015 |
^ nil |
|
1016 |
! |
|
1017 |
||
0 | 1018 |
createFaxImageFromArray:data width:w height:h type:type k:k msbFirst:msbFirst |
1019 |
"create a new faxImage in the workstation |
|
1020 |
type: 0 -> uncompressed |
|
70 | 1021 |
1 -> group3 1D (k is void) |
1022 |
2 -> group3 2D |
|
1023 |
3 -> group4 2D (k is void)" |
|
0 | 1024 |
|
1025 |
|nBytes| |
|
1026 |
||
1027 |
hasFaxExtension ifFalse:[^ nil]. |
|
1028 |
nBytes := data size. |
|
1029 |
%{ |
|
1030 |
#ifdef FAX |
|
1031 |
Display *dpy = myDpy; |
|
1032 |
int screen = _intVal(_INST(screen)); |
|
1033 |
FAXImage newImage; |
|
1034 |
int _type, _msb, _k = 0; |
|
1035 |
unsigned char *bits; |
|
1036 |
||
97 | 1037 |
if (__bothSmallInteger(w, h) |
1038 |
&& __bothSmallInteger(type, k) |
|
1039 |
&& __isSmallInteger(nBytes) |
|
44 | 1040 |
&& __isByteArray(data)) { |
70 | 1041 |
if (msbFirst == true) |
1042 |
_msb = 1; |
|
1043 |
else |
|
1044 |
_msb = 0; |
|
1045 |
_type = _intVal(type); |
|
1046 |
if ((_type < 0) || (_type > 3)) { |
|
1047 |
RETURN ( nil ); |
|
1048 |
} |
|
1049 |
if (_type == 2) { |
|
97 | 1050 |
if (! __isSmallInteger(k)) { |
70 | 1051 |
RETURN ( nil ); |
1052 |
} |
|
1053 |
_k = _intVal(k); |
|
1054 |
} |
|
1055 |
bits = _ByteArrayInstPtr(data)->ba_element; |
|
1056 |
BEGIN_INTERRUPTSBLOCKED |
|
1057 |
newImage = XFAXImageCreateImage(dpy, _intVal(w), _intVal(h), |
|
1058 |
_type, _k, _msb, |
|
1059 |
_intVal(nBytes), bits); |
|
1060 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1061 |
RETURN ( (newImage != (FAXImage)0) ? __MKOBJ(newImage) : nil ); |
0 | 1062 |
} |
1063 |
#else |
|
1064 |
RETURN ( nil ); |
|
1065 |
#endif |
|
1066 |
%} |
|
1067 |
. |
|
43 | 1068 |
self primitiveFailed. |
1069 |
^ nil |
|
0 | 1070 |
! |
1071 |
||
1072 |
createPixmapWidth:w height:h depth:d |
|
1073 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1074 |
(i.e. random). Return a bitmap id or nil" |
|
1075 |
||
1076 |
%{ /* NOCONTEXT */ |
|
1077 |
||
1078 |
Display *dpy = myDpy; |
|
1079 |
int screen = _intVal(_INST(screen)); |
|
1080 |
Pixmap newBitmap; |
|
1081 |
||
150 | 1082 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
70 | 1083 |
BEGIN_INTERRUPTSBLOCKED |
1084 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1085 |
_intVal(w), _intVal(h), _intVal(d)); |
|
1086 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1087 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
0 | 1088 |
} |
1089 |
%} |
|
1090 |
. |
|
43 | 1091 |
self primitiveFailed. |
1092 |
^ nil |
|
0 | 1093 |
! |
1094 |
||
1095 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
|
46 | 1096 |
"will vanish - for compatibility with previous versions" |
1097 |
||
1098 |
^ self |
|
70 | 1099 |
createWindowFor:aView |
1100 |
origin:(xpos @ ypos) |
|
1101 |
extent:(wwidth @ wheight) |
|
1102 |
minExtent:(aView minExtent) |
|
1103 |
maxExtent:(aView maxExtent) |
|
1104 |
borderWidth:(aView borderWidth) |
|
1105 |
subViewOf:(aView superView) |
|
157 | 1106 |
onTop:(aView isPopUpView) |
70 | 1107 |
inputOnly:(aView inputOnly) |
1108 |
label:(aView label) |
|
1109 |
cursor:(aView cursor) |
|
1110 |
icon:(aView icon) |
|
1111 |
iconView:(aView iconView) |
|
46 | 1112 |
! |
1113 |
||
1114 |
createWindowFor:aView |
|
70 | 1115 |
origin:origin |
1116 |
extent:extent |
|
1117 |
minExtent:minExt |
|
1118 |
maxExtent:maxExt |
|
1119 |
borderWidth:bWidth |
|
1120 |
subViewOf:wsuperView |
|
157 | 1121 |
onTop:wisPopUpView |
70 | 1122 |
inputOnly:winputOnly |
1123 |
label:wlabel |
|
1124 |
cursor:wcursor |
|
1125 |
icon:wicon |
|
1126 |
iconView:wiconView |
|
46 | 1127 |
|
1128 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1129 |
bColorId wsuperViewId wcursorId wiconId windowId |
|
1130 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
|
150 | 1131 |
vBgForm deepForm preferredVisual preferredDepth| |
1132 |
||
1133 |
displayId isNil ifTrue:[ |
|
1134 |
self primitiveFailed. |
|
1135 |
^ nil |
|
1136 |
]. |
|
0 | 1137 |
|
46 | 1138 |
origin notNil ifTrue:[ |
70 | 1139 |
xpos := origin x. |
1140 |
ypos := origin y. |
|
46 | 1141 |
] ifFalse:[ |
70 | 1142 |
xpos := ypos := 0. |
0 | 1143 |
]. |
46 | 1144 |
extent notNil ifTrue:[ |
70 | 1145 |
wwidth := extent x. |
1146 |
wheight := extent y. |
|
46 | 1147 |
] ifFalse:[ |
70 | 1148 |
wwidth := wheight := 100. |
46 | 1149 |
]. |
1150 |
minExt notNil ifTrue:[ |
|
70 | 1151 |
minWidth := minExt x. |
1152 |
minHeight := minExt y |
|
0 | 1153 |
]. |
46 | 1154 |
maxExt notNil ifTrue:[ |
70 | 1155 |
maxWidth := maxExt x. |
1156 |
maxHeight := maxExt y |
|
46 | 1157 |
]. |
1158 |
||
0 | 1159 |
wsuperView notNil ifTrue:[ |
70 | 1160 |
wsuperViewId := wsuperView id |
0 | 1161 |
]. |
1162 |
wcursor isNil ifTrue:[ |
|
145 | 1163 |
'XWORKSTATION: cursor nil - defaulted' errorPrintNL |
0 | 1164 |
] ifFalse:[ |
70 | 1165 |
wcursorId := wcursor id |
0 | 1166 |
]. |
1167 |
||
1168 |
wicon notNil ifTrue:[ |
|
70 | 1169 |
wiconId := wicon id |
0 | 1170 |
]. |
1171 |
wiconView notNil ifTrue:[ |
|
70 | 1172 |
wiconViewId := wiconView id |
0 | 1173 |
]. |
1174 |
weventMask := aView eventMask. |
|
1175 |
||
150 | 1176 |
preferredVisual := aView preferredVisual. |
1177 |
preferredDepth := aView preferredDepth. |
|
23 | 1178 |
|
72 | 1179 |
%{ /* STACK:16000 */ |
0 | 1180 |
Display *dpy = myDpy; |
1181 |
int screen = _intVal(_INST(screen)); |
|
1182 |
Visual visual; |
|
1183 |
XGCValues xgcv; |
|
1184 |
XSetWindowAttributes xswa; |
|
1185 |
XSizeHints sizehints; |
|
1186 |
XWMHints wmhints; |
|
46 | 1187 |
int bw, bd, bg; |
0 | 1188 |
Window newWindow, parentWindow; |
1189 |
char *windowName; |
|
1190 |
XFontStruct *f; |
|
1191 |
Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0; |
|
1192 |
int flags = 0, depth, ioClass; |
|
1193 |
Window iconWindow; |
|
1194 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1195 |
Atom WmQuitAppAtom; |
|
1196 |
Atom atoms[3]; |
|
1197 |
int atomCount = 0, isTopWindow = 0; |
|
1198 |
||
1199 |
sizehints.flags = 0; |
|
1200 |
sizehints.width = 100; |
|
1201 |
sizehints.height = 100; |
|
1202 |
sizehints.x = 0; |
|
1203 |
sizehints.y = 0; |
|
1204 |
||
97 | 1205 |
if (__bothSmallInteger(wwidth, wheight)) { |
70 | 1206 |
sizehints.flags |= PSize; |
1207 |
sizehints.width = _intVal(wwidth); |
|
1208 |
sizehints.height = _intVal(wheight); |
|
0 | 1209 |
} |
97 | 1210 |
if (__bothSmallInteger(xpos, ypos)) { |
70 | 1211 |
sizehints.flags |= PPosition; |
1212 |
sizehints.x = _intVal(xpos); |
|
1213 |
sizehints.y = _intVal(ypos); |
|
0 | 1214 |
} |
97 | 1215 |
if (__bothSmallInteger(minWidth, minHeight)) { |
70 | 1216 |
sizehints.flags |= PMinSize; |
1217 |
sizehints.min_width = _intVal(minWidth); |
|
1218 |
sizehints.min_height = _intVal(minHeight); |
|
0 | 1219 |
} |
97 | 1220 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
70 | 1221 |
sizehints.flags |= PMaxSize; |
1222 |
sizehints.max_width = _intVal(maxWidth); |
|
1223 |
sizehints.max_height = _intVal(maxHeight); |
|
0 | 1224 |
} |
1225 |
||
37 | 1226 |
bg = WhitePixel(dpy, screen); |
0 | 1227 |
|
97 | 1228 |
if (__isSmallInteger(bWidth)) { |
70 | 1229 |
bw = _intVal(bWidth); |
46 | 1230 |
} else { |
70 | 1231 |
bw = 0; |
0 | 1232 |
} |
1233 |
||
72 | 1234 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1235 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1236 |
if (__isExternalAddress(wsuperViewId)) { |
70 | 1237 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1238 |
} else { |
70 | 1239 |
parentWindow = RootWindow(dpy, screen); |
1240 |
isTopWindow = 1; |
|
0 | 1241 |
} |
1242 |
||
157 | 1243 |
if (wisPopUpView == true) |
70 | 1244 |
xswa.override_redirect = 1; |
0 | 1245 |
else |
70 | 1246 |
xswa.override_redirect = 0; |
0 | 1247 |
|
1248 |
if (winputOnly == true) |
|
70 | 1249 |
ioClass = InputOnly; |
0 | 1250 |
else |
70 | 1251 |
ioClass = InputOutput; |
0 | 1252 |
|
97 | 1253 |
if (__isSmallInteger(weventMask)) { |
70 | 1254 |
xswa.event_mask = _intVal(weventMask); |
0 | 1255 |
} else { |
70 | 1256 |
xswa.event_mask = 0; |
0 | 1257 |
} |
1258 |
||
1259 |
if (ioClass == InputOnly) { |
|
70 | 1260 |
bw = 0; |
1261 |
depth = 0; |
|
1262 |
flags |= CWEventMask; |
|
0 | 1263 |
} else { |
70 | 1264 |
depth = DefaultDepth(dpy,screen); |
1265 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
1266 |
||
1267 |
if (backPixmap != (Pixmap)0) { |
|
1268 |
xswa.background_pixmap = backPixmap; |
|
1269 |
flags |= CWBackPixmap; |
|
1270 |
} else { |
|
1271 |
xswa.background_pixel = bg; |
|
1272 |
flags |= CWBackPixel; |
|
1273 |
} |
|
1274 |
xswa.border_pixel = bd; |
|
0 | 1275 |
} |
23 | 1276 |
|
0 | 1277 |
visual.visualid = CopyFromParent; |
150 | 1278 |
if (__isSmallInteger(preferredDepth)) { |
1279 |
depth = _intVal(preferredDepth); |
|
23 | 1280 |
} |
54 | 1281 |
|
1282 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1283 |
if (preferredVisual != nil) { |
70 | 1284 |
XVisualInfo vi; |
1285 |
int cls; |
|
1286 |
||
150 | 1287 |
if (preferredVisual == @symbol(StaticGray)) |
70 | 1288 |
cls = StaticGray; |
150 | 1289 |
else if (preferredVisual == @symbol(GrayScale)) |
70 | 1290 |
cls = StaticGray; |
150 | 1291 |
else if (preferredVisual == @symbol(StaticColor)) |
70 | 1292 |
cls = StaticColor; |
150 | 1293 |
else if (preferredVisual == @symbol(PseudoColor)) |
70 | 1294 |
cls = PseudoColor; |
150 | 1295 |
else if (preferredVisual == @symbol(TrueColor)) |
70 | 1296 |
cls = TrueColor; |
150 | 1297 |
else if (preferredVisual == @symbol(DirectColor)) |
70 | 1298 |
cls = DirectColor; |
1299 |
else |
|
1300 |
cls = PseudoColor; |
|
200 | 1301 |
|
70 | 1302 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
1303 |
visual.visualid = vi.visualid; |
|
163 | 1304 |
/* |
1305 |
printf("visualId=%x\n", vi.visualid); |
|
1306 |
*/ |
|
70 | 1307 |
} |
23 | 1308 |
} |
0 | 1309 |
|
1310 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
70 | 1311 |
sizehints.x, sizehints.y, |
1312 |
sizehints.width, sizehints.height, |
|
1313 |
bw, depth, ioClass, &visual, |
|
1314 |
flags, &xswa); |
|
54 | 1315 |
END_INTERRUPTSBLOCKED |
0 | 1316 |
|
1317 |
if (! newWindow) { |
|
70 | 1318 |
RETURN ( nil ); |
0 | 1319 |
} |
1320 |
||
54 | 1321 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1322 |
/* |
1323 |
* define its cursor |
|
1324 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1325 |
if (__isExternalAddress(wcursorId)) { |
70 | 1326 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1327 |
} |
1328 |
||
1329 |
/* |
|
1330 |
* define its icon and name |
|
1331 |
* (only makes sense for topWindows) |
|
1332 |
*/ |
|
1333 |
if (isTopWindow) { |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1334 |
if (__isExternalAddress(wiconId)) |
70 | 1335 |
iconBitmap = _PixmapVal(wiconId); |
1336 |
else |
|
1337 |
iconBitmap = (Pixmap)0; |
|
1338 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1339 |
if (__isExternalAddress(wiconViewId)) |
70 | 1340 |
iconWindow = _WindowVal(wiconViewId); |
1341 |
else |
|
1342 |
iconWindow = (Window)0; |
|
1343 |
||
1344 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1345 |
windowName = (char *)_stringVal(wlabel); |
|
1346 |
else |
|
1347 |
windowName = ""; |
|
1348 |
||
1349 |
if (iconBitmap || windowName) { |
|
1350 |
XSetStandardProperties(dpy, newWindow, |
|
1351 |
windowName, windowName, |
|
1352 |
iconBitmap, |
|
1353 |
0, 0, &sizehints); |
|
1354 |
||
1355 |
} |
|
1356 |
||
1357 |
wmhints.flags = 0; |
|
1358 |
if (iconBitmap) { |
|
1359 |
wmhints.flags |= IconPixmapHint; |
|
1360 |
wmhints.icon_pixmap = iconBitmap; |
|
1361 |
} |
|
1362 |
if (iconWindow) { |
|
1363 |
wmhints.flags |= IconWindowHint; |
|
1364 |
wmhints.icon_window = iconWindow; |
|
1365 |
} |
|
0 | 1366 |
/* |
70 | 1367 |
wmhints.flags |= InputHint; |
1368 |
wmhints.input = True; |
|
0 | 1369 |
*/ |
70 | 1370 |
XSetWMHints(dpy, newWindow, &wmhints); |
1371 |
||
1372 |
/* |
|
1373 |
* tell window manager to not kill us but send an event instead |
|
1374 |
*/ |
|
1375 |
/* |
|
1376 |
* get atoms first (if not already known) |
|
1377 |
*/ |
|
1378 |
if (_INST(protocolsAtom) == nil) { |
|
1379 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1380 |
_INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
0 | 1381 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1382 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1383 |
_INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
0 | 1384 |
#endif |
1385 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1386 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1387 |
_INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
0 | 1388 |
#endif |
70 | 1389 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1390 |
_INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
70 | 1391 |
} else { |
0 | 1392 |
#ifdef USE_QUIT_APP_ATOM |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1393 |
WmQuitAppAtom = _AtomVal(_INST(quitAppAtom)); |
0 | 1394 |
#else |
70 | 1395 |
WmQuitAppAtom = 0; |
0 | 1396 |
#endif |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1397 |
WmProtocolsAtom = _AtomVal(_INST(protocolsAtom)); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1398 |
WmDeleteWindowAtom = _AtomVal(_INST(deleteWindowAtom)); |
0 | 1399 |
#ifdef USE_SAVEYOURSELF_ATOM |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1400 |
WmSaveYourselfAtom = _AtomVal(_INST(saveYourselfAtom)); |
0 | 1401 |
#else |
70 | 1402 |
WmSaveYourselfAtom = 0; |
0 | 1403 |
#endif |
70 | 1404 |
} |
1405 |
||
1406 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 1407 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1408 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1409 |
#endif |
1410 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1411 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1412 |
#endif |
70 | 1413 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
1414 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 1415 |
} |
1416 |
||
54 | 1417 |
END_INTERRUPTSBLOCKED |
1418 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1419 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1420 |
%}. |
0 | 1421 |
self addKnownView:aView withId:windowId. |
1422 |
^ windowId |
|
1423 |
! |
|
1424 |
||
295 | 1425 |
destroyFaxImage:aFaxImageId |
1426 |
||
1427 |
%{ /* NOCONTEXT */ |
|
1428 |
||
1429 |
#ifdef FAX |
|
1430 |
if (__isExternalAddress(aFaxImageId)) { |
|
70 | 1431 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1432 |
XFAXImageFreeImage(myDpy, (FAXImage)_WindowVal(aFaxImageId)); |
70 | 1433 |
END_INTERRUPTSBLOCKED |
295 | 1434 |
RETURN ( self ); |
1435 |
} |
|
1436 |
#endif |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1437 |
%}. |
295 | 1438 |
self primitiveFailed |
0 | 1439 |
! |
1440 |
||
1441 |
destroyGC:aGCId |
|
1442 |
||
1443 |
%{ /* NOCONTEXT */ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1444 |
if (__isExternalAddress(aGCId) && ISCONNECTED) { |
366 | 1445 |
GC gc = _GCVal(aGCId); |
1446 |
||
1447 |
if (gc) { |
|
1448 |
BEGIN_INTERRUPTSBLOCKED |
|
1449 |
XFreeGC(myDpy, gc); |
|
1450 |
END_INTERRUPTSBLOCKED |
|
1451 |
} |
|
70 | 1452 |
RETURN ( self ); |
0 | 1453 |
} |
118 | 1454 |
%}. |
0 | 1455 |
self primitiveFailed |
1456 |
! |
|
1457 |
||
295 | 1458 |
destroyPixmap:aDrawableId |
0 | 1459 |
|
1460 |
%{ /* NOCONTEXT */ |
|
1461 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1462 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
70 | 1463 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1464 |
XFreePixmap(myDpy, _PixmapVal(aDrawableId)); |
70 | 1465 |
END_INTERRUPTSBLOCKED |
295 | 1466 |
RETURN ( self ); |
0 | 1467 |
} |
118 | 1468 |
%}. |
295 | 1469 |
self primitiveFailed |
1470 |
! |
|
1471 |
||
1472 |
destroyView:aView withId:aWindowId |
|
1473 |
%{ |
|
1474 |
if (__isExternalAddress(aWindowId) && ISCONNECTED) { |
|
1475 |
BEGIN_INTERRUPTSBLOCKED |
|
1476 |
XDestroyWindow(myDpy, _WindowVal(aWindowId)); |
|
1477 |
END_INTERRUPTSBLOCKED |
|
1478 |
} |
|
1479 |
%}. |
|
1480 |
self removeKnownView:aView |
|
0 | 1481 |
! |
1482 |
||
1483 |
dpsContextFor:aDrawableId and:aGCId |
|
1484 |
||
1485 |
%{ /* NOCONTEXT */ |
|
1486 |
#ifdef XXDPS |
|
1487 |
int screen = _intVal(_INST(screen)); |
|
1488 |
DPSContext dps; |
|
1489 |
int height; |
|
1490 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1491 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1492 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1493 |
&& ISCONNECTED) { |
70 | 1494 |
BEGIN_INTERRUPTSBLOCKED |
1495 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1496 |
_GCVal(aGCId), |
|
1497 |
0, height, 0, colormap, NULL, 0, |
|
1498 |
XDPSDefaultTextBackstop, |
|
1499 |
XDPSDefaultErrorProc, |
|
1500 |
NULL); |
|
1501 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1502 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
0 | 1503 |
} |
1504 |
#endif |
|
1505 |
%} |
|
1506 |
. |
|
43 | 1507 |
self primitiveFailed. |
1508 |
^ nil |
|
295 | 1509 |
! |
1510 |
||
1511 |
gcFor:aDrawableId |
|
132 | 1512 |
|
1513 |
%{ /* NOCONTEXT */ |
|
295 | 1514 |
int screen = _intVal(_INST(screen)); |
1515 |
GC gc; |
|
1516 |
||
1517 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1518 |
BEGIN_INTERRUPTSBLOCKED |
|
1519 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1520 |
0L, (XGCValues *)0); |
|
1521 |
END_INTERRUPTSBLOCKED |
|
1522 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1523 |
} |
1524 |
%}. |
|
1525 |
self primitiveFailed. |
|
1526 |
^ nil |
|
295 | 1527 |
! |
1528 |
||
1529 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1530 |
|
1531 |
%{ /* UNLIMITEDSTACK */ |
|
1532 |
||
295 | 1533 |
Display *dpy = myDpy; |
1534 |
int screen = _intVal(_INST(screen)); |
|
1535 |
Pixmap newBitmap; |
|
1536 |
unsigned int b_width, b_height; |
|
1537 |
REGISTER unsigned char *cp; |
|
1538 |
REGISTER unsigned char *pBits; |
|
1539 |
unsigned char *b_bits, *allocatedBits; |
|
1540 |
int index, row; |
|
1541 |
REGISTER int col; |
|
1542 |
unsigned bits; |
|
1543 |
static char reverseBitTable[256]; |
|
1544 |
static firstCall = 1; |
|
1545 |
int nBytes; |
|
1546 |
unsigned char fastBits[10000]; |
|
1547 |
OBJ num, *op; |
|
1548 |
int bytesPerRow; |
|
1549 |
||
1550 |
if (firstCall) { |
|
1551 |
for (index=0; index < 256; index++) { |
|
1552 |
reverseBitTable[index] = 0; |
|
1553 |
if (index & 128) reverseBitTable[index] |= 1; |
|
1554 |
if (index & 64) reverseBitTable[index] |= 2; |
|
1555 |
if (index & 32) reverseBitTable[index] |= 4; |
|
1556 |
if (index & 16) reverseBitTable[index] |= 8; |
|
1557 |
if (index & 8) reverseBitTable[index] |= 16; |
|
1558 |
if (index & 4) reverseBitTable[index] |= 32; |
|
1559 |
if (index & 2) reverseBitTable[index] |= 64; |
|
1560 |
if (index & 1) reverseBitTable[index] |= 128; |
|
154 | 1561 |
} |
295 | 1562 |
firstCall = 0; |
1563 |
} |
|
1564 |
||
1565 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
377 | 1566 |
newBitmap = (Pixmap)0; |
295 | 1567 |
b_width = _intVal(w); |
1568 |
b_height = _intVal(h); |
|
1569 |
bytesPerRow = (b_width + 7) / 8; |
|
1570 |
nBytes = b_height * bytesPerRow; |
|
1571 |
if (nBytes < sizeof(fastBits)) { |
|
1572 |
cp = b_bits = fastBits; |
|
1573 |
allocatedBits = 0; |
|
1574 |
} else { |
|
1575 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
1576 |
if (! cp) goto fail; |
|
150 | 1577 |
} |
295 | 1578 |
|
377 | 1579 |
if (__qClass(anArray) == @global(Array)) { |
295 | 1580 |
index = 1; |
1581 |
op = &(_ArrayInstPtr(anArray)->a_element[index - 1]); |
|
1582 |
for (row = b_height; row; row--) { |
|
1583 |
for (col = bytesPerRow; col; col--) { |
|
1584 |
num = *op++; |
|
1585 |
if (! __isSmallInteger(num)) goto fail; |
|
1586 |
bits = _intVal(num); |
|
1587 |
*cp++ = reverseBitTable[bits]; |
|
1588 |
} |
|
1589 |
} |
|
1590 |
} else { |
|
377 | 1591 |
if (__qClass(anArray) == @global(ByteArray)) { |
295 | 1592 |
pBits = _ByteArrayInstPtr(anArray)->ba_element; |
1593 |
for (col = b_height*bytesPerRow; col; col--) { |
|
1594 |
*cp++ = reverseBitTable[*pBits++]; |
|
1595 |
} |
|
1596 |
} else { |
|
1597 |
goto fail; |
|
1598 |
} |
|
150 | 1599 |
} |
295 | 1600 |
|
1601 |
BEGIN_INTERRUPTSBLOCKED |
|
1602 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
|
1603 |
(char *)b_bits, |
|
1604 |
b_width, b_height); |
|
1605 |
END_INTERRUPTSBLOCKED |
|
1606 |
fail: ; |
|
1607 |
if (allocatedBits) |
|
1608 |
free(allocatedBits); |
|
1609 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1610 |
} |
1611 |
%} |
|
295 | 1612 |
! |
1613 |
||
1614 |
realRootWindowFor:aView |
|
1615 |
"the name of this method is historic; |
|
1616 |
- it will vanish" |
|
1617 |
||
1618 |
|id| |
|
1619 |
||
1620 |
id := self realRootWindowId. |
|
1621 |
self addKnownView:aView withId:id. |
|
1622 |
^ id |
|
1623 |
! |
|
1624 |
||
1625 |
realRootWindowId |
|
1626 |
"return the id of the real root window. |
|
1627 |
This may not be the window you see as background, |
|
1628 |
since some window managers install a virtual root window on top |
|
1629 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1630 |
care of any virtual root." |
|
0 | 1631 |
|
1632 |
%{ /* NOCONTEXT */ |
|
1633 |
||
295 | 1634 |
int screen = _intVal(_INST(screen)); |
1635 |
Window root; |
|
1636 |
OBJ id; |
|
1637 |
||
1638 |
if (_INST(rootId) != nil) { |
|
1639 |
RETURN (_INST(rootId)); |
|
1640 |
} |
|
0 | 1641 |
|
150 | 1642 |
if (ISCONNECTED) { |
295 | 1643 |
root = RootWindow(myDpy, screen); |
1644 |
if (! root) { |
|
1645 |
id = nil; |
|
1646 |
} else { |
|
1647 |
_INST(rootId) = id = __MKOBJ(root); __STORE(self, id); |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1648 |
} |
295 | 1649 |
RETURN (id); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1650 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1651 |
%}. |
295 | 1652 |
self primitiveFailed |
1653 |
! |
|
1654 |
||
1655 |
rootWindowFor:aView |
|
1656 |
|id| |
|
1657 |
||
1658 |
id := self rootWindowId. |
|
1659 |
self addKnownView:aView withId:id. |
|
0 | 1660 |
^ id |
1661 |
! |
|
1662 |
||
295 | 1663 |
rootWindowId |
1664 |
"return the id of the root window. |
|
1665 |
This is the window you see as background, |
|
1666 |
however, it may or may not be the real physical root window, |
|
1667 |
since some window managers install a virtual root window on top |
|
1668 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1669 |
|
0 | 1670 |
%{ /* NOCONTEXT */ |
295 | 1671 |
int screen = _intVal(_INST(screen)); |
1672 |
Window rootWin, vRootWin; |
|
1673 |
OBJ id; |
|
1674 |
||
1675 |
if (_INST(virtualRootId) != nil) { |
|
1676 |
RETURN (_INST(virtualRootId)); |
|
1677 |
} |
|
0 | 1678 |
|
169 | 1679 |
if (ISCONNECTED) { |
295 | 1680 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
1681 |
#ifndef IRIS |
|
180 | 1682 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1683 |
/* |
1684 |
* on IRIS, this creates a badwindow error - why ? |
|
1685 |
* children contains a funny window (000034) |
|
1686 |
*/ |
|
1687 |
||
1688 |
/* |
|
1689 |
* care for virtual root windows (tvtwm & friends) |
|
1690 |
*/ |
|
1691 |
{ |
|
1692 |
Atom vRootAtom = None; |
|
1693 |
int i; |
|
1694 |
Window rootReturn, parentReturn; |
|
1695 |
Window* children; |
|
1696 |
unsigned int numChildren; |
|
1697 |
||
1698 |
if (XQueryTree(myDpy, rootWin, |
|
1699 |
&rootReturn, &parentReturn, |
|
1700 |
&children, &numChildren)) { |
|
1701 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1702 |
if (vRootAtom != None) { |
|
1703 |
for (i=0; i < numChildren; i++) { |
|
1704 |
Atom actual_type; |
|
1705 |
int actual_format; |
|
1706 |
unsigned long nitems, bytesafter; |
|
1707 |
Window* newRoot = (Window*) 0; |
|
1708 |
||
1709 |
if (children[i]) { |
|
1710 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1711 |
0L, 1L, False, XA_WINDOW, |
|
1712 |
&actual_type, &actual_format, |
|
1713 |
&nitems, &bytesafter, |
|
1714 |
(unsigned char**) &newRoot |
|
1715 |
) == Success && newRoot) { |
|
1716 |
vRootWin = *newRoot; |
|
1717 |
break; |
|
1718 |
} |
|
1719 |
} |
|
1720 |
} |
|
1721 |
if (children) XFree( children ); |
|
1722 |
} |
|
1723 |
} |
|
1724 |
} |
|
180 | 1725 |
END_INTERRUPTSBLOCKED |
295 | 1726 |
#endif |
1727 |
} |
|
1728 |
||
1729 |
/* cannot happen */ |
|
1730 |
if (! vRootWin) { |
|
1731 |
vRootWin = rootWin; |
|
1732 |
if (! rootWin) { |
|
1733 |
RETURN ( nil ); |
|
1734 |
} |
|
1735 |
} |
|
1736 |
_INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
|
1737 |
_INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
1738 |
RETURN ( id ); |
|
63 | 1739 |
%} |
0 | 1740 |
! ! |
1741 |
||
1742 |
!XWorkstation methodsFor:'color stuff'! |
|
1743 |
||
295 | 1744 |
colorCell |
1745 |
"allocate a color cell - return index. |
|
1746 |
This method will return nil for StaticGrey and StaticGrey displays." |
|
0 | 1747 |
|
1748 |
%{ /* NOCONTEXT */ |
|
1749 |
||
1750 |
Display *dpy = myDpy; |
|
1751 |
int screen = _intVal(_INST(screen)); |
|
295 | 1752 |
XColor color; |
1753 |
unsigned long dummy; |
|
1754 |
Status ok; |
|
1755 |
||
1756 |
BEGIN_INTERRUPTSBLOCKED |
|
1757 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1758 |
&dummy, 0, &color.pixel, 1); |
|
1759 |
END_INTERRUPTSBLOCKED |
|
1760 |
if (ok) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1761 |
RETURN ( __MKSMALLINT(color.pixel) ); |
0 | 1762 |
} |
1763 |
%} |
|
1764 |
. |
|
43 | 1765 |
^ nil |
0 | 1766 |
! |
1767 |
||
1768 |
colorNamed:aString |
|
1769 |
"allocate a color with color name - return index. |
|
1770 |
Dont use this method, colornames are mostly X specific" |
|
1771 |
||
1772 |
%{ /* NOCONTEXT */ |
|
1773 |
||
1774 |
char *colorname; |
|
1775 |
Display *dpy = myDpy; |
|
1776 |
XColor scolor, ecolor; |
|
1777 |
int screen =_intVal(_INST(screen)); |
|
54 | 1778 |
Status ok; |
0 | 1779 |
|
150 | 1780 |
if (ISCONNECTED) { |
1781 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1782 |
colorname = (char *)_stringVal(aString); |
|
1783 |
||
1784 |
BEGIN_INTERRUPTSBLOCKED |
|
1785 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1786 |
if (ok) { |
|
1787 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
1788 |
} |
|
1789 |
END_INTERRUPTSBLOCKED |
|
1790 |
if (! ok) { |
|
1791 |
RETURN ( nil ); |
|
1792 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1793 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
70 | 1794 |
} |
0 | 1795 |
} |
1796 |
%} |
|
1797 |
. |
|
43 | 1798 |
self primitiveFailed. |
1799 |
^ nil |
|
0 | 1800 |
! |
1801 |
||
295 | 1802 |
colorRed:redVal green:greenVal blue:blueVal |
1803 |
"allocate a color with rgb values (0..100) - return index" |
|
1804 |
||
1805 |
|r g b| |
|
1806 |
||
1807 |
r := self percentToXColorValue:redVal. |
|
1808 |
g := self percentToXColorValue:greenVal. |
|
1809 |
b := self percentToXColorValue:blueVal. |
|
1810 |
%{ |
|
1811 |
Display *dpy = myDpy; |
|
1812 |
XColor ecolor; |
|
1813 |
int screen = _intVal(_INST(screen)); |
|
1814 |
Status ok; |
|
1815 |
||
1816 |
if (__bothSmallInteger(r, g) |
|
1817 |
&& __isSmallInteger(b) |
|
1818 |
&& ISCONNECTED) { |
|
1819 |
ecolor.red = _intVal(r); |
|
1820 |
ecolor.green= _intVal(g); |
|
1821 |
ecolor.blue = _intVal(b); |
|
1822 |
BEGIN_INTERRUPTSBLOCKED |
|
1823 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
1824 |
END_INTERRUPTSBLOCKED |
|
1825 |
if (! ok) { |
|
1826 |
RETURN ( nil ); |
|
1827 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1828 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 1829 |
} |
1830 |
%} |
|
1831 |
. |
|
1832 |
self primitiveFailed. |
|
1833 |
^ nil |
|
1834 |
! |
|
1835 |
||
1836 |
freeColor:colorIndex |
|
1837 |
"free a display color when its no longer needed" |
|
0 | 1838 |
|
1839 |
%{ /* NOCONTEXT */ |
|
1840 |
||
1841 |
Display *dpy = myDpy; |
|
295 | 1842 |
unsigned long color; |
0 | 1843 |
int screen = _intVal(_INST(screen)); |
295 | 1844 |
|
1845 |
#ifdef LATER |
|
1846 |
if (_INST(visualType) == @symbol(TrueColor)) { |
|
1847 |
/* no need to do anything on TrueColor displays ... */ |
|
1848 |
RETURN (self); |
|
1849 |
} |
|
1850 |
#endif |
|
1851 |
if (__isSmallInteger(colorIndex) && ISCONNECTED) { |
|
1852 |
color = (long) _intVal(colorIndex); |
|
1853 |
BEGIN_INTERRUPTSBLOCKED |
|
1854 |
XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L); |
|
1855 |
END_INTERRUPTSBLOCKED |
|
1856 |
RETURN ( self ); |
|
0 | 1857 |
} |
1858 |
%} |
|
1859 |
. |
|
295 | 1860 |
self primitiveFailed |
1861 |
! |
|
1862 |
||
1863 |
getRGBFrom:index into:aBlock |
|
1864 |
"get rgb components (0..100) of color in map at:index, |
|
1865 |
and evaluate the 3-arg block, aBlock with them" |
|
1866 |
||
1867 |
|r g b| |
|
1868 |
%{ |
|
1869 |
Display *dpy = myDpy; |
|
1870 |
int screen = _intVal(_INST(screen)); |
|
1871 |
XColor color; |
|
1872 |
double fr, fg, fb; |
|
1873 |
double floor(); |
|
1874 |
int bits, scale, shift; |
|
1875 |
||
1876 |
if (__isSmallInteger(index)) { |
|
1877 |
color.pixel = _intVal(index); |
|
1878 |
BEGIN_INTERRUPTSBLOCKED |
|
1879 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
1880 |
END_INTERRUPTSBLOCKED |
|
1881 |
||
1882 |
/* scale to 0..100 and round to the first decimal */ |
|
1883 |
||
1884 |
/* |
|
1885 |
* have to compensate for an error in X ?, which does not scale |
|
1886 |
* colors correctly if lesser than 16bits are valid in a color, |
|
1887 |
* (for example, color white on a 4bitsPerRGB server will return |
|
1888 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
1889 |
*/ |
|
1890 |
bits = _intVal(_INST(bitsPerRGB)); |
|
1891 |
scale = (1<<bits) - 1; |
|
1892 |
shift = 16 - bits; |
|
1893 |
||
1894 |
fr = floor( ( ((double)(color.red>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
1895 |
fg = floor( ( ((double)(color.green>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
1896 |
fb = floor( ( ((double)(color.blue>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
1897 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1898 |
r = __MKFLOAT(fr COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1899 |
g = __MKFLOAT(fg COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1900 |
b = __MKFLOAT(fb COMMA_CON); |
295 | 1901 |
} |
1902 |
%}. |
|
1903 |
aBlock value:r value:g value:b |
|
1904 |
! |
|
1905 |
||
1906 |
getRGBFromName:colorName into:aBlock |
|
1907 |
"get rgb components (0..100) of color named colorName, |
|
1908 |
and evaluate the 3-arg block, aBlock with them" |
|
1909 |
||
1910 |
|r g b| |
|
1911 |
||
1912 |
displayId isNil ifTrue:[ |
|
1913 |
self pimitiveFailed. |
|
1914 |
^ nil |
|
1915 |
]. |
|
1916 |
%{ |
|
1917 |
Display *dpy = myDpy; |
|
1918 |
int screen = _intVal(_INST(screen)); |
|
1919 |
XColor color; |
|
1920 |
double fr, fg, fb; |
|
1921 |
double floor(); |
|
1922 |
||
1923 |
if (__isString(colorName) || __isSymbol(colorName)) { |
|
1924 |
BEGIN_INTERRUPTSBLOCKED |
|
1925 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
1926 |
(char *)_stringVal(colorName), &color)) { |
|
1927 |
/* |
|
1928 |
* scale to 0..100 and round to the first decimal |
|
1929 |
*/ |
|
1930 |
fr = floor( ((((double)color.red) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
1931 |
fg = floor( ((((double)color.green) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
1932 |
fb = floor( ((((double)color.blue) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
1933 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1934 |
r = __MKFLOAT(fr COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1935 |
g = __MKFLOAT(fg COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1936 |
b = __MKFLOAT(fb COMMA_CON); |
295 | 1937 |
} |
1938 |
END_INTERRUPTSBLOCKED |
|
1939 |
} |
|
1940 |
%} |
|
1941 |
. |
|
1942 |
aBlock value:r value:g value:b |
|
1943 |
! |
|
1944 |
||
1945 |
listOfAvailableColors |
|
1946 |
"return a list of all available colornames. |
|
1947 |
This should not be used, since colornames are very |
|
1948 |
display-specific (here X-specific)." |
|
1949 |
||
1950 |
|aStream list line index colorName| |
|
1951 |
||
1952 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
1953 |
aStream isNil ifTrue:[^ nil]. |
|
1954 |
list := OrderedCollection new. |
|
1955 |
[aStream atEnd] whileFalse:[ |
|
1956 |
line := aStream nextLine. |
|
1957 |
line notNil ifTrue:[ |
|
1958 |
"skip the r/g/b numbers" |
|
1959 |
index := 1. |
|
1960 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
1961 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
1962 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
1963 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
1964 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
1965 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
1966 |
colorName := line copyFrom:index. |
|
1967 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
1968 |
list add:colorName |
|
1969 |
] |
|
1970 |
] |
|
1971 |
]. |
|
1972 |
aStream close. |
|
1973 |
^ list sort |
|
1974 |
! |
|
1975 |
||
1976 |
percentToXColorValue:aPercentage |
|
1977 |
"given a color-component value in percent (0..100), return the corresponding |
|
1978 |
x-component value (0..65k) as an integer" |
|
1979 |
||
1980 |
%{ /* NOCONTEXT */ |
|
1981 |
||
1982 |
if (__isSmallInteger(aPercentage)) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1983 |
RETURN ( __MKSMALLINT(0xFFFF * _intVal(aPercentage) / 100) ); |
295 | 1984 |
} |
1985 |
if (__isFloat(aPercentage)) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1986 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(_floatVal(aPercentage)) / 100) ); |
295 | 1987 |
} |
1988 |
%} |
|
1989 |
. |
|
1990 |
^ (16rFFFF * aPercentage / 100) rounded |
|
0 | 1991 |
! |
1992 |
||
1993 |
setColor:index red:redVal green:greenVal blue:blueVal |
|
1994 |
"change color in map at:index to rgb (0..100). |
|
1995 |
This method is a noop for StaticGrey and StaticGrey displays." |
|
1996 |
||
1997 |
%{ /* NOCONTEXT */ |
|
1998 |
||
1999 |
char *colorname; |
|
2000 |
Display *dpy = myDpy; |
|
2001 |
XColor color; |
|
2002 |
int screen = _intVal(_INST(screen)); |
|
2003 |
int r, g, b; |
|
2004 |
int ok = 1; |
|
2005 |
||
97 | 2006 |
if (__isSmallInteger(redVal)) |
70 | 2007 |
r = 0xFFFF * _intVal(redVal) / 100; |
36 | 2008 |
else if (__isFloat(redVal)) |
70 | 2009 |
r = 0xFFFF * (int)(_floatVal(redVal)) / 100; |
0 | 2010 |
else ok = 0; |
2011 |
||
97 | 2012 |
if (__isSmallInteger(greenVal)) |
70 | 2013 |
g = 0xFFFF * _intVal(greenVal) / 100; |
36 | 2014 |
else if (__isFloat(greenVal)) |
70 | 2015 |
g = 0xFFFF * (int)(_floatVal(greenVal)) / 100; |
0 | 2016 |
else ok = 0; |
2017 |
||
97 | 2018 |
if (__isSmallInteger(blueVal)) |
70 | 2019 |
b = 0xFFFF * _intVal(blueVal) / 100; |
36 | 2020 |
else if (__isFloat(blueVal)) |
70 | 2021 |
b = 0xFFFF * (int)(_floatVal(blueVal)) / 100; |
0 | 2022 |
else ok = 0; |
2023 |
||
97 | 2024 |
if (__isSmallInteger(index) && ok) { |
70 | 2025 |
color.pixel = _intVal(index); |
2026 |
color.red = r; |
|
2027 |
color.green = g; |
|
2028 |
color.blue = b; |
|
2029 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2030 |
||
2031 |
BEGIN_INTERRUPTSBLOCKED |
|
2032 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2033 |
END_INTERRUPTSBLOCKED |
|
2034 |
RETURN ( self ); |
|
0 | 2035 |
} |
2036 |
%} |
|
2037 |
. |
|
2038 |
self primitiveFailed |
|
295 | 2039 |
! ! |
2040 |
||
2041 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2042 |
||
2043 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
2044 |
"change a cursors colors" |
|
2045 |
||
2046 |
|fgR fgG fgB bgR bgG bgB| |
|
2047 |
||
2048 |
fgR := fgColor red. |
|
2049 |
fgG := fgColor green. |
|
2050 |
fgB := fgColor blue. |
|
2051 |
bgR := bgColor red. |
|
2052 |
bgG := bgColor green. |
|
2053 |
bgB := bgColor blue. |
|
2054 |
||
2055 |
fgR := self percentToXColorValue:fgR. |
|
2056 |
fgG := self percentToXColorValue:fgG. |
|
2057 |
fgB := self percentToXColorValue:fgB. |
|
2058 |
bgR := self percentToXColorValue:bgR. |
|
2059 |
bgG := self percentToXColorValue:bgG. |
|
2060 |
bgB := self percentToXColorValue:bgB. |
|
2061 |
||
0 | 2062 |
%{ |
295 | 2063 |
XColor fgcolor, bgcolor; |
2064 |
||
2065 |
if (__isExternalAddress(aCursorId) |
|
2066 |
&& __bothSmallInteger(fgG, fgB) |
|
2067 |
&& __bothSmallInteger(bgR, bgG) |
|
2068 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2069 |
||
2070 |
fgcolor.red = _intVal(fgR); |
|
2071 |
fgcolor.green= _intVal(fgG); |
|
2072 |
fgcolor.blue = _intVal(fgB); |
|
2073 |
bgcolor.red = _intVal(bgR); |
|
2074 |
bgcolor.green= _intVal(bgG); |
|
2075 |
bgcolor.blue = _intVal(bgB); |
|
70 | 2076 |
BEGIN_INTERRUPTSBLOCKED |
295 | 2077 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
72 | 2078 |
END_INTERRUPTSBLOCKED |
2079 |
RETURN ( self ); |
|
2080 |
} |
|
0 | 2081 |
%} |
2082 |
. |
|
2083 |
self primitiveFailed |
|
70 | 2084 |
! |
2085 |
||
295 | 2086 |
createCursorShape:aShape |
2087 |
"create a cursor given a shape-symbol" |
|
2088 |
||
2089 |
|number id| |
|
2090 |
||
2091 |
displayId isNil ifTrue:[ |
|
2092 |
self primitiveFailed. |
|
2093 |
^ nil |
|
2094 |
]. |
|
2095 |
number := self shapeNumberFromSymbol:aShape. |
|
2096 |
%{ |
|
2097 |
Cursor newCursor; |
|
2098 |
||
2099 |
if (__isSmallInteger(number)) { |
|
2100 |
BEGIN_INTERRUPTSBLOCKED |
|
2101 |
newCursor = XCreateFontCursor(myDpy, _intVal(number)); |
|
2102 |
END_INTERRUPTSBLOCKED |
|
2103 |
if (newCursor != (Cursor)0) { |
|
2104 |
id = __MKOBJ(newCursor); |
|
70 | 2105 |
} |
0 | 2106 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2107 |
%}. |
295 | 2108 |
^ id |
2109 |
! |
|
2110 |
||
2111 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy |
|
2112 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
|
2113 |
||
2114 |
|id sourceId maskId| |
|
2115 |
||
2116 |
displayId isNil ifTrue:[ |
|
2117 |
self primitiveFailed. |
|
2118 |
^ nil |
|
2119 |
]. |
|
2120 |
sourceId := sourceForm id. |
|
2121 |
maskId := maskForm id. |
|
2122 |
%{ |
|
2123 |
Cursor newCursor; |
|
2124 |
XColor fgColor, bgColor; |
|
2125 |
||
2126 |
if (__isExternalAddress(sourceId) |
|
2127 |
&& __isExternalAddress(maskId) |
|
2128 |
&& __bothSmallInteger(hx, hy)) { |
|
2129 |
fgColor.red = 0; /* fg is black */ |
|
2130 |
fgColor.green = 0; |
|
2131 |
fgColor.blue = 0; |
|
2132 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2133 |
bgColor.green = 0xFFFF; |
|
2134 |
bgColor.blue = 0xFFFF; |
|
2135 |
||
2136 |
BEGIN_INTERRUPTSBLOCKED |
|
2137 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2138 |
_PixmapVal(sourceId), |
|
2139 |
_PixmapVal(maskId), |
|
2140 |
&fgColor, &bgColor, _intVal(hx), _intVal(hy)); |
|
2141 |
END_INTERRUPTSBLOCKED |
|
2142 |
if (newCursor != (Cursor)0) { |
|
2143 |
id = __MKOBJ(newCursor); |
|
70 | 2144 |
} |
0 | 2145 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2146 |
%}. |
295 | 2147 |
^ id |
2148 |
! |
|
2149 |
||
2150 |
destroyCursor:aCursorId |
|
0 | 2151 |
|
2152 |
%{ /* NOCONTEXT */ |
|
2153 |
||
295 | 2154 |
if (ISCONNECTED) { |
2155 |
if (__isExternalAddress(aCursorId)) { |
|
2156 |
BEGIN_INTERRUPTSBLOCKED |
|
2157 |
XFreeCursor(myDpy, _CursorVal(aCursorId)); |
|
2158 |
END_INTERRUPTSBLOCKED |
|
70 | 2159 |
RETURN ( self ); |
2160 |
} |
|
0 | 2161 |
} |
2162 |
%} |
|
2163 |
. |
|
2164 |
self primitiveFailed |
|
295 | 2165 |
! |
2166 |
||
2167 |
shapeNumberFromSymbol:shape |
|
2168 |
"given a shape-symbol, return the corresponding cursor-number" |
|
2169 |
||
2170 |
"this is pure X-knowlegde - but you may easily add more" |
|
2171 |
||
2172 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2173 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2174 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2175 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2176 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2177 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2178 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2179 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2180 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2181 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2182 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2183 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2184 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2185 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2186 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2187 |
((shape == #origin) |
|
2188 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2189 |
((shape == #corner) |
|
2190 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2191 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2192 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2193 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2194 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2195 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2196 |
('XWORKSTATION: invalid cursorShape:' , shape printString) errorPrintNL. |
|
2197 |
^ 0 |
|
0 | 2198 |
! ! |
2199 |
||
2200 |
!XWorkstation methodsFor:'drawing'! |
|
2201 |
||
2202 |
copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2203 |
width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY |
12 | 2204 |
|
2205 |
"do a bit-blt of a compressed FAX image |
|
2206 |
- this needs my private FAX extension" |
|
132 | 2207 |
|
2208 |
%{ /* NOCONTEXT */ |
|
0 | 2209 |
#ifdef FAX |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2210 |
GC gc; |
0 | 2211 |
FAXImage source; |
2212 |
Drawable dest; |
|
2213 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2214 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2215 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2216 |
&& __isExternalAddress(destId) |
97 | 2217 |
&& __bothSmallInteger(scaleX, scaleY) |
2218 |
&& __bothSmallInteger(w, h) |
|
2219 |
&& __bothSmallInteger(srcX, srcY) |
|
2220 |
&& __bothSmallInteger(dstX, dstY)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2221 |
gc = _GCVal(aGCId); |
70 | 2222 |
source = (FAXImage) _WindowVal(sourceId); |
2223 |
dest = (Drawable) _WindowVal(destId); |
|
2224 |
XFAXImageCopyImage(myDpy, source, dest, gc, |
|
2225 |
_intVal(srcX), _intVal(srcY), |
|
2226 |
_intVal(w), _intVal(h), |
|
2227 |
_intVal(dstX), _intVal(dstY), |
|
2228 |
_intVal(scaleX), _intVal(scaleY)); |
|
2229 |
RETURN ( self ); |
|
0 | 2230 |
} |
2231 |
#endif |
|
118 | 2232 |
%}. |
0 | 2233 |
self primitiveFailed |
2234 |
! |
|
2235 |
||
2236 |
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2237 |
width:w height:h with:aGCId |
118 | 2238 |
"do a bit-blt; copy bits from the rectangle defined by |
2239 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2240 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2241 |
argument is not integer." |
|
0 | 2242 |
|
2243 |
%{ /* NOCONTEXT */ |
|
2244 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2245 |
GC gc; |
0 | 2246 |
Drawable source, dest; |
2247 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2248 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2249 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2250 |
&& __isExternalAddress(destId) |
97 | 2251 |
&& __bothSmallInteger(w, h) |
2252 |
&& __bothSmallInteger(srcX, srcY) |
|
2253 |
&& __bothSmallInteger(dstX, dstY)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2254 |
gc = _GCVal(aGCId); |
70 | 2255 |
source = (Drawable) _WindowVal(sourceId); |
2256 |
dest = (Drawable) _WindowVal(destId); |
|
2257 |
XCopyArea(myDpy, source, dest, gc, |
|
2258 |
_intVal(srcX), _intVal(srcY), |
|
2259 |
_intVal(w), _intVal(h), |
|
2260 |
_intVal(dstX), _intVal(dstY)); |
|
2261 |
RETURN ( self ); |
|
0 | 2262 |
} |
118 | 2263 |
%}. |
2264 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2265 |
or any non integer coordinate" |
|
2266 |
||
0 | 2267 |
self primitiveFailed |
2268 |
! |
|
2269 |
||
2270 |
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2271 |
width:w height:h with:aGCId |
118 | 2272 |
"do a bit-blt, but only copy the low-bit plane; |
2273 |
copy bits from the rectangle defined by |
|
2274 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2275 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2276 |
argument is not integer." |
|
0 | 2277 |
|
2278 |
%{ /* NOCONTEXT */ |
|
2279 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2280 |
GC gc; |
0 | 2281 |
Drawable source, dest; |
2282 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2283 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2284 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2285 |
&& __isExternalAddress(destId) |
97 | 2286 |
&& __bothSmallInteger(w, h) |
2287 |
&& __bothSmallInteger(srcX, srcY) |
|
2288 |
&& __bothSmallInteger(dstX, dstY)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2289 |
gc = _GCVal(aGCId); |
70 | 2290 |
source = (Drawable) _WindowVal(sourceId); |
2291 |
dest = (Drawable) _WindowVal(destId); |
|
2292 |
XCopyPlane(myDpy, source, dest, gc, |
|
2293 |
_intVal(srcX), _intVal(srcY), |
|
2294 |
_intVal(w), _intVal(h), |
|
2295 |
_intVal(dstX), _intVal(dstY), 1); |
|
2296 |
RETURN ( self ); |
|
0 | 2297 |
} |
118 | 2298 |
%}. |
2299 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2300 |
or any non integer coordinate" |
|
2301 |
||
0 | 2302 |
self primitiveFailed |
2303 |
! |
|
2304 |
||
73 | 2305 |
displayArcX:x y:y w:width h:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2306 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2307 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2308 |
|
2309 |
%{ /* NOCONTEXT */ |
|
2310 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2311 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2312 |
Window win; |
0 | 2313 |
int w, h, angle1, angle2; |
2314 |
double f; |
|
2315 |
||
97 | 2316 |
if (__isSmallInteger(startAngle)) |
70 | 2317 |
angle1 = _intVal(startAngle) * 64; |
36 | 2318 |
else if (__isFloat(startAngle)) { |
70 | 2319 |
f = _floatVal(startAngle); |
2320 |
angle1 = f * 64; |
|
0 | 2321 |
} |
97 | 2322 |
if (__isSmallInteger(angle)) |
70 | 2323 |
angle2 = _intVal(angle) * 64; |
36 | 2324 |
else if (__isFloat(angle)) { |
70 | 2325 |
f = _floatVal(angle); |
2326 |
angle2 = f * 64; |
|
0 | 2327 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2328 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2329 |
&& __isExternalAddress(aDrawableId) |
97 | 2330 |
&& __bothSmallInteger(x, y) |
2331 |
&& __bothSmallInteger(width, height)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2332 |
win = _WindowVal(aDrawableId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2333 |
gc = _GCVal(aGCId); |
70 | 2334 |
w = _intVal(width); |
2335 |
h = _intVal(height); |
|
2336 |
/* |
|
2337 |
* need this check here: some servers simply dump core with bad args |
|
2338 |
*/ |
|
2339 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2340 |
XDrawArc(myDpy, win, gc, _intVal(x), _intVal(y), |
|
2341 |
w, h, angle1, angle2); |
|
2342 |
} |
|
2343 |
RETURN ( self ); |
|
0 | 2344 |
} |
73 | 2345 |
%}. |
2346 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2347 |
self primitiveFailed |
2348 |
! |
|
2349 |
||
295 | 2350 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2351 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2352 |
||
2353 |
%{ /* NOCONTEXT */ |
|
2354 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2355 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2356 |
Window win; |
295 | 2357 |
|
2358 |
if (__isExternalAddress(aGCId) |
|
2359 |
&& __isExternalAddress(aDrawableId) |
|
2360 |
&& __bothSmallInteger(x0, y0) |
|
2361 |
&& __bothSmallInteger(x1, y1)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2362 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2363 |
win = _WindowVal(aDrawableId); |
295 | 2364 |
XDrawLine(myDpy, win, gc, _intVal(x0), _intVal(y0), |
2365 |
_intVal(x1), _intVal(y1)); |
|
2366 |
RETURN ( self ); |
|
2367 |
} |
|
2368 |
%}. |
|
2369 |
"badGC, badDrawable or coordinates not integer" |
|
2370 |
self primitiveFailed |
|
2371 |
! |
|
2372 |
||
2373 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2374 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2375 |
||
2376 |
%{ /* NOCONTEXT */ |
|
2377 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2378 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2379 |
Window win; |
295 | 2380 |
|
2381 |
if (__isExternalAddress(aGCId) |
|
2382 |
&& __isExternalAddress(aDrawableId) |
|
2383 |
&& __bothSmallInteger(x, y)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2384 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2385 |
win = _WindowVal(aDrawableId); |
295 | 2386 |
XDrawPoint(myDpy, win, gc, _intVal(x), _intVal(y)); |
2387 |
RETURN ( self ); |
|
2388 |
} |
|
2389 |
%}. |
|
2390 |
"badGC, badDrawable or x/y not integer" |
|
2391 |
self primitiveFailed |
|
2392 |
! |
|
2393 |
||
2394 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2395 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2396 |
define the polygon. |
|
2397 |
If any coordinate is not integer, an error is triggered." |
|
2398 |
||
2399 |
|numberOfPoints newPoints| |
|
2400 |
||
2401 |
numberOfPoints := aPolygon size. |
|
2402 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2403 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2404 |
Window win; |
295 | 2405 |
OBJ point, x, y; |
2406 |
int i, num; |
|
2407 |
XPoint *points; |
|
2408 |
XPoint qPoints[100]; |
|
377 | 2409 |
int mustFree = 0; |
295 | 2410 |
|
2411 |
if (__isExternalAddress(aGCId) |
|
2412 |
&& __isExternalAddress(aDrawableId) |
|
2413 |
&& __isSmallInteger(numberOfPoints)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2414 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2415 |
win = _WindowVal(aDrawableId); |
295 | 2416 |
num = _intVal(numberOfPoints); |
2417 |
/* |
|
2418 |
* avoid a (slow) malloc, if the number of points is small |
|
2419 |
*/ |
|
2420 |
if (num > 100) { |
|
2421 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2422 |
if (! points) goto fail; |
|
377 | 2423 |
mustFree = 1; |
295 | 2424 |
} else |
2425 |
points = qPoints; |
|
2426 |
||
2427 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2428 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
295 | 2429 |
if (! __isPoint(point)) goto fail; |
2430 |
x = _point_X(point); |
|
2431 |
y = _point_Y(point); |
|
2432 |
if (! __bothSmallInteger(x, y)) |
|
2433 |
goto fail; |
|
2434 |
points[i].x = _intVal(x); |
|
2435 |
points[i].y = _intVal(y); |
|
2436 |
} |
|
2437 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
377 | 2438 |
if (mustFree) |
295 | 2439 |
free(points); |
2440 |
RETURN ( self ); |
|
2441 |
} |
|
2442 |
fail: ; |
|
377 | 2443 |
if (mustFree) |
382 | 2444 |
free(points); |
295 | 2445 |
%}. |
2446 |
"badGC, badDrawable or coordinates not integer" |
|
2447 |
self primitiveFailed |
|
2448 |
! |
|
2449 |
||
2450 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2451 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2452 |
||
2453 |
%{ /* NOCONTEXT */ |
|
2454 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2455 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2456 |
Window win; |
295 | 2457 |
int w, h; |
2458 |
||
2459 |
if (__isExternalAddress(aGCId) |
|
2460 |
&& __isExternalAddress(aDrawableId) |
|
2461 |
&& __bothSmallInteger(x, y) |
|
2462 |
&& __bothSmallInteger(width, height)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2463 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2464 |
win = _WindowVal(aDrawableId); |
295 | 2465 |
w = _intVal(width); |
2466 |
h = _intVal(height); |
|
2467 |
/* |
|
2468 |
* need this check here: some servers simply dump core with bad args |
|
2469 |
*/ |
|
2470 |
if ((w >= 0) && (h >= 0)) { |
|
2471 |
XDrawRectangle(myDpy, win, gc, _intVal(x), _intVal(y), w, h); |
|
2472 |
} |
|
2473 |
RETURN ( self ); |
|
2474 |
} |
|
2475 |
%}. |
|
2476 |
"badGC, badDrawable or coordinates not integer" |
|
2477 |
self primitiveFailed |
|
2478 |
! |
|
2479 |
||
2480 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2481 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2482 |
foreground and background characters. |
|
2483 |
If the coordinates are not integers, an error is triggered." |
|
2484 |
||
2485 |
%{ /* NOCONTEXT */ |
|
2486 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2487 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2488 |
Window win; |
295 | 2489 |
unsigned char *cp; |
2490 |
OBJ cls; |
|
2491 |
int i1, i2, l, n; |
|
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2492 |
# define NLOCALBUFFER 50 |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2493 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
295 | 2494 |
|
2495 |
if (__isExternalAddress(aGCId) |
|
2496 |
&& __isExternalAddress(aDrawableId) |
|
2497 |
&& __isNonNilObject(aString) |
|
2498 |
&& __bothSmallInteger(index1, index2) |
|
2499 |
&& __bothSmallInteger(x, y)) { |
|
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2500 |
gc = _GCVal(aGCId); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2501 |
win = _WindowVal(aDrawableId); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2502 |
cls = __qClass(aString); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2503 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2504 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2505 |
i1 = _intVal(index1) - 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2506 |
i2 = _intVal(index2) - 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2507 |
n = _stringSize(aString); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2508 |
cp = _stringVal(aString); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2509 |
if ((i1 >= 0) && (i2 < n)) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2510 |
if (i2 >= i1) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2511 |
cp += i1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2512 |
l = i2 - i1 + 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2513 |
if (l > 1000) l = 1000; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2514 |
if (opaque == true) |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2515 |
XDrawImageString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, l); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2516 |
else |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2517 |
XDrawString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, l); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2518 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2519 |
RETURN ( self ); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2520 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2521 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2522 |
if (__isBytes(aString)) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2523 |
int nInstBytes; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2524 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2525 |
nInstBytes = __OBJS2BYTES__(_intVal(_ClassInstPtr(cls)->c_ninstvars)); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2526 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2527 |
i1 = _intVal(index1) - 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2528 |
i2 = _intVal(index2) - 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2529 |
n = _byteArraySize(aString) - nInstBytes - 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2530 |
cp = _stringVal(aString) + nInstBytes; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2531 |
if ((i1 >= 0) && (i2 < n)) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2532 |
if (i2 >= i1) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2533 |
cp += i1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2534 |
l = i2 - i1 + 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2535 |
if (l > 1000) l = 1000; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2536 |
if (opaque == true) |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2537 |
XDrawImageString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, l); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2538 |
else |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2539 |
XDrawString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, l); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2540 |
RETURN ( self ); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2541 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2542 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2543 |
} |
295 | 2544 |
#ifdef TWOBYTESTRINGS |
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2545 |
if (__isWords(aString)) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2546 |
int nInstBytes; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2547 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2548 |
nInstBytes = __OBJS2BYTES__(_intVal(_ClassInstPtr(cls)->c_ninstvars)); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2549 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2550 |
i1 = _intVal(index1) - 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2551 |
i2 = _intVal(index2) - 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2552 |
n = (_byteArraySize(aString) - nInstBytes) / 2; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2553 |
cp = _stringVal(aString) + nInstBytes; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2554 |
if ((i1 >= 0) && (i2 < n)) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2555 |
if (i2 >= i1) { |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2556 |
union { |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2557 |
char b[2]; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2558 |
unsigned short s; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2559 |
} u; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2560 |
int i; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2561 |
XChar2b *cp2 = (XChar2b *)0; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2562 |
int mustFree = 0; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2563 |
|
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2564 |
cp += (i1 * 2); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2565 |
l = i2 - i1 + 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2566 |
if (l > 1000) l = 1000; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2567 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2568 |
/* |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2569 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2570 |
* X expects them MSB first |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2571 |
* convert as required |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2572 |
*/ |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2573 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2574 |
u.s = 0x1234; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2575 |
if (u.b[0] != 0x12) { |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2576 |
if (l <= NLOCALBUFFER) { |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2577 |
cp2 = xlatebuffer; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2578 |
} else { |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2579 |
cp2 = (XChar2b *)(malloc(l * 2)); |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2580 |
mustFree = 1; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2581 |
} |
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2582 |
for (i=0; i<l; i++) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2583 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2584 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2585 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2586 |
cp = (char *) cp2; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2587 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2588 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2589 |
if (opaque == true) |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2590 |
XDrawImageString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, l); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2591 |
else |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2592 |
XDrawString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, l); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2593 |
|
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2594 |
if (mustFree) { |
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2595 |
free(cp2); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2596 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2597 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2598 |
RETURN ( self ); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2599 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2600 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2601 |
} |
295 | 2602 |
#endif |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2603 |
#undef NLOCALBUFFER |
295 | 2604 |
} |
2605 |
%}. |
|
2606 |
"x/y not integer, badGC or drawable, or not a string" |
|
2607 |
self primitiveFailed |
|
2608 |
! |
|
2609 |
||
2610 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2611 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
2612 |
foreground and background characters. |
|
2613 |
If the coordinates are not integers, an error is triggered." |
|
2614 |
||
2615 |
%{ /* NOCONTEXT */ |
|
2616 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2617 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2618 |
Window win; |
295 | 2619 |
unsigned char *cp; |
2620 |
int n; |
|
2621 |
OBJ cls; |
|
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2622 |
# define NLOCALBUFFER 50 |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2623 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
295 | 2624 |
|
2625 |
if (__isExternalAddress(aGCId) |
|
2626 |
&& __isExternalAddress(aDrawableId) |
|
2627 |
&& __isNonNilObject(aString) |
|
2628 |
&& __bothSmallInteger(x, y)) { |
|
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2629 |
gc = _GCVal(aGCId); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2630 |
win = _WindowVal(aDrawableId); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2631 |
cls = __qClass(aString); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2632 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2633 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2634 |
cp = _stringVal(aString); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2635 |
n = _stringSize(aString); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2636 |
if (n > 1000) n = 1000; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2637 |
if (opaque == true) |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2638 |
XDrawImageString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, n); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2639 |
else |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2640 |
XDrawString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, n); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2641 |
RETURN ( self ); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2642 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2643 |
if (__isBytes(aString)) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2644 |
int nInstBytes; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2645 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2646 |
nInstBytes = __OBJS2BYTES__(_intVal(_ClassInstPtr(cls)->c_ninstvars)); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2647 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2648 |
cp = _stringVal(aString) + nInstBytes; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2649 |
n = _byteArraySize(aString) - nInstBytes - 1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2650 |
if (n > 1000) n = 1000; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2651 |
if (opaque == true) |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2652 |
XDrawImageString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, n); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2653 |
else |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2654 |
XDrawString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, n); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2655 |
RETURN ( self ); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2656 |
} |
295 | 2657 |
#ifdef TWOBYTESTRINGS |
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2658 |
if (__isWords(aString)) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2659 |
int nInstBytes; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2660 |
union { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2661 |
char b[2]; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2662 |
unsigned short s; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2663 |
} u; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2664 |
int i; |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2665 |
XChar2b *cp2; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2666 |
int mustFree = 0; |
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2667 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2668 |
nInstBytes = __OBJS2BYTES__(_intVal(_ClassInstPtr(cls)->c_ninstvars)); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2669 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2670 |
cp = _stringVal(aString) + nInstBytes; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2671 |
n = (_byteArraySize(aString) - nInstBytes) / 2; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2672 |
if (n > 1000) n = 1000; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2673 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2674 |
/* |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2675 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2676 |
* X expects them MSB first |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2677 |
* convert as required |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2678 |
*/ |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2679 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2680 |
u.s = 0x1234; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2681 |
if (u.b[0] != 0x12) { |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2682 |
if (n <= NLOCALBUFFER) { |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2683 |
cp2 = xlatebuffer; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2684 |
} else { |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2685 |
cp2 = (XChar2b *)(malloc(n * 2)); |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2686 |
mustFree = 1; |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2687 |
} |
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2688 |
|
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2689 |
for (i=0; i<n; i++) { |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2690 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2691 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2692 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2693 |
cp = (char *) cp2; |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2694 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2695 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2696 |
if (opaque == true) |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2697 |
XDrawImageString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, n); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2698 |
else |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2699 |
XDrawString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, n); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2700 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2701 |
|
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2702 |
if (mustFree) { |
459
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2703 |
free(cp2); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2704 |
} |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2705 |
|
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2706 |
RETURN ( self ); |
6678caa541c1
X expects twoByteStrings in MSBfirst format
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
2707 |
} |
295 | 2708 |
#endif |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2709 |
#undef NLOCALBUFFER |
295 | 2710 |
} |
2711 |
%}. |
|
2712 |
"x/y not integer, badGC or drawable, or not a string" |
|
2713 |
self primitiveFailed |
|
2714 |
! |
|
2715 |
||
2716 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2717 |
width:imageWidth height:imageHeight |
|
2718 |
x:srcx y:srcy |
|
2719 |
into:aDrawableId |
|
2720 |
x:dstx y:dsty |
|
2721 |
width:w height:h |
|
2722 |
with:aGCId |
|
2723 |
||
2724 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2725 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2726 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
2727 |
depth and pixel-units to be different. |
|
2728 |
It has to be checked elsewhere, that the server can do it with the given |
|
2729 |
depth - otherwise, primitive failure will be signalled. |
|
2730 |
Also it is assumed, that the colormap is setup correctly and the |
|
2731 |
colors are allocated - otherwise the colors may be wrong." |
|
2732 |
||
2733 |
" |
|
2734 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
2735 |
an unlimited stack, and thus cannot send primitiveFailed |
|
2736 |
" |
|
2737 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2738 |
width:imageWidth height:imageHeight |
|
2739 |
x:srcx y:srcy |
|
2740 |
into:aDrawableId |
|
2741 |
x:dstx y:dsty |
|
2742 |
width:w height:h |
|
2743 |
with:aGCId) |
|
2744 |
ifFalse:[ |
|
2745 |
" |
|
2746 |
also happens, if a segmentation violation occurs in the |
|
2747 |
XPutImage ... |
|
2748 |
" |
|
2749 |
self primitiveFailed |
|
2750 |
]. |
|
2751 |
! |
|
2752 |
||
2753 |
drawBits:imageBits depth:imageDepth |
|
2754 |
width:imageWidth height:imageHeight |
|
2755 |
x:srcx y:srcy |
|
2756 |
into:aDrawableId |
|
2757 |
x:dstx y:dsty |
|
2758 |
width:w height:h |
|
2759 |
with:aGCId |
|
2760 |
||
2761 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2762 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2763 |
Individual source pixels must have imageDepth bits. |
|
2764 |
It has to be checked elsewhere, that the server can do it with the given |
|
2765 |
depth - otherwise, primitive failure will be signalled. |
|
2766 |
Also it is assumed, that the colormap is setup correctly and the |
|
2767 |
colors are allocated - otherwise the colors may be wrong." |
|
2768 |
||
2769 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
2770 |
width:imageWidth height:imageHeight |
|
2771 |
x:srcx y:srcy |
|
2772 |
into:aDrawableId |
|
2773 |
x:dstx y:dsty |
|
2774 |
width:w height:h |
|
2775 |
with:aGCId |
|
2776 |
||
2777 |
! |
|
2778 |
||
0 | 2779 |
fillArcX:x y:y w:width h:height from:startAngle angle:angle |
70 | 2780 |
in:aDrawableId with:aGCId |
90 | 2781 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
2782 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2783 |
|
2784 |
%{ /* NOCONTEXT */ |
|
2785 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2786 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2787 |
Window win; |
0 | 2788 |
int w, h, angle1, angle2; |
2789 |
double f; |
|
2790 |
||
97 | 2791 |
if (__isSmallInteger(startAngle)) |
70 | 2792 |
angle1 = _intVal(startAngle) * 64; |
36 | 2793 |
else if (__isFloat(startAngle)) { |
70 | 2794 |
f = _floatVal(startAngle); |
2795 |
angle1 = f * 64; |
|
0 | 2796 |
} |
97 | 2797 |
if (__isSmallInteger(angle)) |
70 | 2798 |
angle2 = _intVal(angle) * 64; |
36 | 2799 |
else if (__isFloat(angle)) { |
70 | 2800 |
f = _floatVal(angle); |
2801 |
angle2 = f * 64; |
|
0 | 2802 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2803 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2804 |
&& __isExternalAddress(aDrawableId) |
97 | 2805 |
&& __bothSmallInteger(x, y) |
2806 |
&& __bothSmallInteger(width, height)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2807 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2808 |
win = _WindowVal(aDrawableId); |
70 | 2809 |
w = _intVal(width); |
2810 |
h = _intVal(height); |
|
2811 |
/* |
|
2812 |
* need this check here: some servers simply dump core with bad args |
|
2813 |
*/ |
|
2814 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2815 |
XFillArc(myDpy, win, gc, _intVal(x), _intVal(y), |
|
2816 |
w, h, angle1, angle2); |
|
2817 |
} |
|
2818 |
RETURN ( self ); |
|
0 | 2819 |
} |
73 | 2820 |
%}. |
2821 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2822 |
self primitiveFailed |
2823 |
! |
|
2824 |
||
2825 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 2826 |
"fill a polygon given by its points. |
2827 |
If any coordinate is not integer, an error is triggered." |
|
73 | 2828 |
|
2829 |
|numberOfPoints| |
|
0 | 2830 |
|
2831 |
numberOfPoints := aPolygon size. |
|
2832 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2833 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2834 |
Window win; |
73 | 2835 |
OBJ point, x, y; |
2836 |
int i, num; |
|
2837 |
XPoint *points; |
|
2838 |
XPoint qPoints[100]; |
|
377 | 2839 |
int mustFree = 0; |
73 | 2840 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2841 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2842 |
&& __isExternalAddress(aDrawableId) |
97 | 2843 |
&& __isSmallInteger(numberOfPoints)) { |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2844 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2845 |
win = _WindowVal(aDrawableId); |
73 | 2846 |
num = _intVal(numberOfPoints); |
2847 |
if (num < 3) { |
|
70 | 2848 |
RETURN ( self ); |
2849 |
} |
|
73 | 2850 |
/* |
2851 |
* avoid (slow) malloc, if not many points |
|
2852 |
*/ |
|
96 | 2853 |
if (num > 100) { |
73 | 2854 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
96 | 2855 |
if (! points) goto fail; |
377 | 2856 |
mustFree = 1; |
96 | 2857 |
} else |
73 | 2858 |
points = qPoints; |
2859 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2860 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
73 | 2861 |
if (! __isPoint(point)) goto fail; |
2862 |
x = _point_X(point); |
|
2863 |
y = _point_Y(point); |
|
97 | 2864 |
if (! __bothSmallInteger(x, y)) |
73 | 2865 |
goto fail; |
2866 |
points[i].x = _intVal(x); |
|
2867 |
points[i].y = _intVal(y); |
|
2868 |
} |
|
2869 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
377 | 2870 |
if (mustFree) |
73 | 2871 |
free(points); |
2872 |
RETURN ( self ); |
|
377 | 2873 |
|
0 | 2874 |
fail: ; |
382 | 2875 |
if (mustFree) |
2876 |
free(points); |
|
0 | 2877 |
} |
73 | 2878 |
%}. |
2879 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2880 |
self primitiveFailed |
2881 |
! |
|
2882 |
||
295 | 2883 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
2884 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
2885 |
||
2886 |
%{ /* NOCONTEXT */ |
|
2887 |
||
2888 |
int w, h; |
|
2889 |
||
2890 |
if (__isExternalAddress(aGCId) |
|
2891 |
&& __isExternalAddress(aDrawableId) |
|
2892 |
&& __bothSmallInteger(x, y) |
|
2893 |
&& __bothSmallInteger(width, height)) { |
|
2894 |
w = _intVal(width); |
|
2895 |
h = _intVal(height); |
|
2896 |
/* |
|
2897 |
* need this check here: some servers simply dump core with bad args |
|
2898 |
*/ |
|
2899 |
if ((w >= 0) && (h >= 0)) { |
|
2900 |
XFillRectangle(myDpy, |
|
2901 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
2902 |
_intVal(x), _intVal(y), w, h); |
|
2903 |
} |
|
2904 |
RETURN ( self ); |
|
2905 |
} |
|
2906 |
%}. |
|
2907 |
"badGC, badDrawable or coordinates not integer" |
|
2908 |
self primitiveFailed |
|
43 | 2909 |
! |
2910 |
||
2911 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
70 | 2912 |
width:imageWidth height:imageHeight |
2913 |
x:srcx y:srcy |
|
2914 |
into:aDrawableId |
|
2915 |
x:dstx y:dsty |
|
2916 |
width:w height:h |
|
2917 |
with:aGCId |
|
0 | 2918 |
|
132 | 2919 |
"since XPutImage may allocate huge amount of stack space |
2920 |
(some implementations use alloca), this must run with unlimited stack." |
|
2921 |
||
12 | 2922 |
%{ /* UNLIMITEDSTACK */ |
0 | 2923 |
|
43 | 2924 |
/* |
2925 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
2926 |
* XPutImage |
|
2927 |
*/ |
|
2928 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2929 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2930 |
Window win; |
43 | 2931 |
XImage image; |
377 | 2932 |
int imgWdth; |
43 | 2933 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2934 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2935 |
&& __isExternalAddress(aDrawableId) |
97 | 2936 |
&& __bothSmallInteger(srcx, srcy) |
2937 |
&& __bothSmallInteger(dstx, dsty) |
|
2938 |
&& __bothSmallInteger(w, h) |
|
2939 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
2940 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 2941 |
&& __isByteArray(imageBits)) { |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2942 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2943 |
win = _WindowVal(aDrawableId); |
46 | 2944 |
#ifdef ARGDEBUG |
70 | 2945 |
printf("args ok\n"); |
46 | 2946 |
#endif |
70 | 2947 |
image.data = (char *)_ByteArrayInstPtr(imageBits)->ba_element; |
377 | 2948 |
image.width = imgWdth = _intVal(imageWidth); |
70 | 2949 |
image.height = _intVal(imageHeight); |
2950 |
image.xoffset = 0; |
|
2951 |
image.format = ZPixmap; |
|
2952 |
image.byte_order = MSBFirst; |
|
2953 |
image.bitmap_unit = 8; |
|
2954 |
image.bitmap_bit_order = MSBFirst; |
|
2955 |
image.bitmap_pad = 8; |
|
2956 |
image.depth = _intVal(imageDepth); |
|
2957 |
image.bits_per_pixel = _intVal(bitsPerPixel); |
|
2958 |
switch (image.bits_per_pixel) { |
|
2959 |
case 1: |
|
377 | 2960 |
image.bytes_per_line = (imgWdth + 7) / 8; |
70 | 2961 |
break; |
2962 |
case 2: |
|
377 | 2963 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
70 | 2964 |
break; |
2965 |
case 4: |
|
377 | 2966 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
70 | 2967 |
break; |
2968 |
case 8: |
|
377 | 2969 |
image.bytes_per_line = imgWdth; |
70 | 2970 |
break; |
2971 |
case 16: |
|
377 | 2972 |
image.bytes_per_line = imgWdth*2; |
70 | 2973 |
break; |
2974 |
case 24: |
|
377 | 2975 |
image.bytes_per_line = imgWdth*3; |
70 | 2976 |
break; |
193 | 2977 |
case 32: |
377 | 2978 |
image.bytes_per_line = imgWdth*4; |
193 | 2979 |
break; |
70 | 2980 |
default: |
46 | 2981 |
#ifdef ARGDEBUG |
70 | 2982 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 2983 |
#endif |
70 | 2984 |
goto fail; |
2985 |
} |
|
2986 |
image.red_mask = 0xFFFF; |
|
2987 |
image.green_mask = 0xFFFF; |
|
2988 |
image.blue_mask = 0xFFFF; |
|
2989 |
XPutImage(dpy, win, gc, &image, _intVal(srcx), _intVal(srcy), |
|
2990 |
_intVal(dstx), _intVal(dsty), |
|
2991 |
_intVal(w), _intVal(h)); |
|
2992 |
RETURN ( true ); |
|
43 | 2993 |
} |
46 | 2994 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2995 |
if (!! __isExternalAddress(aGCId)) printf("GC\n"); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2996 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 2997 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
2998 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
2999 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3000 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3001 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3002 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3003 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3004 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3005 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3006 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3007 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3008 |
#endif |
3009 |
||
0 | 3010 |
fail: ; |
3011 |
%} |
|
3012 |
. |
|
12 | 3013 |
^ false |
0 | 3014 |
! ! |
3015 |
||
86 | 3016 |
!XWorkstation methodsFor:'event handling'! |
0 | 3017 |
|
3018 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3019 |
"central event handling method: |
|
54 | 3020 |
get next event and send appropriate message to the sensor or view. |
0 | 3021 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3022 |
otherwise only events for the view with given id are processed. |
3023 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3024 |
handled." |
|
3025 |
||
54 | 3026 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
3027 |
AbortSignal catch:[ |
83 | 3028 |
self dispatchLastEvent. |
3029 |
] |
|
54 | 3030 |
]. |
12 | 3031 |
! |
3032 |
||
295 | 3033 |
dispatchExposeEventFor:aViewIdOrNil |
3034 |
"get next expose event and send appropriate message to the sensor or view. |
|
3035 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3036 |
otherwise only events for the view with given id are processed." |
|
3037 |
||
3038 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3039 |
! |
3040 |
||
3041 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3042 |
|theView symS arg butt sibling windowID siblingID propertyID selectionID targetID requestorID |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3043 |
eventType| |
12 | 3044 |
|
3045 |
%{ /* STACK: 8000 */ |
|
3046 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3047 |
|
3048 |
Display *dpy = myDpy; |
|
135 | 3049 |
OBJ eB; |
3050 |
XEvent *ev; |
|
3051 |
||
3052 |
# define ae ((XAnyEvent *)ev) |
|
3053 |
# define ee ((XExposeEvent *)ev) |
|
3054 |
# define ke ((XKeyPressedEvent *)ev) |
|
3055 |
# define be ((XButtonPressedEvent *)ev) |
|
3056 |
# define ce ((XConfigureEvent *)ev) |
|
3057 |
# define me ((XMotionEvent *)ev) |
|
3058 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3059 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3060 |
# define de ((XDestroyWindowEvent *)ev) |
|
3061 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3062 |
# define mape ((XMappingEvent *)ev) |
135 | 3063 |
|
0 | 3064 |
KeySym keySym; |
3065 |
unsigned char buffer[10]; |
|
3066 |
int i, nchars; |
|
3067 |
char *keySymString; |
|
3068 |
char keySymStringBuffer[32]; |
|
3069 |
static unsigned multiClickTime = 0; |
|
3070 |
unsigned nextMultiClickTime; |
|
150 | 3071 |
OBJ upDown; |
115 | 3072 |
|
3073 |
struct inlineCache *ipS; |
|
0 | 3074 |
static struct inlineCache vid = _ILC1; |
12 | 3075 |
|
3076 |
static struct inlineCache expS = _ILC5; |
|
3077 |
static struct inlineCache gexpS = _ILC5; |
|
3078 |
static struct inlineCache nexpS = _ILC1; |
|
3079 |
static struct inlineCache motS = _ILC4; |
|
3080 |
static struct inlineCache bpS = _ILC4; |
|
3081 |
static struct inlineCache bmpS = _ILC4; |
|
3082 |
static struct inlineCache bspS = _ILC4; |
|
3083 |
static struct inlineCache brS = _ILC4; |
|
3084 |
static struct inlineCache focInS = _ILC1; |
|
3085 |
static struct inlineCache focOutS = _ILC1; |
|
3086 |
static struct inlineCache peS = _ILC4; |
|
3087 |
static struct inlineCache plS = _ILC2; |
|
54 | 3088 |
static struct inlineCache termS = _ILC1; |
3089 |
static struct inlineCache savtermS = _ILC1; |
|
3090 |
static struct inlineCache destrS = _ILC1; |
|
3091 |
static struct inlineCache unmapS = _ILC1; |
|
3092 |
static struct inlineCache mapS = _ILC1; |
|
3093 |
static struct inlineCache confS = _ILC5; |
|
70 | 3094 |
static struct inlineCache coveredS = _ILC2; |
12 | 3095 |
|
3096 |
static struct inlineCache keymap = _ILC0; |
|
3097 |
static struct inlineCache created = _ILC0; |
|
3098 |
static struct inlineCache mapReq = _ILC0; |
|
3099 |
static struct inlineCache repar = _ILC0; |
|
3100 |
static struct inlineCache confReq = _ILC0; |
|
3101 |
static struct inlineCache resReq = _ILC0; |
|
3102 |
static struct inlineCache prop = _ILC0; |
|
129 | 3103 |
static struct inlineCache selClear = _ILC1; |
90 | 3104 |
static struct inlineCache selReq = _ILC4; |
3105 |
static struct inlineCache selNotify = _ILC4; |
|
12 | 3106 |
static struct inlineCache colormap = _ILC0; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3107 |
static struct inlineCache mapping = _ILC2; |
70 | 3108 |
static struct inlineCache vis = _ILC1; |
12 | 3109 |
|
3110 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3111 |
static struct inlineCache skrS = _ILC4; |
12 | 3112 |
|
135 | 3113 |
eB = _INST(eventBuffer); |
3114 |
if (__isByteArray(eB)) { |
|
3115 |
ev = (XEvent *)(_ByteArrayInstPtr(eB)->ba_element); |
|
3116 |
} else { |
|
3117 |
printf("DISPLAY: no eventBuffer\n"); |
|
3118 |
RETURN (false); |
|
3119 |
} |
|
3120 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3121 |
windowID = __MKOBJ(ae->window); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3122 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID); |
12 | 3123 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3124 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
70 | 3125 |
RETURN (nil); |
12 | 3126 |
} |
3127 |
||
3128 |
/* |
|
3129 |
* key, button and pointer events are sent to the sensor, |
|
3130 |
* or (if there is none) to the delegate. |
|
3131 |
* or (if there is none) to the view. |
|
26 | 3132 |
* |
3133 |
* expose events are sent to the sensor, |
|
3134 |
* or (if there is none) to the view |
|
3135 |
* |
|
12 | 3136 |
* sensor and delegate get view as additional argument |
115 | 3137 |
* all of this has been taken out of here to corresponding methods |
3138 |
* in DeviceWorkstation. |
|
12 | 3139 |
*/ |
90 | 3140 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3141 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3142 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3143 |
#endif |
135 | 3144 |
switch (ev->type) { |
70 | 3145 |
case KeyRelease: |
115 | 3146 |
symS = @symbol(keyRelease:x:y:view:); |
70 | 3147 |
ipS = &skrS; |
150 | 3148 |
upDown = false; |
70 | 3149 |
goto keyPressAndRelease; |
3150 |
||
3151 |
case KeyPress: |
|
115 | 3152 |
symS = @symbol(keyPress:x:y:view:); |
70 | 3153 |
ipS = &skpS; |
150 | 3154 |
upDown = true; |
3155 |
/* FALL INTO */ |
|
70 | 3156 |
|
3157 |
keyPressAndRelease: |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3158 |
_INST(eventRootX) = __MKSMALLINT(ke->x_root); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3159 |
_INST(eventRootY) = __MKSMALLINT(ke->y_root); |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3160 |
#ifdef OLD |
70 | 3161 |
_INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
3162 |
_INST(metaDown) = (ke->state & Mod1Mask) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3163 |
#else |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3164 |
_INST(altDown) = (ke->state & __intVal(_INST(altModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3165 |
_INST(metaDown) = (ke->state & __intVal(_INST(metaModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3166 |
#endif |
70 | 3167 |
_INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
150 | 3168 |
_INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
70 | 3169 |
|
3170 |
arg = nil; |
|
3171 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
|
3172 |
if (nchars |
|
3173 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
|
3174 |
|| (buffer[0] >= 0x80))) { |
|
3175 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
|
3176 |
keySymString = NULL; |
|
3177 |
} else { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3178 |
#ifdef OLD |
150 | 3179 |
switch (keySym) { |
3180 |
case XK_Control_L: |
|
3181 |
case XK_Control_R: |
|
3182 |
_INST(ctrlDown) = upDown; |
|
3183 |
break; |
|
3184 |
case XK_Shift_L: |
|
3185 |
case XK_Shift_R: |
|
3186 |
_INST(shiftDown) = upDown; |
|
3187 |
break; |
|
3188 |
case XK_Meta_L: |
|
3189 |
case XK_Meta_R: |
|
3190 |
_INST(metaDown) = upDown; |
|
3191 |
break; |
|
3192 |
case XK_Alt_L: |
|
3193 |
case XK_Alt_R: |
|
3194 |
_INST(altDown) = upDown; |
|
3195 |
break; |
|
3196 |
} |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3197 |
#endif |
150 | 3198 |
|
70 | 3199 |
keySymString = XKeysymToString(keySym); |
3200 |
if (keySymString) { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3201 |
#ifdef OLD |
70 | 3202 |
if (keySymString[0] == 'D') { |
3203 |
/* |
|
3204 |
* remove underscore, dont want it in symbols |
|
3205 |
*/ |
|
3206 |
if (strcmp(keySymString, "Delete_line") == 0) { |
|
3207 |
keySymString = "DeleteLine"; |
|
3208 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
|
3209 |
keySymString = "DeleteWord"; |
|
3210 |
} |
|
3211 |
} |
|
3212 |
/* |
|
3213 |
* make names compatible |
|
3214 |
*/ |
|
3215 |
if (strcmp(keySymString, "Down") == 0) { |
|
3216 |
keySymString = "CursorDown"; |
|
3217 |
} else if (strcmp(keySymString, "Up") == 0) { |
|
3218 |
keySymString = "CursorUp"; |
|
3219 |
} else if (strcmp(keySymString, "Left") == 0) { |
|
3220 |
keySymString = "CursorLeft"; |
|
3221 |
} else if (strcmp(keySymString, "Right") == 0) { |
|
3222 |
keySymString = "CursorRight"; |
|
3223 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3224 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3225 |
#else |
350 | 3226 |
__PROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3227 |
arg = __MKSTRING(keySymString COMMA_CON); |
350 | 3228 |
__UNPROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3229 |
#endif |
70 | 3230 |
} |
3231 |
} |
|
3232 |
||
3233 |
if (arg == nil) { |
|
3234 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
|
3235 |
break; |
|
3236 |
} |
|
3237 |
||
115 | 3238 |
(*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS, |
3239 |
arg, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3240 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3241 |
__MKSMALLINT(ke->y), |
115 | 3242 |
theView); |
70 | 3243 |
break; |
3244 |
||
3245 |
case ButtonPress: |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3246 |
_INST(buttonsPressed) = __MKSMALLINT(_intVal(_INST(buttonsPressed)) | (1 << be->button)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3247 |
_INST(eventRootX) = __MKSMALLINT(be->x_root); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3248 |
_INST(eventRootY) = __MKSMALLINT(be->y_root); |
70 | 3249 |
|
97 | 3250 |
if (__isSmallInteger(_INST(multiClickTimeDelta))) |
70 | 3251 |
nextMultiClickTime = be->time + _intVal(_INST(multiClickTimeDelta)); |
3252 |
else |
|
3253 |
nextMultiClickTime = 0; |
|
3254 |
||
3255 |
if (multiClickTime) { |
|
3256 |
if (be->time < multiClickTime) { |
|
3257 |
multiClickTime = nextMultiClickTime; |
|
3258 |
ipS = &bmpS; |
|
3259 |
symS = @symbol(buttonMultiPress:x:y:view:); |
|
3260 |
goto sendButtonEvent; |
|
3261 |
break; |
|
3262 |
} |
|
3263 |
} |
|
3264 |
multiClickTime = nextMultiClickTime; |
|
3265 |
if (be->state & ShiftMask) { |
|
3266 |
ipS = &bspS; |
|
3267 |
symS = @symbol(buttonShiftPress:x:y:view:); |
|
3268 |
goto sendButtonEvent; |
|
3269 |
} |
|
3270 |
ipS = &bpS; |
|
3271 |
symS = @symbol(buttonPress:x:y:view:); |
|
3272 |
goto sendButtonEvent; |
|
200 | 3273 |
|
70 | 3274 |
/* NOT REACHED */ |
3275 |
||
3276 |
case ButtonRelease: |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3277 |
_INST(buttonsPressed) = __MKSMALLINT(_intVal(_INST(buttonsPressed)) & ~(1 << be->button)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3278 |
_INST(eventRootX) = __MKSMALLINT(be->x_root); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3279 |
_INST(eventRootY) = __MKSMALLINT(be->y_root); |
70 | 3280 |
ipS = &brS; |
3281 |
symS = @symbol(buttonRelease:x:y:view:); |
|
3282 |
/* fall into */ |
|
3283 |
||
3284 |
sendButtonEvent: |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3285 |
butt = __MKSMALLINT(be->button); |
12 | 3286 |
#ifdef NOTDEF |
70 | 3287 |
/* |
3288 |
* this allows operation with single button mouses: meta-click is always Button 2 |
|
3289 |
*/ |
|
3290 |
if (_INST(metaDown) == true) |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3291 |
butt = __MKSMALLINT(2); |
70 | 3292 |
else |
0 | 3293 |
#endif |
193 | 3294 |
butt = __AT_(_INST(buttonTranslation), butt); |
200 | 3295 |
|
12 | 3296 |
|
115 | 3297 |
(*(*ipS).ilc_func)(self, |
3298 |
symS |
|
3299 |
COMMA_CON, nil, ipS, |
|
3300 |
butt, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3301 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3302 |
__MKSMALLINT(ke->y), |
115 | 3303 |
theView); |
70 | 3304 |
break; |
3305 |
||
3306 |
case MotionNotify: |
|
3307 |
if (_INST(motionEventCompression) != false) { |
|
135 | 3308 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
70 | 3309 |
} |
3310 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3311 |
_INST(eventRootX) = __MKSMALLINT(me->x_root); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3312 |
_INST(eventRootY) = __MKSMALLINT(me->y_root); |
70 | 3313 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3314 |
#ifdef OLD |
150 | 3315 |
_INST(altDown) = (me->state & Mod2Mask) ? true : false; |
3316 |
_INST(metaDown) = (me->state & Mod1Mask) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3317 |
#else |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3318 |
_INST(altDown) = (ke->state & __intVal(_INST(altModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3319 |
_INST(metaDown) = (ke->state & __intVal(_INST(metaModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3320 |
#endif |
150 | 3321 |
_INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
3322 |
_INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
|
3323 |
||
115 | 3324 |
(*motS.ilc_func)(self, |
3325 |
@symbol(buttonMotion:x:y:view:) |
|
3326 |
COMMA_CON, nil, &motS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3327 |
__MKSMALLINT(me->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3328 |
__MKSMALLINT(me->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3329 |
__MKSMALLINT(me->y), |
115 | 3330 |
theView); |
70 | 3331 |
break; |
3332 |
||
3333 |
case FocusIn: |
|
115 | 3334 |
(*focInS.ilc_func)(self, |
3335 |
@symbol(focusInView:) |
|
3336 |
COMMA_CON, nil, &focInS, |
|
3337 |
theView); |
|
70 | 3338 |
break; |
3339 |
||
3340 |
case FocusOut: |
|
115 | 3341 |
(*focOutS.ilc_func)(self, |
3342 |
@symbol(focusOutView:) |
|
3343 |
COMMA_CON, nil, &focOutS, |
|
3344 |
theView); |
|
70 | 3345 |
break; |
3346 |
||
3347 |
case EnterNotify: |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3348 |
#ifdef OLD |
150 | 3349 |
_INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
3350 |
_INST(metaDown) = (ewe->state & Mod1Mask) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3351 |
#else |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3352 |
_INST(altDown) = (ke->state & __intVal(_INST(altModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3353 |
_INST(metaDown) = (ke->state & __intVal(_INST(metaModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3354 |
#endif |
150 | 3355 |
_INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
3356 |
_INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
|
3357 |
||
115 | 3358 |
(*peS.ilc_func)(self, |
3359 |
@symbol(pointerEnter:x:y:view:) |
|
3360 |
COMMA_CON, nil, &peS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3361 |
__MKSMALLINT(ewe->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3362 |
__MKSMALLINT(ewe->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3363 |
__MKSMALLINT(ewe->y), |
115 | 3364 |
theView); |
70 | 3365 |
break; |
3366 |
||
3367 |
case LeaveNotify: |
|
115 | 3368 |
(*plS.ilc_func)(self, |
3369 |
@symbol(pointerLeave:view:) |
|
3370 |
COMMA_CON, nil, &plS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3371 |
__MKSMALLINT(lwe->state), |
115 | 3372 |
theView); |
70 | 3373 |
break; |
3374 |
||
3375 |
case GraphicsExpose: |
|
115 | 3376 |
(*gexpS.ilc_func)(self, |
3377 |
@symbol(graphicExposeX:y:width:height:view:) |
|
3378 |
COMMA_CON, nil, &gexpS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3379 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3380 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3381 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3382 |
__MKSMALLINT(ee->height), |
115 | 3383 |
theView); |
3384 |
||
3385 |
if (ee->count != 0) { |
|
70 | 3386 |
break; |
3387 |
} |
|
115 | 3388 |
/* fall into */ |
3389 |
||
3390 |
case NoExpose: |
|
3391 |
(*nexpS.ilc_func)(self, |
|
3392 |
@symbol(noExposeView:) |
|
3393 |
COMMA_CON, nil, &nexpS, |
|
3394 |
theView); |
|
3395 |
break; |
|
3396 |
||
3397 |
case Expose: |
|
3398 |
(*expS.ilc_func)(self, |
|
3399 |
@symbol(exposeX:y:width:height:view:) |
|
3400 |
COMMA_CON, nil, &expS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3401 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3402 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3403 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3404 |
__MKSMALLINT(ee->height), |
115 | 3405 |
theView); |
70 | 3406 |
break; |
3407 |
||
3408 |
case ConfigureNotify: |
|
3409 |
if (ce->above != None) { |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3410 |
siblingID = __MKOBJ(ce->above); |
70 | 3411 |
sibling = (*vid.ilc_func)(self, @symbol(viewFromId:) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3412 |
COMMA_CON, nil, &vid, siblingID); |
70 | 3413 |
} |
3414 |
||
115 | 3415 |
(*confS.ilc_func)(self, |
3416 |
@symbol(configureX:y:width:height:view:) |
|
3417 |
COMMA_CON, nil, &confS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3418 |
__MKSMALLINT(ce->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3419 |
__MKSMALLINT(ce->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3420 |
__MKSMALLINT(ce->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3421 |
__MKSMALLINT(ce->height), |
115 | 3422 |
theView); |
70 | 3423 |
if (sibling != nil) { |
115 | 3424 |
(*coveredS.ilc_func)(self, |
3425 |
@symbol(coveredBy:view:) |
|
3426 |
COMMA_CON, nil, &coveredS, |
|
3427 |
theView, |
|
3428 |
sibling); |
|
70 | 3429 |
} |
3430 |
break; |
|
3431 |
||
3432 |
case ClientMessage: |
|
135 | 3433 |
if (ev->xclient.message_type == (int) _AtomVal(_INST(protocolsAtom))) { |
3434 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(_INST(quitAppAtom))) |
|
3435 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(_INST(deleteWindowAtom)))) { |
|
115 | 3436 |
(*termS.ilc_func)(self, |
3437 |
@symbol(terminateView:) |
|
3438 |
COMMA_CON, nil, &termS, theView); |
|
70 | 3439 |
break; |
3440 |
} |
|
135 | 3441 |
if (ev->xclient.data.l[0] == (int) _AtomVal(_INST(saveYourselfAtom))) { |
115 | 3442 |
(*savtermS.ilc_func)(self, |
3443 |
@symbol(saveAndTerminateView:) |
|
3444 |
COMMA_CON, nil, &savtermS, theView); |
|
70 | 3445 |
break; |
3446 |
} |
|
3447 |
} |
|
3448 |
break; |
|
3449 |
||
3450 |
case DestroyNotify: |
|
115 | 3451 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
3452 |
COMMA_CON, nil, &destrS, theView); |
|
70 | 3453 |
break; |
3454 |
||
3455 |
case UnmapNotify: |
|
115 | 3456 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
3457 |
COMMA_CON, nil, &unmapS, theView); |
|
70 | 3458 |
break; |
3459 |
||
3460 |
case MapNotify: |
|
115 | 3461 |
(*mapS.ilc_func)(self, |
3462 |
@symbol(mappedView:) |
|
3463 |
COMMA_CON, nil, &mapS, theView); |
|
70 | 3464 |
break; |
3465 |
||
3466 |
case KeymapNotify: |
|
115 | 3467 |
(*keymap.ilc_func)(theView, |
3468 |
@symbol(keyMapChange) |
|
3469 |
COMMA_CON, nil, &keymap); |
|
70 | 3470 |
break; |
3471 |
||
3472 |
case VisibilityNotify: |
|
3473 |
switch (ve->state) { |
|
3474 |
case VisibilityUnobscured: |
|
3475 |
arg = @symbol(unobscured); |
|
3476 |
break; |
|
3477 |
case VisibilityPartiallyObscured: |
|
3478 |
arg = @symbol(partiallyObscured); |
|
3479 |
break; |
|
3480 |
case VisibilityFullyObscured: |
|
3481 |
arg = @symbol(fullyObscured); |
|
3482 |
break; |
|
3483 |
} |
|
3484 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:) COMMA_CON, nil, &vis, arg); |
|
3485 |
break; |
|
3486 |
||
3487 |
case CreateNotify: |
|
3488 |
(*created.ilc_func)(theView, @symbol(created) COMMA_CON, nil, &created); |
|
3489 |
break; |
|
3490 |
||
3491 |
case MapRequest: |
|
3492 |
(*mapReq.ilc_func)(theView, @symbol(mapRequest) COMMA_CON, nil, &mapReq); |
|
3493 |
break; |
|
3494 |
||
3495 |
case ReparentNotify: |
|
3496 |
(*repar.ilc_func)(theView, @symbol(reparented) COMMA_CON, nil, &repar); |
|
3497 |
break; |
|
3498 |
||
3499 |
case ConfigureRequest: |
|
3500 |
(*confReq.ilc_func)(theView, @symbol(configRequest) COMMA_CON, nil, &confReq); |
|
3501 |
break; |
|
3502 |
||
3503 |
case GravityNotify: |
|
3504 |
case ResizeRequest: |
|
3505 |
(*resReq.ilc_func)(theView, @symbol(resizeRequest) COMMA_CON, nil, &resReq); |
|
3506 |
break; |
|
3507 |
||
3508 |
case CirculateNotify: |
|
3509 |
case CirculateRequest: |
|
3510 |
break; |
|
3511 |
||
3512 |
case PropertyNotify: |
|
115 | 3513 |
(*prop.ilc_func)(theView, |
3514 |
@symbol(propertyChange) |
|
3515 |
COMMA_CON, nil, &prop); |
|
70 | 3516 |
break; |
3517 |
||
3518 |
case SelectionClear: |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3519 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
115 | 3520 |
(*selClear.ilc_func)(theView, |
129 | 3521 |
@symbol(selectionClear:) |
3522 |
COMMA_CON, nil, &selClear, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3523 |
selectionID); |
70 | 3524 |
break; |
3525 |
||
90 | 3526 |
case SelectionNotify: |
3527 |
/* |
|
3528 |
* returned selection value (answer from SelectionRequest) |
|
3529 |
*/ |
|
129 | 3530 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
135 | 3531 |
ev->xselection.property, ev->xselection.target, |
3532 |
ev->xselection.selection, ev->xselection.requestor)); |
|
129 | 3533 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3534 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3535 |
targetID = __MKATOMOBJ(ev->xselection.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3536 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3537 |
requestorID = __MKOBJ(ev->xselection.requestor); |
115 | 3538 |
(*selNotify.ilc_func)(theView, |
3539 |
@symbol(selectionNotify:target:selection:from:) |
|
3540 |
COMMA_CON, nil, &selNotify, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3541 |
propertyID, targetID, selectionID, requestorID); |
70 | 3542 |
break; |
3543 |
||
90 | 3544 |
case SelectionRequest: |
129 | 3545 |
/* |
3546 |
* someone wants the selection |
|
3547 |
*/ |
|
3548 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
|
135 | 3549 |
ev->xselectionrequest.property, |
3550 |
ev->xselectionrequest.target, |
|
3551 |
ev->xselectionrequest.selection, |
|
3552 |
ev->xselectionrequest.requestor)); |
|
129 | 3553 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3554 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3555 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3556 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3557 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
115 | 3558 |
(*selReq.ilc_func)(theView, |
3559 |
@symbol(selectionRequest:target:selection:from:) |
|
3560 |
COMMA_CON, nil, &selReq, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3561 |
propertyID, targetID, selectionID, requestorID); |
70 | 3562 |
break; |
3563 |
||
3564 |
case ColormapNotify: |
|
115 | 3565 |
(*colormap.ilc_func)(theView, |
3566 |
@symbol(colorMapChange) |
|
3567 |
COMMA_CON, nil, &colormap); |
|
70 | 3568 |
break; |
3569 |
||
3570 |
case MappingNotify: |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3571 |
switch(mape->request) { |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3572 |
case MappingModifier: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3573 |
arg = @symbol(mappingModifier); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3574 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3575 |
case MappingKeyboard: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3576 |
arg = @symbol(mappingKeyboard); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3577 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3578 |
case MappingPointer: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3579 |
arg = @symbol(mappingPointer); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3580 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3581 |
default: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3582 |
arg = nil; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3583 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3584 |
} |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3585 |
(*mapping.ilc_func)(self, |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3586 |
@symbol(mappingChanged:event:) |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3587 |
COMMA_CON, nil, &mapping, arg, eB); |
70 | 3588 |
break; |
0 | 3589 |
} |
135 | 3590 |
#undef ae |
0 | 3591 |
#undef ee |
3592 |
#undef ke |
|
3593 |
#undef be |
|
3594 |
#undef ce |
|
3595 |
#undef me |
|
3596 |
#undef ewe |
|
3597 |
#undef lwe |
|
3598 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3599 |
#undef mape |
0 | 3600 |
%} |
3601 |
. |
|
3602 |
^ true |
|
3603 |
! |
|
3604 |
||
295 | 3605 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3606 |
"central event handling method for modal operation. |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3607 |
(i.e. this is now only used in the modal debugger) |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3608 |
This code is somewhat special, since X has a concept of graphic |
295 | 3609 |
expose events (which are sent after a bitblt). After such a bitblt, |
3610 |
we only handle exposes until the graphicsExpose arrives. |
|
3611 |
Other systems may not need such a kludge" |
|
3612 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3613 |
"interested in exposes only ?" |
295 | 3614 |
dispatchingExpose notNil ifTrue:[ |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3615 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
295 | 3616 |
self dispatchExposeEventFor:dispatchingExpose |
3617 |
]. |
|
3618 |
^ self |
|
3619 |
]. |
|
3620 |
||
3621 |
"no, general dispatch" |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3622 |
[self eventPendingWithSync:false] whileTrue:[ |
295 | 3623 |
self dispatchEventFor:nil withMask:nil |
3624 |
] |
|
3625 |
! |
|
3626 |
||
81 | 3627 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
3628 |
"dispose (throw away) specific events. If aWindowId is nil, |
|
3629 |
events matching the mask are thrown away regardless of which |
|
3630 |
view they are for. Otherwise, only matching events for that |
|
3631 |
view are flushed." |
|
0 | 3632 |
|
3633 |
%{ /* NOCONTEXT */ |
|
3634 |
||
3635 |
Display *dpy = myDpy; |
|
3636 |
XEvent ev; |
|
3637 |
Window win; |
|
3638 |
||
97 | 3639 |
if (__isSmallInteger(aMask)) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3640 |
if (__isExternalAddress(aWindowIdOrNil)) { |
81 | 3641 |
win = _WindowVal(aWindowIdOrNil); |
3642 |
while (XCheckWindowEvent(dpy, win, _intVal(aMask), &ev)) ;; |
|
3643 |
} else { |
|
3644 |
while (XCheckMaskEvent(dpy, _intVal(aMask), &ev)) ;; |
|
3645 |
} |
|
70 | 3646 |
RETURN ( self ); |
0 | 3647 |
} |
3648 |
%} |
|
3649 |
. |
|
3650 |
self primitiveFailed |
|
3651 |
! |
|
3652 |
||
295 | 3653 |
eventMaskFor:anEventSymbol |
3654 |
"return the eventMask bit-constant corresponding to an event symbol" |
|
3655 |
||
3656 |
%{ /* NOCONTEXT */ |
|
3657 |
||
3658 |
int m = 0; |
|
3659 |
||
3660 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
3661 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
3662 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
3663 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
3664 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
3665 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
3666 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
3667 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
3668 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
3669 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
3670 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
3671 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
3672 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
3673 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
3674 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
3675 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3676 |
RETURN (__MKSMALLINT(m)); |
295 | 3677 |
%} |
3678 |
! |
|
3679 |
||
12 | 3680 |
eventPending |
310 | 3681 |
"return true, if any event is pending. |
3682 |
This looks for both the internal queue and the display connection." |
|
12 | 3683 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3684 |
ConservativeSyncing == true ifTrue:[self sync]. |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3685 |
|
12 | 3686 |
dispatchingExpose notNil ifTrue:[ |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3687 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 3688 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3689 |
^ self eventPendingWithSync:false |
0 | 3690 |
! |
3691 |
||
295 | 3692 |
eventPending:anEventSymbol for:aWindowIdOrNil |
3693 |
"return true, if a specific event is pending" |
|
3694 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3695 |
^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil withSync:false |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3696 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3697 |
|
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3698 |
eventPendingWithSync:doSync |
7 | 3699 |
"return true, if any event is pending. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3700 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 3701 |
before checking." |
0 | 3702 |
|
12 | 3703 |
%{ /* UNLIMITEDSTACK */ |
0 | 3704 |
|
3705 |
Display *dpy = myDpy; |
|
3706 |
||
150 | 3707 |
if (ISCONNECTED) { |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3708 |
if (doSync == true) { |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3709 |
XSync(dpy, 0); /* make certain everything is flushed */ |
150 | 3710 |
} |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3711 |
if (XPending(dpy)) { |
150 | 3712 |
RETURN (true); |
3713 |
} |
|
3714 |
} |
|
3715 |
RETURN ( false ); |
|
0 | 3716 |
%} |
3717 |
! |
|
3718 |
||
341 | 3719 |
eventQueued |
3720 |
"return true, if any event is queued" |
|
3721 |
||
3722 |
dispatchingExpose notNil ifTrue:[ |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3723 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 3724 |
]. |
3725 |
^ self eventQueuedAlready |
|
3726 |
||
3727 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
3728 |
! |
|
3729 |
||
3730 |
eventQueuedAlready |
|
3731 |
"return true, if any event is queued internally. |
|
3732 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
3733 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
3734 |
the display connection)." |
|
3735 |
||
3736 |
%{ /* UNLIMITEDSTACK */ |
|
3737 |
||
3738 |
if (ISCONNECTED) { |
|
3739 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
|
3740 |
RETURN (true); |
|
3741 |
} |
|
3742 |
} |
|
3743 |
RETURN ( false ); |
|
3744 |
%} |
|
3745 |
! |
|
3746 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3747 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 3748 |
"return true, if any of the masked events is pending" |
3749 |
||
3750 |
%{ /* UNLIMITEDSTACK */ |
|
3751 |
||
3752 |
Display *dpy = myDpy; |
|
3753 |
XEvent ev; |
|
3754 |
Window win; |
|
3755 |
int thereIsOne; |
|
3756 |
||
3757 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3758 |
if (doSync == true) { |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3759 |
XSync(dpy, 0); /* make certain everything is flushed */ |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3760 |
} |
295 | 3761 |
if (__isExternalAddress(aWindowIdOrNil)) { |
3762 |
win = _WindowVal(aWindowIdOrNil); |
|
3763 |
thereIsOne = XCheckWindowEvent(dpy, win, _intVal(anEventMask), &ev); |
|
3764 |
} else { |
|
3765 |
thereIsOne = XCheckMaskEvent(dpy, _intVal(anEventMask), &ev); |
|
3766 |
} |
|
3767 |
if (thereIsOne) { |
|
3768 |
XPutBackEvent(dpy, &ev); |
|
3769 |
RETURN ( true ); |
|
3770 |
} |
|
3771 |
} |
|
3772 |
RETURN ( false ); |
|
3773 |
%} |
|
3774 |
! |
|
3775 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3776 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 3777 |
"return true, if any expose event is pending for a specific view, |
3778 |
or any view (if the arg is nil). |
|
3779 |
This is an X specific, only required after a scroll operation." |
|
7 | 3780 |
|
12 | 3781 |
%{ /* UNLIMITEDSTACK */ |
7 | 3782 |
|
3783 |
Display *dpy = myDpy; |
|
3784 |
XEvent ev; |
|
3785 |
Window win; |
|
81 | 3786 |
int thereIsOne; |
3787 |
||
150 | 3788 |
if (ISCONNECTED) { |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3789 |
if (doSync == true) { |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3790 |
XSync(dpy, 0); /* make certain everything is flushed */ |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3791 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3792 |
if (__isExternalAddress(aWindowIdOrNil)) { |
150 | 3793 |
win = _WindowVal(aWindowIdOrNil); |
3794 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
3795 |
} else { |
|
3796 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
3797 |
} |
|
3798 |
if (thereIsOne) { |
|
3799 |
XPutBackEvent(dpy, &ev); |
|
3800 |
RETURN ( true ); |
|
3801 |
} |
|
81 | 3802 |
} |
3803 |
RETURN ( false ); |
|
3804 |
%} |
|
3805 |
! |
|
3806 |
||
295 | 3807 |
getEventFor:aViewIdOrNil withMask:eventMask |
3808 |
"read next event - put into local eventBuffer. |
|
3809 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
3810 |
otherwise only events for that specific view will be fetched. |
|
3811 |
Returns true, if there was an event, false otherwise. |
|
3812 |
This method may block - so you better check for pending events |
|
3813 |
before calling for it. |
|
3814 |
||
3815 |
Sorry I had to split dispatch into this fetch method and an extra |
|
3816 |
handle method to allow unlimitedstack here. |
|
3817 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
3818 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
3819 |
BUG: uses a static buffer - has to be rewritten, to support multiple |
|
3820 |
display connections. |
|
3821 |
" |
|
81 | 3822 |
|
3823 |
%{ /* UNLIMITEDSTACK */ |
|
3824 |
||
3825 |
Display *dpy = myDpy; |
|
295 | 3826 |
Window win, wWanted; |
3827 |
int evMask; |
|
3828 |
OBJ eB; |
|
3829 |
XEvent *ev; |
|
3830 |
||
3831 |
if (! ISCONNECTED) { |
|
3832 |
RETURN (false); |
|
3833 |
} |
|
3834 |
||
3835 |
eB = _INST(eventBuffer); |
|
3836 |
if (__isByteArray(eB)) { |
|
3837 |
ev = (XEvent *)(_ByteArrayInstPtr(eB)->ba_element); |
|
3838 |
} else { |
|
3839 |
printf("DISPLAY: no eventBuffer\n"); |
|
3840 |
RETURN (false); |
|
3841 |
} |
|
3842 |
ev->type = 0; |
|
3843 |
||
3844 |
if (__isSmallInteger(eventMask)) { |
|
3845 |
evMask = _intVal(eventMask); |
|
3846 |
} else { |
|
3847 |
evMask = ~0; |
|
3848 |
} |
|
3849 |
||
3850 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
3851 |
wWanted = _WindowVal(aViewIdOrNil); |
|
3852 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
|
70 | 3853 |
RETURN ( true ); |
3854 |
} |
|
295 | 3855 |
} else { |
3856 |
if (evMask == ~0) { |
|
3857 |
XNextEvent(dpy, ev); |
|
3858 |
RETURN (true); |
|
3859 |
} |
|
3860 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
|
3861 |
RETURN (true); |
|
3862 |
} |
|
3863 |
} |
|
3864 |
%}. |
|
3865 |
^ false |
|
3866 |
! |
|
3867 |
||
3868 |
handleAllEvents |
|
3869 |
"from now on, handle any kind of event" |
|
3870 |
||
3871 |
dispatchingExpose := nil |
|
3872 |
! |
|
3873 |
||
3874 |
handleExposeOnlyFor:aView |
|
3875 |
"from now on, handle expose events only" |
|
3876 |
||
3877 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3878 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3879 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3880 |
mappingChanged:what event:eB |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3881 |
"One of Keyboard-, Modifier- or PointerMap has change, probably by xmodmap. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3882 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3883 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3884 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3885 |
self refreshKeyboardMapping:eB. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3886 |
"Maybe some of our modifiers have been changed" |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3887 |
self initializeModifierMappings. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3888 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3889 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3890 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 3891 |
! |
3892 |
||
3893 |
setEventMask:aMask in:aWindowId |
|
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3894 |
"tell X that we are only interested in events from aMask, which |
295 | 3895 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
3896 |
||
3897 |
%{ /* NOCONTEXT */ |
|
3898 |
||
3899 |
int mask; |
|
3900 |
||
3901 |
if (__isExternalAddress(aWindowId) |
|
3902 |
&& __isSmallInteger(aMask)) { |
|
3903 |
mask = _intVal(aMask); |
|
3904 |
||
3905 |
#ifdef OLD |
|
3906 |
/* these may not be disabled */ |
|
3907 |
mask |= ExposureMask | StructureNotifyMask | |
|
3908 |
KeyPressMask | KeyReleaseMask | |
|
3909 |
EnterWindowMask | LeaveWindowMask | |
|
3910 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
3911 |
#endif |
|
3912 |
||
3913 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
|
3914 |
RETURN ( self ); |
|
3915 |
} |
|
3916 |
%} |
|
3917 |
. |
|
3918 |
self primitiveFailed |
|
3919 |
! |
|
3920 |
||
3921 |
startDispatch |
|
3922 |
"redefined to clear dispatchingExpose, which is a special X feature" |
|
3923 |
||
3924 |
dispatching ifTrue:[^ self]. |
|
3925 |
dispatchingExpose := nil. |
|
3926 |
super startDispatch |
|
0 | 3927 |
! ! |
295 | 3928 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3929 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3930 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3931 |
sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3932 |
"send a keyPress/Release or buttonPress/Release event to some (possibly alien) view. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3933 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3934 |
For buttonEvents, the keySymCodeOrButtonNr must be the buttons number (1, 2 ...); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3935 |
for key events, it can be either a symbol (as listen in X's keySyms) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3936 |
or a numeric keysym code. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3937 |
This is the lowlevel entry, where state must include any shift/ctrl information |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3938 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3939 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3940 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3941 |
Display *dpy = myDpy; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3942 |
int type; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3943 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3944 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3945 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3946 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3947 |
&& __isSmallInteger(stateMask) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3948 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3949 |
XEvent ev; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3950 |
Window target; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3951 |
Status result; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3952 |
KeySym keySym; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3953 |
int screen = _intVal(_INST(screen)); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3954 |
char s[2]; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3955 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3956 |
if ((typeSymbol == @symbol(keyPress)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3957 |
|| (typeSymbol == @symbol(keyRelease))) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3958 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3959 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3960 |
} else { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3961 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3962 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3963 |
s[1] = '\0'; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3964 |
keySym = XStringToKeysym(s); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3965 |
} else { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3966 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3967 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3968 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3969 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3970 |
} else { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3971 |
if ((typeSymbol == @symbol(buttonPress)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3972 |
|| (typeSymbol == @symbol(buttonRelease))) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3973 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3974 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3975 |
} else { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3976 |
ev.xbutton.button = 1; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3977 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3978 |
} else { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3979 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3980 |
RETURN (false); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3981 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3982 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3983 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3984 |
if (typeSymbol == @symbol(keyPress)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3985 |
ev.xany.type = KeyPress; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3986 |
else if (typeSymbol == @symbol(keyRelease)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3987 |
ev.xany.type = KeyRelease; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3988 |
else if (typeSymbol == @symbol(buttonPress)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3989 |
ev.xany.type = ButtonPress; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3990 |
else if (typeSymbol == @symbol(buttonRelease)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3991 |
ev.xany.type = ButtonRelease; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3992 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3993 |
if (__isExternalAddress(targetId)) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3994 |
target = _WindowVal(targetId); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3995 |
} else { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3996 |
target = (Window) __longIntVal(targetId); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3997 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3998 |
ev.xkey.window = target; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3999 |
ev.xkey.same_screen = 1; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4000 |
ev.xkey.subwindow = 0; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4001 |
ev.xkey.root = RootWindow(myDpy, screen); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4002 |
ev.xkey.x = __intVal(xPos); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4003 |
ev.xkey.y = __intVal(yPos); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4004 |
ev.xkey.state = __intVal(stateMask); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4005 |
ev.xkey.time = CurrentTime; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4006 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4007 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4008 |
if ((result == BadValue) || (result == BadWindow)) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4009 |
DPRINTF(("bad status\n")); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4010 |
RETURN ( false ) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4011 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4012 |
RETURN (true) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4013 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4014 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4015 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4016 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4017 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4018 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4019 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4020 |
"send input to some other view, by simulating keyPress/keyRelease |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4021 |
events. Notice: not all alien views allow this kind of synthetic input; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4022 |
some simply ignore it." |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4023 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4024 |
|shifted control code state| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4025 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4026 |
aCharacterOrString isString ifTrue:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4027 |
aCharacterOrString do:[:char | |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4028 |
self simulateKeyboardInput:char inViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4029 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4030 |
^ self |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4031 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4032 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4033 |
shifted := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4034 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4035 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4036 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4037 |
(aCharacterOrString == Character cr) ifTrue:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4038 |
code := #Return |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4039 |
] ifFalse:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4040 |
(aCharacterOrString between:$A and:$Z) ifTrue:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4041 |
"/ shifted |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4042 |
shifted := true |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4043 |
] ifFalse:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4044 |
(aCharacterOrString between:$a and:$z) ifTrue:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4045 |
"/ unshifted alpha |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4046 |
code := code - $a asciiValue + $A asciiValue |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4047 |
] |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4048 |
] |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4049 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4050 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4051 |
shifted ifTrue:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4052 |
state := self shiftMask |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4053 |
] ifFalse:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4054 |
state := 0 |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4055 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4056 |
control ifTrue:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4057 |
state := state bitOr:(self controlMask) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4058 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4059 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4060 |
self sendKeyOrButtonEvent:#keyPress x:0 y:0 keyOrButton:code state:state toViewId:viewId. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4061 |
self sendKeyOrButtonEvent:#keyRelease x:0 y:0 keyOrButton:code state:state toViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4062 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4063 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4064 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4065 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4066 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4067 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4068 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4069 |
id := Display viewIdFromPoint:point. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4070 |
Display simulateKeyboardInput:'hello' inViewId:id |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4071 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4072 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4073 |
|
295 | 4074 |
!XWorkstation methodsFor:'font stuff'! |
4075 |
||
4076 |
ascentOf:aFontId |
|
4077 |
"the normal ascent" |
|
4078 |
||
4079 |
%{ /* NOCONTEXT */ |
|
4080 |
||
4081 |
XFontStruct *f; |
|
4082 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4083 |
if (ISCONNECTED) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4084 |
if (__isExternalAddress(aFontId)) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4085 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4086 |
RETURN ( __MKSMALLINT(f->ascent) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4087 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4088 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4089 |
%}. |
295 | 4090 |
self primitiveFailed. |
4091 |
^ nil |
|
4092 |
! |
|
4093 |
||
4094 |
createFontFor:aFontName |
|
4095 |
"a basic method for X-font allocation; this method allows |
|
4096 |
any font to be aquired (even those not conforming to |
|
4097 |
standard naming conventions, such as cursor, fixed or k14)" |
|
4098 |
||
4099 |
%{ /* UNLIMITEDSTACK */ |
|
4100 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
4101 |
||
4102 |
XFontStruct *newFont; |
|
4103 |
||
4104 |
if (ISCONNECTED) { |
|
4105 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
|
4106 |
BEGIN_INTERRUPTSBLOCKED |
|
4107 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
4108 |
END_INTERRUPTSBLOCKED |
|
4109 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
4110 |
} |
|
4111 |
} |
|
4112 |
%}. |
|
4113 |
^ nil |
|
4114 |
! |
|
4115 |
||
4116 |
decomposeXFontName:aString into:aBlock |
|
4117 |
"extract family, face, style and size from an |
|
4118 |
X-font name |
|
4119 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
4120 |
evaluate aBlock with these" |
|
4121 |
||
4122 |
|origin family face style moreStyle skip fheight size |
|
4123 |
resX resY x1 x2 coding start end | |
|
4124 |
||
4125 |
aString isNil ifTrue:[^ false]. |
|
4126 |
(aString startsWith:'-') ifFalse:[ |
|
4127 |
" |
|
4128 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
|
4129 |
" |
|
4130 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
|
4131 |
end := aString indexOf:$- startingAt:1. |
|
4132 |
family := aString copyFrom:1 to:(end - 1). |
|
4133 |
start := end + 1. |
|
4134 |
end := aString indexOf:$- startingAt:start. |
|
4135 |
style := aString copyFrom:start to:(end - 1). |
|
4136 |
start := end + 1. |
|
4137 |
size := aString copyFrom:start. |
|
4138 |
size := (Number readFromString:size onError:[^false]). |
|
4139 |
aBlock value:family value:nil value:style value:size value:nil. |
|
4140 |
^ true. |
|
4141 |
]. |
|
4142 |
('*-[0-9]*' match:aString) ifTrue:[ |
|
4143 |
" |
|
4144 |
something like lucidasans-24 |
|
4145 |
" |
|
4146 |
end := aString indexOf:$- startingAt:1. |
|
4147 |
||
4148 |
family := aString copyFrom:1 to:(end - 1). |
|
4149 |
start := end + 1. |
|
4150 |
size := aString copyFrom:start. |
|
4151 |
size := (Number readFromString:size onError:[^false]). |
|
4152 |
aBlock value:family value:nil value:nil value:size value:nil. |
|
4153 |
^ true. |
|
4154 |
]. |
|
4155 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
|
4156 |
^ true. |
|
4157 |
]. |
|
4158 |
||
4159 |
end := aString indexOf:$- startingAt:2. |
|
4160 |
(end == 0) ifTrue:[^ false]. |
|
4161 |
origin := aString copyFrom:2 to:(end - 1). |
|
4162 |
||
4163 |
start := end + 1. |
|
4164 |
end := aString indexOf:$- startingAt:start. |
|
4165 |
(end == 0) ifTrue:[^ false]. |
|
4166 |
family := aString copyFrom:start to:(end - 1). |
|
4167 |
||
4168 |
start := end + 1. |
|
4169 |
end := aString indexOf:$- startingAt:start. |
|
4170 |
(end == 0) ifTrue:[^ false]. |
|
4171 |
face := aString copyFrom:start to:(end - 1). |
|
4172 |
||
4173 |
start := end + 1. |
|
4174 |
end := aString indexOf:$- startingAt:start. |
|
4175 |
(end == 0) ifTrue:[^ false]. |
|
4176 |
style := aString copyFrom:start to:(end - 1). |
|
4177 |
(style = 'o') ifTrue:[ |
|
4178 |
style := 'oblique' |
|
4179 |
] ifFalse:[ |
|
4180 |
(style = 'i') ifTrue:[ |
|
4181 |
style := 'italic' |
|
4182 |
] ifFalse:[ |
|
4183 |
(style = 'r') ifTrue:[ |
|
4184 |
style := 'roman' |
|
4185 |
] |
|
4186 |
] |
|
4187 |
]. |
|
4188 |
||
4189 |
start := end + 1. |
|
4190 |
end := aString indexOf:$- startingAt:start. |
|
4191 |
(end == 0) ifTrue:[^ false]. |
|
4192 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
4193 |
||
4194 |
start := end + 1. |
|
4195 |
end := aString indexOf:$- startingAt:start. |
|
4196 |
(end == 0) ifTrue:[^ false]. |
|
4197 |
skip := aString copyFrom:start to:(end - 1). |
|
4198 |
||
4199 |
start := end + 1. |
|
4200 |
end := aString indexOf:$- startingAt:start. |
|
4201 |
(end == 0) ifTrue:[^ false]. |
|
4202 |
fheight := aString copyFrom:start to:(end - 1). |
|
4203 |
||
4204 |
start := end + 1. |
|
4205 |
end := aString indexOf:$- startingAt:start. |
|
4206 |
(end == 0) ifTrue:[^ false]. |
|
4207 |
size := aString copyFrom:start to:(end - 1). |
|
4208 |
size := (Number readFromString:size) / 10. |
|
4209 |
||
4210 |
start := end + 1. |
|
4211 |
end := aString indexOf:$- startingAt:start. |
|
4212 |
(end == 0) ifTrue:[^ false]. |
|
4213 |
resX := aString copyFrom:start to:(end - 1). |
|
4214 |
||
4215 |
start := end + 1. |
|
4216 |
end := aString indexOf:$- startingAt:start. |
|
4217 |
(end == 0) ifTrue:[^ false]. |
|
4218 |
resY := aString copyFrom:start to:(end - 1). |
|
4219 |
||
4220 |
start := end + 1. |
|
4221 |
end := aString indexOf:$- startingAt:start. |
|
4222 |
(end == 0) ifTrue:[^ false]. |
|
4223 |
x1 := aString copyFrom:start to:(end - 1). |
|
4224 |
||
4225 |
start := end + 1. |
|
4226 |
end := aString indexOf:$- startingAt:start. |
|
4227 |
(end == 0) ifTrue:[^ false]. |
|
4228 |
x2 := aString copyFrom:start to:(end - 1). |
|
4229 |
||
4230 |
start := end + 1. |
|
4231 |
end := aString indexOf:$- startingAt:start. |
|
4232 |
(end == 0) ifTrue:[^ false]. |
|
4233 |
coding := aString copyFrom:start to:(end - 1). |
|
4234 |
||
4235 |
aBlock value:family value:face value:style value:size value:coding. |
|
4236 |
^ true |
|
4237 |
||
4238 |
"Modified: 27.9.1995 / 10:46:52 / stefan" |
|
4239 |
! |
|
4240 |
||
4241 |
descentOf:aFontId |
|
4242 |
"the normal descent" |
|
4243 |
||
4244 |
%{ /* NOCONTEXT */ |
|
4245 |
||
4246 |
XFontStruct *f; |
|
4247 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4248 |
if (ISCONNECTED) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4249 |
if (__isExternalAddress(aFontId)) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4250 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4251 |
RETURN ( __MKSMALLINT(f->descent) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4252 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4253 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4254 |
%}. |
295 | 4255 |
self primitiveFailed. |
4256 |
^ nil |
|
4257 |
! |
|
4258 |
||
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4259 |
encodingOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4260 |
"the fonts encoding - if the font does not provide that info, |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4261 |
return nil (and assume #ascii, which is a subset of #iso8859)." |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4262 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4263 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4264 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4265 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4266 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4267 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4268 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4269 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4270 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4271 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4272 |
registryAtom = XInternAtom(myDpy, "CHARSET_REGISTRY", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4273 |
encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4274 |
charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4275 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4276 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4277 |
if (ISCONNECTED) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4278 |
if (__isExternalAddress(aFontId)) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4279 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4280 |
f = _FontVal(aFontId); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4281 |
if (f) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4282 |
n = f->n_properties; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4283 |
prop = f->properties; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4284 |
if (prop) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4285 |
while (n--) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4286 |
cp = XGetAtomName(myDpy, prop->name); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4287 |
#ifdef SUPERDEBUG |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4288 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4289 |
#endif |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4290 |
if (prop->name == XA_FULL_NAME) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4291 |
cp = XGetAtomName(myDpy, prop->card32); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4292 |
if (cp) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4293 |
fullName = __MKSTRING(cp COMMA_CON); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4294 |
#ifdef SUPERDEBUG |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4295 |
printf(" FULL_NAME -> %s\n", cp); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4296 |
#endif |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4297 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4298 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4299 |
if (prop->name == fontAtom) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4300 |
cp = XGetAtomName(myDpy, prop->card32); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4301 |
if (cp) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4302 |
fontName = __MKSTRING(cp COMMA_CON); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4303 |
#ifdef SUPERDEBUG |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4304 |
printf(" FONT -> %s\n", cp); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4305 |
#endif |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4306 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4307 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4308 |
if (prop->name == encodingAtom) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4309 |
cp = XGetAtomName(myDpy, prop->card32); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4310 |
if (cp) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4311 |
encoding = __MKSTRING(cp COMMA_CON); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4312 |
#ifdef SUPERDEBUG |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4313 |
printf(" ENCODING -> %s\n", cp); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4314 |
#endif |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4315 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4316 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4317 |
if (prop->name == registryAtom) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4318 |
cp = XGetAtomName(myDpy, prop->card32); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4319 |
if (cp) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4320 |
registry = __MKSTRING(cp COMMA_CON); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4321 |
#ifdef SUPERDEBUG |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4322 |
printf(" REGISTRY -> %s\n", cp); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4323 |
#endif |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4324 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4325 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4326 |
if (prop->name == charSetCollAtom) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4327 |
cp = XGetAtomName(myDpy, prop->card32); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4328 |
if (cp) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4329 |
charSetCollections = __MKSTRING(cp COMMA_CON); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4330 |
#ifdef SUPERDEBUG |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4331 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4332 |
#endif |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4333 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4334 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4335 |
prop++; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4336 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4337 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4338 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4339 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4340 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4341 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4342 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4343 |
enc := registry asLowercase. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4344 |
"/ (encoding notNil and:[encoding notEmpty]) ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4345 |
"/ enc := enc , '-' , encoding asUppercase |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4346 |
"/ ] |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4347 |
] ifFalse:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4348 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4349 |
enc := encoding asLowercase |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4350 |
] ifFalse:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4351 |
(charSetCollections notNil and:[charSetCollections notEmpty]) ifTrue:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4352 |
charSetCollections := charSetCollections asUppercase asCollectionOfWords. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4353 |
(charSetCollections includes:'ISO8859-1') ifTrue:[ |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4354 |
enc := #iso8859 |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4355 |
] ifFalse:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4356 |
(charSetCollections includes:'ISO8859') ifTrue:[ |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4357 |
enc := #iso8859 |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4358 |
] ifFalse:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4359 |
(charSetCollections includes:'ASCII') ifTrue:[ |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4360 |
enc := #ascii |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4361 |
] ifFalse:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4362 |
(charSetCollections includes:'ADOBE-STANDARD') ifTrue:[ |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4363 |
enc := #iso8859 |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4364 |
] |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4365 |
] |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4366 |
] |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4367 |
] |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4368 |
] |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4369 |
] |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4370 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4371 |
^ enc |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4372 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4373 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4374 |
flushListOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4375 |
"flush the cached list of all available fonts on this display. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4376 |
Required if new fonts have been added on the display server." |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4377 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4378 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4379 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4380 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4381 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4382 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4383 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4384 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4385 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4386 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4387 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4388 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4389 |
fullNameOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4390 |
"the fonts fullName - this is very device specific and should only be |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4391 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4392 |
If the display/font do not provide that info, return nil." |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4393 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4394 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4395 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4396 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4397 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4398 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4399 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4400 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4401 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4402 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4403 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4404 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4405 |
if (ISCONNECTED) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4406 |
if (__isExternalAddress(aFontId)) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4407 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4408 |
f = _FontVal(aFontId); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4409 |
if (f) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4410 |
n = f->n_properties; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4411 |
prop = f->properties; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4412 |
if (prop) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4413 |
while (n--) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4414 |
cp = XGetAtomName(myDpy, prop->name); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4415 |
#ifdef SUPERDEBUG |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4416 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4417 |
#endif |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4418 |
if (prop->name == XA_FULL_NAME) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4419 |
cp = XGetAtomName(myDpy, prop->card32); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4420 |
if (cp) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4421 |
fullName = __MKSTRING(cp COMMA_CON); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4422 |
#ifdef SUPERDEBUG |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4423 |
printf(" FULL_NAME -> %s\n", cp); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4424 |
#endif |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4425 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4426 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4427 |
if (prop->name == fontAtom) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4428 |
cp = XGetAtomName(myDpy, prop->card32); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4429 |
if (cp) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4430 |
fontName = __MKSTRING(cp COMMA_CON); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4431 |
#ifdef SUPERDEBUG |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4432 |
printf(" FONT -> %s\n", cp); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4433 |
#endif |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4434 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4435 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4436 |
prop++; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4437 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4438 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4439 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4440 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4441 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4442 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4443 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4444 |
^ fullName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4445 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4446 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4447 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4448 |
|
295 | 4449 |
getAvailableFontsMatching:pattern |
4450 |
"return an Array filled with font names matching aPattern" |
|
4451 |
||
4452 |
%{ /* UNLIMITEDSTACK */ |
|
4453 |
||
4454 |
int nnames = 1500; |
|
4455 |
int available = nnames + 1; |
|
4456 |
char **fonts; |
|
4457 |
OBJ arr, str; |
|
4458 |
int i; |
|
4459 |
||
4460 |
if (ISCONNECTED) { |
|
4461 |
if (__isString(pattern)) { |
|
4462 |
for (;;) { |
|
4463 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
4464 |
if ((fonts == NULL) || (available < nnames)) break; |
|
4465 |
XFreeFontNames(fonts); |
|
4466 |
nnames = available * 2; |
|
4467 |
} |
|
4468 |
if (fonts == NULL) { |
|
4469 |
RETURN ( nil ); |
|
4470 |
} |
|
4471 |
/* |
|
4472 |
* now, that we know the number of font names, |
|
4473 |
* create the array ... |
|
4474 |
*/ |
|
4475 |
arr = __ARRAY_NEW_INT(available); |
|
4476 |
if (! arr) { |
|
4477 |
RETURN (nil); |
|
4478 |
} |
|
4479 |
/* |
|
4480 |
* ... and fill it |
|
4481 |
*/ |
|
4482 |
for (i=0; i<available; i++) { |
|
350 | 4483 |
__PROTECT__(arr); |
295 | 4484 |
str = __MKSTRING(fonts[i] COMMA_CON); |
350 | 4485 |
__UNPROTECT__(arr); |
295 | 4486 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
4487 |
} |
|
4488 |
RETURN (arr); |
|
4489 |
} |
|
4490 |
} |
|
4491 |
%}. |
|
4492 |
^ nil |
|
4493 |
! |
|
4494 |
||
4495 |
getDefaultFont |
|
4496 |
"return a default font id - used when class Font cannot |
|
4497 |
find anything usable" |
|
4498 |
||
4499 |
^ self createFontFor:'fixed' |
|
4500 |
! |
|
4501 |
||
4502 |
getFontWithFamily:familyString face:faceString |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4503 |
style:styleString size:sizeArg encoding:encodingSym |
295 | 4504 |
|
4505 |
"try to get the specified font, if not available, try next smaller |
|
4506 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
4507 |
as family and the other parameters as nil. For example, the cursor font |
|
4508 |
can be aquired that way." |
|
4509 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4510 |
|theName theId xlatedStyle id | |
295 | 4511 |
|
4512 |
"special: if face is nil, allow access to X-fonts" |
|
4513 |
faceString isNil ifTrue:[ |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4514 |
sizeArg notNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4515 |
theName := familyString , '-' , sizeArg printString |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4516 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4517 |
theName := familyString |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4518 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4519 |
theName isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4520 |
" |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4521 |
mhmh - fall back to the default font |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4522 |
" |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4523 |
theName := 'fixed' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4524 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4525 |
theId := self createFontFor:theName. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4526 |
theId isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4527 |
theId := self getDefaultFont |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4528 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4529 |
^ theId |
295 | 4530 |
]. |
4531 |
||
4532 |
xlatedStyle := styleString. |
|
4533 |
xlatedStyle notNil ifTrue:[ |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4534 |
xlatedStyle := xlatedStyle first asString |
295 | 4535 |
]. |
4536 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4537 |
id := self |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4538 |
getFontWithFoundry:'*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4539 |
family:familyString asLowercase |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4540 |
weight:faceString |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4541 |
slant:xlatedStyle |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4542 |
spacing:'normal' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4543 |
pixelSize:nil |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4544 |
size:sizeArg |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4545 |
registry:encodingSym |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4546 |
encoding:'*'. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4547 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4548 |
id isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4549 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4550 |
"/ too stupid: encodings come in both cases |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4551 |
"/ and X does not ignore case |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4552 |
"/ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4553 |
id := self |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4554 |
getFontWithFoundry:'*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4555 |
family:familyString asLowercase |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4556 |
weight:faceString |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4557 |
slant:xlatedStyle |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4558 |
spacing:'normal' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4559 |
pixelSize:nil |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4560 |
size:sizeArg |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4561 |
registry:encodingSym asUppercase |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4562 |
encoding:'*'. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4563 |
id isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4564 |
id := self |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4565 |
getFontWithFoundry:'*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4566 |
family:familyString asLowercase |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4567 |
weight:faceString |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4568 |
slant:xlatedStyle |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4569 |
spacing:'normal' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4570 |
pixelSize:nil |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4571 |
size:sizeArg |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4572 |
registry:encodingSym asLowercase |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4573 |
encoding:'*'. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4574 |
] |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4575 |
] |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4576 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4577 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4578 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4579 |
"Modified: 24.2.1996 / 22:37:24 / cg" |
295 | 4580 |
! |
4581 |
||
4582 |
getFontWithFoundry:foundry family:family weight:weight |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4583 |
slant:slant spacing:spc pixelSize:pSize size:size |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4584 |
registry:registry encoding:encoding |
295 | 4585 |
|
4586 |
"get the specified font, if not available, return nil. |
|
4587 |
This is the new font creation method - all others will be changed to |
|
4588 |
use this entry. |
|
4589 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
4590 |
||
4591 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
4592 |
family: 'helvetica' 'courier' 'times' ... |
|
4593 |
weight: 'bold' 'medium' 'demi' ... |
|
4594 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
4595 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
4596 |
pixelSize: 16,18 ... usually left empty |
|
4597 |
size: size in point (1/72th of an inch) |
|
4598 |
registry: iso8859, sgi ... '*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4599 |
encoding: vendor specific encoding (usually '*') |
295 | 4600 |
" |
4601 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4602 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4603 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4604 |
pSizeMatch registryMatch encodingMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4605 |
id| |
295 | 4606 |
|
4607 |
"this works only on 'Release >= 3' - X-servers" |
|
4608 |
"name is: |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4609 |
-foundry-family -weight -slant- |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4610 |
sony helvetica bold r |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4611 |
adobe courier medium i |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4612 |
msic fixed o |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4613 |
... ... |
295 | 4614 |
" |
4615 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4616 |
size isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4617 |
sizeMatch := '*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4618 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4619 |
sizeMatch := size printString , '0' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4620 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4621 |
foundry isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4622 |
foundryMatch := '*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4623 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4624 |
foundryMatch := foundry |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4625 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4626 |
family isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4627 |
familyMatch := '*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4628 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4629 |
familyMatch := family |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4630 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4631 |
weight isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4632 |
weightMatch := '*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4633 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4634 |
weightMatch := weight |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4635 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4636 |
slant isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4637 |
slantMatch := '*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4638 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4639 |
slantMatch := slant |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4640 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4641 |
spc isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4642 |
spcMatch := '*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4643 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4644 |
spcMatch := spc |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4645 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4646 |
pSize isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4647 |
pSizeMatch := '*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4648 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4649 |
pSizeMatch := pSize printString |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4650 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4651 |
registry isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4652 |
registryMatch := '*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4653 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4654 |
registryMatch := registry |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4655 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4656 |
encoding isNil ifTrue:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4657 |
encodingMatch := '*' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4658 |
] ifFalse:[ |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4659 |
encodingMatch := encoding |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4660 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4661 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4662 |
theName := ('-' , foundryMatch, |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4663 |
'-' , familyMatch, |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4664 |
'-' , weightMatch , |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4665 |
'-' , slantMatch , |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4666 |
'-' , spcMatch , |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4667 |
'-*' , |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4668 |
'-' , pSizeMatch , |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4669 |
'-' , sizeMatch , |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4670 |
'-*-*-*-*' , |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4671 |
'-' , registryMatch , |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4672 |
'-' , encodingMatch). |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4673 |
|
295 | 4674 |
"/ Transcript showCr:theName; endEntry. |
4675 |
||
4676 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4677 |
|
295 | 4678 |
|
4679 |
" |
|
4680 |
Display getFontWithFoundry:'*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4681 |
family:'courier' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4682 |
weight:'medium' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4683 |
slant:'r' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4684 |
spacing:nil |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4685 |
pixelSize:nil |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4686 |
size:13 |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4687 |
registry:'iso8859' |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4688 |
encoding:'*' |
295 | 4689 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4690 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4691 |
"Modified: 24.2.1996 / 22:33:29 / cg" |
295 | 4692 |
! |
4693 |
||
4694 |
listOfAvailableFonts |
|
4695 |
"return a list with all available fonts on this display. |
|
4696 |
Since this takes a long time, keep the result of the query for the |
|
4697 |
next time. The elements of the returned collection are instances of |
|
4698 |
FontDescription." |
|
4699 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
4700 |
|"stream aName fntDescr" names| |
295 | 4701 |
|
4702 |
listOfXFonts isNil ifTrue:[ |
|
4703 |
"/ |
|
4704 |
"/ old code; using a pipe to xlsfonts |
|
4705 |
"/ |
|
4706 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
4707 |
"/ stream isNil ifTrue:[^ nil]. |
|
4708 |
"/ listOfXFonts := OrderedCollection new. |
|
4709 |
"/ [stream atEnd] whileFalse:[ |
|
4710 |
"/ aName := stream nextLine. |
|
4711 |
"/ aName notNil ifTrue:[ |
|
4712 |
"/ self decomposeXFontName:aName into: |
|
4713 |
"/ [:family :face :style :size :coding | |
|
4714 |
"/ family notNil ifTrue:[ |
|
4715 |
"/ fntDescr := FontDescription |
|
4716 |
"/ family:family |
|
4717 |
"/ face:face |
|
4718 |
"/ style:style |
|
4719 |
"/ size:size |
|
4720 |
"/ encoding:coding. |
|
4721 |
"/ listOfXFonts add:fntDescr |
|
4722 |
"/ ] |
|
4723 |
"/ ] |
|
4724 |
"/ ] |
|
4725 |
"/ ]. |
|
4726 |
"/ stream close. |
|
4727 |
"/ "if xlsfont is broken ... (hey sco)" |
|
4728 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
4729 |
"/ listOfXFonts := nil |
|
4730 |
"/ ] ifFalse:[ |
|
4731 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
4732 |
"/ ]. |
|
4733 |
||
4734 |
"/ |
|
4735 |
"/ new code: |
|
4736 |
"/ use new primitive to get font names; |
|
4737 |
"/ this is much faster, and also works on systems where |
|
4738 |
"/ a) xlsfonts is broken (sco) |
|
4739 |
"/ b) xlsfonts is not available (aix) |
|
4740 |
"/ |
|
4741 |
names := self getAvailableFontsMatching:'*'. |
|
4742 |
names isNil ifTrue:[ |
|
4743 |
"no names returned ..." |
|
4744 |
^ nil |
|
4745 |
]. |
|
4746 |
listOfXFonts := names collect:[:aName | |
|
4747 |
|fntDescr| |
|
4748 |
||
4749 |
(self decomposeXFontName:aName into: |
|
4750 |
[:family :face :style :size :coding | |
|
4751 |
family notNil ifTrue:[ |
|
4752 |
fntDescr := FontDescription |
|
4753 |
family:family |
|
4754 |
face:face |
|
4755 |
style:style |
|
4756 |
size:size |
|
4757 |
encoding:coding. |
|
4758 |
] ifFalse:[ |
|
4759 |
fntDescr := FontDescription |
|
4760 |
name:aName |
|
4761 |
] |
|
4762 |
] |
|
4763 |
) ifFalse:[ |
|
4764 |
fntDescr := FontDescription name:aName. |
|
4765 |
]. |
|
4766 |
fntDescr |
|
4767 |
]. |
|
4768 |
||
4769 |
]. |
|
4770 |
^ listOfXFonts |
|
4771 |
||
4772 |
" |
|
4773 |
Display listOfAvailableFonts |
|
4774 |
" |
|
4775 |
||
4776 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
|
4777 |
! |
|
4778 |
||
4779 |
maxAscentOf:aFontId |
|
4780 |
"the max ascent" |
|
4781 |
||
4782 |
%{ /* NOCONTEXT */ |
|
4783 |
||
4784 |
XFontStruct *f; |
|
4785 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4786 |
if (ISCONNECTED) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4787 |
if (__isExternalAddress(aFontId)) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4788 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4789 |
RETURN ( __MKSMALLINT(f->max_bounds.ascent) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4790 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4791 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4792 |
%}. |
295 | 4793 |
self primitiveFailed. |
4794 |
^ nil |
|
4795 |
! |
|
4796 |
||
4797 |
maxDescentOf:aFontId |
|
4798 |
"the max descent" |
|
4799 |
||
4800 |
%{ /* NOCONTEXT */ |
|
4801 |
||
4802 |
XFontStruct *f; |
|
4803 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4804 |
if (ISCONNECTED) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4805 |
if (__isExternalAddress(aFontId)) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4806 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4807 |
RETURN ( __MKSMALLINT(f->max_bounds.descent) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4808 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4809 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4810 |
%}. |
295 | 4811 |
self primitiveFailed. |
4812 |
^ nil |
|
4813 |
! |
|
4814 |
||
4815 |
maxWidthOfFont:aFontId |
|
4816 |
"the width of the widest character" |
|
4817 |
||
4818 |
%{ /* NOCONTEXT */ |
|
4819 |
||
4820 |
XFontStruct *f; |
|
4821 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4822 |
if (ISCONNECTED) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4823 |
if (__isExternalAddress(aFontId)) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4824 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4825 |
RETURN ( __MKSMALLINT(f->max_bounds.width) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4826 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4827 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4828 |
%}. |
295 | 4829 |
self primitiveFailed. |
4830 |
^ nil |
|
4831 |
! |
|
4832 |
||
4833 |
minWidthOfFont:aFontId |
|
4834 |
||
4835 |
%{ /* NOCONTEXT */ |
|
4836 |
||
4837 |
XFontStruct *f; |
|
4838 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4839 |
if (ISCONNECTED) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4840 |
if (__isExternalAddress(aFontId)) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4841 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4842 |
RETURN ( __MKSMALLINT(f->min_bounds.width) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4843 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4844 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4845 |
%}. |
295 | 4846 |
self primitiveFailed. |
4847 |
^ nil |
|
4848 |
! |
|
4849 |
||
4850 |
releaseFont:aFontId |
|
4851 |
||
4852 |
%{ /* NOCONTEXT */ |
|
4853 |
||
4854 |
XFontStruct *f; |
|
4855 |
||
4856 |
if (ISCONNECTED) { |
|
4857 |
if (__isExternalAddress(aFontId)) { |
|
4858 |
f = _FontVal(aFontId); |
|
4859 |
BEGIN_INTERRUPTSBLOCKED |
|
4860 |
XFreeFont(myDpy, f); |
|
4861 |
END_INTERRUPTSBLOCKED |
|
4862 |
RETURN ( self ); |
|
4863 |
} |
|
4864 |
} |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4865 |
%}. |
295 | 4866 |
self primitiveFailed |
4867 |
! |
|
4868 |
||
466 | 4869 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 4870 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
4871 |
on this display. |
|
4872 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
4873 |
||
4874 |
|sizes| |
|
4875 |
||
466 | 4876 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 4877 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
466 | 4878 |
"special: in X11R5 and above, size 0 means: |
4879 |
there are scaled versions in all sizes available" |
|
4880 |
||
4881 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
|
295 | 4882 |
]. |
4883 |
^ sizes |
|
4884 |
||
4885 |
" |
|
4886 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
4887 |
" |
|
466 | 4888 |
|
4889 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 4890 |
! |
4891 |
||
4892 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
|
4893 |
||
4894 |
%{ /* NOCONTEXT */ |
|
4895 |
||
4896 |
XFontStruct *f; |
|
4897 |
char *cp; |
|
4898 |
int len, n, i1, i2; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4899 |
OBJ cls; |
295 | 4900 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4901 |
if (ISCONNECTED) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4902 |
if (__bothSmallInteger(index1, index2) |
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4903 |
&& __isExternalAddress(aFontId) |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4904 |
&& __isNonNilObject(aString)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4905 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4906 |
i1 = _intVal(index1) - 1; |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4907 |
i2 = _intVal(index2) - 1; |
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4908 |
cls = _qClass(aString); |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4909 |
|
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4910 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4911 |
cp = (char *) _stringVal(aString); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4912 |
n = _stringSize(aString); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4913 |
if ((i1 >= 0) && (i2 >= i1) && (i2 < n)) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4914 |
cp += i1; |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4915 |
BEGIN_INTERRUPTSBLOCKED |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4916 |
len = XTextWidth(f, cp, i2 - i1 + 1); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4917 |
END_INTERRUPTSBLOCKED |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4918 |
RETURN ( __MKSMALLINT(len) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4919 |
} |
295 | 4920 |
} |
4921 |
#ifdef TWOBYTESTRINGS |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4922 |
if (__isWords(aString)) { |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4923 |
int nInstBytes; |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4924 |
|
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4925 |
nInstBytes = __OBJS2BYTES__(_intVal(_ClassInstPtr(cls)->c_ninstvars)); |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4926 |
|
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4927 |
cp = (char *) _stringVal(aString) + nInstBytes; |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4928 |
n = (_byteArraySize(aString) - nInstBytes) / 2; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4929 |
if ((i1 >= 0) && (i2 >= i1) && (i2 < n)) { |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4930 |
cp += (i1 * 2); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4931 |
BEGIN_INTERRUPTSBLOCKED |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4932 |
len = XTextWidth16(f, (XChar2b *)cp, i2 - i1 + 1); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4933 |
END_INTERRUPTSBLOCKED |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4934 |
RETURN ( __MKSMALLINT(len) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4935 |
} |
295 | 4936 |
} |
4937 |
#endif |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4938 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4939 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4940 |
%}. |
295 | 4941 |
self primitiveFailed. |
4942 |
^ nil |
|
4943 |
! |
|
4944 |
||
4945 |
widthOf:aString inFont:aFontId |
|
4946 |
||
4947 |
%{ /* NOCONTEXT */ |
|
4948 |
||
4949 |
XFontStruct *f; |
|
4950 |
char *cp; |
|
4951 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4952 |
OBJ cls; |
295 | 4953 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4954 |
if (ISCONNECTED) { |
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4955 |
if (__isExternalAddress(aFontId) |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4956 |
&& __isNonNilObject(aString)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4957 |
f = _FontVal(aFontId); |
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4958 |
cls = _qClass(aString); |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4959 |
|
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4960 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4961 |
n = _stringSize(aString); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4962 |
cp = (char *)_stringVal(aString); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4963 |
BEGIN_INTERRUPTSBLOCKED |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4964 |
len = XTextWidth(f, cp, n); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4965 |
END_INTERRUPTSBLOCKED |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4966 |
RETURN ( __MKSMALLINT(len) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4967 |
} |
295 | 4968 |
#ifdef TWOBYTESTRINGS |
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4969 |
if (__isWords(aString)) { |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4970 |
int nInstBytes; |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4971 |
|
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4972 |
nInstBytes = __OBJS2BYTES__(_intVal(_ClassInstPtr(cls)->c_ninstvars)); |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4973 |
|
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4974 |
n = (_byteArraySize(aString) - nInstBytes) / 2; |
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4975 |
cp = (char *) _stringVal(aString) + nInstBytes; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4976 |
BEGIN_INTERRUPTSBLOCKED |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4977 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4978 |
END_INTERRUPTSBLOCKED |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4979 |
RETURN ( __MKSMALLINT(len) ); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4980 |
} |
295 | 4981 |
#endif |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4982 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4983 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4984 |
%}. |
295 | 4985 |
self primitiveFailed. |
4986 |
^ nil |
|
4987 |
! ! |
|
4988 |
||
4989 |
!XWorkstation methodsFor:'grabbing '! |
|
4990 |
||
4991 |
allowEvents:mode |
|
4992 |
%{ /* NOCONTEXT */ |
|
4993 |
||
4994 |
int _mode, ok = 1; |
|
4995 |
||
4996 |
if (mode == @symbol(asyncPointer)) |
|
4997 |
_mode = AsyncPointer; |
|
4998 |
else if (mode == @symbol(syncPointer)) |
|
4999 |
_mode = SyncPointer; |
|
5000 |
else if (mode == @symbol(asyncKeyboard)) |
|
5001 |
_mode = AsyncKeyboard; |
|
5002 |
else if (mode == @symbol(syncKeyboard)) |
|
5003 |
_mode = SyncKeyboard; |
|
5004 |
else if (mode == @symbol(syncBoth)) |
|
5005 |
_mode = SyncBoth; |
|
5006 |
else if (mode == @symbol(asyncBoth)) |
|
5007 |
_mode = AsyncBoth; |
|
5008 |
else if (mode == @symbol(replayPointer)) |
|
5009 |
_mode = ReplayPointer; |
|
5010 |
else if (mode == @symbol(replayKeyboard)) |
|
5011 |
_mode = ReplayKeyboard; |
|
5012 |
else |
|
5013 |
ok = 0; |
|
5014 |
||
5015 |
if (ok) { |
|
5016 |
BEGIN_INTERRUPTSBLOCKED |
|
5017 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
5018 |
END_INTERRUPTSBLOCKED |
|
5019 |
RETURN (self); |
|
5020 |
} |
|
5021 |
%} |
|
5022 |
. |
|
5023 |
self primitiveFailed |
|
5024 |
! |
|
5025 |
||
5026 |
grabKeyboardIn:aWindowId |
|
5027 |
"grab the keyboard" |
|
5028 |
||
5029 |
%{ /* NOCONTEXT */ |
|
5030 |
int result, ok; |
|
5031 |
||
5032 |
if (__isExternalAddress(aWindowId)) { |
|
5033 |
BEGIN_INTERRUPTSBLOCKED |
|
5034 |
result = XGrabKeyboard(myDpy, |
|
5035 |
_WindowVal(aWindowId), |
|
5036 |
True /* False */, |
|
5037 |
GrabModeAsync, |
|
5038 |
GrabModeAsync, |
|
5039 |
CurrentTime); |
|
5040 |
END_INTERRUPTSBLOCKED |
|
5041 |
ok = 0; |
|
5042 |
switch(result) { |
|
5043 |
case AlreadyGrabbed: |
|
5044 |
printf("XWORKSTAT: grab keyboard: AlreadyGrabbed\n"); |
|
5045 |
break; |
|
5046 |
case GrabNotViewable: |
|
5047 |
printf("XWORKSTAT: grab keyboard: GrabNotViewable\n"); |
|
5048 |
break; |
|
5049 |
case GrabInvalidTime: |
|
5050 |
printf("XWORKSTAT: grab keyboard: InvalidTime\n"); |
|
5051 |
break; |
|
5052 |
case GrabFrozen: |
|
5053 |
printf("XWORKSTAT: grab keyboard: Frozen\n"); |
|
5054 |
break; |
|
5055 |
default: |
|
5056 |
ok = 1; |
|
5057 |
break; |
|
5058 |
} |
|
5059 |
if (! ok) { |
|
5060 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5061 |
RETURN (false); |
|
5062 |
} |
|
5063 |
||
5064 |
RETURN ( true ); |
|
5065 |
} |
|
5066 |
%} |
|
5067 |
. |
|
5068 |
self primitiveFailed |
|
5069 |
! |
|
5070 |
||
5071 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
|
5072 |
"grap the pointer - return true if ok" |
|
5073 |
||
5074 |
%{ /* NOCONTEXT */ |
|
5075 |
||
5076 |
int result, ok; |
|
5077 |
Window confineWin; |
|
5078 |
Cursor curs; |
|
5079 |
int pointer_mode, keyboard_mode; |
|
5080 |
||
5081 |
if (__isExternalAddress(aWindowId)) { |
|
5082 |
if (__isExternalAddress(confineId)) |
|
5083 |
confineWin = _WindowVal(confineId); |
|
5084 |
else |
|
5085 |
confineWin = (Window) None; |
|
5086 |
||
5087 |
if (__isExternalAddress(aCursorId)) |
|
5088 |
curs = _CursorVal(aCursorId); |
|
5089 |
else |
|
5090 |
curs = (Cursor) None; |
|
5091 |
||
5092 |
if (pMode == @symbol(sync)) |
|
5093 |
pointer_mode = GrabModeSync; |
|
5094 |
else |
|
5095 |
pointer_mode = GrabModeAsync; |
|
5096 |
||
5097 |
if (kMode == @symbol(sync)) |
|
5098 |
keyboard_mode = GrabModeSync; |
|
5099 |
else |
|
5100 |
keyboard_mode = GrabModeAsync; |
|
5101 |
||
5102 |
BEGIN_INTERRUPTSBLOCKED |
|
5103 |
result = XGrabPointer(myDpy, |
|
5104 |
_WindowVal(aWindowId), |
|
5105 |
False, |
|
5106 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
5107 |
pointer_mode, keyboard_mode, |
|
5108 |
confineWin, |
|
5109 |
curs, |
|
5110 |
CurrentTime); |
|
5111 |
END_INTERRUPTSBLOCKED |
|
5112 |
||
5113 |
ok = 0; |
|
5114 |
switch (result) { |
|
5115 |
case AlreadyGrabbed: |
|
5116 |
printf("XWORKSTAT: grab pointer: AlreadyGrabbed\n"); |
|
5117 |
break; |
|
5118 |
case GrabNotViewable: |
|
5119 |
printf("XWORKSTAT: grab pointer: GrabNotViewable\n"); |
|
5120 |
break; |
|
5121 |
case GrabInvalidTime: |
|
5122 |
printf("XWORKSTAT: grab pointer: InvalidTime\n"); |
|
5123 |
break; |
|
5124 |
case GrabFrozen: |
|
5125 |
printf("XWORKSTAT: grab pointer: Frozen\n"); |
|
5126 |
break; |
|
5127 |
default: |
|
5128 |
ok = 1; |
|
5129 |
break; |
|
5130 |
} |
|
5131 |
||
5132 |
if (! ok) { |
|
5133 |
XUngrabPointer(myDpy, CurrentTime); |
|
5134 |
RETURN (false); |
|
5135 |
} |
|
5136 |
RETURN ( true ); |
|
5137 |
} |
|
5138 |
%} |
|
5139 |
. |
|
5140 |
self primitiveFailed |
|
5141 |
! |
|
5142 |
||
5143 |
ungrabKeyboard |
|
5144 |
"release the keyboard" |
|
5145 |
||
5146 |
%{ /* NOCONTEXT */ |
|
5147 |
||
5148 |
if (ISCONNECTED) { |
|
5149 |
BEGIN_INTERRUPTSBLOCKED |
|
5150 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5151 |
XSync(myDpy, 0); |
|
5152 |
END_INTERRUPTSBLOCKED |
|
5153 |
} |
|
5154 |
%}. |
|
5155 |
activeKeyboardGrab := nil |
|
5156 |
! |
|
5157 |
||
5158 |
ungrabPointer |
|
5159 |
"release the pointer" |
|
5160 |
||
5161 |
%{ /* NOCONTEXT */ |
|
5162 |
||
5163 |
if (ISCONNECTED) { |
|
5164 |
BEGIN_INTERRUPTSBLOCKED |
|
5165 |
XUngrabPointer(myDpy, CurrentTime); |
|
5166 |
XSync(myDpy, 0); |
|
5167 |
END_INTERRUPTSBLOCKED |
|
5168 |
} |
|
5169 |
%}. |
|
5170 |
activePointerGrab := nil |
|
5171 |
! ! |
|
5172 |
||
5173 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
5174 |
||
5175 |
noClipIn:aGCId |
|
5176 |
"disable clipping rectangle" |
|
5177 |
||
5178 |
%{ /* NOCONTEXT */ |
|
5179 |
||
5180 |
XGCValues gcv; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5181 |
GC gc; |
295 | 5182 |
|
5183 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5184 |
gc = _GCVal(aGCId); |
295 | 5185 |
gcv.clip_mask = None; |
5186 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
5187 |
RETURN ( self ); |
|
5188 |
} |
|
5189 |
%}. |
|
5190 |
self primitiveFailed |
|
5191 |
! |
|
5192 |
||
5193 |
setBackground:bgColorIndex in:aGCId |
|
5194 |
"set background color to be drawn with" |
|
5195 |
||
5196 |
%{ /* NOCONTEXT */ |
|
5197 |
||
5198 |
if (__isExternalAddress(aGCId) |
|
5199 |
&& __isSmallInteger(bgColorIndex)) { |
|
5200 |
XSetBackground(myDpy, _GCVal(aGCId), _intVal(bgColorIndex)); |
|
5201 |
RETURN ( self ); |
|
5202 |
} |
|
5203 |
%}. |
|
5204 |
self primitiveFailed |
|
5205 |
! |
|
5206 |
||
5207 |
setBitmapMask:aBitmapId in:aGCId |
|
5208 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
|
5209 |
||
5210 |
%{ /* NOCONTEXT */ |
|
5211 |
||
5212 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5213 |
GC gc; |
295 | 5214 |
Pixmap bitmap; |
5215 |
||
5216 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5217 |
gc = _GCVal(aGCId); |
295 | 5218 |
if (__isExternalAddress(aBitmapId)) { |
5219 |
bitmap = _PixmapVal(aBitmapId); |
|
5220 |
XSetStipple(dpy, gc, bitmap); |
|
5221 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5222 |
RETURN ( self ); |
|
5223 |
} |
|
5224 |
if (aBitmapId == nil) { |
|
5225 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5226 |
RETURN ( self ); |
|
5227 |
} |
|
5228 |
} |
|
5229 |
%}. |
|
5230 |
self primitiveFailed |
|
5231 |
! |
|
5232 |
||
5233 |
setClipByChildren:aBool in:aGCId |
|
5234 |
"enable/disable drawing into child views" |
|
5235 |
||
5236 |
%{ /* NOCONTEXT */ |
|
5237 |
||
5238 |
XGCValues gcv; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5239 |
GC gc; |
295 | 5240 |
|
5241 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5242 |
gc = _GCVal(aGCId); |
295 | 5243 |
if (aBool == true) |
5244 |
gcv.subwindow_mode = ClipByChildren; |
|
5245 |
else |
|
5246 |
gcv.subwindow_mode = IncludeInferiors; |
|
5247 |
||
5248 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
5249 |
RETURN ( self ); |
|
5250 |
} |
|
5251 |
%}. |
|
5252 |
self primitiveFailed |
|
5253 |
! |
|
5254 |
||
5255 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
|
5256 |
"clip to a rectangle" |
|
5257 |
||
5258 |
%{ /* NOCONTEXT */ |
|
5259 |
||
5260 |
XRectangle r; |
|
5261 |
||
5262 |
if (__isExternalAddress(aGCId) |
|
5263 |
&& __bothSmallInteger(clipX, clipY) |
|
5264 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
5265 |
r.x = _intVal(clipX); |
|
5266 |
r.y = _intVal(clipY); |
|
5267 |
r.width = _intVal(clipWidth); |
|
5268 |
r.height = _intVal(clipHeight); |
|
5269 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
|
5270 |
RETURN ( self ); |
|
5271 |
} |
|
5272 |
%}. |
|
5273 |
self primitiveFailed |
|
5274 |
! |
|
5275 |
||
5276 |
setFont:aFontId in:aGCId |
|
5277 |
"set font to be drawn in" |
|
5278 |
||
5279 |
%{ /* NOCONTEXT */ |
|
5280 |
||
5281 |
XFontStruct *f; |
|
5282 |
||
5283 |
if (__isExternalAddress(aFontId) |
|
5284 |
&& __isExternalAddress(aGCId)) { |
|
5285 |
f = (XFontStruct *) _FontVal(aFontId); |
|
5286 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
5287 |
RETURN ( self ); |
|
5288 |
} |
|
5289 |
%}. |
|
5290 |
" |
|
5291 |
aGCId and/or aFontId are invalid |
|
5292 |
" |
|
5293 |
self primitiveFailed |
|
5294 |
! |
|
5295 |
||
5296 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
|
5297 |
"set foreground and background colors to be drawn with" |
|
5298 |
||
5299 |
%{ /* NOCONTEXT */ |
|
5300 |
||
5301 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5302 |
GC gc; |
295 | 5303 |
|
5304 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
5305 |
&& __isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5306 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5307 |
|
295 | 5308 |
XSetForeground(dpy, gc, _intVal(fgColorIndex)); |
5309 |
XSetBackground(dpy, gc, _intVal(bgColorIndex)); |
|
5310 |
RETURN ( self ); |
|
5311 |
} |
|
5312 |
%}. |
|
5313 |
self primitiveFailed |
|
5314 |
! |
|
5315 |
||
5316 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId |
|
5317 |
"set foreground and background colors to be drawn with using mask or |
|
5318 |
solid (if aBitmapId is nil)" |
|
5319 |
||
5320 |
%{ /* NOCONTEXT */ |
|
5321 |
||
5322 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5323 |
GC gc; |
295 | 5324 |
|
5325 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5326 |
gc = _GCVal(aGCId); |
295 | 5327 |
if (__isSmallInteger(fgColor)) |
5328 |
XSetForeground(dpy, gc, _intVal(fgColor)); |
|
5329 |
if (__isSmallInteger(bgColor)) |
|
5330 |
XSetBackground(dpy, gc, _intVal(bgColor)); |
|
5331 |
||
5332 |
if (__isExternalAddress(aBitmapId)) { |
|
5333 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5334 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5335 |
RETURN ( self ); |
|
5336 |
} |
|
5337 |
if (aBitmapId == nil) { |
|
5338 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5339 |
RETURN ( self ); |
|
5340 |
} |
|
5341 |
} |
|
5342 |
%}. |
|
5343 |
self primitiveFailed |
|
5344 |
! |
|
5345 |
||
5346 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId |
|
5347 |
"set foreground and background colors to be drawn with using mask or |
|
5348 |
solid (if aBitmapId is nil); also set lineWidth" |
|
5349 |
||
5350 |
%{ /* NOCONTEXT */ |
|
5351 |
||
5352 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5353 |
GC gc; |
295 | 5354 |
|
5355 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5356 |
gc = _GCVal(aGCId); |
295 | 5357 |
if (__isSmallInteger(lw)) { |
5358 |
XSetLineAttributes(dpy, gc, _intVal(lw), |
|
5359 |
LineSolid, CapNotLast, JoinMiter); |
|
5360 |
} |
|
5361 |
if (__isSmallInteger(fgColor)) |
|
5362 |
XSetForeground(dpy, gc, _intVal(fgColor)); |
|
5363 |
if (__isSmallInteger(bgColor)) |
|
5364 |
XSetBackground(dpy, gc, _intVal(bgColor)); |
|
5365 |
||
5366 |
if (__isExternalAddress(aBitmapId)) { |
|
5367 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5368 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5369 |
RETURN ( self ); |
|
5370 |
} |
|
5371 |
if (aBitmapId == nil) { |
|
5372 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5373 |
RETURN ( self ); |
|
5374 |
} |
|
5375 |
} |
|
5376 |
%}. |
|
5377 |
self primitiveFailed |
|
5378 |
! |
|
5379 |
||
5380 |
setForeground:fgColorIndex in:aGCId |
|
5381 |
"set foreground color to be drawn with" |
|
5382 |
||
5383 |
%{ /* NOCONTEXT */ |
|
5384 |
||
5385 |
if (__isExternalAddress(aGCId) |
|
5386 |
&& __isSmallInteger(fgColorIndex)) { |
|
5387 |
XSetForeground(myDpy, _GCVal(aGCId), _intVal(fgColorIndex)); |
|
5388 |
RETURN ( self ); |
|
5389 |
} |
|
5390 |
%}. |
|
5391 |
self primitiveFailed |
|
5392 |
! |
|
5393 |
||
5394 |
setFunction:aFunctionSymbol in:aGCId |
|
5395 |
"set alu function to be drawn with" |
|
5396 |
||
5397 |
%{ /* NOCONTEXT */ |
|
5398 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5399 |
GC gc; |
295 | 5400 |
int fun = -1; |
5401 |
||
5402 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5403 |
gc = _GCVal(aGCId); |
295 | 5404 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
5405 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
5406 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
5407 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
5408 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
5409 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
5410 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
5411 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
5412 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
5413 |
if (fun != -1) { |
|
5414 |
XSetFunction(myDpy, gc, fun); |
|
5415 |
RETURN ( self ); |
|
5416 |
} |
|
5417 |
} |
|
5418 |
%}. |
|
5419 |
" |
|
5420 |
either aGCId is not an integer, or an invalid symbol |
|
5421 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
5422 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
5423 |
" |
|
5424 |
self primitiveFailed |
|
5425 |
! |
|
5426 |
||
5427 |
setGraphicsExposures:aBoolean in:aGCId |
|
5428 |
"set or clear the graphics exposures flag" |
|
5429 |
||
5430 |
%{ /* NOCONTEXT */ |
|
5431 |
||
5432 |
if (__isExternalAddress(aGCId)) { |
|
5433 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
5434 |
RETURN ( self ); |
|
5435 |
} |
|
5436 |
%} |
|
5437 |
. |
|
5438 |
self primitiveFailed |
|
5439 |
! |
|
5440 |
||
5441 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
|
5442 |
"set line attributes" |
|
5443 |
||
5444 |
%{ /* NOCONTEXT */ |
|
5445 |
||
5446 |
int x_style, x_cap, x_join; |
|
5447 |
||
5448 |
if (__isExternalAddress(aGCId) |
|
5449 |
&& __isSmallInteger(aNumber)) { |
|
5450 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
5451 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
5452 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
5453 |
else goto bad; |
|
5454 |
||
5455 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
5456 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
5457 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
5458 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
5459 |
else goto bad; |
|
5460 |
||
5461 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
5462 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
5463 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
5464 |
else goto bad; |
|
5465 |
||
5466 |
XSetLineAttributes(myDpy, |
|
5467 |
_GCVal(aGCId), _intVal(aNumber), |
|
5468 |
x_style, x_cap, x_join); |
|
5469 |
RETURN ( self ); |
|
5470 |
} |
|
5471 |
bad: ; |
|
5472 |
%}. |
|
5473 |
" |
|
5474 |
either aGCId is invalid, |
|
5475 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
|
5476 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
5477 |
and/or joinStyle is none of #miter, #bevel, #round |
|
5478 |
" |
|
5479 |
self primitiveFailed |
|
5480 |
! |
|
5481 |
||
5482 |
setMaskOriginX:orgX y:orgY in:aGCid |
|
5483 |
"set the mask origin" |
|
5484 |
||
5485 |
%{ /* NOCONTEXT */ |
|
5486 |
||
5487 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
|
5488 |
XSetTSOrigin(myDpy, _GCVal(aGCid), _intVal(orgX), _intVal(orgY)); |
|
5489 |
RETURN ( self ); |
|
5490 |
} |
|
5491 |
%}. |
|
5492 |
self primitiveFailed |
|
5493 |
! |
|
5494 |
||
5495 |
setPixmapMask:aPixmapId in:aGCId |
|
5496 |
"set or clear the drawing mask - a pixmap mask providing full color" |
|
5497 |
||
5498 |
%{ /* NOCONTEXT */ |
|
5499 |
||
5500 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5501 |
GC gc; |
295 | 5502 |
Pixmap pixmap; |
5503 |
||
5504 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5505 |
gc = _GCVal(aGCId); |
295 | 5506 |
if (__isExternalAddress(aPixmapId)) { |
5507 |
pixmap = _PixmapVal(aPixmapId); |
|
5508 |
XSetTile(dpy, gc, pixmap); |
|
5509 |
XSetFillStyle(dpy, gc, FillTiled); |
|
5510 |
RETURN ( self ); |
|
5511 |
} |
|
5512 |
if (aPixmapId == nil) { |
|
5513 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5514 |
RETURN ( self ); |
|
5515 |
} |
|
5516 |
} |
|
5517 |
%}. |
|
5518 |
self primitiveFailed |
|
5519 |
! ! |
|
5520 |
||
5521 |
!XWorkstation methodsFor:'initialize / release'! |
|
5522 |
||
5523 |
close |
|
5524 |
"close down the connection to the X-server" |
|
5525 |
||
5526 |
%{ /* NOCONTEXT */ |
|
5527 |
||
5528 |
if (ISCONNECTED) { |
|
5529 |
BEGIN_INTERRUPTSBLOCKED |
|
5530 |
XCloseDisplay(myDpy); |
|
5531 |
_INST(displayId) = nil; |
|
5532 |
END_INTERRUPTSBLOCKED |
|
5533 |
} |
|
5534 |
%} |
|
5535 |
! |
|
5536 |
||
5537 |
initializeDefaultValues |
|
5538 |
buttonTranslation := ButtonTranslation. |
|
5539 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
5540 |
||
5541 |
self initializeModifierMappings |
|
5542 |
! |
|
5543 |
||
5544 |
initializeEventBuffer |
|
5545 |
|sz| |
|
5546 |
||
5547 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5548 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 5549 |
%}. |
5550 |
eventBuffer isNil ifTrue:[ |
|
5551 |
eventBuffer := ByteArray new:sz. |
|
5552 |
]. |
|
5553 |
! |
|
5554 |
||
5555 |
initializeFor:aDisplayName |
|
5556 |
"initialize the receiver for a connection to an X-Server; |
|
5557 |
the argument, aDisplayName may be nil (for the default server from |
|
5558 |
DISPLAY-variable or command line argument) or the name of the server |
|
5559 |
as hostname:number" |
|
5560 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5561 |
|dpyName index arguments| |
295 | 5562 |
|
5563 |
dpyName := aDisplayName. |
|
5564 |
dpyName isNil ifTrue:[ |
|
5565 |
"look for a '-display xxx' argument" |
|
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5566 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5567 |
index := arguments indexOf:'-display'. |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5568 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5569 |
dpyName := arguments at:index+1 |
295 | 5570 |
] |
5571 |
] |
|
5572 |
]. |
|
5573 |
%{ |
|
5574 |
int scr; |
|
5575 |
Display *dpy; |
|
5576 |
Visual *visual; |
|
5577 |
XVisualInfo viproto; |
|
5578 |
XVisualInfo *vip; /* retured info */ |
|
5579 |
int maxRGBDepth; |
|
5580 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5581 |
int rgbVisualID; |
|
5582 |
int nvi, i; |
|
5583 |
int shapeEventBase, shapeErrorBase; |
|
5584 |
int shmEventBase, shmErrorBase; |
|
5585 |
int faxEventBase, faxErrorBase; |
|
5586 |
char *type, *nm; |
|
5587 |
int dummy; |
|
5588 |
OBJ dpyID; |
|
5589 |
||
5590 |
if (_INST(displayId) != nil) { |
|
5591 |
/* |
|
5592 |
* already connected - you bad guy try to |
|
5593 |
* trick me manually ? |
|
5594 |
*/ |
|
5595 |
RETURN ( self ); |
|
5596 |
} |
|
5597 |
||
5598 |
BEGIN_INTERRUPTSBLOCKED |
|
5599 |
||
5600 |
if (__isString(dpyName)) |
|
5601 |
nm = (char *)_stringVal(dpyName); |
|
5602 |
else { |
|
5603 |
dpyName = __MKSTRING((char *)getenv("DISPLAY") COMMA_CON); |
|
5604 |
nm = NULL; |
|
5605 |
} |
|
5606 |
dpy = XOpenDisplay(nm); |
|
5607 |
||
5608 |
if (dpy) { |
|
5609 |
_INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
|
5610 |
||
5611 |
#ifdef SUPERDEBUG |
|
5612 |
XSynchronize(dpy, 1); |
|
5613 |
#endif |
|
5614 |
||
5615 |
XSetErrorHandler(__XErrorHandler__); |
|
5616 |
} |
|
5617 |
||
5618 |
END_INTERRUPTSBLOCKED |
|
5619 |
%}. |
|
5620 |
displayId isNil ifTrue:[ |
|
5621 |
'XWORKSTATION: cannot connect to Display.' errorPrintNL. |
|
5622 |
^ nil |
|
5623 |
]. |
|
5624 |
||
5625 |
dispatching := false. |
|
5626 |
dispatchingExpose := false. |
|
5627 |
isSlow := false. |
|
5628 |
shiftDown := false. |
|
5629 |
ctrlDown := false. |
|
5630 |
metaDown := false. |
|
5631 |
altDown := false. |
|
5632 |
motionEventCompression := true. |
|
5633 |
buttonsPressed := 0. |
|
5634 |
displayName := dpyName. |
|
5635 |
||
5636 |
protocolsAtom := nil. |
|
5637 |
deleteWindowAtom := nil. |
|
5638 |
saveYourselfAtom := nil. |
|
5639 |
quitAppAtom := nil. |
|
5640 |
||
5641 |
self initializeScreenProperties. |
|
5642 |
||
5643 |
self initializeDefaultValues. |
|
5644 |
self initializeEventBuffer. |
|
5645 |
self initializeSpecialFlags. |
|
5646 |
self initializeKeyboardMap. |
|
5647 |
||
5648 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
5649 |
! |
|
5650 |
||
5651 |
initializeModifierMappings |
|
5652 |
|map mod| |
|
5653 |
||
5654 |
"/ altModifiers := #(Alt_L Alt_R). |
|
5655 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
5656 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
5657 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
5658 |
||
5659 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
5660 |
altModifierMask := metaModifierMask := nil. |
|
5661 |
||
5662 |
map := self modifierMapping. |
|
342 | 5663 |
map isNil ifTrue:[ |
5664 |
"/ |
|
5665 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
5666 |
"/ setup some reasonable default. If that is not sufficient, |
|
5667 |
"/ you have to change things from your display.rc file. |
|
5668 |
"/ |
|
5669 |
altModifierMask := self modifier1Mask. |
|
5670 |
metaModifierMask := self modifier2Mask. |
|
5671 |
||
5672 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
5673 |
ctrlModifiers := #(Control_L Control_R Control). |
|
5674 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
5675 |
altModifiers := #(Alt_R Alt). |
|
5676 |
] ifFalse:[ |
|
5677 |
altModifierMask := 0. |
|
374 | 5678 |
metaModifierMask := 0. |
5679 |
||
5680 |
mod := map at:1. |
|
5681 |
mod notNil ifTrue:[ |
|
342 | 5682 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 5683 |
]. |
5684 |
mod := map at:3. |
|
5685 |
mod notNil ifTrue:[ |
|
342 | 5686 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 5687 |
]. |
5688 |
mod := map at:4. |
|
5689 |
mod notNil ifTrue:[ |
|
342 | 5690 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
5691 |
metaModifierMask := 1 bitShift:(4-1). |
|
374 | 5692 |
]. |
5693 |
mod := map at:5. |
|
5694 |
mod notNil ifTrue:[ |
|
342 | 5695 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
5696 |
altModifierMask := 1 bitShift:(5-1). |
|
5697 |
] |
|
295 | 5698 |
]. |
5699 |
||
5700 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
5701 |
! |
|
5702 |
||
5703 |
initializeScreenProperties |
|
5704 |
%{ /* NOCONTEXT */ |
|
5705 |
||
5706 |
Display *dpy = myDpy; |
|
5707 |
int scr; |
|
5708 |
Visual *visual; |
|
5709 |
XVisualInfo viproto; |
|
5710 |
XVisualInfo *vip; /* retured info */ |
|
5711 |
int maxRGBDepth; |
|
5712 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5713 |
int rgbVisualID; |
|
5714 |
int nvi, i; |
|
5715 |
int shapeEventBase, shapeErrorBase; |
|
5716 |
int shmEventBase, shmErrorBase; |
|
5717 |
int faxEventBase, faxErrorBase; |
|
5718 |
char *type, *nm; |
|
5719 |
int dummy; |
|
5720 |
int mask, shift, nBits; |
|
5721 |
||
5722 |
if (ISCONNECTED) { |
|
5723 |
_INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
|
5724 |
_INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
5725 |
||
5726 |
BEGIN_INTERRUPTSBLOCKED |
|
5727 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5728 |
_INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5729 |
_INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5730 |
_INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5731 |
_INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5732 |
_INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5733 |
_INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5734 |
_INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5735 |
_INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5736 |
_INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
295 | 5737 |
|
5738 |
#ifdef SHAPE |
|
5739 |
if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase)) |
|
5740 |
_INST(hasShapeExtension) = true; |
|
5741 |
else |
|
5742 |
#endif |
|
5743 |
_INST(hasShapeExtension) = false; |
|
5744 |
||
5745 |
#ifdef SHM |
|
5746 |
if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase)) |
|
5747 |
_INST(hasShmExtension) = true; |
|
5748 |
else |
|
5749 |
#endif |
|
5750 |
_INST(hasShmExtension) = false; |
|
5751 |
||
5752 |
#ifdef FAX |
|
5753 |
if (XFAXImageQueryExtension(dpy, &faxEventBase, &faxErrorBase)) |
|
5754 |
_INST(hasFaxExtension) = true; |
|
5755 |
else |
|
5756 |
#endif |
|
5757 |
_INST(hasFaxExtension) = false; |
|
5758 |
||
5759 |
#ifdef DPS |
|
5760 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
|
5761 |
_INST(hasDPSExtension) = true; |
|
5762 |
else |
|
5763 |
#endif |
|
5764 |
_INST(hasDPSExtension) = false; |
|
5765 |
||
5766 |
#ifdef XVIDEO |
|
5767 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
|
5768 |
_INST(hasXVideoExtension) = true; |
|
5769 |
else |
|
5770 |
#endif |
|
5771 |
_INST(hasXVideoExtension) = false; |
|
5772 |
||
5773 |
#ifdef MBUF |
|
5774 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
|
5775 |
_INST(hasMbufExtension) = true; |
|
5776 |
else |
|
5777 |
#endif |
|
5778 |
_INST(hasMbufExtension) = false; |
|
5779 |
||
5780 |
#ifdef PEX5 |
|
5781 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
|
5782 |
_INST(hasPEXExtension) = true; |
|
5783 |
else |
|
5784 |
#endif |
|
5785 |
_INST(hasPEXExtension) = false; |
|
5786 |
||
5787 |
#ifdef XIE |
|
5788 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
|
5789 |
_INST(hasImageExtension) = true; |
|
5790 |
else |
|
5791 |
#endif |
|
5792 |
_INST(hasImageExtension) = false; |
|
5793 |
||
5794 |
#ifdef XI |
|
5795 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
|
5796 |
_INST(hasInputExtension) = true; |
|
5797 |
else |
|
5798 |
#endif |
|
5799 |
_INST(hasInputExtension) = false; |
|
5800 |
||
5801 |
/* |
|
5802 |
* look for RGB visual |
|
5803 |
*/ |
|
5804 |
nvi = 0; |
|
5805 |
viproto.screen = scr; |
|
5806 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
5807 |
maxRGBDepth = 0; |
|
5808 |
for (i = 0; i < nvi; i++) { |
|
5809 |
switch (vip[i].class) { |
|
5810 |
case TrueColor: |
|
5811 |
if (vip[i].depth > maxRGBDepth) { |
|
5812 |
maxRGBDepth = vip[i].depth; |
|
5813 |
rgbRedMask = vip[i].red_mask; |
|
5814 |
rgbGreenMask = vip[i].green_mask; |
|
5815 |
rgbBlueMask = vip[i].blue_mask; |
|
5816 |
rgbVisualID = vip[i].visualid; |
|
5817 |
} |
|
5818 |
break; |
|
5819 |
} |
|
5820 |
} |
|
5821 |
if (vip) XFree ((char *) vip); |
|
5822 |
||
5823 |
if (maxRGBDepth) { |
|
5824 |
_INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
|
5825 |
} |
|
5826 |
||
5827 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
5828 |
_INST(monitorType) = @symbol(unknown); |
|
5829 |
_INST(hasColors) = true; |
|
5830 |
_INST(hasGreyscales) = true; |
|
5831 |
switch (visual->class) { |
|
5832 |
case StaticGray: |
|
5833 |
_INST(visualType) = @symbol(StaticGray); |
|
5834 |
_INST(hasColors) = false; |
|
5835 |
_INST(monitorType) = @symbol(monochrome); |
|
5836 |
break; |
|
5837 |
case GrayScale: |
|
5838 |
_INST(visualType) = @symbol(GrayScale); |
|
5839 |
_INST(hasColors) = false; |
|
5840 |
_INST(monitorType) = @symbol(monochrome); |
|
5841 |
break; |
|
5842 |
case StaticColor: |
|
5843 |
_INST(visualType) = @symbol(StaticColor); |
|
5844 |
break; |
|
5845 |
case PseudoColor: |
|
5846 |
_INST(visualType) = @symbol(PseudoColor); |
|
5847 |
break; |
|
5848 |
case TrueColor: |
|
5849 |
_INST(visualType) = @symbol(TrueColor); |
|
5850 |
break; |
|
5851 |
case DirectColor: |
|
5852 |
_INST(visualType) = @symbol(DirectColor); |
|
5853 |
break; |
|
5854 |
} |
|
5855 |
if (DisplayCells(dpy, scr) == 2) { |
|
5856 |
_INST(hasColors) = false; |
|
5857 |
_INST(hasGreyscales) = false; |
|
5858 |
_INST(monitorType) = @symbol(monochrome); |
|
5859 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5860 |
_INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5861 |
_INST(redMask) = __MKSMALLINT(visual->red_mask); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5862 |
_INST(greenMask) = __MKSMALLINT(visual->green_mask); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5863 |
_INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
295 | 5864 |
switch (visual->class) { |
5865 |
case TrueColor: |
|
5866 |
/* extract number of bits and shift counts */ |
|
5867 |
mask = visual->red_mask; |
|
5868 |
shift = 0; |
|
5869 |
while (mask && ((mask & 1) == 0)) { |
|
5870 |
mask >>= 1; |
|
5871 |
shift++; |
|
5872 |
} |
|
5873 |
_INST(redShift) = __MKSMALLINT(shift); |
|
5874 |
nBits = 0; |
|
5875 |
while (mask) { |
|
5876 |
mask >>= 1; |
|
5877 |
nBits++; |
|
5878 |
} |
|
5879 |
_INST(bitsRed) = __MKSMALLINT(nBits); |
|
5880 |
||
5881 |
mask = visual->green_mask; |
|
5882 |
shift = 0; |
|
5883 |
while (mask && ((mask & 1) == 0)) { |
|
5884 |
mask >>= 1; |
|
5885 |
shift++; |
|
5886 |
} |
|
5887 |
_INST(greenShift) = __MKSMALLINT(shift); |
|
5888 |
nBits = 0; |
|
5889 |
while (mask) { |
|
5890 |
mask >>= 1; |
|
5891 |
nBits++; |
|
5892 |
} |
|
5893 |
_INST(bitsGreen) = __MKSMALLINT(nBits); |
|
5894 |
||
5895 |
mask = visual->blue_mask; |
|
5896 |
shift = 0; |
|
5897 |
while (mask && ((mask & 1) == 0)) { |
|
5898 |
mask >>= 1; |
|
5899 |
shift++; |
|
5900 |
} |
|
5901 |
_INST(blueShift) = __MKSMALLINT(shift); |
|
5902 |
nBits = 0; |
|
5903 |
while (mask) { |
|
5904 |
mask >>= 1; |
|
5905 |
nBits++; |
|
5906 |
} |
|
5907 |
_INST(bitsBlue) = __MKSMALLINT(nBits); |
|
5908 |
break; |
|
5909 |
} |
|
5910 |
||
5911 |
#ifndef XA_PRIMARY |
|
5912 |
_INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
|
5913 |
#else |
|
5914 |
_INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
|
5915 |
#endif |
|
5916 |
#ifndef XA_SECONDARY |
|
5917 |
_INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
|
5918 |
#else |
|
5919 |
_INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
|
5920 |
#endif |
|
5921 |
#ifndef XA_CUT_BUFFER0 |
|
5922 |
_INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
|
5923 |
#else |
|
5924 |
_INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
|
5925 |
#endif |
|
5926 |
#ifndef XA_STRING |
|
5927 |
_INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
|
5928 |
#else |
|
5929 |
_INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
|
5930 |
#endif |
|
5931 |
#ifndef XA_LENGTH |
|
5932 |
_INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
|
5933 |
#else |
|
5934 |
_INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
|
5935 |
#endif |
|
5936 |
||
5937 |
END_INTERRUPTSBLOCKED |
|
5938 |
} |
|
5939 |
%} |
|
5940 |
! |
|
5941 |
||
5942 |
initializeSpecialFlags |
|
5943 |
"perform additional special server implementation flags" |
|
5944 |
||
5945 |
"/ |
|
5946 |
"/ assume we have it ... (should check) |
|
5947 |
"/ |
|
5948 |
hasSaveUnder := true. |
|
5949 |
ignoreBackingStore := false. |
|
5950 |
||
5951 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
5952 |
"/ |
|
5953 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
5954 |
"/ which does not correctly handle saveUnder |
|
5955 |
"/ |
|
5956 |
hasSaveUnder := false. |
|
5957 |
]. |
|
5958 |
! |
|
5959 |
||
5960 |
reinitialize |
|
5961 |
virtualRootId := rootId := nil. |
|
5962 |
super reinitialize. |
|
5963 |
dispatchingExpose := nil |
|
5964 |
! ! |
|
5965 |
||
5966 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
5967 |
||
341 | 5968 |
altModifierMask:aSmallInteger |
5969 |
"define which key takes the role of an alt-key. |
|
5970 |
By default, this is X's modifier1, which is the ALT key on |
|
5971 |
most keyboards. However, there may be exceptions to this, |
|
5972 |
and the setting can be changed with: |
|
5973 |
Display altModifierMask:(Display modifier2Mask) |
|
5974 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
|
5975 |
" |
|
5976 |
||
5977 |
altModifierMask := aSmallInteger |
|
5978 |
! |
|
5979 |
||
5980 |
metaModifierMask:aSmallInteger |
|
5981 |
"define which key takes the role of a meta key. |
|
5982 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
5983 |
most keyboards (if present at all). |
|
5984 |
However, there may be exceptions to this, and the setting can |
|
5985 |
be changed with: |
|
5986 |
Display metaModifierMask:(Display modifier1Mask) |
|
5987 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
|
5988 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
5989 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
5990 |
all the time. On those, you should disable the meta key by setting |
|
5991 |
the mask to 0. |
|
5992 |
" |
|
5993 |
||
5994 |
metaModifierMask := aSmallInteger |
|
5995 |
! |
|
5996 |
||
5997 |
modifier1Mask |
|
5998 |
"return the Xlib mask bit for the 1st modifier key. |
|
5999 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6000 |
this could be used." |
|
6001 |
||
6002 |
%{ /* NOCONTEXT */ |
|
6003 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
6004 |
%} |
|
6005 |
! |
|
6006 |
||
6007 |
modifier2Mask |
|
6008 |
"return the Xlib mask bit for the 2nd modifier key. |
|
6009 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6010 |
this could be used." |
|
6011 |
||
6012 |
%{ /* NOCONTEXT */ |
|
6013 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
6014 |
%} |
|
6015 |
! |
|
6016 |
||
6017 |
modifierMapping |
|
6018 |
"Get the Modifier Mapping. |
|
6019 |
We return an array of arrays of keycodes" |
|
6020 |
||
6021 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
6022 |
||
6023 |
%{ |
|
6024 |
Display *dpy = myDpy; |
|
6025 |
XModifierKeymap *modmap; |
|
6026 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
6027 |
||
6028 |
if (ISCONNECTED) { |
|
6029 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
6030 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6031 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
6032 |
if (modifierKeyMap != nil) { |
|
6033 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6034 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
6035 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
6036 |
} |
|
6037 |
XFreeModifiermap(modmap); |
|
6038 |
} |
|
6039 |
} |
|
6040 |
%}. |
|
6041 |
||
6042 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
6043 |
||
6044 |
ret := Array new:8. |
|
6045 |
nextKey := 1. |
|
6046 |
1 to:8 do:[ :i | |
|
6047 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
|
6048 |
|mod| |
|
6049 |
||
6050 |
mod := OrderedCollection new:maxKeyPerMod. |
|
6051 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
6052 |
key ~= 0 ifTrue:[ |
|
6053 |
mod add:key |
|
6054 |
]. |
|
6055 |
]. |
|
6056 |
ret at:i put:mod. |
|
6057 |
]. |
|
6058 |
nextKey := nextKey+maxKeyPerMod. |
|
6059 |
]. |
|
6060 |
||
6061 |
^ ret |
|
6062 |
||
6063 |
" |
|
6064 |
Display modifierMapping |
|
6065 |
" |
|
6066 |
! |
|
6067 |
||
6068 |
stringFromKeycode:code |
|
6069 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
|
6070 |
||
6071 |
|str| |
|
6072 |
||
6073 |
%{ |
|
6074 |
Display *dpy = myDpy; |
|
6075 |
KeySym keysym; |
|
6076 |
char *keystring; |
|
6077 |
||
6078 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
6079 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
6080 |
(keystring = XKeysymToString(keysym)) != 0) |
|
6081 |
str = __MKSTRING(keystring); |
|
6082 |
} |
|
6083 |
%}. |
|
6084 |
^ str |
|
6085 |
||
6086 |
" |
|
6087 |
Display stringFromKeycode:28 |
|
6088 |
" |
|
6089 |
! |
|
6090 |
||
295 | 6091 |
translateKey:untranslatedKey |
6092 |
"Return the key translated via the translation table. |
|
6093 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
6094 |
which gets further processed in the superclasses translation method." |
|
6095 |
||
6096 |
|key| |
|
6097 |
||
6098 |
(key := untranslatedKey) isString ifTrue:[ |
|
6099 |
key := RawKeysymTranslation at:key ifAbsent:key. |
|
6100 |
key := key asSymbol. |
|
6101 |
]. |
|
6102 |
^ super translateKey:key |
|
6103 |
! ! |
|
6104 |
||
6105 |
!XWorkstation methodsFor:'misc'! |
|
6106 |
||
6107 |
beep |
|
6108 |
"output an audible beep or bell" |
|
6109 |
||
6110 |
self beep:50 |
|
6111 |
! |
|
6112 |
||
6113 |
beep:volumeInPercent |
|
6114 |
"output an audible beep" |
|
6115 |
%{ |
|
6116 |
int volume; |
|
6117 |
||
6118 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
6119 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
|
6120 |
volume = _intVal(volumeInPercent) * 2 - 100; |
|
6121 |
if (volume < -100) volume = -100; |
|
6122 |
else if (volume > 100) volume = 100; |
|
6123 |
BEGIN_INTERRUPTSBLOCKED |
|
6124 |
XBell(myDpy, volume); |
|
6125 |
END_INTERRUPTSBLOCKED |
|
6126 |
} |
|
6127 |
%} |
|
6128 |
! |
|
6129 |
||
6130 |
buffered |
|
6131 |
"buffer drawing - do not send it immediately to the display. |
|
374 | 6132 |
This is the default anyway. |
6133 |
See #unBuffered for additional info." |
|
295 | 6134 |
|
6135 |
%{ /* NOCONTEXT */ |
|
6136 |
||
6137 |
if (ISCONNECTED) { |
|
6138 |
BEGIN_INTERRUPTSBLOCKED |
|
6139 |
XSynchronize(myDpy, 0); |
|
6140 |
END_INTERRUPTSBLOCKED |
|
6141 |
} |
|
6142 |
%} |
|
374 | 6143 |
" |
6144 |
Display buffered |
|
6145 |
" |
|
295 | 6146 |
! |
6147 |
||
6148 |
flush |
|
6149 |
"send all buffered drawing to the display. |
|
6150 |
This may be required to make certain, that all previous operations |
|
6151 |
are really sent to the display before continuing. For example, |
|
6152 |
after a cursor-change with a followup long computation. |
|
374 | 6153 |
(otherwise, the cursor change request may still be in the output buffer) |
6154 |
See also #sync, which even waits until the request has been processed." |
|
295 | 6155 |
|
6156 |
%{ /* NOCONTEXT */ |
|
6157 |
||
6158 |
if (ISCONNECTED) { |
|
6159 |
BEGIN_INTERRUPTSBLOCKED |
|
310 | 6160 |
XFlush(myDpy); |
6161 |
END_INTERRUPTSBLOCKED |
|
6162 |
} |
|
6163 |
%} |
|
6164 |
! |
|
6165 |
||
295 | 6166 |
flushDpsContext:aDPSContext |
6167 |
||
6168 |
%{ /* NOCONTEXT */ |
|
6169 |
#ifdef DPS |
|
6170 |
if (__isExternalAddress(aDPSContext)) { |
|
6171 |
BEGIN_INTERRUPTSBLOCKED |
|
6172 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
6173 |
END_INTERRUPTSBLOCKED |
|
6174 |
RETURN ( self ); |
|
6175 |
} |
|
6176 |
#endif |
|
374 | 6177 |
%}. |
295 | 6178 |
self primitiveFailed |
6179 |
! |
|
6180 |
||
6181 |
refreshKeyboardMapping:eB |
|
6182 |
%{ |
|
6183 |
XMappingEvent *ev; |
|
6184 |
||
6185 |
if (__isByteArray(eB)) { |
|
6186 |
ev = (XMappingEvent *)(_ByteArrayInstPtr(eB)->ba_element); |
|
6187 |
XRefreshKeyboardMapping(ev); |
|
6188 |
} |
|
6189 |
%} |
|
6190 |
! |
|
6191 |
||
6192 |
setInputFocusTo:aWindowId |
|
6193 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
|
6194 |
self setInputFocusTo:aWindowId revertTo:#root |
|
6195 |
! |
|
6196 |
||
6197 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
|
6198 |
"set the focus to the view as defined by aWindowId. |
|
6199 |
Passing nil set the focus to no window and lets the display discard all |
|
6200 |
input until a new focus is set. |
|
6201 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
6202 |
passing one of #parent, #root or nil specifies that the focus should be |
|
6203 |
given to the parent view, the root view or no view." |
|
6204 |
||
6205 |
%{ /* NOCONTEXT */ |
|
6206 |
int arg; |
|
6207 |
Window focusWindow; |
|
6208 |
||
6209 |
if (ISCONNECTED) { |
|
6210 |
if (__isExternalAddress(aWindowId)) { |
|
6211 |
focusWindow = _WindowVal(aWindowId); |
|
6212 |
} else { |
|
6213 |
focusWindow = None; |
|
6214 |
} |
|
6215 |
if (revertSymbol == @symbol(parent)) |
|
6216 |
arg = RevertToParent; |
|
6217 |
else if (revertSymbol == @symbol(root)) |
|
6218 |
arg = RevertToPointerRoot; |
|
6219 |
else |
|
6220 |
arg = RevertToNone; |
|
6221 |
||
6222 |
BEGIN_INTERRUPTSBLOCKED |
|
6223 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
6224 |
END_INTERRUPTSBLOCKED |
|
6225 |
RETURN ( self ); |
|
6226 |
} |
|
6227 |
%}. |
|
6228 |
self primitiveFailed |
|
6229 |
! |
|
6230 |
||
341 | 6231 |
sync |
6232 |
"send all buffered drawing to the display AND wait until the display |
|
6233 |
has finished drawing it. |
|
6234 |
This is almost never needed, except if you are about to read previously |
|
374 | 6235 |
drawn pixels back from the display screen, or you want to wait for a beep |
6236 |
to be finished. See also #flush." |
|
341 | 6237 |
|
6238 |
%{ /* NOCONTEXT */ |
|
6239 |
||
6240 |
if (ISCONNECTED) { |
|
6241 |
BEGIN_INTERRUPTSBLOCKED |
|
6242 |
XSync(myDpy, 0); |
|
6243 |
END_INTERRUPTSBLOCKED |
|
6244 |
} |
|
6245 |
%} |
|
6246 |
! |
|
6247 |
||
295 | 6248 |
unBuffered |
374 | 6249 |
"make all drawing be sent immediately to the display. |
6250 |
This makes all graphics synchronous and turns off any buffering |
|
6251 |
(i.e. each individual draw-request is sent immediately without |
|
6252 |
packing multiple requests into a larger message buffer). |
|
6253 |
Be prepared, that this slows down graphics considerably. |
|
6254 |
However, it allows display errors to be handled immediately and |
|
6255 |
may be useful if you get Xdisplay errors and want to find the request |
|
6256 |
which was responsiblefor it. See also #buffered." |
|
295 | 6257 |
|
6258 |
%{ /* NOCONTEXT */ |
|
6259 |
||
6260 |
if (ISCONNECTED) { |
|
6261 |
BEGIN_INTERRUPTSBLOCKED |
|
6262 |
XSynchronize(myDpy, 1); |
|
6263 |
END_INTERRUPTSBLOCKED |
|
6264 |
} |
|
6265 |
%} |
|
6266 |
"Display unbuffered" |
|
6267 |
! ! |
|
6268 |
||
6269 |
!XWorkstation methodsFor:'pointer queries '! |
|
6270 |
||
6271 |
buttonStates |
|
6272 |
"return an integer representing the state of the pointer buttons; |
|
6273 |
a one-bit in positions 0.. represent a pressed button" |
|
6274 |
||
6275 |
%{ /* NOCONTEXT*/ |
|
6276 |
Display *dpy = myDpy; |
|
6277 |
Window w; |
|
6278 |
int screen = _intVal(_INST(screen)); |
|
6279 |
Window rootRet, childRet; |
|
6280 |
int rootX, rootY, winX, winY; |
|
6281 |
unsigned int mask; |
|
6282 |
||
6283 |
BEGIN_INTERRUPTSBLOCKED |
|
6284 |
#ifdef VIRTUAL_ROOT |
|
6285 |
w = getRootWindow(myDpy, screen); |
|
6286 |
#else |
|
6287 |
w = RootWindow(dpy, screen); |
|
6288 |
#endif |
|
6289 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
6290 |
&rootX, &rootY, |
|
6291 |
&winX, &winY, |
|
6292 |
&mask); |
|
6293 |
END_INTERRUPTSBLOCKED |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6294 |
RETURN (__MKSMALLINT(mask)); |
295 | 6295 |
%} |
6296 |
! |
|
6297 |
||
6298 |
leftButtonStateMask |
|
6299 |
"return an integer for masking out the left button from a |
|
6300 |
buttonStates value" |
|
6301 |
||
6302 |
^ 256 |
|
6303 |
! |
|
6304 |
||
6305 |
middleButtonStateMask |
|
6306 |
"return an integer for masking out the middle button from a |
|
6307 |
buttonStates value" |
|
6308 |
||
6309 |
^ 512 |
|
6310 |
! |
|
6311 |
||
6312 |
pointerPosition |
|
6313 |
"return the current pointer position in root-window coordinates" |
|
6314 |
||
6315 |
|xpos ypos| |
|
6316 |
||
6317 |
%{ |
|
6318 |
Display *dpy = myDpy; |
|
6319 |
Window w; |
|
6320 |
int screen = _intVal(_INST(screen)); |
|
6321 |
Window rootRet, childRet; |
|
6322 |
int rootX, rootY, winX, winY; |
|
6323 |
unsigned int mask; |
|
6324 |
||
6325 |
BEGIN_INTERRUPTSBLOCKED |
|
6326 |
#ifdef VIRTUAL_ROOT |
|
6327 |
w = getRootWindow(myDpy, screen); |
|
6328 |
#else |
|
6329 |
w = RootWindow(dpy, screen); |
|
6330 |
#endif |
|
6331 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
6332 |
&rootX, &rootY, |
|
6333 |
&winX, &winY, |
|
6334 |
&mask); |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6335 |
xpos = __MKSMALLINT(rootX); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6336 |
ypos = __MKSMALLINT(rootY); |
295 | 6337 |
END_INTERRUPTSBLOCKED |
6338 |
%} |
|
6339 |
. |
|
6340 |
^ xpos @ ypos |
|
6341 |
! |
|
6342 |
||
6343 |
rightButtonStateMask |
|
6344 |
"return an integer for masking out the right button from a |
|
6345 |
buttonStates value" |
|
6346 |
||
6347 |
^ 1024 |
|
6348 |
! |
|
6349 |
||
6350 |
rootPositionOfLastEvent |
|
6351 |
"return the position in root-window coordinates |
|
6352 |
of the last button, key or pointer event" |
|
6353 |
||
6354 |
^ eventRootX @ eventRootY |
|
6355 |
! ! |
|
6356 |
||
6357 |
!XWorkstation methodsFor:'resources'! |
|
6358 |
||
6359 |
getResource:name class:cls |
|
6360 |
%{ |
|
6361 |
char *rslt; |
|
6362 |
||
6363 |
if ((__isString(name) || __isSymbol(name)) |
|
6364 |
&& (__isString(cls) || __isSymbol(cls)) |
|
6365 |
&& ISCONNECTED) { |
|
6366 |
BEGIN_INTERRUPTSBLOCKED |
|
6367 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
6368 |
(char *)_stringVal(name)); |
|
6369 |
END_INTERRUPTSBLOCKED |
|
6370 |
RETURN (rslt ? __MKSTRING(rslt COMMA_CON) : nil ); |
|
6371 |
} |
|
6372 |
%} |
|
6373 |
. |
|
6374 |
self primitiveFailed. |
|
6375 |
^ nil |
|
6376 |
! ! |
|
6377 |
||
6378 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
6379 |
||
6380 |
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
|
6381 |
"get bits from a drawable into the imageBits. The storage for the bits |
|
6382 |
must be big enough for the data to fit. If ok, returns an array with some |
|
6383 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
6384 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
6385 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
6386 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6387 |
|rawInfo info| |
295 | 6388 |
|
6389 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
6390 |
self primitiveFailed. |
|
6391 |
^ nil |
|
6392 |
]. |
|
6393 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6394 |
rawInfo := Array new:8. |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6395 |
"1 -> bit order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6396 |
"2 -> depth" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6397 |
"3 -> bytes_per_line" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6398 |
"4 -> byte_order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6399 |
"5 -> format" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6400 |
"6 -> bitmap_unit" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6401 |
"7 -> bitmap_pad" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6402 |
"8 -> bits_per_pixel" |
295 | 6403 |
|
6404 |
"/ had to extract the getPixel call into a separate method, to specify |
|
6405 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
6406 |
"/ of temporary stack space |
|
6407 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6408 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6409 |
info := IdentityDictionary new. |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6410 |
info at:#bitOrder put:(rawInfo at:1). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6411 |
info at:#depth put:(rawInfo at:2). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6412 |
info at:#bytesPerLine put:(rawInfo at:3). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6413 |
info at:#byteOrder put:(rawInfo at:4). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6414 |
info at:#format put:(rawInfo at:5). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6415 |
info at:#bitmapUnit put:(rawInfo at:6). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6416 |
info at:#bitmapPad put:(rawInfo at:7). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6417 |
info at:#bitsPerPixel put:(rawInfo at:8). |
295 | 6418 |
^ info |
6419 |
]. |
|
6420 |
" |
|
6421 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
6422 |
or is too small to hold the bits |
|
6423 |
" |
|
6424 |
^ self primitiveFailed |
|
6425 |
! |
|
6426 |
||
6427 |
getPixelX:x y:y from:aDrawableId |
|
6428 |
"return the pixel value at x/y; coordinates start at 0/0 for the upper left." |
|
6429 |
||
6430 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
6431 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6432 |
Window win; |
295 | 6433 |
XImage *img; |
6434 |
int ret; |
|
6435 |
int xpos, ypos; |
|
6436 |
||
6437 |
if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6438 |
win = _WindowVal(aDrawableId); |
295 | 6439 |
xpos = _intVal(x); |
6440 |
ypos = _intVal(y); |
|
6441 |
if ((xpos < 0) || (ypos < 0)) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6442 |
RETURN ( __MKSMALLINT(0) ); |
295 | 6443 |
} |
6444 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
6445 |
ret = XGetPixel(img, 0, 0); |
|
6446 |
XDestroyImage(img); |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6447 |
RETURN ( __MKSMALLINT(ret) ); |
295 | 6448 |
} |
6449 |
%}. |
|
6450 |
^ nil |
|
6451 |
! |
|
6452 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6453 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 6454 |
"since XGetImage may allocate huge amount of stack space |
6455 |
(some implementations use alloca), this must run with unlimited stack." |
|
6456 |
||
6457 |
%{ /* UNLIMITEDSTACK */ |
|
6458 |
||
6459 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6460 |
Window win; |
295 | 6461 |
XImage *image = (XImage *)0; |
6462 |
int pad, bytes_per_line, numBytes; |
|
6463 |
||
6464 |
if (__isExternalAddress(aDrawableId) |
|
6465 |
&& __bothSmallInteger(srcx, srcy) |
|
6466 |
&& __bothSmallInteger(w, h) |
|
6467 |
&& __isArray(info) |
|
6468 |
&& __isByteArray(imageBits)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6469 |
win = _WindowVal(aDrawableId); |
295 | 6470 |
image = XGetImage(dpy, win, _intVal(srcx), _intVal(srcy), |
6471 |
_intVal(w), _intVal(h), |
|
6472 |
(unsigned)AllPlanes, ZPixmap); |
|
6473 |
||
378 | 6474 |
if (! image) { |
6475 |
RETURN ( false ); |
|
6476 |
} |
|
6477 |
||
295 | 6478 |
pad = image->bitmap_pad; |
6479 |
#ifdef SUPERDEBUG |
|
6480 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
|
6481 |
#endif |
|
6482 |
switch (image->depth) { |
|
6483 |
case 1: |
|
6484 |
case 2: |
|
6485 |
case 4: |
|
6486 |
case 8: |
|
6487 |
case 16: |
|
6488 |
case 24: |
|
6489 |
case 32: |
|
6490 |
numBytes = image->bytes_per_line * image->height; |
|
6491 |
break; |
|
6492 |
default: |
|
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6493 |
/* unsupported depth ? */ |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6494 |
printf("possibly unsupported depth:%d in primGetBits\n", image->depth); |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6495 |
numBytes = image->bytes_per_line * image->height; |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6496 |
break; |
295 | 6497 |
} |
6498 |
||
6499 |
#ifdef SUPERDEBUG |
|
6500 |
printf("bytes need:%d bytes given:%d\n", numBytes, _byteArraySize(imageBits)); |
|
6501 |
#endif |
|
6502 |
||
6503 |
if (numBytes > _byteArraySize(imageBits)) { |
|
6504 |
/* imageBits too small */ |
|
378 | 6505 |
printf("provided byteArray too small\n"); |
295 | 6506 |
goto fail; |
6507 |
} |
|
6508 |
if (image->bitmap_bit_order == MSBFirst) |
|
6509 |
_ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
|
6510 |
else |
|
6511 |
_ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6512 |
_ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6513 |
_ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
295 | 6514 |
if (image->byte_order == MSBFirst) |
6515 |
_ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
|
6516 |
else |
|
6517 |
_ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
|
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6518 |
if (image->format == XYBitmap) |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6519 |
_ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6520 |
else if (image->format == XYPixmap) |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6521 |
_ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6522 |
else if (image->format == ZPixmap) |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6523 |
_ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6524 |
|
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6525 |
_ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6526 |
_ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6527 |
_ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
295 | 6528 |
bcopy(image->data, _ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
6529 |
XDestroyImage(image); |
|
6530 |
RETURN ( true ); |
|
6531 |
} |
|
6532 |
fail: |
|
6533 |
if (image) { |
|
6534 |
XDestroyImage(image); |
|
6535 |
} |
|
6536 |
%}. |
|
6537 |
^ false |
|
6538 |
! ! |
|
6539 |
||
6540 |
!XWorkstation methodsFor:'selections'! |
|
6541 |
||
6542 |
atomIDOf:aStringOrSymbol |
|
6543 |
"return an Atoms ID; dont create if not already present" |
|
6544 |
||
6545 |
^ self atomIDOf:aStringOrSymbol create:false |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6546 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6547 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6548 |
Display atomIDOf:'FACE_NAME' |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6549 |
Display atomIDOf:'FULL_NAME' |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6550 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6551 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6552 |
"Modified: 22.2.1996 / 23:29:32 / cg" |
295 | 6553 |
! |
6554 |
||
6555 |
atomIDOf:aStringOrSymbol create:create |
|
6556 |
"return an Atoms ID; if create is true, create it if not already present" |
|
6557 |
||
6558 |
%{ /* NOCONTEXT */ |
|
6559 |
Atom prop; |
|
6560 |
||
6561 |
if (ISCONNECTED) { |
|
6562 |
if (__isString(aStringOrSymbol) |
|
6563 |
|| __isSymbol(aStringOrSymbol)) { |
|
6564 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
6565 |
(create == true) ? False : True); |
|
6566 |
if (prop == None) { |
|
6567 |
RETURN (nil); |
|
6568 |
} |
|
6569 |
RETURN ( __MKATOMOBJ(prop) ); |
|
6570 |
} |
|
6571 |
} |
|
6572 |
%}. |
|
6573 |
self primitiveFailed. |
|
6574 |
^ nil |
|
6575 |
||
6576 |
" |
|
6577 |
Display atomIDOf:'VT_SELECTION' create:false |
|
6578 |
Display atomIDOf:'CUT_BUFFER0' create:false |
|
6579 |
Display atomIDOf:'STRING' create:false |
|
6580 |
Display atomIDOf:'PRIMARY' create:false |
|
6581 |
Display atomIDOfPRIMARY |
|
6582 |
" |
|
6583 |
! |
|
6584 |
||
6585 |
atomIDOfCUTBUFFER0 |
|
6586 |
^ cutBuffer0Atom |
|
6587 |
! |
|
6588 |
||
6589 |
atomIDOfLENGTH |
|
6590 |
^ lengthAtom |
|
6591 |
! |
|
6592 |
||
6593 |
atomIDOfPRIMARY |
|
6594 |
^ primaryAtom |
|
6595 |
! |
|
6596 |
||
6597 |
atomIDOfSECONDARY |
|
6598 |
^ secondaryAtom |
|
6599 |
! |
|
6600 |
||
6601 |
atomIDOfSTRING |
|
6602 |
^ stringAtom |
|
6603 |
! |
|
6604 |
||
6605 |
atomName:anAtomID |
|
6606 |
%{ /* NOCONTEXT */ |
|
6607 |
OBJ str; |
|
6608 |
char *name; |
|
6609 |
||
6610 |
if (ISCONNECTED) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6611 |
if (__isAtomID(anAtomID)) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6612 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6613 |
if (name == 0) { |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6614 |
RETURN (nil); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6615 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6616 |
str = __MKSTRING(name COMMA_CON); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6617 |
XFree(name); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6618 |
RETURN ( str ); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6619 |
} |
295 | 6620 |
} |
6621 |
%}. |
|
6622 |
self primitiveFailed. |
|
6623 |
^ nil |
|
6624 |
||
6625 |
" |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6626 |
Display atomName:1 |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6627 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6628 |
Display atomName:132 'FONTNAME_REGISTRY' |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6629 |
Display atomName:135 'FOUNDRY' |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6630 |
Display atomName:150 'CHARSET_REGISTRY' |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6631 |
Display atomName:151 'ISO8859' |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6632 |
Display atomName:152 'CHARSET_ENCODING' |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6633 |
Display atomName:154 |
295 | 6634 |
" |
6635 |
! |
|
6636 |
||
6637 |
getObjectProperty:propertyID from:aWindowID |
|
6638 |
"get an object property; return object or nil" |
|
6639 |
||
6640 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
6641 |
type == stringAtom ifTrue:[ |
|
6642 |
^ value |
|
6643 |
]. |
|
6644 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
6645 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
6646 |
] |
|
6647 |
]. |
|
6648 |
^ nil |
|
6649 |
! |
|
6650 |
||
6651 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
6652 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
6653 |
||
6654 |
|val typeID cls| |
|
6655 |
||
6656 |
cls := ByteArray. |
|
6657 |
%{ |
|
6658 |
Display *dpy = myDpy; |
|
6659 |
Window window; |
|
6660 |
Atom property; |
|
6661 |
char *cp, *cp2; |
|
6662 |
Atom actual_type; |
|
6663 |
int actual_format,i; |
|
6664 |
unsigned long nitems, bytes_after, nread; |
|
6665 |
unsigned char *data; |
|
6666 |
int ok = 1; |
|
449 | 6667 |
OBJ __MKSTRING_L(); |
295 | 6668 |
# define PROP_SIZE 2048 |
6669 |
||
6670 |
if (__isAtomID(propertyID)) { |
|
6671 |
property = _AtomVal(propertyID); |
|
6672 |
if (__isExternalAddress(aWindowID)) { |
|
6673 |
window = _WindowVal(aWindowID); |
|
6674 |
} else { |
|
6675 |
window = DefaultRootWindow(dpy); |
|
6676 |
} |
|
6677 |
||
6678 |
nread = 0; |
|
6679 |
cp = 0; |
|
6680 |
/* |
|
6681 |
fprintf(stderr, "getProperty: "); |
|
6682 |
*/ |
|
6683 |
do { |
|
6684 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
6685 |
AnyPropertyType,&actual_type,&actual_format, |
|
6686 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
6687 |
!= Success) { |
|
6688 |
ok = 0; |
|
6689 |
break; |
|
6690 |
} |
|
6691 |
typeID = __MKATOMOBJ(actual_type); |
|
6692 |
if (! cp) { |
|
6693 |
cp = cp2 = (char *)malloc(nitems+1); |
|
6694 |
} else { |
|
6695 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
6696 |
cp2 = cp + nread; |
|
6697 |
} |
|
6698 |
if (! cp) goto fail; |
|
6699 |
||
6700 |
nread += nitems; |
|
6701 |
bcopy(data, cp2, nitems); |
|
6702 |
XFree(data); |
|
6703 |
/* |
|
6704 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
6705 |
*/ |
|
6706 |
} while (bytes_after > 0); |
|
6707 |
/* |
|
6708 |
fprintf(stderr, "\n"); |
|
6709 |
*/ |
|
6710 |
||
6711 |
if (ok) { |
|
6712 |
if (actual_type == XA_STRING) { |
|
6713 |
cp[nread] = '\0'; |
|
6714 |
val = __MKSTRING_L(cp, nread COMMA_CON); |
|
6715 |
} else { |
|
6716 |
val = __new(nread + OHDR_SIZE); |
|
6717 |
val->o_class = cls; |
|
6718 |
bcopy(cp, _ByteArrayInstPtr(val)->ba_element, nread); |
|
6719 |
} |
|
6720 |
} |
|
6721 |
if (cp) |
|
6722 |
free(cp); |
|
6723 |
} |
|
6724 |
fail: ; |
|
6725 |
%}. |
|
6726 |
typeID isNil ifTrue:[ |
|
6727 |
^ false |
|
6728 |
]. |
|
6729 |
aTwoArgBlock value:typeID value:val. |
|
6730 |
^ true |
|
6731 |
! |
|
6732 |
||
6733 |
getSelectionFor:drawableId |
|
6734 |
"get the object selection - either immediate, or asynchronous. |
|
6735 |
Returns nil, if async request is on its way" |
|
6736 |
||
6737 |
|selProp sel| |
|
6738 |
||
6739 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
6740 |
"no primary selection - use cut buffer" |
|
6741 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
6742 |
^ sel |
|
6743 |
]. |
|
6744 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
6745 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
6746 |
^ nil |
|
6747 |
! |
|
6748 |
||
6749 |
getSelectionOwnerOf:selectionAtomID |
|
6750 |
"get the owner of a selection" |
|
6751 |
||
6752 |
%{ /* NOCONTEXT */ |
|
6753 |
Display *dpy = myDpy; |
|
6754 |
Atom selection; |
|
6755 |
Window window; |
|
6756 |
||
6757 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
6758 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
6759 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
6760 |
} |
|
6761 |
%}. |
|
6762 |
self primitiveFailed. |
|
6763 |
^ nil |
|
6764 |
! |
|
6765 |
||
6766 |
getTextProperty:propertyID from:aWindowID |
|
6767 |
"get a text property; return string or nil" |
|
6768 |
||
6769 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
6770 |
type == stringAtom ifTrue:[ |
|
6771 |
^ value |
|
6772 |
] |
|
6773 |
]. |
|
6774 |
^ nil |
|
6775 |
! |
|
6776 |
||
6777 |
getTextSelectionFor:drawableId |
|
6778 |
"get the text selection - either immediate, or asynchronous. |
|
6779 |
Returns nil, if async request is on its way" |
|
6780 |
||
6781 |
|selProp sel| |
|
6782 |
||
6783 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
6784 |
"no primary selection - use cut buffer" |
|
6785 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
6786 |
^ sel |
|
6787 |
]. |
|
6788 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
6789 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
6790 |
^ nil |
|
6791 |
! |
|
6792 |
||
6793 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
|
6794 |
"ask the server to send us the selection - the view with ID aWindowID |
|
6795 |
will later receive a SelectionNotify event for it." |
|
6796 |
||
6797 |
^ self requestSelection:selectionID |
|
6798 |
property:propertyID |
|
6799 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
6800 |
for:aWindowId |
|
6801 |
! |
|
6802 |
||
6803 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
6804 |
"ask the server to send us the selection - the view with id aWindowID |
|
6805 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
6806 |
with the selections value)." |
|
6807 |
||
6808 |
%{ /* NOCONTEXT */ |
|
6809 |
Display *dpy = myDpy; |
|
6810 |
Atom sel_prop; |
|
6811 |
char *cp; |
|
6812 |
||
6813 |
if (__isExternalAddress(aWindowId) |
|
6814 |
&& ISCONNECTED |
|
6815 |
&& __isSmallInteger(typeID) |
|
6816 |
&& __isAtomID(selectionID)) { |
|
6817 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
6818 |
/* |
|
6819 |
* no owner of primary selection |
|
6820 |
*/ |
|
6821 |
RETURN (false); |
|
6822 |
} |
|
6823 |
/* |
|
6824 |
* PRIMARY selection |
|
6825 |
*/ |
|
6826 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
6827 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
6828 |
RETURN (true); |
|
6829 |
} |
|
6830 |
%}. |
|
6831 |
self primitiveFailed. |
|
6832 |
^ false |
|
6833 |
||
6834 |
" |
|
6835 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
6836 |
property:(Display atomIDOf:'VT_SELECTION') |
|
6837 |
for:0 |
|
6838 |
" |
|
6839 |
! |
|
6840 |
||
6841 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
|
6842 |
"ask the server to send us the selection - the view with ID aWindowID |
|
6843 |
will later receive a SelectionNotify event for it." |
|
6844 |
||
6845 |
^ self requestSelection:selectionID |
|
6846 |
property:propertyID |
|
6847 |
type:stringAtom |
|
6848 |
for:aWindowId |
|
6849 |
! |
|
6850 |
||
6851 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
6852 |
"send aString back from a SelectionRequest" |
|
6853 |
||
6854 |
self |
|
6855 |
sendSelection:something |
|
6856 |
selection:primaryAtom |
|
6857 |
property:propertyID |
|
6858 |
target:targetID |
|
6859 |
from:windowID |
|
6860 |
to:requestorID |
|
6861 |
! |
|
6862 |
||
6863 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
6864 |
"send aString back from a SelectionRequest" |
|
6865 |
||
6866 |
self |
|
6867 |
setProperty:propertyID |
|
6868 |
type:targetID |
|
6869 |
value:something |
|
6870 |
for:requestorID. |
|
6871 |
self |
|
6872 |
sendSelectionNotifySelection:selectionID |
|
6873 |
property:propertyID |
|
6874 |
target:targetID |
|
6875 |
from:requestorID |
|
6876 |
to:requestorID. |
|
6877 |
! |
|
6878 |
||
6879 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
6880 |
"send a selectionNotify back from a SelectionRequest" |
|
6881 |
||
6882 |
%{ /* NOCONTEXT */ |
|
6883 |
Display *dpy = myDpy; |
|
6884 |
||
6885 |
if (__isAtomID(propertyID) |
|
6886 |
&& __isExternalAddress(requestorID) |
|
6887 |
&& ISCONNECTED |
|
6888 |
&& __isAtomID(targetID) |
|
6889 |
&& __isAtomID(selectionID)) { |
|
6890 |
XEvent ev; |
|
6891 |
Window requestor = _WindowVal(requestorID); |
|
6892 |
Atom property = _AtomVal(propertyID); |
|
6893 |
Atom target = _AtomVal(targetID); |
|
6894 |
Atom selection = _AtomVal(selectionID); |
|
6895 |
Status result; |
|
6896 |
||
6897 |
ev.xselection.type = SelectionNotify; |
|
6898 |
ev.xselection.selection = selection; |
|
6899 |
ev.xselection.target = target; |
|
6900 |
if (__isExternalAddress(windowID)) |
|
6901 |
ev.xselection.requestor = _WindowVal(windowID); |
|
6902 |
else |
|
6903 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
6904 |
ev.xselection.time = CurrentTime; |
|
6905 |
if (property == None) |
|
6906 |
ev.xselection.property = target; |
|
6907 |
else |
|
6908 |
ev.xselection.property = property; |
|
6909 |
||
6910 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
6911 |
ev.xselection.selection, |
|
6912 |
ev.xselection.property, |
|
6913 |
ev.xselection.target, |
|
6914 |
ev.xselection.requestor, |
|
6915 |
requestor)); |
|
6916 |
||
6917 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
6918 |
if ((result == BadValue) || (result == BadWindow)) { |
|
6919 |
DPRINTF(("bad status\n")); |
|
382 | 6920 |
RETURN (false); |
295 | 6921 |
} |
382 | 6922 |
RETURN (true) |
6923 |
} |
|
6924 |
%}. |
|
6925 |
self primitiveFailed. |
|
6926 |
^ false |
|
295 | 6927 |
! |
6928 |
||
6929 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
6930 |
^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID |
|
6931 |
! |
|
6932 |
||
6933 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
6934 |
|s| |
|
6935 |
||
6936 |
(anObject isMemberOf:String) ifTrue:[ |
|
6937 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
|
6938 |
]. |
|
6939 |
s := WriteStream on:(ByteArray new:200). |
|
6940 |
anObject storeBinaryOn:s. |
|
6941 |
^ self |
|
6942 |
setProperty:propertyID |
|
6943 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
6944 |
value:(s contents) |
|
6945 |
for:aWindowID |
|
6946 |
! |
|
6947 |
||
6948 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
6949 |
||
6950 |
%{ /* UNLIMITEDSTACK */ |
|
6951 |
||
6952 |
Display *dpy = myDpy; |
|
6953 |
Atom prop, type; |
|
6954 |
Window window; |
|
6955 |
unsigned int value; |
|
6956 |
||
6957 |
if (__isAtomID(propertyID) |
|
6958 |
&& __isAtomID(typeID) |
|
6959 |
&& ISCONNECTED |
|
6960 |
&& (__isString(anObject) |
|
463
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6961 |
|| __isSmallInteger(anObject) |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6962 |
|| __isSymbol(anObject) |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6963 |
|| __isByteArray(anObject) |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6964 |
|| __isWords(anObject))) { |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6965 |
|
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6966 |
prop = _AtomVal(propertyID); |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6967 |
type = _AtomVal(typeID); |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6968 |
if (__isExternalAddress(aWindowID)) { |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6969 |
window = _WindowVal(aWindowID); |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6970 |
} else { |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6971 |
window = DefaultRootWindow(dpy); |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6972 |
} |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6973 |
if (__isSmallInteger(anObject)) { |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6974 |
value = _intVal(anObject); |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6975 |
XChangeProperty(dpy, window, prop, type, 32, |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6976 |
PropModeReplace, |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6977 |
(unsigned char *)(&value), sizeof(unsigned int)); |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6978 |
} else { |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6979 |
if (__isByteArray(anObject)) { |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6980 |
XChangeProperty(dpy, window, prop, type, 8, |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6981 |
PropModeReplace, |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6982 |
__ByteArrayInstPtr(anObject)->ba_element, |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6983 |
__byteArraySize(anObject)); |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6984 |
} else { |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6985 |
/* string or symbol or wordArray-like (16bit-string) object */ |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6986 |
if (__isWords(__qClass(anObject))) { |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6987 |
XChangeProperty(dpy, window, prop, XA_STRING, 16, |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6988 |
PropModeReplace, |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6989 |
__stringVal(anObject), |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6990 |
__wordArraySize(anObject)); |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6991 |
} else { |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6992 |
XChangeProperty(dpy, window, prop, XA_STRING, 8, |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6993 |
PropModeReplace, |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6994 |
__stringVal(anObject), |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6995 |
strlen(__stringVal(anObject))); |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6996 |
} |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6997 |
} |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6998 |
} |
cb4731ced6b5
handle selection with 16bit strings
Claus Gittinger <cg@exept.de>
parents:
461
diff
changeset
|
6999 |
RETURN (true); |
295 | 7000 |
} |
7001 |
%}. |
|
7002 |
^ false |
|
7003 |
! |
|
7004 |
||
7005 |
setSelection:anObject owner:aWindowId |
|
7006 |
"set the object selection, and make aWindowId be the owner. |
|
7007 |
This can be used by other Smalltalk(X) applications only." |
|
7008 |
||
7009 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7010 |
^ false |
|
7011 |
]. |
|
7012 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
7013 |
^ true |
|
7014 |
! |
|
7015 |
||
7016 |
setSelectionOwner:aWindowId of:selectionID |
|
7017 |
"set the owner of a selection; return false if failed" |
|
7018 |
||
7019 |
%{ /* NOCONTEXT */ |
|
7020 |
Display *dpy = myDpy; |
|
7021 |
Window win; |
|
7022 |
||
7023 |
if (__isExternalAddress(aWindowId) |
|
7024 |
&& __isAtomID(selectionID) |
|
7025 |
&& ISCONNECTED) { |
|
7026 |
win = _WindowVal(aWindowId); |
|
7027 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
7028 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
7029 |
RETURN (false); |
|
7030 |
} |
|
7031 |
RETURN (true); |
|
7032 |
} |
|
7033 |
%} |
|
7034 |
. |
|
7035 |
self primitiveFailed. |
|
7036 |
^ nil |
|
7037 |
! |
|
7038 |
||
7039 |
setTextProperty:propertyID value:aString for:aWindowID |
|
7040 |
^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID |
|
7041 |
! |
|
7042 |
||
7043 |
setTextSelection:aString owner:aWindowId |
|
7044 |
"set the text selection, and make aWindowId be the owner. |
|
7045 |
This can be used by any other X application." |
|
7046 |
||
7047 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7048 |
'ownerchange failed' errorPrintNL. |
|
7049 |
]. |
|
7050 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
7051 |
! ! |
|
7052 |
||
7053 |
!XWorkstation methodsFor:'window stuff'! |
|
7054 |
||
7055 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
|
7056 |
"clear a rectangular area to viewbackground" |
|
7057 |
||
7058 |
%{ /* NOCONTEXT */ |
|
7059 |
||
7060 |
int w, h; |
|
7061 |
||
7062 |
if (__isExternalAddress(aWindowId) |
|
7063 |
&& __bothSmallInteger(x, y) |
|
7064 |
&& __bothSmallInteger(width, height)) { |
|
7065 |
w = _intVal(width); |
|
7066 |
h = _intVal(height); |
|
7067 |
if (w < 0) w = 0; |
|
7068 |
if (h < 0) h = 0; |
|
7069 |
XClearArea(myDpy, _WindowVal(aWindowId), _intVal(x), _intVal(y), w, h, 0); |
|
7070 |
RETURN ( self ); |
|
7071 |
} |
|
7072 |
%} |
|
7073 |
. |
|
7074 |
self primitiveFailed |
|
7075 |
! |
|
7076 |
||
7077 |
clearWindow:aWindowId |
|
7078 |
"clear a window to viewbackground" |
|
7079 |
||
7080 |
%{ /* NOCONTEXT */ |
|
7081 |
||
7082 |
if (__isExternalAddress(aWindowId)) { |
|
7083 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
7084 |
RETURN ( self ); |
|
7085 |
} |
|
7086 |
%} |
|
7087 |
. |
|
7088 |
self primitiveFailed |
|
7089 |
! |
|
7090 |
||
7091 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
|
7092 |
"configure stacking operation of aWindowId w.r.t siblingId" |
|
7093 |
||
7094 |
%{ /* NOCONTEXT */ |
|
7095 |
||
7096 |
XWindowChanges chg; |
|
7097 |
int mask = CWSibling | CWStackMode; |
|
7098 |
||
7099 |
if (__isExternalAddress(aWindowId) |
|
7100 |
&& __isExternalAddress(siblingId)) { |
|
7101 |
if (modeSymbol == @symbol(above)) { |
|
7102 |
chg.stack_mode = Above; |
|
7103 |
} else if (modeSymbol == @symbol(below)) { |
|
7104 |
chg.stack_mode = Below; |
|
7105 |
} else if (modeSymbol == @symbol(topIf)) { |
|
7106 |
chg.stack_mode = TopIf; |
|
7107 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
7108 |
chg.stack_mode = BottomIf; |
|
7109 |
} else if (modeSymbol == @symbol(opposite)) { |
|
7110 |
chg.stack_mode = Opposite; |
|
7111 |
} else { |
|
7112 |
mask = CWSibling; |
|
7113 |
} |
|
7114 |
||
7115 |
chg.sibling = _WindowVal(siblingId); |
|
7116 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
7117 |
mask, &chg); |
|
7118 |
RETURN ( self ); |
|
7119 |
} |
|
7120 |
bad: ; |
|
7121 |
%} |
|
7122 |
. |
|
7123 |
self primitiveFailed |
|
7124 |
! |
|
7125 |
||
7126 |
lowerWindow:aWindowId |
|
7127 |
"bring a window to back" |
|
7128 |
||
7129 |
%{ /* NOCONTEXT */ |
|
7130 |
||
7131 |
if (__isExternalAddress(aWindowId)) { |
|
7132 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
|
7133 |
RETURN ( self ); |
|
7134 |
} |
|
7135 |
%} |
|
7136 |
. |
|
7137 |
self primitiveFailed |
|
7138 |
! |
|
7139 |
||
7140 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
|
7141 |
"make a window visible - either as icon or as a real view - needed for restart" |
|
7142 |
||
7143 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
7144 |
||
7145 |
aBoolean ifTrue:[ |
|
7146 |
wicon := aView icon. |
|
7147 |
wicon notNil ifTrue:[ |
|
7148 |
wiconId := wicon id |
|
7149 |
]. |
|
7150 |
wiconView := aView iconView. |
|
7151 |
wiconView notNil ifTrue:[ |
|
7152 |
wiconViewId := wiconView id |
|
7153 |
]. |
|
7154 |
wlabel := aView label. |
|
7155 |
]. |
|
7156 |
%{ |
|
7157 |
||
7158 |
XWMHints wmhints; |
|
7159 |
XSizeHints szhints; |
|
7160 |
Display *dpy = myDpy; |
|
7161 |
Window win; |
|
7162 |
||
7163 |
if (__isExternalAddress(aWindowId)) { |
|
7164 |
win = _WindowVal(aWindowId); |
|
7165 |
||
7166 |
szhints.flags = 0; |
|
7167 |
if (__bothSmallInteger(xPos, yPos)) { |
|
7168 |
szhints.x = _intVal(xPos); |
|
7169 |
szhints.y = _intVal(yPos); |
|
7170 |
szhints.flags |= USPosition; |
|
7171 |
} |
|
7172 |
if (__bothSmallInteger(w, h)) { |
|
7173 |
szhints.width = _intVal(w); |
|
7174 |
szhints.height = _intVal(h); |
|
7175 |
szhints.flags |= USSize; |
|
7176 |
} |
|
7177 |
||
7178 |
if (aBoolean == true) { |
|
7179 |
char *windowName; |
|
7180 |
Pixmap iconBitmap = (Pixmap)0; |
|
7181 |
Window iconWindow; |
|
7182 |
||
7183 |
if (__isExternalAddress(wiconId)) |
|
7184 |
iconBitmap = _PixmapVal(wiconId); |
|
7185 |
else |
|
7186 |
iconBitmap = (Pixmap)0; |
|
7187 |
||
7188 |
if (__isExternalAddress(wiconViewId)) |
|
7189 |
iconWindow = _WindowVal(wiconViewId); |
|
7190 |
else |
|
7191 |
iconWindow = (Window)0; |
|
7192 |
||
7193 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
7194 |
windowName = (char *)_stringVal(wlabel); |
|
7195 |
else |
|
7196 |
windowName = ""; |
|
7197 |
||
7198 |
if (iconBitmap || windowName) { |
|
7199 |
XSetStandardProperties(dpy, win, |
|
7200 |
windowName, windowName, |
|
7201 |
iconBitmap, |
|
7202 |
0, 0, &szhints); |
|
7203 |
} |
|
7204 |
||
7205 |
wmhints.flags = 0; |
|
7206 |
if (iconBitmap) { |
|
7207 |
wmhints.flags |= IconPixmapHint; |
|
7208 |
wmhints.icon_pixmap = iconBitmap; |
|
7209 |
} |
|
7210 |
if (iconWindow) { |
|
7211 |
wmhints.flags |= IconWindowHint; |
|
7212 |
wmhints.icon_window = iconWindow; |
|
7213 |
} |
|
7214 |
||
7215 |
wmhints.initial_state = IconicState; |
|
7216 |
wmhints.flags |= StateHint; |
|
7217 |
XSetWMHints(dpy, win, &wmhints); |
|
7218 |
} |
|
7219 |
||
7220 |
if (szhints.flags) { |
|
7221 |
XSetNormalHints(dpy, win, &szhints); |
|
7222 |
} |
|
7223 |
||
7224 |
XMapWindow(dpy, win); |
|
7225 |
RETURN ( self ); |
|
7226 |
} |
|
7227 |
%} |
|
7228 |
. |
|
7229 |
self primitiveFailed |
|
7230 |
! |
|
7231 |
||
7232 |
mapWindow:aWindowId |
|
7233 |
"make a window visible" |
|
7234 |
||
7235 |
%{ /* NOCONTEXT */ |
|
7236 |
||
7237 |
if (__isExternalAddress(aWindowId)) { |
|
7238 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
|
7239 |
RETURN ( self ); |
|
7240 |
} |
|
7241 |
%} |
|
7242 |
. |
|
7243 |
self primitiveFailed |
|
7244 |
! |
|
7245 |
||
7246 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
|
7247 |
"move and resize a window" |
|
7248 |
||
7249 |
%{ /* NOCONTEXT */ |
|
7250 |
||
7251 |
int newWidth, newHeight; |
|
7252 |
||
7253 |
if (__isExternalAddress(aWindowId) |
|
7254 |
&& __bothSmallInteger(w, h) |
|
7255 |
&& __bothSmallInteger(x, y)) { |
|
7256 |
newWidth = _intVal(w); |
|
7257 |
newHeight = _intVal(h); |
|
7258 |
if (newWidth < 1) newWidth = 1; |
|
7259 |
if (newHeight < 1) newHeight = 1; |
|
7260 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
7261 |
_intVal(x), _intVal(y), |
|
7262 |
newWidth, newHeight); |
|
7263 |
RETURN ( self ); |
|
7264 |
} |
|
7265 |
%} |
|
7266 |
. |
|
7267 |
self primitiveFailed |
|
7268 |
! |
|
7269 |
||
7270 |
moveWindow:aWindowId x:x y:y |
|
7271 |
"move a window" |
|
7272 |
||
7273 |
%{ /* NOCONTEXT */ |
|
7274 |
||
7275 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
|
7276 |
XMoveWindow(myDpy, _WindowVal(aWindowId), _intVal(x), _intVal(y)); |
|
7277 |
RETURN ( self ); |
|
7278 |
} |
|
7279 |
%} |
|
7280 |
. |
|
7281 |
self primitiveFailed |
|
7282 |
! |
|
7283 |
||
7284 |
raiseWindow:aWindowId |
|
7285 |
"bring a window to front" |
|
7286 |
||
7287 |
%{ /* NOCONTEXT */ |
|
7288 |
||
7289 |
if (__isExternalAddress(aWindowId)) { |
|
7290 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
|
7291 |
RETURN ( self ); |
|
7292 |
} |
|
7293 |
%} |
|
7294 |
. |
|
7295 |
self primitiveFailed |
|
7296 |
! |
|
7297 |
||
7298 |
resizeWindow:aWindowId width:w height:h |
|
7299 |
"resize a window" |
|
7300 |
||
7301 |
%{ /* NOCONTEXT */ |
|
7302 |
||
7303 |
int newWidth, newHeight; |
|
7304 |
||
7305 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
|
7306 |
newWidth = _intVal(w); |
|
7307 |
newHeight = _intVal(h); |
|
7308 |
if (newWidth < 1) newWidth = 1; |
|
7309 |
if (newHeight < 1) newHeight = 1; |
|
7310 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
7311 |
RETURN ( self ); |
|
7312 |
} |
|
7313 |
%} |
|
7314 |
. |
|
7315 |
self primitiveFailed |
|
7316 |
! |
|
7317 |
||
7318 |
setBackingStore:how in:aWindowId |
|
7319 |
"turn on/off backing-store for a window" |
|
7320 |
||
7321 |
%{ /* NOCONTEXT */ |
|
7322 |
||
7323 |
XSetWindowAttributes wa; |
|
7324 |
||
7325 |
if (__isExternalAddress(aWindowId)) { |
|
7326 |
if (_INST(ignoreBackingStore) != true) { |
|
7327 |
if (how == @symbol(always)) wa.backing_store = Always; |
|
7328 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
7329 |
else if (how == true) wa.backing_store = Always; |
|
7330 |
else wa.backing_store = 0; |
|
7331 |
BEGIN_INTERRUPTSBLOCKED |
|
7332 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
7333 |
END_INTERRUPTSBLOCKED |
|
7334 |
} |
|
7335 |
RETURN ( self ); |
|
7336 |
} |
|
7337 |
%}. |
|
7338 |
self primitiveFailed |
|
7339 |
! |
|
7340 |
||
7341 |
setBitGravity:how in:aWindowId |
|
7342 |
"set bit gravity for a window" |
|
7343 |
||
7344 |
%{ /* NOCONTEXT */ |
|
7345 |
||
7346 |
XSetWindowAttributes wa; |
|
7347 |
||
7348 |
if (__isExternalAddress(aWindowId)) { |
|
7349 |
if (how == @symbol(NorthWest)) { |
|
7350 |
wa.bit_gravity = NorthWestGravity; |
|
7351 |
} else if (how == @symbol(NorthEast)) { |
|
7352 |
wa.bit_gravity = NorthEastGravity; |
|
7353 |
} else if (how == @symbol(SouthWest)) { |
|
7354 |
wa.bit_gravity = SouthWestGravity; |
|
7355 |
} else if (how == @symbol(SouthEast)) { |
|
7356 |
wa.bit_gravity = SouthEastGravity; |
|
7357 |
} else if (how == @symbol(Center)) { |
|
7358 |
wa.bit_gravity = CenterGravity; |
|
7359 |
} else if (how == @symbol(North)) { |
|
7360 |
wa.bit_gravity = NorthGravity; |
|
7361 |
} else if (how == @symbol(South)) { |
|
7362 |
wa.bit_gravity = SouthGravity; |
|
7363 |
} else if (how == @symbol(West)) { |
|
7364 |
wa.bit_gravity = WestGravity; |
|
7365 |
} else if (how == @symbol(East)) { |
|
7366 |
wa.bit_gravity = EastGravity; |
|
7367 |
} else { |
|
7368 |
wa.bit_gravity = NorthWestGravity; |
|
7369 |
} |
|
7370 |
||
7371 |
BEGIN_INTERRUPTSBLOCKED |
|
7372 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
7373 |
END_INTERRUPTSBLOCKED |
|
7374 |
RETURN ( self ); |
|
7375 |
} |
|
7376 |
%}. |
|
7377 |
self primitiveFailed |
|
7378 |
! |
|
7379 |
||
7380 |
setCursor:aCursorId in:aWindowId |
|
7381 |
"define a windows cursor" |
|
7382 |
||
7383 |
%{ /* NOCONTEXT */ |
|
7384 |
||
7385 |
Display *dpy = myDpy; |
|
7386 |
||
7387 |
if (__isExternalAddress(aWindowId) |
|
7388 |
&& __isExternalAddress(aCursorId)) { |
|
7389 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
|
7390 |
RETURN ( self ); |
|
7391 |
} |
|
7392 |
%}. |
|
7393 |
self primitiveFailed |
|
7394 |
! |
|
7395 |
||
7396 |
setIconName:aString in:aWindowId |
|
7397 |
"define a windows iconname" |
|
7398 |
||
7399 |
%{ /* NOCONTEXT */ |
|
7400 |
||
7401 |
if (__isExternalAddress(aWindowId) |
|
7402 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
7403 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
7404 |
RETURN ( self ); |
|
7405 |
} |
|
7406 |
%}. |
|
7407 |
self primitiveFailed |
|
7408 |
! |
|
7409 |
||
7410 |
setSaveUnder:yesOrNo in:aWindowId |
|
7411 |
"turn on/off save-under for a window" |
|
7412 |
||
7413 |
%{ /* NOCONTEXT */ |
|
7414 |
||
7415 |
XSetWindowAttributes wa; |
|
7416 |
||
7417 |
if (__isExternalAddress(aWindowId)) { |
|
7418 |
if (_INST(hasSaveUnder) == true) { |
|
7419 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
|
7420 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
7421 |
} |
|
7422 |
RETURN ( self ); |
|
7423 |
} |
|
7424 |
%}. |
|
7425 |
self primitiveFailed |
|
7426 |
! |
|
7427 |
||
7428 |
setTransient:aWindowId for:aMainWindowId |
|
7429 |
"set aWindowId to be a transient of aMainWindow" |
|
7430 |
||
7431 |
%{ /* NOCONTEXT */ |
|
7432 |
||
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7433 |
if (__isExternalAddress(aWindowId)) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7434 |
Window w; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7435 |
|
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7436 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7437 |
w = (Window) 0; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7438 |
} else { |
374 | 7439 |
if (__isExternalAddress(aMainWindowId)) { |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7440 |
w = _WindowVal(aMainWindowId); |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7441 |
} else { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7442 |
goto getOutOfHere; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7443 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7444 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7445 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
295 | 7446 |
RETURN ( self ); |
7447 |
} |
|
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7448 |
getOutOfHere: ; |
295 | 7449 |
%}. |
7450 |
self primitiveFailed |
|
7451 |
! |
|
7452 |
||
7453 |
setWindowBackground:aColorIndex in:aWindowId |
|
7454 |
"set the windows background color. This is the color with which |
|
7455 |
the view is filled whenever exposed. Do not confuse this with |
|
7456 |
the background drawing color, which is used with opaque drawing." |
|
7457 |
||
7458 |
%{ /* NOCONTEXT */ |
|
7459 |
||
7460 |
if (__isExternalAddress(aWindowId) |
|
7461 |
&& __isSmallInteger(aColorIndex)) { |
|
7462 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), _intVal(aColorIndex)); |
|
7463 |
RETURN ( self ); |
|
7464 |
} |
|
7465 |
%}. |
|
7466 |
self primitiveFailed |
|
7467 |
! |
|
7468 |
||
7469 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
|
7470 |
"set the windows background pattern to be a form. |
|
7471 |
This is the pattern with which the view is filled whenever exposed. |
|
7472 |
Do not confuse this with the background drawing color, which is used |
|
7473 |
with opaque drawing." |
|
7474 |
||
7475 |
%{ /* NOCONTEXT */ |
|
7476 |
||
7477 |
if (__isExternalAddress(aWindowId) |
|
7478 |
&& __isExternalAddress(aPixmapId)) { |
|
7479 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7480 |
RETURN ( self ); |
|
7481 |
} |
|
7482 |
%}. |
|
7483 |
self primitiveFailed |
|
7484 |
! |
|
7485 |
||
7486 |
setWindowBorderColor:aColorIndex in:aWindowId |
|
7487 |
"set the windows border color" |
|
7488 |
||
7489 |
%{ /* NOCONTEXT */ |
|
7490 |
||
7491 |
if (__isExternalAddress(aWindowId) |
|
7492 |
&& __isSmallInteger(aColorIndex)) { |
|
7493 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), _intVal(aColorIndex)); |
|
7494 |
RETURN ( self ); |
|
7495 |
} |
|
7496 |
%}. |
|
7497 |
self primitiveFailed |
|
7498 |
! |
|
7499 |
||
7500 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
|
7501 |
"set the windows border pattern" |
|
7502 |
||
7503 |
%{ /* NOCONTEXT */ |
|
7504 |
||
7505 |
if (__isExternalAddress(aWindowId) |
|
7506 |
&& __isExternalAddress(aPixmapId)) { |
|
7507 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7508 |
RETURN ( self ); |
|
7509 |
} |
|
7510 |
%} |
|
7511 |
. |
|
7512 |
self primitiveFailed |
|
7513 |
! |
|
7514 |
||
7515 |
setWindowBorderShape:aPixmapId in:aWindowId |
|
7516 |
"set the windows border shape" |
|
7517 |
||
7518 |
hasShapeExtension ifFalse:[^ self]. |
|
7519 |
||
7520 |
%{ /* NOCONTEXT */ |
|
7521 |
||
7522 |
#ifdef SHAPE |
|
7523 |
if (__isExternalAddress(aWindowId) |
|
7524 |
&& __isExternalAddress(aPixmapId)) { |
|
7525 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
|
7526 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
7527 |
RETURN ( self ); |
|
7528 |
} |
|
7529 |
#endif |
|
7530 |
%}. |
|
7531 |
self primitiveFailed |
|
7532 |
! |
|
7533 |
||
7534 |
setWindowBorderWidth:aNumber in:aWindowId |
|
7535 |
"set the windows border width" |
|
7536 |
||
7537 |
%{ /* NOCONTEXT */ |
|
7538 |
||
7539 |
if (__isExternalAddress(aWindowId) |
|
7540 |
&& __isSmallInteger(aNumber)) { |
|
7541 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), _intVal(aNumber)); |
|
7542 |
RETURN ( self ); |
|
7543 |
} |
|
7544 |
%}. |
|
7545 |
self primitiveFailed |
|
7546 |
! |
|
7547 |
||
7548 |
setWindowGravity:how in:aWindowId |
|
7549 |
"set window gravity for a window" |
|
7550 |
||
7551 |
%{ /* NOCONTEXT */ |
|
7552 |
||
7553 |
XSetWindowAttributes wa; |
|
7554 |
||
7555 |
if (__isExternalAddress(aWindowId)) { |
|
7556 |
if (how == @symbol(NorthWest)) { |
|
7557 |
wa.win_gravity = NorthWestGravity; |
|
7558 |
} else if (how == @symbol(NorthEast)) { |
|
7559 |
wa.win_gravity = NorthEastGravity; |
|
7560 |
} else if (how == @symbol(SouthWest)) { |
|
7561 |
wa.win_gravity = SouthWestGravity; |
|
7562 |
} else if (how == @symbol(SouthEast)) { |
|
7563 |
wa.win_gravity = SouthEastGravity; |
|
7564 |
} else if (how == @symbol(Center)) { |
|
7565 |
wa.win_gravity = CenterGravity; |
|
7566 |
} else if (how == @symbol(North)) { |
|
7567 |
wa.win_gravity = NorthGravity; |
|
7568 |
} else if (how == @symbol(South)) { |
|
7569 |
wa.win_gravity = SouthGravity; |
|
7570 |
} else if (how == @symbol(West)) { |
|
7571 |
wa.win_gravity = WestGravity; |
|
7572 |
} else if (how == @symbol(East)) { |
|
7573 |
wa.win_gravity = EastGravity; |
|
7574 |
} else { |
|
7575 |
wa.win_gravity = NorthWestGravity; |
|
7576 |
} |
|
7577 |
||
7578 |
BEGIN_INTERRUPTSBLOCKED |
|
7579 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
7580 |
END_INTERRUPTSBLOCKED |
|
7581 |
RETURN ( self ); |
|
7582 |
} |
|
7583 |
%}. |
|
7584 |
self primitiveFailed |
|
7585 |
! |
|
7586 |
||
7587 |
setWindowIcon:aForm in:aWindowId |
|
7588 |
"define a bitmap to be used as icon" |
|
7589 |
||
7590 |
|iconId| |
|
7591 |
||
7592 |
aForm notNil ifTrue:[ |
|
7593 |
iconId := aForm id |
|
7594 |
]. |
|
7595 |
%{ |
|
7596 |
if (__isExternalAddress(iconId) |
|
7597 |
&& __isExternalAddress(aWindowId)) { |
|
7598 |
XWMHints hints; |
|
7599 |
||
7600 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
7601 |
hints.flags = IconPixmapHint; |
|
7602 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
7603 |
RETURN ( self ); |
|
7604 |
} |
|
7605 |
%}. |
|
7606 |
self primitiveFailed |
|
7607 |
! |
|
7608 |
||
7609 |
setWindowIconWindow:aView in:aWindowId |
|
7610 |
"define a window to be used as icon" |
|
7611 |
||
7612 |
|iconWindowId| |
|
7613 |
||
7614 |
aView notNil ifTrue:[ |
|
7615 |
iconWindowId := aView id |
|
7616 |
]. |
|
7617 |
%{ |
|
7618 |
if (__isExternalAddress(iconWindowId) |
|
7619 |
&& __isExternalAddress(aWindowId)) { |
|
7620 |
XWMHints wmhints; |
|
7621 |
||
7622 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
7623 |
wmhints.flags = IconWindowHint; |
|
7624 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
7625 |
RETURN ( self ); |
|
7626 |
} |
|
7627 |
%}. |
|
7628 |
self primitiveFailed |
|
7629 |
! |
|
7630 |
||
7631 |
setWindowName:aString in:aWindowId |
|
7632 |
"define a windows name" |
|
7633 |
||
7634 |
%{ /* NOCONTEXT */ |
|
7635 |
||
7636 |
if (__isExternalAddress(aWindowId) |
|
7637 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
7638 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
7639 |
RETURN ( self ); |
|
7640 |
} |
|
7641 |
%}. |
|
7642 |
self primitiveFailed |
|
7643 |
! |
|
7644 |
||
7645 |
setWindowShape:aPixmapId in:aWindowId |
|
7646 |
"set the windows shape" |
|
7647 |
||
7648 |
hasShapeExtension ifFalse:[^ self]. |
|
7649 |
||
7650 |
%{ /* NOCONTEXT */ |
|
7651 |
||
7652 |
#ifdef SHAPE |
|
7653 |
if (__isExternalAddress(aWindowId) |
|
7654 |
&& __isExternalAddress(aPixmapId)) { |
|
7655 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
|
7656 |
0, 0, |
|
7657 |
_PixmapVal(aPixmapId), ShapeSet); |
|
7658 |
RETURN ( self ); |
|
7659 |
} |
|
7660 |
#endif |
|
7661 |
%}. |
|
7662 |
self primitiveFailed |
|
7663 |
! |
|
7664 |
||
7665 |
unmapWindow:aWindowId |
|
7666 |
"make a window invisible" |
|
7667 |
||
7668 |
%{ /* NOCONTEXT */ |
|
7669 |
||
7670 |
if (__isExternalAddress(aWindowId)) { |
|
7671 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
|
7672 |
RETURN ( self ); |
|
7673 |
} |
|
7674 |
%} |
|
7675 |
. |
|
7676 |
self primitiveFailed |
|
7677 |
! ! |
|
7678 |
||
7679 |
!XWorkstation class methodsFor:'documentation'! |
|
7680 |
||
7681 |
version |
|
466 | 7682 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.117 1996-02-27 01:10:42 cg Exp $' |
295 | 7683 |
! ! |
7684 |
XWorkstation initialize! |