author | Claus Gittinger <cg@exept.de> |
Wed, 05 Jun 1996 16:01:41 +0200 | |
changeset 790 | 05ea637c94c3 |
parent 788 | 23b4d0a26e3c |
child 811 | bf8721a1e3ec |
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 |
||
555 | 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 |
{ |
|
217 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); |
|
218 |
if (lastErrorMsg[0] == '\0') { |
|
70 | 219 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 220 |
} |
2 | 221 |
lastRequestCode = event->request_code; |
222 |
lastMinorCode = event->minor_code; |
|
223 |
lastResource = event->resourceid; |
|
224 |
||
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
225 |
if (@global(ErrorPrinting) == true) { |
219
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
226 |
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
|
227 |
event->request_code, event->request_code, |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
228 |
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
|
229 |
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
|
230 |
} |
43 | 231 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
232 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 233 |
return 0; |
234 |
} |
|
235 |
||
90 | 236 |
#ifdef VIRTUAL_ROOT |
0 | 237 |
/* |
18 | 238 |
* added since RootWindow-macro is not suficient |
239 |
* when virtual root-windows are involved (i.e. tvtwm) |
|
240 |
*/ |
|
241 |
static Window |
|
242 |
getRootWindow(dpy, screen) |
|
243 |
Display *dpy; |
|
244 |
{ |
|
245 |
Window root; |
|
246 |
Atom vRootAtom = None; |
|
247 |
int i; |
|
248 |
Window rootReturn, parentReturn; |
|
249 |
Window* children; |
|
250 |
unsigned int numChildren; |
|
251 |
||
252 |
root = RootWindow(dpy, screen); |
|
253 |
/* |
|
254 |
* on IRIS, this creates a badwindow error - why ? |
|
255 |
* children contains a funny window (000034) |
|
256 |
*/ |
|
90 | 257 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 258 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
70 | 259 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
260 |
if (vRootAtom != None) { |
|
261 |
for (i=0; i < numChildren; i++) { |
|
262 |
Atom actual_type; |
|
263 |
int actual_format; |
|
264 |
unsigned long nitems, bytesafter; |
|
265 |
Window* newRoot = (Window*) 0; |
|
266 |
||
267 |
if (children[i]) { |
|
268 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
269 |
0L, 1L, False, XA_WINDOW, |
|
270 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
271 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
272 |
root = *newRoot; |
|
273 |
break; |
|
274 |
} |
|
275 |
} |
|
276 |
} |
|
277 |
if (children) XFree( children ); |
|
278 |
} |
|
18 | 279 |
} |
90 | 280 |
# endif |
18 | 281 |
return root; |
282 |
} |
|
90 | 283 |
#endif |
0 | 284 |
%} |
78 | 285 |
! ! |
0 | 286 |
|
295 | 287 |
!XWorkstation class methodsFor:'documentation'! |
288 |
||
289 |
copyright |
|
290 |
" |
|
291 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
292 |
All Rights Reserved |
|
293 |
||
294 |
This software is furnished under a license and may be used |
|
295 |
only in accordance with the terms of that license and with the |
|
296 |
inclusion of the above copyright notice. This software may not |
|
297 |
be provided or otherwise made available to, or used by, any |
|
298 |
other person. No title to or ownership of the software is |
|
299 |
hereby transferred. |
|
300 |
" |
|
301 |
! |
|
302 |
||
303 |
documentation |
|
304 |
" |
|
305 |
this class provides the interface to X11. It redefines all required methods |
|
306 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
307 |
limited to one display - in theory, you can create Views on many displays |
|
308 |
simultanously. However, the default setup is for one display only. |
|
309 |
To support multiple displays, you will have to start another event dispatcher |
|
310 |
process for the other display(s) and create the other views with a slightly |
|
311 |
different protocol. However, 'normal' applications do not have to care for |
|
312 |
all of this ... |
|
313 |
||
314 |
See more documentation in my superclass, DeviceWorkstation. |
|
613 | 315 |
|
316 |
[author:] |
|
317 |
Claus Gittinger |
|
295 | 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 |
||
715 | 410 |
^ 'X11' "I don't know what ST-80 returns for X ..." |
411 |
||
412 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
104 | 413 |
! ! |
414 |
||
0 | 415 |
!XWorkstation methodsFor:'accessing & queries'! |
416 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
417 |
anyButtonMotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
418 |
"return the state-mask for any button in motion events' state-field. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
419 |
This is the devices mask." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
420 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
421 |
%{ /* NOCONTEXT */ |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
422 |
RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
423 |
%}. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
424 |
^ nil |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
425 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
426 |
|
295 | 427 |
blackpixel |
428 |
"return the colornumber of black" |
|
429 |
||
430 |
^ blackpixel |
|
431 |
! |
|
432 |
||
433 |
button1MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
434 |
"return the state-mask for button1 in motion events' state-field. |
295 | 435 |
For backward compatibility." |
436 |
||
437 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
438 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 439 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
440 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
441 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
442 |
Display button1MotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
443 |
" |
295 | 444 |
! |
445 |
||
446 |
button2MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
447 |
"return the state-mask for button2 in motion events' state-field |
295 | 448 |
For backward compatibility." |
449 |
||
450 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
451 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 452 |
%} |
453 |
! |
|
454 |
||
455 |
button3MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
456 |
"return the state-mask for button3 in motion events' state-field |
295 | 457 |
For backward compatibility." |
458 |
||
459 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
460 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 461 |
%} |
462 |
! |
|
463 |
||
464 |
buttonMotionMask:aButton |
|
465 |
"return the state-mask for button1 in motion events state-field. |
|
466 |
This is the devices mask." |
|
467 |
||
468 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
469 |
if (aButton == __MKSMALLINT(1)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
470 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
471 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
472 |
if (aButton == __MKSMALLINT(2)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
473 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
474 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
475 |
if (aButton == __MKSMALLINT(3)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
476 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 477 |
} |
478 |
%}. |
|
479 |
^ nil |
|
480 |
! |
|
481 |
||
382 | 482 |
controlMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
483 |
"return the state-mask for the CTRL modified in motion events' state-field." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
484 |
|
382 | 485 |
%{ /* NOCONTEXT */ |
486 |
RETURN (__MKSMALLINT(ControlMask)); |
|
487 |
%} |
|
488 |
! |
|
489 |
||
295 | 490 |
defaultEventMask |
491 |
"return a mask to enable some events by default." |
|
492 |
||
493 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
494 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
295 | 495 |
KeyPressMask | KeyReleaseMask | |
496 |
EnterWindowMask | LeaveWindowMask | |
|
497 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
498 |
%} |
|
499 |
! |
|
500 |
||
0 | 501 |
displayFileDescriptor |
502 |
"return the displays fileNumber - for select" |
|
503 |
||
504 |
%{ /* NOCONTEXT */ |
|
505 |
||
150 | 506 |
if (ISCONNECTED) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
507 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 508 |
} |
509 |
RETURN (nil); |
|
0 | 510 |
%} |
511 |
! |
|
512 |
||
133 | 513 |
displayName |
514 |
"return the X-connections display name. |
|
515 |
This is (currently) nil for the default display, |
|
516 |
something like foo:0 for any other remote display. |
|
517 |
Future versions may return non-nil strings for the default display as well." |
|
518 |
||
519 |
^ displayName |
|
520 |
! |
|
521 |
||
341 | 522 |
protocolVersion |
523 |
"return the X-servers protocol version - should normally not be of |
|
524 |
any interest" |
|
525 |
||
526 |
%{ /* NOCONTEXT */ |
|
527 |
if (ISCONNECTED) { |
|
528 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
|
529 |
} |
|
530 |
RETURN (nil); |
|
531 |
%} |
|
532 |
||
533 |
" |
|
534 |
Display protocolVersion |
|
535 |
" |
|
536 |
! |
|
537 |
||
538 |
serverVendor |
|
539 |
"return the X-server vendor string - this should normally not be of |
|
540 |
any interest, but can be for special cases |
|
541 |
(to avoid bugs in certain implementations)" |
|
542 |
%{ |
|
543 |
if (ISCONNECTED) { |
|
544 |
RETURN ( __MKSTRING(XServerVendor(myDpy) COMMA_CON) ); |
|
545 |
} |
|
546 |
RETURN (nil); |
|
547 |
%} |
|
548 |
||
549 |
" |
|
550 |
Display serverVendor |
|
551 |
" |
|
552 |
! |
|
553 |
||
382 | 554 |
shiftMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
555 |
"return the state-mask for the SHIFT modified in motion events' state-field." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
556 |
|
382 | 557 |
%{ /* NOCONTEXT */ |
558 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
559 |
%} |
|
560 |
! |
|
561 |
||
341 | 562 |
translatePoint:aPoint from:windowId1 to:windowId2 |
563 |
"given a point in window1, return the coordinate in window2. |
|
564 |
This expects a device coordinate (relative to the first views origin) |
|
565 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
566 |
- use to xlate points from a window to rootwindow" |
|
567 |
||
568 |
|x1 y1 x2 y2| |
|
569 |
||
570 |
x1 := x2 := aPoint x truncated. |
|
571 |
y1 := y2 := aPoint y truncated. |
|
572 |
%{ |
|
573 |
int xpos, ypos; |
|
574 |
Window w1, w2, child_return; |
|
555 | 575 |
int screen = __intVal(__INST(screen)); |
341 | 576 |
Display *dpy = myDpy; |
577 |
||
578 |
if (__isExternalAddress(windowId1) |
|
579 |
&& __isExternalAddress(windowId2) |
|
580 |
&& __bothSmallInteger(x1, y1)) { |
|
581 |
w1 = _WindowVal(windowId1); |
|
582 |
w2 = _WindowVal(windowId2); |
|
583 |
#ifdef VIRTUAL_ROOT |
|
584 |
if ((w1 == RootWindow(dpy, screen)) |
|
585 |
|| (w2 == RootWindow(dpy, screen))) { |
|
586 |
if (w1 == RootWindow(dpy, screen)) { |
|
587 |
w1 = getRootWindow(dpy, screen); |
|
588 |
} |
|
589 |
if (w2 == RootWindow(dpy, screen)) { |
|
590 |
w2 = getRootWindow(dpy, screen); |
|
591 |
} |
|
592 |
} |
|
593 |
#endif |
|
594 |
BEGIN_INTERRUPTSBLOCKED |
|
595 |
XTranslateCoordinates(dpy, w1, w2, |
|
555 | 596 |
__intVal(x1), __intVal(y1), |
341 | 597 |
&xpos, &ypos, &child_return); |
598 |
END_INTERRUPTSBLOCKED |
|
599 |
x2 = __MKSMALLINT(xpos); |
|
600 |
y2 = __MKSMALLINT(ypos); |
|
601 |
} |
|
602 |
%}. |
|
603 |
||
604 |
^ (x2 @ y2) |
|
605 |
! |
|
606 |
||
607 |
vendorRelease |
|
608 |
"return the X-servers vendor release - should normally not be of |
|
609 |
any interest, but can be for special cases. |
|
610 |
(to avoid bugs in certain implementations)" |
|
611 |
||
612 |
%{ /* NOCONTEXT */ |
|
613 |
if (ISCONNECTED) { |
|
614 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
|
615 |
} |
|
616 |
RETURN (nil); |
|
617 |
%} |
|
618 |
||
619 |
" |
|
620 |
Display vendorRelease |
|
621 |
" |
|
622 |
! |
|
623 |
||
624 |
viewIdFromPoint:aPoint in:windowId |
|
625 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
626 |
hit by this coordinate. Return nil if no view was hit. |
|
627 |
The returned id may be the id of a non ST view. |
|
628 |
- used to find the window to drop objects after a cross-view drag." |
|
629 |
||
630 |
%{ /* NOCONTEXT */ |
|
631 |
||
632 |
Display *dpy = myDpy; |
|
555 | 633 |
int screen = __intVal(__INST(screen)); |
341 | 634 |
OBJ xp, yp; |
635 |
int xpos, ypos; |
|
636 |
Window child_return; |
|
637 |
||
638 |
if (__isExternalAddress(windowId) |
|
639 |
&& __isPoint(aPoint)) { |
|
640 |
xp = _point_X(aPoint); |
|
641 |
yp = _point_Y(aPoint); |
|
642 |
if (__bothSmallInteger(xp, yp)) { |
|
643 |
BEGIN_INTERRUPTSBLOCKED |
|
644 |
XTranslateCoordinates(dpy, |
|
645 |
RootWindow(dpy, screen), |
|
646 |
_WindowVal(windowId), |
|
555 | 647 |
__intVal(xp), __intVal(yp), |
341 | 648 |
&xpos, &ypos, &child_return); |
649 |
END_INTERRUPTSBLOCKED |
|
650 |
if (child_return) { |
|
651 |
RETURN ( __MKOBJ(child_return) ); |
|
652 |
} |
|
653 |
RETURN ( nil ); |
|
654 |
} |
|
655 |
} |
|
656 |
%}. |
|
657 |
windowId notNil ifTrue:[ |
|
658 |
aPoint isPoint ifTrue:[ |
|
659 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
660 |
] |
|
661 |
]. |
|
662 |
||
663 |
^ nil |
|
664 |
! |
|
665 |
||
666 |
virtualExtent |
|
667 |
"return the virtual extent of the display (in pixels). |
|
668 |
On most systems, this is the same as the physical width; |
|
669 |
except, if a window manager with a virtual desktop like olvwm |
|
670 |
(simulating a bigger screen) is running." |
|
671 |
||
672 |
%{ |
|
555 | 673 |
if ((__INST(rootId) != __INST(virtualRootId)) |
674 |
&& __isExternalAddress(__INST(virtualRootId))) { |
|
341 | 675 |
Window vRootWin; |
676 |
Window root; |
|
677 |
int x, y; |
|
678 |
unsigned int width, height; |
|
679 |
unsigned int dummy; |
|
680 |
||
555 | 681 |
vRootWin = _WindowVal(__INST(virtualRootId)); |
341 | 682 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
683 |
&dummy, &dummy)) { |
|
684 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
685 |
} |
|
686 |
} |
|
687 |
%}. |
|
688 |
^ width @ height |
|
689 |
! |
|
690 |
||
691 |
whitepixel |
|
692 |
"return the colornumber of white" |
|
693 |
||
694 |
^ whitepixel |
|
695 |
! ! |
|
696 |
||
697 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
698 |
||
0 | 699 |
hasDPS |
186 | 700 |
"return true, if this workstation supports display postscript. |
701 |
Both the server must support it, and the feature must have been |
|
702 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 703 |
|
704 |
^ hasDPSExtension |
|
186 | 705 |
|
706 |
" |
|
707 |
Display hasDPS |
|
708 |
" |
|
709 |
! |
|
710 |
||
150 | 711 |
hasExtension:extensionString |
712 |
"query for an X extension. The argument, extensionString |
|
713 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 714 |
Return true, if that extension is available in the server. |
715 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 716 |
|
717 |
%{ |
|
718 |
int dummy; |
|
719 |
||
720 |
if (__isString(extensionString) && ISCONNECTED) { |
|
721 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
|
722 |
RETURN ( true ); |
|
723 |
} |
|
724 |
} |
|
725 |
%}. |
|
726 |
^ false |
|
186 | 727 |
|
728 |
" |
|
729 |
Display hasExtension:'XVideo' |
|
730 |
Display hasExtension:'Input' |
|
731 |
Display hasExtension:'GLX' |
|
732 |
Display hasExtension:'X3D-PEX' |
|
733 |
Display hasExtension:'XInputExtension' |
|
734 |
Display hasExtension:'SHAPE' |
|
735 |
Display hasExtension:'MIT-SHM' |
|
736 |
Display hasExtension:'SGIFullScreenStereo' |
|
737 |
" |
|
150 | 738 |
! |
739 |
||
295 | 740 |
hasFax |
741 |
"return true, if this workstation supports decompression of fax images. |
|
742 |
Both the server must support it, and the feature must have been |
|
743 |
enabled in the smalltalk system, for true to be returned." |
|
744 |
||
745 |
^ hasFaxExtension |
|
746 |
||
747 |
" |
|
748 |
Display hasFaxExtension |
|
749 |
" |
|
750 |
! |
|
751 |
||
752 |
hasImageExtension |
|
753 |
"return true, if this workstation supports the X image extension. |
|
754 |
Both the server must support it, and the feature must have been |
|
755 |
enabled in the smalltalk system, for true to be returned." |
|
756 |
||
757 |
^ hasImageExtension |
|
758 |
||
759 |
" |
|
760 |
Display hasImageExtension |
|
761 |
" |
|
762 |
! |
|
763 |
||
764 |
hasInputExtension |
|
765 |
"return true, if this workstation supports the X input extension. |
|
766 |
Both the server must support it, and the feature must have been |
|
767 |
enabled in the smalltalk system, for true to be returned." |
|
768 |
||
769 |
^ hasInputExtension |
|
770 |
||
771 |
" |
|
772 |
Display hasInputExtension |
|
773 |
" |
|
774 |
! |
|
775 |
||
776 |
hasMultibuffer |
|
777 |
"return true, if this workstation supports the multibuffer extension. |
|
778 |
Both the server must support it, and the feature must have been |
|
779 |
enabled in the smalltalk system, for true to be returned." |
|
780 |
||
781 |
^ hasMbufExtension |
|
782 |
||
783 |
" |
|
784 |
Display hasMultibuffer |
|
785 |
" |
|
786 |
! |
|
787 |
||
788 |
hasPEX |
|
789 |
"return true, if this workstation supports PEX 3D graphics. |
|
790 |
Both the server must support it, and the feature must have been |
|
791 |
enabled in the smalltalk system, for true to be returned." |
|
792 |
||
793 |
^ hasPEXExtension |
|
794 |
||
795 |
" |
|
796 |
Display hasPEX |
|
797 |
" |
|
798 |
! |
|
799 |
||
800 |
hasShape |
|
801 |
"return true, if this workstation supports non-rectangular windows. |
|
802 |
Both the server must support it, and the feature must have been |
|
803 |
enabled in the smalltalk system, for true to be returned." |
|
804 |
||
805 |
^ hasShapeExtension |
|
806 |
||
807 |
" |
|
808 |
Display hasShape |
|
809 |
" |
|
810 |
! |
|
811 |
||
812 |
hasShm |
|
813 |
"return true, if this workstation supports the shared pixmap extension. |
|
814 |
Both the server must support it, and the feature must have been |
|
815 |
enabled in the smalltalk system, for true to be returned." |
|
816 |
||
817 |
^ hasShmExtension |
|
818 |
||
819 |
" |
|
820 |
Display hasShm |
|
821 |
" |
|
822 |
! |
|
823 |
||
824 |
hasXVideo |
|
825 |
"return true, if this workstation supports the XVideo extension. |
|
826 |
Both the server must support it, and the feature must have been |
|
827 |
enabled in the smalltalk system, for true to be returned." |
|
828 |
||
829 |
^ hasXVideoExtension |
|
830 |
||
831 |
" |
|
832 |
Display hasXVideo |
|
833 |
" |
|
834 |
! |
|
835 |
||
836 |
iconSizes |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
837 |
"Get the preferred/supported icon sizes. These are set by the window manager. |
295 | 838 |
We return nil (if not set) or an OrderedCollection of Intervals." |
839 |
||
840 |
|xIconSizes count ret| |
|
841 |
||
842 |
%{ |
|
843 |
Display *dpy = myDpy; |
|
555 | 844 |
int screen = __intVal(__INST(screen)); |
295 | 845 |
XIconSize *sizeList; |
846 |
int cnt; |
|
847 |
||
848 |
if (ISCONNECTED) { |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
849 |
if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) { |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
850 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
851 |
count = __MKSMALLINT(cnt); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
852 |
} |
295 | 853 |
} |
854 |
%}. |
|
855 |
xIconSizes isNil ifTrue:[^ nil]. |
|
856 |
||
857 |
ret := OrderedCollection new:count. |
|
858 |
1 to:count do:[ :i | |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
859 |
| startX startY stopX stopY stepX stepY| |
295 | 860 |
|
861 |
%{ |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
862 |
XIconSize *slp; |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
863 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
864 |
slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1]; |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
865 |
startX = __MKSMALLINT(slp->min_width); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
866 |
startY = __MKSMALLINT(slp->min_height); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
867 |
stopX = __MKSMALLINT(slp->max_width); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
868 |
stopY = __MKSMALLINT(slp->max_height); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
869 |
stepX = __MKSMALLINT(slp->width_inc); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
870 |
stepY = __MKSMALLINT(slp->height_inc); |
295 | 871 |
%}. |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
872 |
ret add:(Interval from:startX@startY to:stopX@stopY by:stepX@stepY) |
295 | 873 |
]. |
874 |
||
875 |
xIconSizes free. |
|
876 |
^ ret |
|
877 |
||
878 |
" |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
879 |
Display iconSizes OrderedCollection(Interval(16@16 17@17 18@18 19@19 20@20 21@21 22@22 23@23 24@24 25@25 26@26 27@27 28@28 29@29 30@30 31@31 32@32 33@33 34@34 35@35 36@36 37@37 38@38 39@39 40@40 41@41 42@42 43@43 44@44 45@45 46@46 47@47 48@48 49@49 50@50 51@51 52@52 53@53 54@54 55@55 56@56 57@57 58@58 59@59 60@60 61@61 62@62 63@63 64@64 65@65 66@66 67@67 68@68 69@69 70@70 71@71 72@72 73@73 74@74 75@75 76@76 77@77 78@78 79@79 80@80 81@81 82@82 83@83 84@84 85@85)) |
295 | 880 |
" |
881 |
! |
|
882 |
||
341 | 883 |
ignoreBackingStore:aBoolean |
884 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
885 |
no backing store used - this can be used on servers where backing store is |
|
886 |
very slow or is broken (can be put into display-rc-file)" |
|
887 |
||
888 |
ignoreBackingStore := aBoolean |
|
295 | 889 |
! |
890 |
||
43 | 891 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
892 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
893 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
894 |
depth, bitsPerPixel and padding values." |
43 | 895 |
|
150 | 896 |
|nFormats "{ Class: SmallInteger }" |
897 |
formatArray| |
|
43 | 898 |
%{ |
899 |
Display *dpy = myDpy; |
|
150 | 900 |
|
901 |
if (! ISCONNECTED) { |
|
902 |
RETURN (nil); |
|
903 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
904 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 905 |
%}. |
906 |
formatArray := Array new:nFormats. |
|
150 | 907 |
1 to:nFormats do:[:index | |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
908 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
150 | 909 |
|
910 |
i := index. |
|
43 | 911 |
%{ |
70 | 912 |
ScreenFormat *format; |
913 |
Display *dpy = myDpy; |
|
914 |
||
90 | 915 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
555 | 916 |
format += (__intVal(i)-1); |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
917 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
918 |
depthInfo = __MKSMALLINT(format->depth); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
919 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
43 | 920 |
%}. |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
921 |
info := IdentityDictionary new. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
922 |
info at:#depth put:depthInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
923 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
924 |
info at:#padding put:paddingInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
925 |
formatArray at:index put:info. |
43 | 926 |
]. |
927 |
^ formatArray |
|
928 |
||
929 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
930 |
Display supportedImageFormats |
43 | 931 |
" |
932 |
! |
|
933 |
||
81 | 934 |
supportsDeepIcons |
935 |
"return true, if this device supports non b&w (i.e. greyScale |
|
936 |
or colored icons). Many Xservers (and/or windowManagers) crash, |
|
186 | 937 |
if you pass them a deep form as icon; therefore, we return false. |
938 |
It may be a good idea to check for the server vendor/release and |
|
939 |
return trie sometimes." |
|
81 | 940 |
|
941 |
^ false |
|
942 |
! |
|
943 |
||
944 |
supportsViewGravity |
|
945 |
"return true, if this device supports gravity attributes. |
|
82 | 946 |
We do not depend on it being implemented, but some resizing operations |
81 | 947 |
are faster, it is is." |
948 |
||
949 |
^ true |
|
0 | 950 |
! ! |
951 |
||
952 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
953 |
||
295 | 954 |
createBitmapFromArray:anArray width:w height:h |
955 |
|bitmapId| |
|
956 |
||
957 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
958 |
bitmapId isNil ifTrue:[ |
|
959 |
self primitiveFailed |
|
960 |
]. |
|
961 |
^ bitmapId |
|
962 |
! |
|
963 |
||
964 |
createBitmapFromFile:aString for:aForm |
|
965 |
|id w h| |
|
966 |
||
967 |
%{ |
|
968 |
Display *dpy = myDpy; |
|
555 | 969 |
int screen = __intVal(__INST(screen)); |
295 | 970 |
Pixmap newBitmap; |
971 |
char *filename; |
|
972 |
unsigned b_width, b_height; |
|
973 |
int b_x_hot, b_y_hot; |
|
974 |
int status; |
|
975 |
||
976 |
if (ISCONNECTED) { |
|
977 |
if (__isString(aString) || __isSymbol(aString)) { |
|
978 |
filename = (char *)_stringVal(aString); |
|
979 |
||
980 |
BEGIN_INTERRUPTSBLOCKED |
|
981 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
982 |
filename, &b_width, &b_height, &newBitmap, |
|
983 |
&b_x_hot, &b_y_hot); |
|
984 |
END_INTERRUPTSBLOCKED |
|
985 |
||
986 |
if (status == BitmapSuccess) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
987 |
w = __MKSMALLINT(b_width); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
988 |
h = __MKSMALLINT(b_height); |
295 | 989 |
id = __MKOBJ(newBitmap); |
990 |
} |
|
991 |
} |
|
992 |
} |
|
993 |
%}. |
|
994 |
id notNil ifTrue:[ |
|
995 |
aForm setWidth:w height:h |
|
996 |
]. |
|
997 |
^ id |
|
998 |
! |
|
999 |
||
1000 |
createBitmapWidth:w height:h |
|
1001 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1002 |
(i.e. random). Return a bitmap id or nil" |
|
1003 |
||
1004 |
%{ /* NOCONTEXT */ |
|
1005 |
||
1006 |
Display *dpy = myDpy; |
|
555 | 1007 |
int screen = __intVal(__INST(screen)); |
295 | 1008 |
Pixmap newBitmap; |
1009 |
||
1010 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1011 |
BEGIN_INTERRUPTSBLOCKED |
|
1012 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1013 |
__intVal(w), __intVal(h), 1); |
295 | 1014 |
END_INTERRUPTSBLOCKED |
1015 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
1016 |
} |
|
1017 |
%} |
|
1018 |
. |
|
1019 |
self primitiveFailed. |
|
1020 |
^ nil |
|
1021 |
! |
|
1022 |
||
0 | 1023 |
createFaxImageFromArray:data width:w height:h type:type k:k msbFirst:msbFirst |
1024 |
"create a new faxImage in the workstation |
|
1025 |
type: 0 -> uncompressed |
|
70 | 1026 |
1 -> group3 1D (k is void) |
1027 |
2 -> group3 2D |
|
1028 |
3 -> group4 2D (k is void)" |
|
0 | 1029 |
|
1030 |
|nBytes| |
|
1031 |
||
1032 |
hasFaxExtension ifFalse:[^ nil]. |
|
1033 |
nBytes := data size. |
|
1034 |
%{ |
|
1035 |
#ifdef FAX |
|
1036 |
Display *dpy = myDpy; |
|
555 | 1037 |
int screen = __intVal(__INST(screen)); |
0 | 1038 |
FAXImage newImage; |
1039 |
int _type, _msb, _k = 0; |
|
1040 |
unsigned char *bits; |
|
1041 |
||
97 | 1042 |
if (__bothSmallInteger(w, h) |
1043 |
&& __bothSmallInteger(type, k) |
|
1044 |
&& __isSmallInteger(nBytes) |
|
44 | 1045 |
&& __isByteArray(data)) { |
70 | 1046 |
if (msbFirst == true) |
1047 |
_msb = 1; |
|
1048 |
else |
|
1049 |
_msb = 0; |
|
555 | 1050 |
_type = __intVal(type); |
70 | 1051 |
if ((_type < 0) || (_type > 3)) { |
1052 |
RETURN ( nil ); |
|
1053 |
} |
|
1054 |
if (_type == 2) { |
|
97 | 1055 |
if (! __isSmallInteger(k)) { |
70 | 1056 |
RETURN ( nil ); |
1057 |
} |
|
555 | 1058 |
_k = __intVal(k); |
70 | 1059 |
} |
555 | 1060 |
bits = __ByteArrayInstPtr(data)->ba_element; |
70 | 1061 |
BEGIN_INTERRUPTSBLOCKED |
555 | 1062 |
newImage = XFAXImageCreateImage(dpy, __intVal(w), __intVal(h), |
70 | 1063 |
_type, _k, _msb, |
555 | 1064 |
__intVal(nBytes), bits); |
70 | 1065 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1066 |
RETURN ( (newImage != (FAXImage)0) ? __MKOBJ(newImage) : nil ); |
0 | 1067 |
} |
1068 |
#else |
|
1069 |
RETURN ( nil ); |
|
1070 |
#endif |
|
1071 |
%} |
|
1072 |
. |
|
43 | 1073 |
self primitiveFailed. |
1074 |
^ nil |
|
0 | 1075 |
! |
1076 |
||
1077 |
createPixmapWidth:w height:h depth:d |
|
1078 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1079 |
(i.e. random). Return a bitmap id or nil" |
|
1080 |
||
1081 |
%{ /* NOCONTEXT */ |
|
1082 |
||
1083 |
Display *dpy = myDpy; |
|
555 | 1084 |
int screen = __intVal(__INST(screen)); |
0 | 1085 |
Pixmap newBitmap; |
1086 |
||
150 | 1087 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
70 | 1088 |
BEGIN_INTERRUPTSBLOCKED |
1089 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1090 |
__intVal(w), __intVal(h), __intVal(d)); |
70 | 1091 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1092 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
0 | 1093 |
} |
1094 |
%} |
|
1095 |
. |
|
43 | 1096 |
self primitiveFailed. |
1097 |
^ nil |
|
0 | 1098 |
! |
1099 |
||
1100 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
|
46 | 1101 |
"will vanish - for compatibility with previous versions" |
1102 |
||
1103 |
^ self |
|
780
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1104 |
createWindowFor:aView |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1105 |
origin:(xpos @ ypos) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1106 |
extent:(wwidth @ wheight) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1107 |
minExtent:(aView minExtent) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1108 |
maxExtent:(aView maxExtent) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1109 |
borderWidth:(aView borderWidth) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1110 |
subViewOf:(aView superView) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1111 |
onTop:(aView isPopUpView) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1112 |
inputOnly:(aView isInputOnly) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1113 |
label:(aView label) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1114 |
cursor:(aView cursor) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1115 |
icon:(aView icon) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1116 |
iconView:(aView iconView) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1117 |
|
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1118 |
"Modified: 1.6.1996 / 13:22:48 / cg" |
46 | 1119 |
! |
1120 |
||
1121 |
createWindowFor:aView |
|
70 | 1122 |
origin:origin |
1123 |
extent:extent |
|
1124 |
minExtent:minExt |
|
1125 |
maxExtent:maxExt |
|
1126 |
borderWidth:bWidth |
|
1127 |
subViewOf:wsuperView |
|
157 | 1128 |
onTop:wisPopUpView |
70 | 1129 |
inputOnly:winputOnly |
1130 |
label:wlabel |
|
1131 |
cursor:wcursor |
|
1132 |
icon:wicon |
|
1133 |
iconView:wiconView |
|
46 | 1134 |
|
1135 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1136 |
bColorId wsuperViewId wcursorId wiconId windowId |
|
1137 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
|
150 | 1138 |
vBgForm deepForm preferredVisual preferredDepth| |
1139 |
||
1140 |
displayId isNil ifTrue:[ |
|
1141 |
self primitiveFailed. |
|
1142 |
^ nil |
|
1143 |
]. |
|
0 | 1144 |
|
46 | 1145 |
origin notNil ifTrue:[ |
70 | 1146 |
xpos := origin x. |
1147 |
ypos := origin y. |
|
46 | 1148 |
] ifFalse:[ |
70 | 1149 |
xpos := ypos := 0. |
0 | 1150 |
]. |
46 | 1151 |
extent notNil ifTrue:[ |
70 | 1152 |
wwidth := extent x. |
1153 |
wheight := extent y. |
|
46 | 1154 |
] ifFalse:[ |
70 | 1155 |
wwidth := wheight := 100. |
46 | 1156 |
]. |
1157 |
minExt notNil ifTrue:[ |
|
70 | 1158 |
minWidth := minExt x. |
1159 |
minHeight := minExt y |
|
0 | 1160 |
]. |
46 | 1161 |
maxExt notNil ifTrue:[ |
70 | 1162 |
maxWidth := maxExt x. |
1163 |
maxHeight := maxExt y |
|
46 | 1164 |
]. |
1165 |
||
0 | 1166 |
wsuperView notNil ifTrue:[ |
70 | 1167 |
wsuperViewId := wsuperView id |
0 | 1168 |
]. |
1169 |
wcursor isNil ifTrue:[ |
|
145 | 1170 |
'XWORKSTATION: cursor nil - defaulted' errorPrintNL |
0 | 1171 |
] ifFalse:[ |
70 | 1172 |
wcursorId := wcursor id |
0 | 1173 |
]. |
1174 |
||
1175 |
wicon notNil ifTrue:[ |
|
70 | 1176 |
wiconId := wicon id |
0 | 1177 |
]. |
1178 |
wiconView notNil ifTrue:[ |
|
70 | 1179 |
wiconViewId := wiconView id |
0 | 1180 |
]. |
1181 |
weventMask := aView eventMask. |
|
1182 |
||
150 | 1183 |
preferredVisual := aView preferredVisual. |
1184 |
preferredDepth := aView preferredDepth. |
|
23 | 1185 |
|
72 | 1186 |
%{ /* STACK:16000 */ |
0 | 1187 |
Display *dpy = myDpy; |
555 | 1188 |
int screen = __intVal(__INST(screen)); |
0 | 1189 |
Visual visual; |
1190 |
XGCValues xgcv; |
|
1191 |
XSetWindowAttributes xswa; |
|
1192 |
XSizeHints sizehints; |
|
1193 |
XWMHints wmhints; |
|
46 | 1194 |
int bw, bd, bg; |
0 | 1195 |
Window newWindow, parentWindow; |
1196 |
char *windowName; |
|
1197 |
XFontStruct *f; |
|
1198 |
Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0; |
|
1199 |
int flags = 0, depth, ioClass; |
|
1200 |
Window iconWindow; |
|
1201 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1202 |
Atom WmQuitAppAtom; |
|
1203 |
Atom atoms[3]; |
|
1204 |
int atomCount = 0, isTopWindow = 0; |
|
1205 |
||
1206 |
sizehints.flags = 0; |
|
1207 |
sizehints.width = 100; |
|
1208 |
sizehints.height = 100; |
|
1209 |
sizehints.x = 0; |
|
1210 |
sizehints.y = 0; |
|
1211 |
||
97 | 1212 |
if (__bothSmallInteger(wwidth, wheight)) { |
70 | 1213 |
sizehints.flags |= PSize; |
555 | 1214 |
sizehints.width = __intVal(wwidth); |
1215 |
sizehints.height = __intVal(wheight); |
|
0 | 1216 |
} |
97 | 1217 |
if (__bothSmallInteger(xpos, ypos)) { |
70 | 1218 |
sizehints.flags |= PPosition; |
555 | 1219 |
sizehints.x = __intVal(xpos); |
1220 |
sizehints.y = __intVal(ypos); |
|
0 | 1221 |
} |
97 | 1222 |
if (__bothSmallInteger(minWidth, minHeight)) { |
70 | 1223 |
sizehints.flags |= PMinSize; |
555 | 1224 |
sizehints.min_width = __intVal(minWidth); |
1225 |
sizehints.min_height = __intVal(minHeight); |
|
0 | 1226 |
} |
97 | 1227 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
70 | 1228 |
sizehints.flags |= PMaxSize; |
555 | 1229 |
sizehints.max_width = __intVal(maxWidth); |
1230 |
sizehints.max_height = __intVal(maxHeight); |
|
0 | 1231 |
} |
1232 |
||
37 | 1233 |
bg = WhitePixel(dpy, screen); |
0 | 1234 |
|
97 | 1235 |
if (__isSmallInteger(bWidth)) { |
555 | 1236 |
bw = __intVal(bWidth); |
46 | 1237 |
} else { |
70 | 1238 |
bw = 0; |
0 | 1239 |
} |
1240 |
||
72 | 1241 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1242 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1243 |
if (__isExternalAddress(wsuperViewId)) { |
70 | 1244 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1245 |
} else { |
70 | 1246 |
parentWindow = RootWindow(dpy, screen); |
1247 |
isTopWindow = 1; |
|
0 | 1248 |
} |
1249 |
||
157 | 1250 |
if (wisPopUpView == true) |
70 | 1251 |
xswa.override_redirect = 1; |
0 | 1252 |
else |
70 | 1253 |
xswa.override_redirect = 0; |
0 | 1254 |
|
1255 |
if (winputOnly == true) |
|
70 | 1256 |
ioClass = InputOnly; |
0 | 1257 |
else |
70 | 1258 |
ioClass = InputOutput; |
0 | 1259 |
|
97 | 1260 |
if (__isSmallInteger(weventMask)) { |
555 | 1261 |
xswa.event_mask = __intVal(weventMask); |
0 | 1262 |
} else { |
70 | 1263 |
xswa.event_mask = 0; |
0 | 1264 |
} |
1265 |
||
1266 |
if (ioClass == InputOnly) { |
|
70 | 1267 |
bw = 0; |
1268 |
depth = 0; |
|
1269 |
flags |= CWEventMask; |
|
0 | 1270 |
} else { |
70 | 1271 |
depth = DefaultDepth(dpy,screen); |
1272 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
1273 |
||
1274 |
if (backPixmap != (Pixmap)0) { |
|
1275 |
xswa.background_pixmap = backPixmap; |
|
1276 |
flags |= CWBackPixmap; |
|
1277 |
} else { |
|
1278 |
xswa.background_pixel = bg; |
|
1279 |
flags |= CWBackPixel; |
|
1280 |
} |
|
1281 |
xswa.border_pixel = bd; |
|
0 | 1282 |
} |
23 | 1283 |
|
0 | 1284 |
visual.visualid = CopyFromParent; |
150 | 1285 |
if (__isSmallInteger(preferredDepth)) { |
555 | 1286 |
depth = __intVal(preferredDepth); |
23 | 1287 |
} |
54 | 1288 |
|
1289 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1290 |
if (preferredVisual != nil) { |
70 | 1291 |
XVisualInfo vi; |
1292 |
int cls; |
|
1293 |
||
150 | 1294 |
if (preferredVisual == @symbol(StaticGray)) |
70 | 1295 |
cls = StaticGray; |
150 | 1296 |
else if (preferredVisual == @symbol(GrayScale)) |
70 | 1297 |
cls = StaticGray; |
150 | 1298 |
else if (preferredVisual == @symbol(StaticColor)) |
70 | 1299 |
cls = StaticColor; |
150 | 1300 |
else if (preferredVisual == @symbol(PseudoColor)) |
70 | 1301 |
cls = PseudoColor; |
150 | 1302 |
else if (preferredVisual == @symbol(TrueColor)) |
70 | 1303 |
cls = TrueColor; |
150 | 1304 |
else if (preferredVisual == @symbol(DirectColor)) |
70 | 1305 |
cls = DirectColor; |
1306 |
else |
|
1307 |
cls = PseudoColor; |
|
200 | 1308 |
|
70 | 1309 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
1310 |
visual.visualid = vi.visualid; |
|
163 | 1311 |
/* |
1312 |
printf("visualId=%x\n", vi.visualid); |
|
1313 |
*/ |
|
70 | 1314 |
} |
23 | 1315 |
} |
0 | 1316 |
|
1317 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
70 | 1318 |
sizehints.x, sizehints.y, |
1319 |
sizehints.width, sizehints.height, |
|
1320 |
bw, depth, ioClass, &visual, |
|
1321 |
flags, &xswa); |
|
54 | 1322 |
END_INTERRUPTSBLOCKED |
0 | 1323 |
|
1324 |
if (! newWindow) { |
|
70 | 1325 |
RETURN ( nil ); |
0 | 1326 |
} |
1327 |
||
54 | 1328 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1329 |
/* |
1330 |
* define its cursor |
|
1331 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1332 |
if (__isExternalAddress(wcursorId)) { |
70 | 1333 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1334 |
} |
1335 |
||
1336 |
/* |
|
1337 |
* define its icon and name |
|
1338 |
* (only makes sense for topWindows) |
|
1339 |
*/ |
|
1340 |
if (isTopWindow) { |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1341 |
if (__isExternalAddress(wiconId)) |
70 | 1342 |
iconBitmap = _PixmapVal(wiconId); |
1343 |
else |
|
1344 |
iconBitmap = (Pixmap)0; |
|
1345 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1346 |
if (__isExternalAddress(wiconViewId)) |
70 | 1347 |
iconWindow = _WindowVal(wiconViewId); |
1348 |
else |
|
1349 |
iconWindow = (Window)0; |
|
1350 |
||
1351 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1352 |
windowName = (char *)_stringVal(wlabel); |
|
1353 |
else |
|
1354 |
windowName = ""; |
|
1355 |
||
1356 |
if (iconBitmap || windowName) { |
|
1357 |
XSetStandardProperties(dpy, newWindow, |
|
1358 |
windowName, windowName, |
|
1359 |
iconBitmap, |
|
1360 |
0, 0, &sizehints); |
|
1361 |
||
1362 |
} |
|
1363 |
||
1364 |
wmhints.flags = 0; |
|
1365 |
if (iconBitmap) { |
|
1366 |
wmhints.flags |= IconPixmapHint; |
|
1367 |
wmhints.icon_pixmap = iconBitmap; |
|
1368 |
} |
|
1369 |
if (iconWindow) { |
|
1370 |
wmhints.flags |= IconWindowHint; |
|
1371 |
wmhints.icon_window = iconWindow; |
|
1372 |
} |
|
0 | 1373 |
/* |
70 | 1374 |
wmhints.flags |= InputHint; |
1375 |
wmhints.input = True; |
|
0 | 1376 |
*/ |
70 | 1377 |
XSetWMHints(dpy, newWindow, &wmhints); |
1378 |
||
1379 |
/* |
|
1380 |
* tell window manager to not kill us but send an event instead |
|
1381 |
*/ |
|
1382 |
/* |
|
1383 |
* get atoms first (if not already known) |
|
1384 |
*/ |
|
555 | 1385 |
if (__INST(protocolsAtom) == nil) { |
70 | 1386 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
555 | 1387 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
0 | 1388 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1389 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
555 | 1390 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
0 | 1391 |
#endif |
1392 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1393 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
555 | 1394 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
0 | 1395 |
#endif |
70 | 1396 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
555 | 1397 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
70 | 1398 |
} else { |
0 | 1399 |
#ifdef USE_QUIT_APP_ATOM |
555 | 1400 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1401 |
#else |
70 | 1402 |
WmQuitAppAtom = 0; |
0 | 1403 |
#endif |
555 | 1404 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
1405 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
|
0 | 1406 |
#ifdef USE_SAVEYOURSELF_ATOM |
555 | 1407 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1408 |
#else |
70 | 1409 |
WmSaveYourselfAtom = 0; |
0 | 1410 |
#endif |
70 | 1411 |
} |
1412 |
||
1413 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 1414 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1415 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1416 |
#endif |
1417 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1418 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1419 |
#endif |
70 | 1420 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
1421 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 1422 |
} |
1423 |
||
54 | 1424 |
END_INTERRUPTSBLOCKED |
1425 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1426 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1427 |
%}. |
0 | 1428 |
self addKnownView:aView withId:windowId. |
1429 |
^ windowId |
|
1430 |
! |
|
1431 |
||
295 | 1432 |
destroyFaxImage:aFaxImageId |
1433 |
||
1434 |
%{ /* NOCONTEXT */ |
|
1435 |
||
1436 |
#ifdef FAX |
|
1437 |
if (__isExternalAddress(aFaxImageId)) { |
|
70 | 1438 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1439 |
XFAXImageFreeImage(myDpy, (FAXImage)_WindowVal(aFaxImageId)); |
70 | 1440 |
END_INTERRUPTSBLOCKED |
295 | 1441 |
RETURN ( self ); |
1442 |
} |
|
1443 |
#endif |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1444 |
%}. |
295 | 1445 |
self primitiveFailed |
0 | 1446 |
! |
1447 |
||
1448 |
destroyGC:aGCId |
|
1449 |
||
1450 |
%{ /* NOCONTEXT */ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1451 |
if (__isExternalAddress(aGCId) && ISCONNECTED) { |
366 | 1452 |
GC gc = _GCVal(aGCId); |
1453 |
||
1454 |
if (gc) { |
|
1455 |
BEGIN_INTERRUPTSBLOCKED |
|
1456 |
XFreeGC(myDpy, gc); |
|
1457 |
END_INTERRUPTSBLOCKED |
|
1458 |
} |
|
70 | 1459 |
RETURN ( self ); |
0 | 1460 |
} |
118 | 1461 |
%}. |
0 | 1462 |
self primitiveFailed |
1463 |
! |
|
1464 |
||
295 | 1465 |
destroyPixmap:aDrawableId |
0 | 1466 |
|
1467 |
%{ /* NOCONTEXT */ |
|
1468 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1469 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
70 | 1470 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1471 |
XFreePixmap(myDpy, _PixmapVal(aDrawableId)); |
70 | 1472 |
END_INTERRUPTSBLOCKED |
295 | 1473 |
RETURN ( self ); |
0 | 1474 |
} |
118 | 1475 |
%}. |
295 | 1476 |
self primitiveFailed |
1477 |
! |
|
1478 |
||
1479 |
destroyView:aView withId:aWindowId |
|
1480 |
%{ |
|
1481 |
if (__isExternalAddress(aWindowId) && ISCONNECTED) { |
|
1482 |
BEGIN_INTERRUPTSBLOCKED |
|
1483 |
XDestroyWindow(myDpy, _WindowVal(aWindowId)); |
|
1484 |
END_INTERRUPTSBLOCKED |
|
1485 |
} |
|
1486 |
%}. |
|
1487 |
self removeKnownView:aView |
|
0 | 1488 |
! |
1489 |
||
1490 |
dpsContextFor:aDrawableId and:aGCId |
|
1491 |
||
1492 |
%{ /* NOCONTEXT */ |
|
1493 |
#ifdef XXDPS |
|
555 | 1494 |
int screen = __intVal(__INST(screen)); |
0 | 1495 |
DPSContext dps; |
1496 |
int height; |
|
1497 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1498 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1499 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1500 |
&& ISCONNECTED) { |
70 | 1501 |
BEGIN_INTERRUPTSBLOCKED |
1502 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1503 |
_GCVal(aGCId), |
|
1504 |
0, height, 0, colormap, NULL, 0, |
|
1505 |
XDPSDefaultTextBackstop, |
|
1506 |
XDPSDefaultErrorProc, |
|
1507 |
NULL); |
|
1508 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1509 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
0 | 1510 |
} |
1511 |
#endif |
|
1512 |
%} |
|
1513 |
. |
|
43 | 1514 |
self primitiveFailed. |
1515 |
^ nil |
|
295 | 1516 |
! |
1517 |
||
1518 |
gcFor:aDrawableId |
|
132 | 1519 |
|
1520 |
%{ /* NOCONTEXT */ |
|
555 | 1521 |
int screen = __intVal(__INST(screen)); |
295 | 1522 |
GC gc; |
1523 |
||
1524 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1525 |
BEGIN_INTERRUPTSBLOCKED |
|
1526 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1527 |
0L, (XGCValues *)0); |
|
1528 |
END_INTERRUPTSBLOCKED |
|
1529 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1530 |
} |
1531 |
%}. |
|
1532 |
self primitiveFailed. |
|
1533 |
^ nil |
|
295 | 1534 |
! |
1535 |
||
1536 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1537 |
|
1538 |
%{ /* UNLIMITEDSTACK */ |
|
1539 |
||
295 | 1540 |
Display *dpy = myDpy; |
555 | 1541 |
int screen = __intVal(__INST(screen)); |
295 | 1542 |
Pixmap newBitmap; |
1543 |
unsigned int b_width, b_height; |
|
1544 |
REGISTER unsigned char *cp; |
|
1545 |
REGISTER unsigned char *pBits; |
|
1546 |
unsigned char *b_bits, *allocatedBits; |
|
1547 |
int index, row; |
|
1548 |
REGISTER int col; |
|
1549 |
unsigned bits; |
|
1550 |
static char reverseBitTable[256]; |
|
1551 |
static firstCall = 1; |
|
1552 |
int nBytes; |
|
1553 |
unsigned char fastBits[10000]; |
|
1554 |
OBJ num, *op; |
|
1555 |
int bytesPerRow; |
|
1556 |
||
1557 |
if (firstCall) { |
|
1558 |
for (index=0; index < 256; index++) { |
|
1559 |
reverseBitTable[index] = 0; |
|
1560 |
if (index & 128) reverseBitTable[index] |= 1; |
|
1561 |
if (index & 64) reverseBitTable[index] |= 2; |
|
1562 |
if (index & 32) reverseBitTable[index] |= 4; |
|
1563 |
if (index & 16) reverseBitTable[index] |= 8; |
|
1564 |
if (index & 8) reverseBitTable[index] |= 16; |
|
1565 |
if (index & 4) reverseBitTable[index] |= 32; |
|
1566 |
if (index & 2) reverseBitTable[index] |= 64; |
|
1567 |
if (index & 1) reverseBitTable[index] |= 128; |
|
154 | 1568 |
} |
295 | 1569 |
firstCall = 0; |
1570 |
} |
|
1571 |
||
1572 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
377 | 1573 |
newBitmap = (Pixmap)0; |
555 | 1574 |
b_width = __intVal(w); |
1575 |
b_height = __intVal(h); |
|
295 | 1576 |
bytesPerRow = (b_width + 7) / 8; |
1577 |
nBytes = b_height * bytesPerRow; |
|
1578 |
if (nBytes < sizeof(fastBits)) { |
|
1579 |
cp = b_bits = fastBits; |
|
1580 |
allocatedBits = 0; |
|
1581 |
} else { |
|
1582 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
1583 |
if (! cp) goto fail; |
|
150 | 1584 |
} |
295 | 1585 |
|
377 | 1586 |
if (__qClass(anArray) == @global(Array)) { |
295 | 1587 |
index = 1; |
555 | 1588 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
295 | 1589 |
for (row = b_height; row; row--) { |
1590 |
for (col = bytesPerRow; col; col--) { |
|
1591 |
num = *op++; |
|
1592 |
if (! __isSmallInteger(num)) goto fail; |
|
555 | 1593 |
bits = __intVal(num); |
295 | 1594 |
*cp++ = reverseBitTable[bits]; |
1595 |
} |
|
1596 |
} |
|
1597 |
} else { |
|
377 | 1598 |
if (__qClass(anArray) == @global(ByteArray)) { |
555 | 1599 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
295 | 1600 |
for (col = b_height*bytesPerRow; col; col--) { |
1601 |
*cp++ = reverseBitTable[*pBits++]; |
|
1602 |
} |
|
1603 |
} else { |
|
1604 |
goto fail; |
|
1605 |
} |
|
150 | 1606 |
} |
295 | 1607 |
|
1608 |
BEGIN_INTERRUPTSBLOCKED |
|
1609 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
|
1610 |
(char *)b_bits, |
|
1611 |
b_width, b_height); |
|
1612 |
END_INTERRUPTSBLOCKED |
|
1613 |
fail: ; |
|
1614 |
if (allocatedBits) |
|
1615 |
free(allocatedBits); |
|
1616 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1617 |
} |
1618 |
%} |
|
295 | 1619 |
! |
1620 |
||
1621 |
realRootWindowFor:aView |
|
1622 |
"the name of this method is historic; |
|
1623 |
- it will vanish" |
|
1624 |
||
1625 |
|id| |
|
1626 |
||
1627 |
id := self realRootWindowId. |
|
1628 |
self addKnownView:aView withId:id. |
|
1629 |
^ id |
|
1630 |
! |
|
1631 |
||
1632 |
realRootWindowId |
|
1633 |
"return the id of the real root window. |
|
1634 |
This may not be the window you see as background, |
|
1635 |
since some window managers install a virtual root window on top |
|
1636 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1637 |
care of any virtual root." |
|
0 | 1638 |
|
1639 |
%{ /* NOCONTEXT */ |
|
1640 |
||
555 | 1641 |
int screen = __intVal(__INST(screen)); |
295 | 1642 |
Window root; |
1643 |
OBJ id; |
|
1644 |
||
555 | 1645 |
if (__INST(rootId) != nil) { |
1646 |
RETURN (__INST(rootId)); |
|
295 | 1647 |
} |
0 | 1648 |
|
150 | 1649 |
if (ISCONNECTED) { |
295 | 1650 |
root = RootWindow(myDpy, screen); |
1651 |
if (! root) { |
|
1652 |
id = nil; |
|
1653 |
} else { |
|
555 | 1654 |
__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
|
1655 |
} |
295 | 1656 |
RETURN (id); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1657 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1658 |
%}. |
295 | 1659 |
self primitiveFailed |
1660 |
! |
|
1661 |
||
1662 |
rootWindowFor:aView |
|
1663 |
|id| |
|
1664 |
||
1665 |
id := self rootWindowId. |
|
1666 |
self addKnownView:aView withId:id. |
|
0 | 1667 |
^ id |
1668 |
! |
|
1669 |
||
295 | 1670 |
rootWindowId |
1671 |
"return the id of the root window. |
|
1672 |
This is the window you see as background, |
|
1673 |
however, it may or may not be the real physical root window, |
|
1674 |
since some window managers install a virtual root window on top |
|
1675 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1676 |
|
0 | 1677 |
%{ /* NOCONTEXT */ |
555 | 1678 |
int screen = __intVal(__INST(screen)); |
295 | 1679 |
Window rootWin, vRootWin; |
1680 |
OBJ id; |
|
1681 |
||
555 | 1682 |
if (__INST(virtualRootId) != nil) { |
1683 |
RETURN (__INST(virtualRootId)); |
|
295 | 1684 |
} |
0 | 1685 |
|
169 | 1686 |
if (ISCONNECTED) { |
295 | 1687 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
1688 |
#ifndef IRIS |
|
180 | 1689 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1690 |
/* |
1691 |
* on IRIS, this creates a badwindow error - why ? |
|
1692 |
* children contains a funny window (000034) |
|
1693 |
*/ |
|
1694 |
||
1695 |
/* |
|
1696 |
* care for virtual root windows (tvtwm & friends) |
|
1697 |
*/ |
|
1698 |
{ |
|
1699 |
Atom vRootAtom = None; |
|
1700 |
int i; |
|
1701 |
Window rootReturn, parentReturn; |
|
1702 |
Window* children; |
|
1703 |
unsigned int numChildren; |
|
1704 |
||
1705 |
if (XQueryTree(myDpy, rootWin, |
|
1706 |
&rootReturn, &parentReturn, |
|
1707 |
&children, &numChildren)) { |
|
1708 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1709 |
if (vRootAtom != None) { |
|
1710 |
for (i=0; i < numChildren; i++) { |
|
1711 |
Atom actual_type; |
|
1712 |
int actual_format; |
|
1713 |
unsigned long nitems, bytesafter; |
|
1714 |
Window* newRoot = (Window*) 0; |
|
1715 |
||
1716 |
if (children[i]) { |
|
1717 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1718 |
0L, 1L, False, XA_WINDOW, |
|
1719 |
&actual_type, &actual_format, |
|
1720 |
&nitems, &bytesafter, |
|
1721 |
(unsigned char**) &newRoot |
|
1722 |
) == Success && newRoot) { |
|
1723 |
vRootWin = *newRoot; |
|
1724 |
break; |
|
1725 |
} |
|
1726 |
} |
|
1727 |
} |
|
1728 |
if (children) XFree( children ); |
|
1729 |
} |
|
1730 |
} |
|
1731 |
} |
|
180 | 1732 |
END_INTERRUPTSBLOCKED |
295 | 1733 |
#endif |
1734 |
} |
|
1735 |
||
1736 |
/* cannot happen */ |
|
1737 |
if (! vRootWin) { |
|
1738 |
vRootWin = rootWin; |
|
1739 |
if (! rootWin) { |
|
1740 |
RETURN ( nil ); |
|
1741 |
} |
|
1742 |
} |
|
555 | 1743 |
__INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
1744 |
__INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
295 | 1745 |
RETURN ( id ); |
63 | 1746 |
%} |
0 | 1747 |
! ! |
1748 |
||
1749 |
!XWorkstation methodsFor:'color stuff'! |
|
1750 |
||
295 | 1751 |
colorCell |
1752 |
"allocate a color cell - return index. |
|
1753 |
This method will return nil for StaticGrey and StaticGrey displays." |
|
0 | 1754 |
|
1755 |
%{ /* NOCONTEXT */ |
|
1756 |
||
1757 |
Display *dpy = myDpy; |
|
555 | 1758 |
int screen = __intVal(__INST(screen)); |
295 | 1759 |
XColor color; |
1760 |
unsigned long dummy; |
|
1761 |
Status ok; |
|
1762 |
||
1763 |
BEGIN_INTERRUPTSBLOCKED |
|
1764 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1765 |
&dummy, 0, &color.pixel, 1); |
|
1766 |
END_INTERRUPTSBLOCKED |
|
1767 |
if (ok) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1768 |
RETURN ( __MKSMALLINT(color.pixel) ); |
0 | 1769 |
} |
1770 |
%} |
|
1771 |
. |
|
43 | 1772 |
^ nil |
0 | 1773 |
! |
1774 |
||
1775 |
colorNamed:aString |
|
1776 |
"allocate a color with color name - return index. |
|
1777 |
Dont use this method, colornames are mostly X specific" |
|
1778 |
||
1779 |
%{ /* NOCONTEXT */ |
|
1780 |
||
1781 |
char *colorname; |
|
1782 |
Display *dpy = myDpy; |
|
1783 |
XColor scolor, ecolor; |
|
555 | 1784 |
int screen = __intVal(__INST(screen)); |
54 | 1785 |
Status ok; |
0 | 1786 |
|
150 | 1787 |
if (ISCONNECTED) { |
1788 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1789 |
colorname = (char *)_stringVal(aString); |
|
1790 |
||
1791 |
BEGIN_INTERRUPTSBLOCKED |
|
1792 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1793 |
if (ok) { |
|
1794 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
1795 |
} |
|
1796 |
END_INTERRUPTSBLOCKED |
|
1797 |
if (! ok) { |
|
1798 |
RETURN ( nil ); |
|
1799 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1800 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
70 | 1801 |
} |
0 | 1802 |
} |
1803 |
%} |
|
1804 |
. |
|
43 | 1805 |
self primitiveFailed. |
1806 |
^ nil |
|
0 | 1807 |
! |
1808 |
||
295 | 1809 |
colorRed:redVal green:greenVal blue:blueVal |
1810 |
"allocate a color with rgb values (0..100) - return index" |
|
1811 |
||
1812 |
|r g b| |
|
1813 |
||
1814 |
r := self percentToXColorValue:redVal. |
|
1815 |
g := self percentToXColorValue:greenVal. |
|
1816 |
b := self percentToXColorValue:blueVal. |
|
1817 |
%{ |
|
1818 |
Display *dpy = myDpy; |
|
1819 |
XColor ecolor; |
|
555 | 1820 |
int screen = __intVal(__INST(screen)); |
295 | 1821 |
Status ok; |
1822 |
||
1823 |
if (__bothSmallInteger(r, g) |
|
1824 |
&& __isSmallInteger(b) |
|
1825 |
&& ISCONNECTED) { |
|
555 | 1826 |
ecolor.red = __intVal(r); |
1827 |
ecolor.green= __intVal(g); |
|
1828 |
ecolor.blue = __intVal(b); |
|
295 | 1829 |
BEGIN_INTERRUPTSBLOCKED |
1830 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
1831 |
END_INTERRUPTSBLOCKED |
|
1832 |
if (! ok) { |
|
1833 |
RETURN ( nil ); |
|
1834 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1835 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 1836 |
} |
1837 |
%} |
|
1838 |
. |
|
1839 |
self primitiveFailed. |
|
1840 |
^ nil |
|
1841 |
! |
|
1842 |
||
1843 |
freeColor:colorIndex |
|
1844 |
"free a display color when its no longer needed" |
|
0 | 1845 |
|
1846 |
%{ /* NOCONTEXT */ |
|
1847 |
||
1848 |
Display *dpy = myDpy; |
|
295 | 1849 |
unsigned long color; |
555 | 1850 |
int screen = __intVal(__INST(screen)); |
295 | 1851 |
|
1852 |
#ifdef LATER |
|
555 | 1853 |
if (__INST(visualType) == @symbol(TrueColor)) { |
295 | 1854 |
/* no need to do anything on TrueColor displays ... */ |
1855 |
RETURN (self); |
|
1856 |
} |
|
1857 |
#endif |
|
1858 |
if (__isSmallInteger(colorIndex) && ISCONNECTED) { |
|
555 | 1859 |
color = (long) __intVal(colorIndex); |
295 | 1860 |
BEGIN_INTERRUPTSBLOCKED |
1861 |
XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L); |
|
1862 |
END_INTERRUPTSBLOCKED |
|
1863 |
RETURN ( self ); |
|
0 | 1864 |
} |
1865 |
%} |
|
1866 |
. |
|
295 | 1867 |
self primitiveFailed |
1868 |
! |
|
1869 |
||
1870 |
getRGBFrom:index into:aBlock |
|
1871 |
"get rgb components (0..100) of color in map at:index, |
|
1872 |
and evaluate the 3-arg block, aBlock with them" |
|
1873 |
||
1874 |
|r g b| |
|
1875 |
%{ |
|
1876 |
Display *dpy = myDpy; |
|
555 | 1877 |
int screen = __intVal(__INST(screen)); |
295 | 1878 |
XColor color; |
1879 |
double fr, fg, fb; |
|
1880 |
double floor(); |
|
1881 |
int bits, scale, shift; |
|
1882 |
||
1883 |
if (__isSmallInteger(index)) { |
|
555 | 1884 |
color.pixel = __intVal(index); |
295 | 1885 |
BEGIN_INTERRUPTSBLOCKED |
1886 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
1887 |
END_INTERRUPTSBLOCKED |
|
1888 |
||
1889 |
/* scale to 0..100 and round to the first decimal */ |
|
1890 |
||
1891 |
/* |
|
1892 |
* have to compensate for an error in X ?, which does not scale |
|
1893 |
* colors correctly if lesser than 16bits are valid in a color, |
|
1894 |
* (for example, color white on a 4bitsPerRGB server will return |
|
1895 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
1896 |
*/ |
|
555 | 1897 |
bits = __intVal(__INST(bitsPerRGB)); |
295 | 1898 |
scale = (1<<bits) - 1; |
1899 |
shift = 16 - bits; |
|
1900 |
||
1901 |
fr = floor( ( ((double)(color.red>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
1902 |
fg = floor( ( ((double)(color.green>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
1903 |
fb = floor( ( ((double)(color.blue>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
1904 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1905 |
r = __MKFLOAT(fr COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1906 |
g = __MKFLOAT(fg COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1907 |
b = __MKFLOAT(fb COMMA_CON); |
295 | 1908 |
} |
1909 |
%}. |
|
1910 |
aBlock value:r value:g value:b |
|
1911 |
! |
|
1912 |
||
1913 |
getRGBFromName:colorName into:aBlock |
|
1914 |
"get rgb components (0..100) of color named colorName, |
|
1915 |
and evaluate the 3-arg block, aBlock with them" |
|
1916 |
||
1917 |
|r g b| |
|
1918 |
||
1919 |
displayId isNil ifTrue:[ |
|
1920 |
self pimitiveFailed. |
|
1921 |
^ nil |
|
1922 |
]. |
|
1923 |
%{ |
|
1924 |
Display *dpy = myDpy; |
|
555 | 1925 |
int screen = __intVal(__INST(screen)); |
295 | 1926 |
XColor color; |
1927 |
double fr, fg, fb; |
|
1928 |
double floor(); |
|
1929 |
||
1930 |
if (__isString(colorName) || __isSymbol(colorName)) { |
|
1931 |
BEGIN_INTERRUPTSBLOCKED |
|
1932 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
1933 |
(char *)_stringVal(colorName), &color)) { |
|
1934 |
/* |
|
1935 |
* scale to 0..100 and round to the first decimal |
|
1936 |
*/ |
|
1937 |
fr = floor( ((((double)color.red) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
1938 |
fg = floor( ((((double)color.green) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
1939 |
fb = floor( ((((double)color.blue) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
1940 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1941 |
r = __MKFLOAT(fr COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1942 |
g = __MKFLOAT(fg COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1943 |
b = __MKFLOAT(fb COMMA_CON); |
295 | 1944 |
} |
1945 |
END_INTERRUPTSBLOCKED |
|
1946 |
} |
|
1947 |
%} |
|
1948 |
. |
|
1949 |
aBlock value:r value:g value:b |
|
1950 |
! |
|
1951 |
||
1952 |
listOfAvailableColors |
|
1953 |
"return a list of all available colornames. |
|
1954 |
This should not be used, since colornames are very |
|
1955 |
display-specific (here X-specific)." |
|
1956 |
||
1957 |
|aStream list line index colorName| |
|
1958 |
||
1959 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
1960 |
aStream isNil ifTrue:[^ nil]. |
|
1961 |
list := OrderedCollection new. |
|
1962 |
[aStream atEnd] whileFalse:[ |
|
1963 |
line := aStream nextLine. |
|
1964 |
line notNil ifTrue:[ |
|
1965 |
"skip the r/g/b numbers" |
|
1966 |
index := 1. |
|
1967 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
1968 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
1969 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
1970 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
1971 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
1972 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
1973 |
colorName := line copyFrom:index. |
|
1974 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
1975 |
list add:colorName |
|
1976 |
] |
|
1977 |
] |
|
1978 |
]. |
|
1979 |
aStream close. |
|
1980 |
^ list sort |
|
1981 |
! |
|
1982 |
||
1983 |
percentToXColorValue:aPercentage |
|
1984 |
"given a color-component value in percent (0..100), return the corresponding |
|
1985 |
x-component value (0..65k) as an integer" |
|
1986 |
||
1987 |
%{ /* NOCONTEXT */ |
|
1988 |
||
1989 |
if (__isSmallInteger(aPercentage)) { |
|
555 | 1990 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 1991 |
} |
1992 |
if (__isFloat(aPercentage)) { |
|
555 | 1993 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 1994 |
} |
1995 |
%} |
|
1996 |
. |
|
1997 |
^ (16rFFFF * aPercentage / 100) rounded |
|
0 | 1998 |
! |
1999 |
||
2000 |
setColor:index red:redVal green:greenVal blue:blueVal |
|
2001 |
"change color in map at:index to rgb (0..100). |
|
2002 |
This method is a noop for StaticGrey and StaticGrey displays." |
|
2003 |
||
2004 |
%{ /* NOCONTEXT */ |
|
2005 |
||
2006 |
char *colorname; |
|
2007 |
Display *dpy = myDpy; |
|
2008 |
XColor color; |
|
555 | 2009 |
int screen = __intVal(__INST(screen)); |
0 | 2010 |
int r, g, b; |
2011 |
int ok = 1; |
|
2012 |
||
97 | 2013 |
if (__isSmallInteger(redVal)) |
555 | 2014 |
r = 0xFFFF * __intVal(redVal) / 100; |
36 | 2015 |
else if (__isFloat(redVal)) |
555 | 2016 |
r = 0xFFFF * (int)(__floatVal(redVal)) / 100; |
0 | 2017 |
else ok = 0; |
2018 |
||
97 | 2019 |
if (__isSmallInteger(greenVal)) |
555 | 2020 |
g = 0xFFFF * __intVal(greenVal) / 100; |
36 | 2021 |
else if (__isFloat(greenVal)) |
555 | 2022 |
g = 0xFFFF * (int)(__floatVal(greenVal)) / 100; |
0 | 2023 |
else ok = 0; |
2024 |
||
97 | 2025 |
if (__isSmallInteger(blueVal)) |
555 | 2026 |
b = 0xFFFF * __intVal(blueVal) / 100; |
36 | 2027 |
else if (__isFloat(blueVal)) |
555 | 2028 |
b = 0xFFFF * (int)(__floatVal(blueVal)) / 100; |
0 | 2029 |
else ok = 0; |
2030 |
||
97 | 2031 |
if (__isSmallInteger(index) && ok) { |
555 | 2032 |
color.pixel = __intVal(index); |
70 | 2033 |
color.red = r; |
2034 |
color.green = g; |
|
2035 |
color.blue = b; |
|
2036 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2037 |
||
2038 |
BEGIN_INTERRUPTSBLOCKED |
|
2039 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2040 |
END_INTERRUPTSBLOCKED |
|
2041 |
RETURN ( self ); |
|
0 | 2042 |
} |
2043 |
%} |
|
2044 |
. |
|
2045 |
self primitiveFailed |
|
295 | 2046 |
! ! |
2047 |
||
2048 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2049 |
||
2050 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
2051 |
"change a cursors colors" |
|
2052 |
||
2053 |
|fgR fgG fgB bgR bgG bgB| |
|
2054 |
||
2055 |
fgR := fgColor red. |
|
2056 |
fgG := fgColor green. |
|
2057 |
fgB := fgColor blue. |
|
2058 |
bgR := bgColor red. |
|
2059 |
bgG := bgColor green. |
|
2060 |
bgB := bgColor blue. |
|
2061 |
||
2062 |
fgR := self percentToXColorValue:fgR. |
|
2063 |
fgG := self percentToXColorValue:fgG. |
|
2064 |
fgB := self percentToXColorValue:fgB. |
|
2065 |
bgR := self percentToXColorValue:bgR. |
|
2066 |
bgG := self percentToXColorValue:bgG. |
|
2067 |
bgB := self percentToXColorValue:bgB. |
|
2068 |
||
0 | 2069 |
%{ |
295 | 2070 |
XColor fgcolor, bgcolor; |
2071 |
||
2072 |
if (__isExternalAddress(aCursorId) |
|
2073 |
&& __bothSmallInteger(fgG, fgB) |
|
2074 |
&& __bothSmallInteger(bgR, bgG) |
|
2075 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2076 |
||
555 | 2077 |
fgcolor.red = __intVal(fgR); |
2078 |
fgcolor.green= __intVal(fgG); |
|
2079 |
fgcolor.blue = __intVal(fgB); |
|
2080 |
bgcolor.red = __intVal(bgR); |
|
2081 |
bgcolor.green= __intVal(bgG); |
|
2082 |
bgcolor.blue = __intVal(bgB); |
|
70 | 2083 |
BEGIN_INTERRUPTSBLOCKED |
295 | 2084 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
72 | 2085 |
END_INTERRUPTSBLOCKED |
2086 |
RETURN ( self ); |
|
2087 |
} |
|
0 | 2088 |
%} |
2089 |
. |
|
2090 |
self primitiveFailed |
|
70 | 2091 |
! |
2092 |
||
295 | 2093 |
createCursorShape:aShape |
2094 |
"create a cursor given a shape-symbol" |
|
2095 |
||
2096 |
|number id| |
|
2097 |
||
2098 |
displayId isNil ifTrue:[ |
|
2099 |
self primitiveFailed. |
|
2100 |
^ nil |
|
2101 |
]. |
|
2102 |
number := self shapeNumberFromSymbol:aShape. |
|
2103 |
%{ |
|
2104 |
Cursor newCursor; |
|
2105 |
||
2106 |
if (__isSmallInteger(number)) { |
|
2107 |
BEGIN_INTERRUPTSBLOCKED |
|
555 | 2108 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
295 | 2109 |
END_INTERRUPTSBLOCKED |
2110 |
if (newCursor != (Cursor)0) { |
|
2111 |
id = __MKOBJ(newCursor); |
|
70 | 2112 |
} |
0 | 2113 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2114 |
%}. |
295 | 2115 |
^ id |
2116 |
! |
|
2117 |
||
2118 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy |
|
2119 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
|
2120 |
||
2121 |
|id sourceId maskId| |
|
2122 |
||
2123 |
displayId isNil ifTrue:[ |
|
2124 |
self primitiveFailed. |
|
2125 |
^ nil |
|
2126 |
]. |
|
2127 |
sourceId := sourceForm id. |
|
2128 |
maskId := maskForm id. |
|
2129 |
%{ |
|
2130 |
Cursor newCursor; |
|
2131 |
XColor fgColor, bgColor; |
|
2132 |
||
2133 |
if (__isExternalAddress(sourceId) |
|
2134 |
&& __isExternalAddress(maskId) |
|
2135 |
&& __bothSmallInteger(hx, hy)) { |
|
2136 |
fgColor.red = 0; /* fg is black */ |
|
2137 |
fgColor.green = 0; |
|
2138 |
fgColor.blue = 0; |
|
2139 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2140 |
bgColor.green = 0xFFFF; |
|
2141 |
bgColor.blue = 0xFFFF; |
|
2142 |
||
2143 |
BEGIN_INTERRUPTSBLOCKED |
|
2144 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2145 |
_PixmapVal(sourceId), |
|
2146 |
_PixmapVal(maskId), |
|
555 | 2147 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
295 | 2148 |
END_INTERRUPTSBLOCKED |
2149 |
if (newCursor != (Cursor)0) { |
|
2150 |
id = __MKOBJ(newCursor); |
|
70 | 2151 |
} |
0 | 2152 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2153 |
%}. |
295 | 2154 |
^ id |
2155 |
! |
|
2156 |
||
2157 |
destroyCursor:aCursorId |
|
0 | 2158 |
|
2159 |
%{ /* NOCONTEXT */ |
|
2160 |
||
295 | 2161 |
if (ISCONNECTED) { |
2162 |
if (__isExternalAddress(aCursorId)) { |
|
2163 |
BEGIN_INTERRUPTSBLOCKED |
|
2164 |
XFreeCursor(myDpy, _CursorVal(aCursorId)); |
|
2165 |
END_INTERRUPTSBLOCKED |
|
70 | 2166 |
RETURN ( self ); |
2167 |
} |
|
0 | 2168 |
} |
2169 |
%} |
|
2170 |
. |
|
2171 |
self primitiveFailed |
|
295 | 2172 |
! |
2173 |
||
2174 |
shapeNumberFromSymbol:shape |
|
2175 |
"given a shape-symbol, return the corresponding cursor-number" |
|
2176 |
||
2177 |
"this is pure X-knowlegde - but you may easily add more" |
|
2178 |
||
2179 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2180 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2181 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2182 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2183 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2184 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2185 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2186 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2187 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2188 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2189 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2190 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2191 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2192 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2193 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2194 |
((shape == #origin) |
|
2195 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2196 |
((shape == #corner) |
|
2197 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2198 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2199 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2200 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2201 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2202 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2203 |
('XWORKSTATION: invalid cursorShape:' , shape printString) errorPrintNL. |
|
2204 |
^ 0 |
|
0 | 2205 |
! ! |
2206 |
||
2207 |
!XWorkstation methodsFor:'drawing'! |
|
2208 |
||
2209 |
copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2210 |
width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY |
12 | 2211 |
|
2212 |
"do a bit-blt of a compressed FAX image |
|
2213 |
- this needs my private FAX extension" |
|
132 | 2214 |
|
2215 |
%{ /* NOCONTEXT */ |
|
0 | 2216 |
#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
|
2217 |
GC gc; |
0 | 2218 |
FAXImage source; |
2219 |
Drawable dest; |
|
2220 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2221 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2222 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2223 |
&& __isExternalAddress(destId) |
97 | 2224 |
&& __bothSmallInteger(scaleX, scaleY) |
2225 |
&& __bothSmallInteger(w, h) |
|
2226 |
&& __bothSmallInteger(srcX, srcY) |
|
2227 |
&& __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
|
2228 |
gc = _GCVal(aGCId); |
70 | 2229 |
source = (FAXImage) _WindowVal(sourceId); |
2230 |
dest = (Drawable) _WindowVal(destId); |
|
2231 |
XFAXImageCopyImage(myDpy, source, dest, gc, |
|
555 | 2232 |
__intVal(srcX), __intVal(srcY), |
2233 |
__intVal(w), __intVal(h), |
|
2234 |
__intVal(dstX), __intVal(dstY), |
|
2235 |
__intVal(scaleX), __intVal(scaleY)); |
|
70 | 2236 |
RETURN ( self ); |
0 | 2237 |
} |
2238 |
#endif |
|
118 | 2239 |
%}. |
0 | 2240 |
self primitiveFailed |
2241 |
! |
|
2242 |
||
2243 |
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2244 |
width:w height:h with:aGCId |
118 | 2245 |
"do a bit-blt; copy bits from the rectangle defined by |
2246 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2247 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2248 |
argument is not integer." |
|
0 | 2249 |
|
2250 |
%{ /* NOCONTEXT */ |
|
2251 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2252 |
GC gc; |
0 | 2253 |
Drawable source, dest; |
2254 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2255 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2256 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2257 |
&& __isExternalAddress(destId) |
97 | 2258 |
&& __bothSmallInteger(w, h) |
2259 |
&& __bothSmallInteger(srcX, srcY) |
|
2260 |
&& __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
|
2261 |
gc = _GCVal(aGCId); |
70 | 2262 |
source = (Drawable) _WindowVal(sourceId); |
2263 |
dest = (Drawable) _WindowVal(destId); |
|
2264 |
XCopyArea(myDpy, source, dest, gc, |
|
555 | 2265 |
__intVal(srcX), __intVal(srcY), |
2266 |
__intVal(w), __intVal(h), |
|
2267 |
__intVal(dstX), __intVal(dstY)); |
|
70 | 2268 |
RETURN ( self ); |
0 | 2269 |
} |
118 | 2270 |
%}. |
2271 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2272 |
or any non integer coordinate" |
|
2273 |
||
0 | 2274 |
self primitiveFailed |
2275 |
! |
|
2276 |
||
2277 |
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2278 |
width:w height:h with:aGCId |
118 | 2279 |
"do a bit-blt, but only copy the low-bit plane; |
2280 |
copy bits from the rectangle defined by |
|
2281 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2282 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2283 |
argument is not integer." |
|
0 | 2284 |
|
2285 |
%{ /* NOCONTEXT */ |
|
2286 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2287 |
GC gc; |
0 | 2288 |
Drawable source, dest; |
2289 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2290 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2291 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2292 |
&& __isExternalAddress(destId) |
97 | 2293 |
&& __bothSmallInteger(w, h) |
2294 |
&& __bothSmallInteger(srcX, srcY) |
|
2295 |
&& __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
|
2296 |
gc = _GCVal(aGCId); |
70 | 2297 |
source = (Drawable) _WindowVal(sourceId); |
2298 |
dest = (Drawable) _WindowVal(destId); |
|
2299 |
XCopyPlane(myDpy, source, dest, gc, |
|
555 | 2300 |
__intVal(srcX), __intVal(srcY), |
2301 |
__intVal(w), __intVal(h), |
|
2302 |
__intVal(dstX), __intVal(dstY), 1); |
|
70 | 2303 |
RETURN ( self ); |
0 | 2304 |
} |
118 | 2305 |
%}. |
2306 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2307 |
or any non integer coordinate" |
|
2308 |
||
0 | 2309 |
self primitiveFailed |
2310 |
! |
|
2311 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2312 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2313 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2314 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2315 |
|
2316 |
%{ /* NOCONTEXT */ |
|
2317 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2318 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2319 |
Window win; |
0 | 2320 |
int w, h, angle1, angle2; |
2321 |
double f; |
|
2322 |
||
97 | 2323 |
if (__isSmallInteger(startAngle)) |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2324 |
angle1 = __intVal(startAngle) * 64; |
36 | 2325 |
else if (__isFloat(startAngle)) { |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2326 |
f = __floatVal(startAngle); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2327 |
angle1 = f * 64; |
0 | 2328 |
} |
97 | 2329 |
if (__isSmallInteger(angle)) |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2330 |
angle2 = __intVal(angle) * 64; |
36 | 2331 |
else if (__isFloat(angle)) { |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2332 |
f = __floatVal(angle); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2333 |
angle2 = f * 64; |
0 | 2334 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2335 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2336 |
&& __isExternalAddress(aDrawableId) |
97 | 2337 |
&& __bothSmallInteger(x, y) |
2338 |
&& __bothSmallInteger(width, height)) { |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2339 |
win = _WindowVal(aDrawableId); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2340 |
gc = _GCVal(aGCId); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2341 |
w = __intVal(width); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2342 |
h = __intVal(height); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2343 |
/* |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2344 |
* need this check here: some servers simply dump core with bad args |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2345 |
*/ |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2346 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2347 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2348 |
w, h, angle1, angle2); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2349 |
} |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2350 |
RETURN ( self ); |
0 | 2351 |
} |
73 | 2352 |
%}. |
2353 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2354 |
self primitiveFailed |
2355 |
! |
|
2356 |
||
295 | 2357 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2358 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2359 |
||
2360 |
%{ /* NOCONTEXT */ |
|
2361 |
||
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 gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2363 |
Window win; |
295 | 2364 |
|
2365 |
if (__isExternalAddress(aGCId) |
|
2366 |
&& __isExternalAddress(aDrawableId) |
|
2367 |
&& __bothSmallInteger(x0, y0) |
|
2368 |
&& __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
|
2369 |
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
|
2370 |
win = _WindowVal(aDrawableId); |
555 | 2371 |
XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0), |
2372 |
__intVal(x1), __intVal(y1)); |
|
295 | 2373 |
RETURN ( self ); |
2374 |
} |
|
2375 |
%}. |
|
2376 |
"badGC, badDrawable or coordinates not integer" |
|
2377 |
self primitiveFailed |
|
2378 |
! |
|
2379 |
||
2380 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2381 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2382 |
||
2383 |
%{ /* NOCONTEXT */ |
|
2384 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2385 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2386 |
Window win; |
295 | 2387 |
|
2388 |
if (__isExternalAddress(aGCId) |
|
2389 |
&& __isExternalAddress(aDrawableId) |
|
2390 |
&& __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
|
2391 |
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
|
2392 |
win = _WindowVal(aDrawableId); |
555 | 2393 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
295 | 2394 |
RETURN ( self ); |
2395 |
} |
|
2396 |
%}. |
|
2397 |
"badGC, badDrawable or x/y not integer" |
|
2398 |
self primitiveFailed |
|
2399 |
! |
|
2400 |
||
2401 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2402 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2403 |
define the polygon. |
|
2404 |
If any coordinate is not integer, an error is triggered." |
|
2405 |
||
2406 |
|numberOfPoints newPoints| |
|
2407 |
||
2408 |
numberOfPoints := aPolygon size. |
|
2409 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2410 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2411 |
Window win; |
295 | 2412 |
OBJ point, x, y; |
2413 |
int i, num; |
|
2414 |
XPoint *points; |
|
2415 |
XPoint qPoints[100]; |
|
377 | 2416 |
int mustFree = 0; |
295 | 2417 |
|
2418 |
if (__isExternalAddress(aGCId) |
|
2419 |
&& __isExternalAddress(aDrawableId) |
|
2420 |
&& __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
|
2421 |
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
|
2422 |
win = _WindowVal(aDrawableId); |
555 | 2423 |
num = __intVal(numberOfPoints); |
295 | 2424 |
/* |
2425 |
* avoid a (slow) malloc, if the number of points is small |
|
2426 |
*/ |
|
2427 |
if (num > 100) { |
|
2428 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2429 |
if (! points) goto fail; |
|
377 | 2430 |
mustFree = 1; |
295 | 2431 |
} else |
2432 |
points = qPoints; |
|
2433 |
||
2434 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2435 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
295 | 2436 |
if (! __isPoint(point)) goto fail; |
2437 |
x = _point_X(point); |
|
2438 |
y = _point_Y(point); |
|
2439 |
if (! __bothSmallInteger(x, y)) |
|
2440 |
goto fail; |
|
555 | 2441 |
points[i].x = __intVal(x); |
2442 |
points[i].y = __intVal(y); |
|
295 | 2443 |
} |
2444 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
377 | 2445 |
if (mustFree) |
295 | 2446 |
free(points); |
2447 |
RETURN ( self ); |
|
2448 |
} |
|
2449 |
fail: ; |
|
377 | 2450 |
if (mustFree) |
382 | 2451 |
free(points); |
295 | 2452 |
%}. |
2453 |
"badGC, badDrawable or coordinates not integer" |
|
2454 |
self primitiveFailed |
|
2455 |
! |
|
2456 |
||
2457 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2458 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2459 |
||
2460 |
%{ /* NOCONTEXT */ |
|
2461 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2462 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2463 |
Window win; |
295 | 2464 |
int w, h; |
2465 |
||
2466 |
if (__isExternalAddress(aGCId) |
|
2467 |
&& __isExternalAddress(aDrawableId) |
|
2468 |
&& __bothSmallInteger(x, y) |
|
2469 |
&& __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
|
2470 |
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
|
2471 |
win = _WindowVal(aDrawableId); |
555 | 2472 |
w = __intVal(width); |
2473 |
h = __intVal(height); |
|
295 | 2474 |
/* |
2475 |
* need this check here: some servers simply dump core with bad args |
|
2476 |
*/ |
|
2477 |
if ((w >= 0) && (h >= 0)) { |
|
555 | 2478 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
295 | 2479 |
} |
2480 |
RETURN ( self ); |
|
2481 |
} |
|
2482 |
%}. |
|
2483 |
"badGC, badDrawable or coordinates not integer" |
|
2484 |
self primitiveFailed |
|
2485 |
! |
|
2486 |
||
2487 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2488 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2489 |
foreground and background characters. |
|
2490 |
If the coordinates are not integers, an error is triggered." |
|
2491 |
||
2492 |
%{ /* NOCONTEXT */ |
|
2493 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2494 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2495 |
Window win; |
295 | 2496 |
unsigned char *cp; |
2497 |
OBJ cls; |
|
2498 |
int i1, i2, l, n; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2499 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2500 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2501 |
int nInstBytes; |
295 | 2502 |
|
2503 |
if (__isExternalAddress(aGCId) |
|
2504 |
&& __isExternalAddress(aDrawableId) |
|
2505 |
&& __isNonNilObject(aString) |
|
2506 |
&& __bothSmallInteger(index1, index2) |
|
2507 |
&& __bothSmallInteger(x, y)) { |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2508 |
gc = _GCVal(aGCId); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2509 |
win = _WindowVal(aDrawableId); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2510 |
cls = __qClass(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2511 |
|
555 | 2512 |
i1 = __intVal(index1) - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2513 |
if (i1 >= 0) { |
555 | 2514 |
i2 = __intVal(index2) - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2515 |
if (i2 < i1) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2516 |
RETURN (self); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2517 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2518 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2519 |
cp = _stringVal(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2520 |
l = i2 - i1 + 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2521 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2522 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2523 |
n = _stringSize(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2524 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2525 |
cp += i1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2526 |
if (l > 1000) l = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2527 |
if (opaque == true) |
555 | 2528 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2529 |
else |
555 | 2530 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2531 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2532 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2533 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2534 |
|
555 | 2535 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2536 |
cp += nInstBytes; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2537 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2538 |
if (__isBytes(aString)) { |
555 | 2539 |
n = __byteArraySize(aString) - nInstBytes - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2540 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2541 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2542 |
cp += i1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2543 |
if (l > 1000) l = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2544 |
if (opaque == true) |
555 | 2545 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2546 |
else |
555 | 2547 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2548 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2549 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2550 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2551 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2552 |
/* TWOBYTESTRINGS */ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2553 |
if (__isWords(aString)) { |
555 | 2554 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2555 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2556 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2557 |
union { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2558 |
char b[2]; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2559 |
unsigned short s; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2560 |
} u; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2561 |
int i; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2562 |
XChar2b *cp2 = (XChar2b *)0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2563 |
int mustFree = 0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2564 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2565 |
cp += (i1 * 2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2566 |
if (l > 1000) l = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2567 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2568 |
/* |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2569 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2570 |
* X expects them MSB first |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2571 |
* convert as required |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2572 |
*/ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2573 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2574 |
u.s = 0x1234; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2575 |
if (u.b[0] != 0x12) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2576 |
if (l <= NLOCALBUFFER) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2577 |
cp2 = xlatebuffer; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2578 |
} else { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2579 |
cp2 = (XChar2b *)(malloc(l * 2)); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2580 |
mustFree = 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2581 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2582 |
for (i=0; i<l; i++) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2583 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2584 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2585 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2586 |
cp = (char *) cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2587 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2588 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2589 |
if (opaque == true) |
555 | 2590 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2591 |
else |
555 | 2592 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2593 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2594 |
if (mustFree) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2595 |
free(cp2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2596 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2597 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2598 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2599 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2600 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2601 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2602 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2603 |
#undef NLOCALBUFFER |
295 | 2604 |
%}. |
2605 |
"x/y not integer, badGC or drawable, or not a string" |
|
2606 |
self primitiveFailed |
|
2607 |
! |
|
2608 |
||
2609 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2610 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
2611 |
foreground and background characters. |
|
2612 |
If the coordinates are not integers, an error is triggered." |
|
2613 |
||
2614 |
%{ /* NOCONTEXT */ |
|
2615 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2616 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2617 |
Window win; |
295 | 2618 |
unsigned char *cp; |
2619 |
int n; |
|
2620 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2621 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2622 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2623 |
int nInstBytes; |
295 | 2624 |
|
2625 |
if (__isExternalAddress(aGCId) |
|
2626 |
&& __isExternalAddress(aDrawableId) |
|
2627 |
&& __isNonNilObject(aString) |
|
2628 |
&& __bothSmallInteger(x, y)) { |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2629 |
gc = _GCVal(aGCId); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2630 |
win = _WindowVal(aDrawableId); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2631 |
cls = __qClass(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2632 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2633 |
cp = _stringVal(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2634 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2635 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2636 |
n = _stringSize(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2637 |
if (n > 1000) n = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2638 |
if (opaque == true) |
555 | 2639 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2640 |
else |
555 | 2641 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2642 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2643 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2644 |
|
555 | 2645 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2646 |
cp += nInstBytes; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2647 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2648 |
if (__isBytes(aString)) { |
555 | 2649 |
n = __byteArraySize(aString) - nInstBytes - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2650 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2651 |
if (n > 1000) n = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2652 |
if (opaque == true) |
555 | 2653 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2654 |
else |
555 | 2655 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2656 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2657 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2658 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2659 |
/* TWOBYTESTRINGS */ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2660 |
if (__isWords(aString)) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2661 |
union { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2662 |
char b[2]; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2663 |
unsigned short s; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2664 |
} u; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2665 |
int i; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2666 |
XChar2b *cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2667 |
int mustFree = 0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2668 |
|
555 | 2669 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2670 |
if (n > 1000) n = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2671 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2672 |
/* |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2673 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2674 |
* X expects them MSB first |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2675 |
* convert as required |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2676 |
*/ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2677 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2678 |
u.s = 0x1234; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2679 |
if (u.b[0] != 0x12) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2680 |
if (n <= NLOCALBUFFER) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2681 |
cp2 = xlatebuffer; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2682 |
} else { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2683 |
cp2 = (XChar2b *)(malloc(n * 2)); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2684 |
mustFree = 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2685 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2686 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2687 |
for (i=0; i<n; i++) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2688 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2689 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2690 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2691 |
cp = (char *) cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2692 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2693 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2694 |
if (opaque == true) |
555 | 2695 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2696 |
else |
555 | 2697 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2698 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2699 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2700 |
if (mustFree) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2701 |
free(cp2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2702 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2703 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2704 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2705 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2706 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2707 |
#undef NLOCALBUFFER |
295 | 2708 |
%}. |
2709 |
"x/y not integer, badGC or drawable, or not a string" |
|
2710 |
self primitiveFailed |
|
2711 |
! |
|
2712 |
||
2713 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2714 |
width:imageWidth height:imageHeight |
|
2715 |
x:srcx y:srcy |
|
2716 |
into:aDrawableId |
|
2717 |
x:dstx y:dsty |
|
2718 |
width:w height:h |
|
2719 |
with:aGCId |
|
2720 |
||
2721 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2722 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2723 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
2724 |
depth and pixel-units to be different. |
|
2725 |
It has to be checked elsewhere, that the server can do it with the given |
|
2726 |
depth - otherwise, primitive failure will be signalled. |
|
2727 |
Also it is assumed, that the colormap is setup correctly and the |
|
2728 |
colors are allocated - otherwise the colors may be wrong." |
|
2729 |
||
2730 |
" |
|
2731 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
2732 |
an unlimited stack, and thus cannot send primitiveFailed |
|
2733 |
" |
|
2734 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2735 |
width:imageWidth height:imageHeight |
|
2736 |
x:srcx y:srcy |
|
2737 |
into:aDrawableId |
|
2738 |
x:dstx y:dsty |
|
2739 |
width:w height:h |
|
2740 |
with:aGCId) |
|
2741 |
ifFalse:[ |
|
2742 |
" |
|
2743 |
also happens, if a segmentation violation occurs in the |
|
2744 |
XPutImage ... |
|
2745 |
" |
|
2746 |
self primitiveFailed |
|
2747 |
]. |
|
2748 |
! |
|
2749 |
||
2750 |
drawBits:imageBits depth:imageDepth |
|
2751 |
width:imageWidth height:imageHeight |
|
2752 |
x:srcx y:srcy |
|
2753 |
into:aDrawableId |
|
2754 |
x:dstx y:dsty |
|
2755 |
width:w height:h |
|
2756 |
with:aGCId |
|
2757 |
||
2758 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2759 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2760 |
Individual source pixels must have imageDepth bits. |
|
2761 |
It has to be checked elsewhere, that the server can do it with the given |
|
2762 |
depth - otherwise, primitive failure will be signalled. |
|
2763 |
Also it is assumed, that the colormap is setup correctly and the |
|
2764 |
colors are allocated - otherwise the colors may be wrong." |
|
2765 |
||
2766 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
2767 |
width:imageWidth height:imageHeight |
|
2768 |
x:srcx y:srcy |
|
2769 |
into:aDrawableId |
|
2770 |
x:dstx y:dsty |
|
2771 |
width:w height:h |
|
2772 |
with:aGCId |
|
2773 |
||
2774 |
! |
|
2775 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2776 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2777 |
in:aDrawableId with:aGCId |
90 | 2778 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
2779 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2780 |
|
2781 |
%{ /* NOCONTEXT */ |
|
2782 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2783 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2784 |
Window win; |
0 | 2785 |
int w, h, angle1, angle2; |
2786 |
double f; |
|
2787 |
||
97 | 2788 |
if (__isSmallInteger(startAngle)) |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2789 |
angle1 = __intVal(startAngle) * 64; |
36 | 2790 |
else if (__isFloat(startAngle)) { |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2791 |
f = __floatVal(startAngle); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2792 |
angle1 = f * 64; |
0 | 2793 |
} |
97 | 2794 |
if (__isSmallInteger(angle)) |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2795 |
angle2 = __intVal(angle) * 64; |
36 | 2796 |
else if (__isFloat(angle)) { |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2797 |
f = __floatVal(angle); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2798 |
angle2 = f * 64; |
0 | 2799 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2800 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2801 |
&& __isExternalAddress(aDrawableId) |
97 | 2802 |
&& __bothSmallInteger(x, y) |
2803 |
&& __bothSmallInteger(width, height)) { |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2804 |
gc = _GCVal(aGCId); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2805 |
win = _WindowVal(aDrawableId); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2806 |
w = __intVal(width); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2807 |
h = __intVal(height); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2808 |
/* |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2809 |
* need this check here: some servers simply dump core with bad args |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2810 |
*/ |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2811 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2812 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2813 |
w, h, angle1, angle2); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2814 |
} |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2815 |
RETURN ( self ); |
0 | 2816 |
} |
73 | 2817 |
%}. |
2818 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2819 |
self primitiveFailed |
2820 |
! |
|
2821 |
||
2822 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 2823 |
"fill a polygon given by its points. |
2824 |
If any coordinate is not integer, an error is triggered." |
|
73 | 2825 |
|
2826 |
|numberOfPoints| |
|
0 | 2827 |
|
2828 |
numberOfPoints := aPolygon size. |
|
2829 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2830 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2831 |
Window win; |
73 | 2832 |
OBJ point, x, y; |
2833 |
int i, num; |
|
2834 |
XPoint *points; |
|
2835 |
XPoint qPoints[100]; |
|
377 | 2836 |
int mustFree = 0; |
73 | 2837 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2838 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2839 |
&& __isExternalAddress(aDrawableId) |
97 | 2840 |
&& __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
|
2841 |
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
|
2842 |
win = _WindowVal(aDrawableId); |
555 | 2843 |
num = __intVal(numberOfPoints); |
73 | 2844 |
if (num < 3) { |
70 | 2845 |
RETURN ( self ); |
2846 |
} |
|
73 | 2847 |
/* |
2848 |
* avoid (slow) malloc, if not many points |
|
2849 |
*/ |
|
96 | 2850 |
if (num > 100) { |
73 | 2851 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
96 | 2852 |
if (! points) goto fail; |
377 | 2853 |
mustFree = 1; |
96 | 2854 |
} else |
73 | 2855 |
points = qPoints; |
2856 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2857 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
73 | 2858 |
if (! __isPoint(point)) goto fail; |
2859 |
x = _point_X(point); |
|
2860 |
y = _point_Y(point); |
|
97 | 2861 |
if (! __bothSmallInteger(x, y)) |
73 | 2862 |
goto fail; |
555 | 2863 |
points[i].x = __intVal(x); |
2864 |
points[i].y = __intVal(y); |
|
73 | 2865 |
} |
2866 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
377 | 2867 |
if (mustFree) |
73 | 2868 |
free(points); |
2869 |
RETURN ( self ); |
|
377 | 2870 |
|
0 | 2871 |
fail: ; |
382 | 2872 |
if (mustFree) |
2873 |
free(points); |
|
0 | 2874 |
} |
73 | 2875 |
%}. |
2876 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2877 |
self primitiveFailed |
2878 |
! |
|
2879 |
||
295 | 2880 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
2881 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
2882 |
||
2883 |
%{ /* NOCONTEXT */ |
|
2884 |
||
2885 |
int w, h; |
|
2886 |
||
2887 |
if (__isExternalAddress(aGCId) |
|
2888 |
&& __isExternalAddress(aDrawableId) |
|
2889 |
&& __bothSmallInteger(x, y) |
|
2890 |
&& __bothSmallInteger(width, height)) { |
|
555 | 2891 |
w = __intVal(width); |
2892 |
h = __intVal(height); |
|
295 | 2893 |
/* |
2894 |
* need this check here: some servers simply dump core with bad args |
|
2895 |
*/ |
|
2896 |
if ((w >= 0) && (h >= 0)) { |
|
2897 |
XFillRectangle(myDpy, |
|
2898 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
555 | 2899 |
__intVal(x), __intVal(y), w, h); |
295 | 2900 |
} |
2901 |
RETURN ( self ); |
|
2902 |
} |
|
2903 |
%}. |
|
2904 |
"badGC, badDrawable or coordinates not integer" |
|
2905 |
self primitiveFailed |
|
43 | 2906 |
! |
2907 |
||
2908 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
70 | 2909 |
width:imageWidth height:imageHeight |
2910 |
x:srcx y:srcy |
|
2911 |
into:aDrawableId |
|
2912 |
x:dstx y:dsty |
|
2913 |
width:w height:h |
|
2914 |
with:aGCId |
|
0 | 2915 |
|
132 | 2916 |
"since XPutImage may allocate huge amount of stack space |
2917 |
(some implementations use alloca), this must run with unlimited stack." |
|
2918 |
||
12 | 2919 |
%{ /* UNLIMITEDSTACK */ |
0 | 2920 |
|
43 | 2921 |
/* |
2922 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
2923 |
* XPutImage |
|
2924 |
*/ |
|
2925 |
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
|
2926 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2927 |
Window win; |
43 | 2928 |
XImage image; |
377 | 2929 |
int imgWdth; |
43 | 2930 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2931 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2932 |
&& __isExternalAddress(aDrawableId) |
97 | 2933 |
&& __bothSmallInteger(srcx, srcy) |
2934 |
&& __bothSmallInteger(dstx, dsty) |
|
2935 |
&& __bothSmallInteger(w, h) |
|
2936 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
2937 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 2938 |
&& __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
|
2939 |
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
|
2940 |
win = _WindowVal(aDrawableId); |
46 | 2941 |
#ifdef ARGDEBUG |
70 | 2942 |
printf("args ok\n"); |
46 | 2943 |
#endif |
555 | 2944 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
2945 |
image.width = imgWdth = __intVal(imageWidth); |
|
2946 |
image.height = __intVal(imageHeight); |
|
70 | 2947 |
image.xoffset = 0; |
2948 |
image.format = ZPixmap; |
|
2949 |
image.byte_order = MSBFirst; |
|
2950 |
image.bitmap_unit = 8; |
|
2951 |
image.bitmap_bit_order = MSBFirst; |
|
2952 |
image.bitmap_pad = 8; |
|
555 | 2953 |
image.depth = __intVal(imageDepth); |
2954 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
70 | 2955 |
switch (image.bits_per_pixel) { |
2956 |
case 1: |
|
377 | 2957 |
image.bytes_per_line = (imgWdth + 7) / 8; |
70 | 2958 |
break; |
2959 |
case 2: |
|
377 | 2960 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
70 | 2961 |
break; |
2962 |
case 4: |
|
377 | 2963 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
70 | 2964 |
break; |
2965 |
case 8: |
|
377 | 2966 |
image.bytes_per_line = imgWdth; |
70 | 2967 |
break; |
2968 |
case 16: |
|
377 | 2969 |
image.bytes_per_line = imgWdth*2; |
70 | 2970 |
break; |
2971 |
case 24: |
|
377 | 2972 |
image.bytes_per_line = imgWdth*3; |
70 | 2973 |
break; |
193 | 2974 |
case 32: |
377 | 2975 |
image.bytes_per_line = imgWdth*4; |
193 | 2976 |
break; |
70 | 2977 |
default: |
46 | 2978 |
#ifdef ARGDEBUG |
70 | 2979 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 2980 |
#endif |
70 | 2981 |
goto fail; |
2982 |
} |
|
2983 |
image.red_mask = 0xFFFF; |
|
2984 |
image.green_mask = 0xFFFF; |
|
2985 |
image.blue_mask = 0xFFFF; |
|
555 | 2986 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
2987 |
__intVal(dstx), __intVal(dsty), |
|
2988 |
__intVal(w), __intVal(h)); |
|
70 | 2989 |
RETURN ( true ); |
43 | 2990 |
} |
46 | 2991 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2992 |
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
|
2993 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 2994 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
2995 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
2996 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
2997 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
2998 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
2999 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3000 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3001 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3002 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3003 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3004 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3005 |
#endif |
3006 |
||
0 | 3007 |
fail: ; |
3008 |
%} |
|
3009 |
. |
|
12 | 3010 |
^ false |
0 | 3011 |
! ! |
3012 |
||
86 | 3013 |
!XWorkstation methodsFor:'event handling'! |
0 | 3014 |
|
3015 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3016 |
"central event handling method: |
|
54 | 3017 |
get next event and send appropriate message to the sensor or view. |
0 | 3018 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3019 |
otherwise only events for the view with given id are processed. |
3020 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3021 |
handled." |
|
3022 |
||
54 | 3023 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
3024 |
AbortSignal catch:[ |
83 | 3025 |
self dispatchLastEvent. |
3026 |
] |
|
54 | 3027 |
]. |
12 | 3028 |
! |
3029 |
||
295 | 3030 |
dispatchExposeEventFor:aViewIdOrNil |
3031 |
"get next expose event and send appropriate message to the sensor or view. |
|
3032 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3033 |
otherwise only events for the view with given id are processed." |
|
3034 |
||
3035 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3036 |
! |
3037 |
||
3038 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3039 |
|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
|
3040 |
eventType| |
12 | 3041 |
|
3042 |
%{ /* STACK: 8000 */ |
|
3043 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3044 |
|
3045 |
Display *dpy = myDpy; |
|
135 | 3046 |
OBJ eB; |
3047 |
XEvent *ev; |
|
3048 |
||
3049 |
# define ae ((XAnyEvent *)ev) |
|
3050 |
# define ee ((XExposeEvent *)ev) |
|
3051 |
# define ke ((XKeyPressedEvent *)ev) |
|
3052 |
# define be ((XButtonPressedEvent *)ev) |
|
3053 |
# define ce ((XConfigureEvent *)ev) |
|
3054 |
# define me ((XMotionEvent *)ev) |
|
3055 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3056 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3057 |
# define de ((XDestroyWindowEvent *)ev) |
|
3058 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3059 |
# define mape ((XMappingEvent *)ev) |
135 | 3060 |
|
0 | 3061 |
KeySym keySym; |
3062 |
unsigned char buffer[10]; |
|
3063 |
int i, nchars; |
|
3064 |
char *keySymString; |
|
3065 |
char keySymStringBuffer[32]; |
|
3066 |
static unsigned multiClickTime = 0; |
|
3067 |
unsigned nextMultiClickTime; |
|
150 | 3068 |
OBJ upDown; |
115 | 3069 |
|
3070 |
struct inlineCache *ipS; |
|
0 | 3071 |
static struct inlineCache vid = _ILC1; |
12 | 3072 |
|
3073 |
static struct inlineCache expS = _ILC5; |
|
3074 |
static struct inlineCache gexpS = _ILC5; |
|
3075 |
static struct inlineCache nexpS = _ILC1; |
|
3076 |
static struct inlineCache motS = _ILC4; |
|
3077 |
static struct inlineCache bpS = _ILC4; |
|
3078 |
static struct inlineCache bmpS = _ILC4; |
|
3079 |
static struct inlineCache bspS = _ILC4; |
|
3080 |
static struct inlineCache brS = _ILC4; |
|
3081 |
static struct inlineCache focInS = _ILC1; |
|
3082 |
static struct inlineCache focOutS = _ILC1; |
|
3083 |
static struct inlineCache peS = _ILC4; |
|
3084 |
static struct inlineCache plS = _ILC2; |
|
54 | 3085 |
static struct inlineCache termS = _ILC1; |
3086 |
static struct inlineCache savtermS = _ILC1; |
|
3087 |
static struct inlineCache destrS = _ILC1; |
|
3088 |
static struct inlineCache unmapS = _ILC1; |
|
3089 |
static struct inlineCache mapS = _ILC1; |
|
3090 |
static struct inlineCache confS = _ILC5; |
|
70 | 3091 |
static struct inlineCache coveredS = _ILC2; |
12 | 3092 |
|
3093 |
static struct inlineCache keymap = _ILC0; |
|
3094 |
static struct inlineCache created = _ILC0; |
|
3095 |
static struct inlineCache mapReq = _ILC0; |
|
3096 |
static struct inlineCache repar = _ILC0; |
|
3097 |
static struct inlineCache confReq = _ILC0; |
|
3098 |
static struct inlineCache resReq = _ILC0; |
|
3099 |
static struct inlineCache prop = _ILC0; |
|
129 | 3100 |
static struct inlineCache selClear = _ILC1; |
90 | 3101 |
static struct inlineCache selReq = _ILC4; |
3102 |
static struct inlineCache selNotify = _ILC4; |
|
12 | 3103 |
static struct inlineCache colormap = _ILC0; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3104 |
static struct inlineCache mapping = _ILC2; |
70 | 3105 |
static struct inlineCache vis = _ILC1; |
12 | 3106 |
|
3107 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3108 |
static struct inlineCache skrS = _ILC4; |
12 | 3109 |
|
555 | 3110 |
eB = __INST(eventBuffer); |
135 | 3111 |
if (__isByteArray(eB)) { |
555 | 3112 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3113 |
} else { |
3114 |
printf("DISPLAY: no eventBuffer\n"); |
|
3115 |
RETURN (false); |
|
3116 |
} |
|
3117 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3118 |
windowID = __MKOBJ(ae->window); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3119 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID); |
12 | 3120 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3121 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
70 | 3122 |
RETURN (nil); |
12 | 3123 |
} |
3124 |
||
3125 |
/* |
|
3126 |
* key, button and pointer events are sent to the sensor, |
|
3127 |
* or (if there is none) to the delegate. |
|
3128 |
* or (if there is none) to the view. |
|
26 | 3129 |
* |
3130 |
* expose events are sent to the sensor, |
|
3131 |
* or (if there is none) to the view |
|
3132 |
* |
|
12 | 3133 |
* sensor and delegate get view as additional argument |
115 | 3134 |
* all of this has been taken out of here to corresponding methods |
3135 |
* in DeviceWorkstation. |
|
12 | 3136 |
*/ |
90 | 3137 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3138 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3139 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3140 |
#endif |
135 | 3141 |
switch (ev->type) { |
70 | 3142 |
case KeyRelease: |
115 | 3143 |
symS = @symbol(keyRelease:x:y:view:); |
70 | 3144 |
ipS = &skrS; |
150 | 3145 |
upDown = false; |
70 | 3146 |
goto keyPressAndRelease; |
3147 |
||
3148 |
case KeyPress: |
|
115 | 3149 |
symS = @symbol(keyPress:x:y:view:); |
70 | 3150 |
ipS = &skpS; |
150 | 3151 |
upDown = true; |
3152 |
/* FALL INTO */ |
|
70 | 3153 |
|
3154 |
keyPressAndRelease: |
|
555 | 3155 |
__INST(eventRootX) = __MKSMALLINT(ke->x_root); |
3156 |
__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
|
3157 |
#ifdef OLD |
555 | 3158 |
__INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
3159 |
__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
|
3160 |
#else |
555 | 3161 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3162 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3163 |
#endif |
555 | 3164 |
__INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
3165 |
__INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
|
70 | 3166 |
|
3167 |
arg = nil; |
|
3168 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
|
3169 |
if (nchars |
|
3170 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
|
3171 |
|| (buffer[0] >= 0x80))) { |
|
3172 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
|
3173 |
keySymString = NULL; |
|
3174 |
} else { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3175 |
#ifdef OLD |
150 | 3176 |
switch (keySym) { |
3177 |
case XK_Control_L: |
|
3178 |
case XK_Control_R: |
|
555 | 3179 |
__INST(ctrlDown) = upDown; |
150 | 3180 |
break; |
3181 |
case XK_Shift_L: |
|
3182 |
case XK_Shift_R: |
|
555 | 3183 |
__INST(shiftDown) = upDown; |
150 | 3184 |
break; |
3185 |
case XK_Meta_L: |
|
3186 |
case XK_Meta_R: |
|
555 | 3187 |
__INST(metaDown) = upDown; |
150 | 3188 |
break; |
3189 |
case XK_Alt_L: |
|
3190 |
case XK_Alt_R: |
|
555 | 3191 |
__INST(altDown) = upDown; |
150 | 3192 |
break; |
3193 |
} |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3194 |
#endif |
150 | 3195 |
|
70 | 3196 |
keySymString = XKeysymToString(keySym); |
3197 |
if (keySymString) { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3198 |
#ifdef OLD |
70 | 3199 |
if (keySymString[0] == 'D') { |
3200 |
/* |
|
3201 |
* remove underscore, dont want it in symbols |
|
3202 |
*/ |
|
3203 |
if (strcmp(keySymString, "Delete_line") == 0) { |
|
3204 |
keySymString = "DeleteLine"; |
|
3205 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
|
3206 |
keySymString = "DeleteWord"; |
|
3207 |
} |
|
3208 |
} |
|
3209 |
/* |
|
3210 |
* make names compatible |
|
3211 |
*/ |
|
3212 |
if (strcmp(keySymString, "Down") == 0) { |
|
3213 |
keySymString = "CursorDown"; |
|
3214 |
} else if (strcmp(keySymString, "Up") == 0) { |
|
3215 |
keySymString = "CursorUp"; |
|
3216 |
} else if (strcmp(keySymString, "Left") == 0) { |
|
3217 |
keySymString = "CursorLeft"; |
|
3218 |
} else if (strcmp(keySymString, "Right") == 0) { |
|
3219 |
keySymString = "CursorRight"; |
|
3220 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3221 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3222 |
#else |
350 | 3223 |
__PROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3224 |
arg = __MKSTRING(keySymString COMMA_CON); |
350 | 3225 |
__UNPROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3226 |
#endif |
70 | 3227 |
} |
3228 |
} |
|
3229 |
||
3230 |
if (arg == nil) { |
|
3231 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
|
3232 |
break; |
|
3233 |
} |
|
3234 |
||
115 | 3235 |
(*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS, |
3236 |
arg, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3237 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3238 |
__MKSMALLINT(ke->y), |
115 | 3239 |
theView); |
70 | 3240 |
break; |
3241 |
||
3242 |
case ButtonPress: |
|
555 | 3243 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); |
3244 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3245 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
3246 |
||
3247 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
|
3248 |
nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); |
|
70 | 3249 |
else |
3250 |
nextMultiClickTime = 0; |
|
3251 |
||
3252 |
if (multiClickTime) { |
|
3253 |
if (be->time < multiClickTime) { |
|
3254 |
multiClickTime = nextMultiClickTime; |
|
3255 |
ipS = &bmpS; |
|
3256 |
symS = @symbol(buttonMultiPress:x:y:view:); |
|
3257 |
goto sendButtonEvent; |
|
3258 |
break; |
|
3259 |
} |
|
3260 |
} |
|
3261 |
multiClickTime = nextMultiClickTime; |
|
3262 |
if (be->state & ShiftMask) { |
|
3263 |
ipS = &bspS; |
|
3264 |
symS = @symbol(buttonShiftPress:x:y:view:); |
|
3265 |
goto sendButtonEvent; |
|
3266 |
} |
|
3267 |
ipS = &bpS; |
|
3268 |
symS = @symbol(buttonPress:x:y:view:); |
|
3269 |
goto sendButtonEvent; |
|
200 | 3270 |
|
70 | 3271 |
/* NOT REACHED */ |
3272 |
||
3273 |
case ButtonRelease: |
|
555 | 3274 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); |
3275 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3276 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
70 | 3277 |
ipS = &brS; |
3278 |
symS = @symbol(buttonRelease:x:y:view:); |
|
3279 |
/* fall into */ |
|
3280 |
||
3281 |
sendButtonEvent: |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3282 |
butt = __MKSMALLINT(be->button); |
12 | 3283 |
#ifdef NOTDEF |
70 | 3284 |
/* |
3285 |
* this allows operation with single button mouses: meta-click is always Button 2 |
|
3286 |
*/ |
|
555 | 3287 |
if (__INST(metaDown) == true) |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3288 |
butt = __MKSMALLINT(2); |
70 | 3289 |
else |
0 | 3290 |
#endif |
555 | 3291 |
butt = __AT_(__INST(buttonTranslation), butt); |
200 | 3292 |
|
12 | 3293 |
|
115 | 3294 |
(*(*ipS).ilc_func)(self, |
3295 |
symS |
|
3296 |
COMMA_CON, nil, ipS, |
|
3297 |
butt, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3298 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3299 |
__MKSMALLINT(ke->y), |
115 | 3300 |
theView); |
70 | 3301 |
break; |
3302 |
||
3303 |
case MotionNotify: |
|
555 | 3304 |
if (__INST(motionEventCompression) != false) { |
135 | 3305 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
70 | 3306 |
} |
3307 |
||
555 | 3308 |
__INST(eventRootX) = __MKSMALLINT(me->x_root); |
3309 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
|
70 | 3310 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3311 |
#ifdef OLD |
555 | 3312 |
__INST(altDown) = (me->state & Mod2Mask) ? true : false; |
3313 |
__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
|
3314 |
#else |
555 | 3315 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3316 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3317 |
#endif |
555 | 3318 |
__INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
3319 |
__INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
|
150 | 3320 |
|
115 | 3321 |
(*motS.ilc_func)(self, |
3322 |
@symbol(buttonMotion:x:y:view:) |
|
3323 |
COMMA_CON, nil, &motS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3324 |
__MKSMALLINT(me->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3325 |
__MKSMALLINT(me->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3326 |
__MKSMALLINT(me->y), |
115 | 3327 |
theView); |
70 | 3328 |
break; |
3329 |
||
3330 |
case FocusIn: |
|
115 | 3331 |
(*focInS.ilc_func)(self, |
3332 |
@symbol(focusInView:) |
|
3333 |
COMMA_CON, nil, &focInS, |
|
3334 |
theView); |
|
70 | 3335 |
break; |
3336 |
||
3337 |
case FocusOut: |
|
115 | 3338 |
(*focOutS.ilc_func)(self, |
3339 |
@symbol(focusOutView:) |
|
3340 |
COMMA_CON, nil, &focOutS, |
|
3341 |
theView); |
|
70 | 3342 |
break; |
3343 |
||
3344 |
case EnterNotify: |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3345 |
#ifdef OLD |
555 | 3346 |
__INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
3347 |
__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
|
3348 |
#else |
555 | 3349 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3350 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3351 |
#endif |
555 | 3352 |
__INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
3353 |
__INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
|
150 | 3354 |
|
115 | 3355 |
(*peS.ilc_func)(self, |
3356 |
@symbol(pointerEnter:x:y:view:) |
|
3357 |
COMMA_CON, nil, &peS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3358 |
__MKSMALLINT(ewe->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3359 |
__MKSMALLINT(ewe->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3360 |
__MKSMALLINT(ewe->y), |
115 | 3361 |
theView); |
70 | 3362 |
break; |
3363 |
||
3364 |
case LeaveNotify: |
|
115 | 3365 |
(*plS.ilc_func)(self, |
3366 |
@symbol(pointerLeave:view:) |
|
3367 |
COMMA_CON, nil, &plS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3368 |
__MKSMALLINT(lwe->state), |
115 | 3369 |
theView); |
70 | 3370 |
break; |
3371 |
||
3372 |
case GraphicsExpose: |
|
115 | 3373 |
(*gexpS.ilc_func)(self, |
3374 |
@symbol(graphicExposeX:y:width:height:view:) |
|
3375 |
COMMA_CON, nil, &gexpS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3376 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3377 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3378 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3379 |
__MKSMALLINT(ee->height), |
115 | 3380 |
theView); |
3381 |
||
3382 |
if (ee->count != 0) { |
|
70 | 3383 |
break; |
3384 |
} |
|
115 | 3385 |
/* fall into */ |
3386 |
||
3387 |
case NoExpose: |
|
3388 |
(*nexpS.ilc_func)(self, |
|
3389 |
@symbol(noExposeView:) |
|
3390 |
COMMA_CON, nil, &nexpS, |
|
3391 |
theView); |
|
3392 |
break; |
|
3393 |
||
3394 |
case Expose: |
|
3395 |
(*expS.ilc_func)(self, |
|
3396 |
@symbol(exposeX:y:width:height:view:) |
|
3397 |
COMMA_CON, nil, &expS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3398 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3399 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3400 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3401 |
__MKSMALLINT(ee->height), |
115 | 3402 |
theView); |
70 | 3403 |
break; |
3404 |
||
3405 |
case ConfigureNotify: |
|
3406 |
if (ce->above != None) { |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3407 |
siblingID = __MKOBJ(ce->above); |
70 | 3408 |
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
|
3409 |
COMMA_CON, nil, &vid, siblingID); |
70 | 3410 |
} |
3411 |
||
115 | 3412 |
(*confS.ilc_func)(self, |
3413 |
@symbol(configureX:y:width:height:view:) |
|
3414 |
COMMA_CON, nil, &confS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3415 |
__MKSMALLINT(ce->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3416 |
__MKSMALLINT(ce->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3417 |
__MKSMALLINT(ce->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3418 |
__MKSMALLINT(ce->height), |
115 | 3419 |
theView); |
70 | 3420 |
if (sibling != nil) { |
115 | 3421 |
(*coveredS.ilc_func)(self, |
3422 |
@symbol(coveredBy:view:) |
|
3423 |
COMMA_CON, nil, &coveredS, |
|
3424 |
theView, |
|
3425 |
sibling); |
|
70 | 3426 |
} |
3427 |
break; |
|
3428 |
||
3429 |
case ClientMessage: |
|
555 | 3430 |
if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) { |
3431 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom))) |
|
3432 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) { |
|
115 | 3433 |
(*termS.ilc_func)(self, |
3434 |
@symbol(terminateView:) |
|
3435 |
COMMA_CON, nil, &termS, theView); |
|
70 | 3436 |
break; |
3437 |
} |
|
555 | 3438 |
if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) { |
115 | 3439 |
(*savtermS.ilc_func)(self, |
3440 |
@symbol(saveAndTerminateView:) |
|
3441 |
COMMA_CON, nil, &savtermS, theView); |
|
70 | 3442 |
break; |
3443 |
} |
|
3444 |
} |
|
3445 |
break; |
|
3446 |
||
3447 |
case DestroyNotify: |
|
115 | 3448 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
3449 |
COMMA_CON, nil, &destrS, theView); |
|
70 | 3450 |
break; |
3451 |
||
3452 |
case UnmapNotify: |
|
115 | 3453 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
3454 |
COMMA_CON, nil, &unmapS, theView); |
|
70 | 3455 |
break; |
3456 |
||
3457 |
case MapNotify: |
|
115 | 3458 |
(*mapS.ilc_func)(self, |
3459 |
@symbol(mappedView:) |
|
3460 |
COMMA_CON, nil, &mapS, theView); |
|
70 | 3461 |
break; |
3462 |
||
3463 |
case KeymapNotify: |
|
115 | 3464 |
(*keymap.ilc_func)(theView, |
3465 |
@symbol(keyMapChange) |
|
3466 |
COMMA_CON, nil, &keymap); |
|
70 | 3467 |
break; |
3468 |
||
3469 |
case VisibilityNotify: |
|
3470 |
switch (ve->state) { |
|
3471 |
case VisibilityUnobscured: |
|
3472 |
arg = @symbol(unobscured); |
|
3473 |
break; |
|
3474 |
case VisibilityPartiallyObscured: |
|
3475 |
arg = @symbol(partiallyObscured); |
|
3476 |
break; |
|
3477 |
case VisibilityFullyObscured: |
|
3478 |
arg = @symbol(fullyObscured); |
|
3479 |
break; |
|
3480 |
} |
|
3481 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:) COMMA_CON, nil, &vis, arg); |
|
3482 |
break; |
|
3483 |
||
3484 |
case CreateNotify: |
|
3485 |
(*created.ilc_func)(theView, @symbol(created) COMMA_CON, nil, &created); |
|
3486 |
break; |
|
3487 |
||
3488 |
case MapRequest: |
|
3489 |
(*mapReq.ilc_func)(theView, @symbol(mapRequest) COMMA_CON, nil, &mapReq); |
|
3490 |
break; |
|
3491 |
||
3492 |
case ReparentNotify: |
|
3493 |
(*repar.ilc_func)(theView, @symbol(reparented) COMMA_CON, nil, &repar); |
|
3494 |
break; |
|
3495 |
||
3496 |
case ConfigureRequest: |
|
3497 |
(*confReq.ilc_func)(theView, @symbol(configRequest) COMMA_CON, nil, &confReq); |
|
3498 |
break; |
|
3499 |
||
3500 |
case GravityNotify: |
|
3501 |
case ResizeRequest: |
|
3502 |
(*resReq.ilc_func)(theView, @symbol(resizeRequest) COMMA_CON, nil, &resReq); |
|
3503 |
break; |
|
3504 |
||
3505 |
case CirculateNotify: |
|
3506 |
case CirculateRequest: |
|
3507 |
break; |
|
3508 |
||
3509 |
case PropertyNotify: |
|
115 | 3510 |
(*prop.ilc_func)(theView, |
3511 |
@symbol(propertyChange) |
|
3512 |
COMMA_CON, nil, &prop); |
|
70 | 3513 |
break; |
3514 |
||
3515 |
case SelectionClear: |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3516 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
115 | 3517 |
(*selClear.ilc_func)(theView, |
129 | 3518 |
@symbol(selectionClear:) |
3519 |
COMMA_CON, nil, &selClear, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3520 |
selectionID); |
70 | 3521 |
break; |
3522 |
||
90 | 3523 |
case SelectionNotify: |
3524 |
/* |
|
3525 |
* returned selection value (answer from SelectionRequest) |
|
3526 |
*/ |
|
129 | 3527 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
135 | 3528 |
ev->xselection.property, ev->xselection.target, |
3529 |
ev->xselection.selection, ev->xselection.requestor)); |
|
129 | 3530 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3531 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3532 |
targetID = __MKATOMOBJ(ev->xselection.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3533 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3534 |
requestorID = __MKOBJ(ev->xselection.requestor); |
115 | 3535 |
(*selNotify.ilc_func)(theView, |
3536 |
@symbol(selectionNotify:target:selection:from:) |
|
3537 |
COMMA_CON, nil, &selNotify, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3538 |
propertyID, targetID, selectionID, requestorID); |
70 | 3539 |
break; |
3540 |
||
90 | 3541 |
case SelectionRequest: |
129 | 3542 |
/* |
3543 |
* someone wants the selection |
|
3544 |
*/ |
|
3545 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
|
135 | 3546 |
ev->xselectionrequest.property, |
3547 |
ev->xselectionrequest.target, |
|
3548 |
ev->xselectionrequest.selection, |
|
3549 |
ev->xselectionrequest.requestor)); |
|
129 | 3550 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3551 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3552 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3553 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3554 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
115 | 3555 |
(*selReq.ilc_func)(theView, |
3556 |
@symbol(selectionRequest:target:selection:from:) |
|
3557 |
COMMA_CON, nil, &selReq, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3558 |
propertyID, targetID, selectionID, requestorID); |
70 | 3559 |
break; |
3560 |
||
3561 |
case ColormapNotify: |
|
115 | 3562 |
(*colormap.ilc_func)(theView, |
3563 |
@symbol(colorMapChange) |
|
3564 |
COMMA_CON, nil, &colormap); |
|
70 | 3565 |
break; |
3566 |
||
3567 |
case MappingNotify: |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3568 |
switch(mape->request) { |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3569 |
case MappingModifier: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3570 |
arg = @symbol(mappingModifier); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3571 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3572 |
case MappingKeyboard: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3573 |
arg = @symbol(mappingKeyboard); |
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 MappingPointer: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3576 |
arg = @symbol(mappingPointer); |
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 |
default: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3579 |
arg = nil; |
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 |
} |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3582 |
(*mapping.ilc_func)(self, |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3583 |
@symbol(mappingChanged:event:) |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3584 |
COMMA_CON, nil, &mapping, arg, eB); |
70 | 3585 |
break; |
0 | 3586 |
} |
135 | 3587 |
#undef ae |
0 | 3588 |
#undef ee |
3589 |
#undef ke |
|
3590 |
#undef be |
|
3591 |
#undef ce |
|
3592 |
#undef me |
|
3593 |
#undef ewe |
|
3594 |
#undef lwe |
|
3595 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3596 |
#undef mape |
0 | 3597 |
%} |
3598 |
. |
|
3599 |
^ true |
|
3600 |
! |
|
3601 |
||
295 | 3602 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3603 |
"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
|
3604 |
(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
|
3605 |
This code is somewhat special, since X has a concept of graphic |
295 | 3606 |
expose events (which are sent after a bitblt). After such a bitblt, |
3607 |
we only handle exposes until the graphicsExpose arrives. |
|
3608 |
Other systems may not need such a kludge" |
|
3609 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3610 |
"interested in exposes only ?" |
295 | 3611 |
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
|
3612 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
295 | 3613 |
self dispatchExposeEventFor:dispatchingExpose |
3614 |
]. |
|
3615 |
^ self |
|
3616 |
]. |
|
3617 |
||
3618 |
"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
|
3619 |
[self eventPendingWithSync:false] whileTrue:[ |
295 | 3620 |
self dispatchEventFor:nil withMask:nil |
3621 |
] |
|
3622 |
! |
|
3623 |
||
81 | 3624 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
3625 |
"dispose (throw away) specific events. If aWindowId is nil, |
|
3626 |
events matching the mask are thrown away regardless of which |
|
3627 |
view they are for. Otherwise, only matching events for that |
|
3628 |
view are flushed." |
|
0 | 3629 |
|
3630 |
%{ /* NOCONTEXT */ |
|
3631 |
||
3632 |
Display *dpy = myDpy; |
|
3633 |
XEvent ev; |
|
3634 |
Window win; |
|
3635 |
||
97 | 3636 |
if (__isSmallInteger(aMask)) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3637 |
if (__isExternalAddress(aWindowIdOrNil)) { |
81 | 3638 |
win = _WindowVal(aWindowIdOrNil); |
555 | 3639 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
81 | 3640 |
} else { |
555 | 3641 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
81 | 3642 |
} |
70 | 3643 |
RETURN ( self ); |
0 | 3644 |
} |
3645 |
%} |
|
3646 |
. |
|
3647 |
self primitiveFailed |
|
3648 |
! |
|
3649 |
||
295 | 3650 |
eventMaskFor:anEventSymbol |
3651 |
"return the eventMask bit-constant corresponding to an event symbol" |
|
3652 |
||
3653 |
%{ /* NOCONTEXT */ |
|
3654 |
||
3655 |
int m = 0; |
|
3656 |
||
3657 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
3658 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
3659 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
3660 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
3661 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
3662 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
3663 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
3664 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
3665 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
3666 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
3667 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
3668 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
3669 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
3670 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
3671 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
3672 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3673 |
RETURN (__MKSMALLINT(m)); |
295 | 3674 |
%} |
3675 |
! |
|
3676 |
||
12 | 3677 |
eventPending |
310 | 3678 |
"return true, if any event is pending. |
3679 |
This looks for both the internal queue and the display connection." |
|
12 | 3680 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3681 |
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
|
3682 |
|
12 | 3683 |
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
|
3684 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 3685 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3686 |
^ self eventPendingWithSync:false |
0 | 3687 |
! |
3688 |
||
295 | 3689 |
eventPending:anEventSymbol for:aWindowIdOrNil |
3690 |
"return true, if a specific event is pending" |
|
3691 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3692 |
^ 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
|
3693 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3694 |
|
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3695 |
eventPendingWithSync:doSync |
7 | 3696 |
"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
|
3697 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 3698 |
before checking." |
0 | 3699 |
|
12 | 3700 |
%{ /* UNLIMITEDSTACK */ |
0 | 3701 |
|
3702 |
Display *dpy = myDpy; |
|
3703 |
||
150 | 3704 |
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
|
3705 |
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
|
3706 |
XSync(dpy, 0); /* make certain everything is flushed */ |
150 | 3707 |
} |
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 (XPending(dpy)) { |
150 | 3709 |
RETURN (true); |
3710 |
} |
|
3711 |
} |
|
3712 |
RETURN ( false ); |
|
0 | 3713 |
%} |
3714 |
! |
|
3715 |
||
341 | 3716 |
eventQueued |
3717 |
"return true, if any event is queued" |
|
3718 |
||
3719 |
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
|
3720 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 3721 |
]. |
3722 |
^ self eventQueuedAlready |
|
3723 |
||
3724 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
3725 |
! |
|
3726 |
||
3727 |
eventQueuedAlready |
|
3728 |
"return true, if any event is queued internally. |
|
3729 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
3730 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
3731 |
the display connection)." |
|
3732 |
||
3733 |
%{ /* UNLIMITEDSTACK */ |
|
3734 |
||
3735 |
if (ISCONNECTED) { |
|
3736 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
|
3737 |
RETURN (true); |
|
3738 |
} |
|
3739 |
} |
|
3740 |
RETURN ( false ); |
|
3741 |
%} |
|
3742 |
! |
|
3743 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3744 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 3745 |
"return true, if any of the masked events is pending" |
3746 |
||
3747 |
%{ /* UNLIMITEDSTACK */ |
|
3748 |
||
3749 |
Display *dpy = myDpy; |
|
3750 |
XEvent ev; |
|
3751 |
Window win; |
|
3752 |
int thereIsOne; |
|
3753 |
||
3754 |
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
|
3755 |
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
|
3756 |
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
|
3757 |
} |
295 | 3758 |
if (__isExternalAddress(aWindowIdOrNil)) { |
3759 |
win = _WindowVal(aWindowIdOrNil); |
|
555 | 3760 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
295 | 3761 |
} else { |
555 | 3762 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
295 | 3763 |
} |
3764 |
if (thereIsOne) { |
|
3765 |
XPutBackEvent(dpy, &ev); |
|
3766 |
RETURN ( true ); |
|
3767 |
} |
|
3768 |
} |
|
3769 |
RETURN ( false ); |
|
3770 |
%} |
|
3771 |
! |
|
3772 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3773 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 3774 |
"return true, if any expose event is pending for a specific view, |
3775 |
or any view (if the arg is nil). |
|
3776 |
This is an X specific, only required after a scroll operation." |
|
7 | 3777 |
|
12 | 3778 |
%{ /* UNLIMITEDSTACK */ |
7 | 3779 |
|
3780 |
Display *dpy = myDpy; |
|
3781 |
XEvent ev; |
|
3782 |
Window win; |
|
81 | 3783 |
int thereIsOne; |
3784 |
||
150 | 3785 |
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
|
3786 |
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
|
3787 |
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
|
3788 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3789 |
if (__isExternalAddress(aWindowIdOrNil)) { |
150 | 3790 |
win = _WindowVal(aWindowIdOrNil); |
3791 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
3792 |
} else { |
|
3793 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
3794 |
} |
|
3795 |
if (thereIsOne) { |
|
3796 |
XPutBackEvent(dpy, &ev); |
|
3797 |
RETURN ( true ); |
|
3798 |
} |
|
81 | 3799 |
} |
3800 |
RETURN ( false ); |
|
3801 |
%} |
|
3802 |
! |
|
3803 |
||
295 | 3804 |
getEventFor:aViewIdOrNil withMask:eventMask |
3805 |
"read next event - put into local eventBuffer. |
|
3806 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
3807 |
otherwise only events for that specific view will be fetched. |
|
3808 |
Returns true, if there was an event, false otherwise. |
|
3809 |
This method may block - so you better check for pending events |
|
3810 |
before calling for it. |
|
3811 |
||
3812 |
Sorry I had to split dispatch into this fetch method and an extra |
|
3813 |
handle method to allow unlimitedstack here. |
|
3814 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
3815 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
3816 |
BUG: uses a static buffer - has to be rewritten, to support multiple |
|
3817 |
display connections. |
|
3818 |
" |
|
81 | 3819 |
|
3820 |
%{ /* UNLIMITEDSTACK */ |
|
3821 |
||
3822 |
Display *dpy = myDpy; |
|
295 | 3823 |
Window win, wWanted; |
3824 |
int evMask; |
|
3825 |
OBJ eB; |
|
3826 |
XEvent *ev; |
|
3827 |
||
3828 |
if (! ISCONNECTED) { |
|
3829 |
RETURN (false); |
|
3830 |
} |
|
3831 |
||
555 | 3832 |
eB = __INST(eventBuffer); |
295 | 3833 |
if (__isByteArray(eB)) { |
555 | 3834 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 3835 |
} else { |
3836 |
printf("DISPLAY: no eventBuffer\n"); |
|
3837 |
RETURN (false); |
|
3838 |
} |
|
3839 |
ev->type = 0; |
|
3840 |
||
3841 |
if (__isSmallInteger(eventMask)) { |
|
555 | 3842 |
evMask = __intVal(eventMask); |
295 | 3843 |
} else { |
3844 |
evMask = ~0; |
|
3845 |
} |
|
3846 |
||
3847 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
3848 |
wWanted = _WindowVal(aViewIdOrNil); |
|
3849 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
|
70 | 3850 |
RETURN ( true ); |
3851 |
} |
|
295 | 3852 |
} else { |
3853 |
if (evMask == ~0) { |
|
3854 |
XNextEvent(dpy, ev); |
|
3855 |
RETURN (true); |
|
3856 |
} |
|
3857 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
|
3858 |
RETURN (true); |
|
3859 |
} |
|
3860 |
} |
|
3861 |
%}. |
|
3862 |
^ false |
|
3863 |
! |
|
3864 |
||
3865 |
handleAllEvents |
|
3866 |
"from now on, handle any kind of event" |
|
3867 |
||
3868 |
dispatchingExpose := nil |
|
3869 |
! |
|
3870 |
||
3871 |
handleExposeOnlyFor:aView |
|
3872 |
"from now on, handle expose events only" |
|
3873 |
||
3874 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3875 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3876 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3877 |
mappingChanged:what event:eB |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3878 |
"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
|
3879 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3880 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3881 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3882 |
self refreshKeyboardMapping:eB. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3883 |
"Maybe some of our modifiers have been changed" |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3884 |
self initializeModifierMappings. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3885 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3886 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3887 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 3888 |
! |
3889 |
||
3890 |
setEventMask:aMask in:aWindowId |
|
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3891 |
"tell X that we are only interested in events from aMask, which |
295 | 3892 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
3893 |
||
3894 |
%{ /* NOCONTEXT */ |
|
3895 |
||
3896 |
int mask; |
|
3897 |
||
3898 |
if (__isExternalAddress(aWindowId) |
|
3899 |
&& __isSmallInteger(aMask)) { |
|
555 | 3900 |
mask = __intVal(aMask); |
295 | 3901 |
|
3902 |
#ifdef OLD |
|
3903 |
/* these may not be disabled */ |
|
3904 |
mask |= ExposureMask | StructureNotifyMask | |
|
3905 |
KeyPressMask | KeyReleaseMask | |
|
3906 |
EnterWindowMask | LeaveWindowMask | |
|
3907 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
3908 |
#endif |
|
3909 |
||
3910 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
|
3911 |
RETURN ( self ); |
|
3912 |
} |
|
3913 |
%} |
|
3914 |
. |
|
3915 |
self primitiveFailed |
|
3916 |
! |
|
3917 |
||
3918 |
startDispatch |
|
3919 |
"redefined to clear dispatchingExpose, which is a special X feature" |
|
3920 |
||
3921 |
dispatching ifTrue:[^ self]. |
|
3922 |
dispatchingExpose := nil. |
|
3923 |
super startDispatch |
|
0 | 3924 |
! ! |
295 | 3925 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3926 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3927 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3928 |
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
|
3929 |
"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
|
3930 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3931 |
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
|
3932 |
for key events, it can be either a symbol (as listen in X's keySyms) |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3933 |
or a numeric keysym code. If state is nil, the modifier bits (shift & control) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3934 |
are computed from the keyboardMap - if non-nil, these are passed as modifierbits. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3935 |
The non-nil case is the lowlevel entry, where state must include any shift/ctrl information |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3936 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3937 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3938 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3939 |
Display *dpy = myDpy; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3940 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3941 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3942 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3943 |
if (__isSmallInteger(stateMask)) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3944 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3945 |
} else { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3946 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3947 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3948 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3949 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3950 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3951 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3952 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3953 |
XEvent ev; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3954 |
Window target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3955 |
Status result; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3956 |
KeySym keySym, *syms; |
555 | 3957 |
int screen = __intVal(__INST(screen)); |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3958 |
char s[2]; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3959 |
int nSyms; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3960 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3961 |
if ((typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3962 |
|| (typeSymbol == @symbol(keyRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3963 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3964 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3965 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3966 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3967 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3968 |
s[1] = '\0'; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3969 |
keySym = XStringToKeysym(s); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3970 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3971 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3972 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3973 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3974 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3975 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3976 |
if (stateMask == nil) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3977 |
/* |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3978 |
* get the modifier from the keySym |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3979 |
*/ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3980 |
nSyms = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3981 |
syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3982 |
if (syms) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3983 |
int i; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3984 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3985 |
for (i=0; i<nSyms; i++) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3986 |
if (syms[i] == keySym) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3987 |
#ifdef MODIFIERDEBUG |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3988 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3989 |
#endif |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3990 |
if (i) state = (1 << (i-1)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3991 |
break; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3992 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3993 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3994 |
XFree(syms); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3995 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3996 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3997 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3998 |
if ((typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3999 |
|| (typeSymbol == @symbol(buttonRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4000 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4001 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4002 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4003 |
ev.xbutton.button = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4004 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4005 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4006 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4007 |
RETURN (false); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4008 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4009 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4010 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4011 |
if (typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4012 |
ev.xany.type = KeyPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4013 |
else if (typeSymbol == @symbol(keyRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4014 |
ev.xany.type = KeyRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4015 |
else if (typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4016 |
ev.xany.type = ButtonPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4017 |
else if (typeSymbol == @symbol(buttonRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4018 |
ev.xany.type = ButtonRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4019 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4020 |
if (__isExternalAddress(targetId)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4021 |
target = _WindowVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4022 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4023 |
target = (Window) __longIntVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4024 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4025 |
ev.xkey.window = target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4026 |
ev.xkey.same_screen = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4027 |
ev.xkey.subwindow = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4028 |
ev.xkey.root = RootWindow(myDpy, screen); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4029 |
ev.xkey.x = __intVal(xPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4030 |
ev.xkey.y = __intVal(yPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4031 |
ev.xkey.state = state; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4032 |
ev.xkey.time = CurrentTime; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4033 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4034 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4035 |
if ((result == BadValue) || (result == BadWindow)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4036 |
DPRINTF(("bad status\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4037 |
RETURN ( false ) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4038 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4039 |
RETURN (true) |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4040 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4041 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4042 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4043 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4044 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4045 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4046 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4047 |
"send input to some other view, by simulating keyPress/keyRelease |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4048 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4049 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4050 |
Notice: not all alien views allow this kind of synthetic input; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4051 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4052 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4053 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4054 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4055 |
aCharacterOrString isString ifTrue:[ |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4056 |
aCharacterOrString do:[:char | |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4057 |
self simulateKeyboardInput:char inViewId:viewId |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4058 |
]. |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4059 |
^ self |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4060 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4061 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4062 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4063 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4064 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4065 |
(aCharacterOrString == Character cr) ifTrue:[ |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4066 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4067 |
] ifFalse:[ |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4068 |
(aCharacterOrString == Character tab) ifTrue:[ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4069 |
code := #Tab |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4070 |
] ifFalse:[ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4071 |
(aCharacterOrString == Character esc) ifTrue:[ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4072 |
code := #Escape |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4073 |
] |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4074 |
] |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4075 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4076 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4077 |
control ifTrue:[ |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4078 |
state := state bitOr:(self controlMask) |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4079 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4080 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4081 |
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
|
4082 |
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
|
4083 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4084 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4085 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4086 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4087 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4088 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4089 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4090 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4091 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4092 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4093 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4094 |
"Modified: 1.3.1996 / 18:31:15 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4095 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4096 |
|
295 | 4097 |
!XWorkstation methodsFor:'font stuff'! |
4098 |
||
4099 |
ascentOf:aFontId |
|
4100 |
"the normal ascent" |
|
4101 |
||
4102 |
%{ /* NOCONTEXT */ |
|
4103 |
||
4104 |
XFontStruct *f; |
|
4105 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4106 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4107 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4108 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4109 |
RETURN ( __MKSMALLINT(f->ascent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4110 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4111 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4112 |
%}. |
295 | 4113 |
self primitiveFailed. |
4114 |
^ nil |
|
4115 |
! |
|
4116 |
||
4117 |
createFontFor:aFontName |
|
4118 |
"a basic method for X-font allocation; this method allows |
|
4119 |
any font to be aquired (even those not conforming to |
|
4120 |
standard naming conventions, such as cursor, fixed or k14)" |
|
4121 |
||
4122 |
%{ /* UNLIMITEDSTACK */ |
|
4123 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
4124 |
||
4125 |
XFontStruct *newFont; |
|
4126 |
||
4127 |
if (ISCONNECTED) { |
|
4128 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
|
4129 |
BEGIN_INTERRUPTSBLOCKED |
|
4130 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
4131 |
END_INTERRUPTSBLOCKED |
|
4132 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
4133 |
} |
|
4134 |
} |
|
4135 |
%}. |
|
4136 |
^ nil |
|
4137 |
! |
|
4138 |
||
4139 |
decomposeXFontName:aString into:aBlock |
|
4140 |
"extract family, face, style and size from an |
|
4141 |
X-font name |
|
4142 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
4143 |
evaluate aBlock with these" |
|
4144 |
||
4145 |
|origin family face style moreStyle skip fheight size |
|
4146 |
resX resY x1 x2 coding start end | |
|
4147 |
||
4148 |
aString isNil ifTrue:[^ false]. |
|
4149 |
(aString startsWith:'-') ifFalse:[ |
|
4150 |
" |
|
4151 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
|
4152 |
" |
|
4153 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
|
4154 |
end := aString indexOf:$- startingAt:1. |
|
4155 |
family := aString copyFrom:1 to:(end - 1). |
|
4156 |
start := end + 1. |
|
4157 |
end := aString indexOf:$- startingAt:start. |
|
4158 |
style := aString copyFrom:start to:(end - 1). |
|
4159 |
start := end + 1. |
|
4160 |
size := aString copyFrom:start. |
|
4161 |
size := (Number readFromString:size onError:[^false]). |
|
4162 |
aBlock value:family value:nil value:style value:size value:nil. |
|
4163 |
^ true. |
|
4164 |
]. |
|
4165 |
('*-[0-9]*' match:aString) ifTrue:[ |
|
4166 |
" |
|
4167 |
something like lucidasans-24 |
|
4168 |
" |
|
4169 |
end := aString indexOf:$- startingAt:1. |
|
4170 |
||
4171 |
family := aString copyFrom:1 to:(end - 1). |
|
4172 |
start := end + 1. |
|
4173 |
size := aString copyFrom:start. |
|
4174 |
size := (Number readFromString:size onError:[^false]). |
|
4175 |
aBlock value:family value:nil value:nil value:size value:nil. |
|
4176 |
^ true. |
|
4177 |
]. |
|
4178 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
|
4179 |
^ true. |
|
4180 |
]. |
|
4181 |
||
4182 |
end := aString indexOf:$- startingAt:2. |
|
4183 |
(end == 0) ifTrue:[^ false]. |
|
4184 |
origin := aString copyFrom:2 to:(end - 1). |
|
4185 |
||
4186 |
start := end + 1. |
|
4187 |
end := aString indexOf:$- startingAt:start. |
|
4188 |
(end == 0) ifTrue:[^ false]. |
|
4189 |
family := aString copyFrom:start to:(end - 1). |
|
4190 |
||
4191 |
start := end + 1. |
|
4192 |
end := aString indexOf:$- startingAt:start. |
|
4193 |
(end == 0) ifTrue:[^ false]. |
|
4194 |
face := aString copyFrom:start to:(end - 1). |
|
4195 |
||
4196 |
start := end + 1. |
|
4197 |
end := aString indexOf:$- startingAt:start. |
|
4198 |
(end == 0) ifTrue:[^ false]. |
|
4199 |
style := aString copyFrom:start to:(end - 1). |
|
4200 |
(style = 'o') ifTrue:[ |
|
4201 |
style := 'oblique' |
|
4202 |
] ifFalse:[ |
|
4203 |
(style = 'i') ifTrue:[ |
|
4204 |
style := 'italic' |
|
4205 |
] ifFalse:[ |
|
4206 |
(style = 'r') ifTrue:[ |
|
4207 |
style := 'roman' |
|
4208 |
] |
|
4209 |
] |
|
4210 |
]. |
|
4211 |
||
4212 |
start := end + 1. |
|
4213 |
end := aString indexOf:$- startingAt:start. |
|
4214 |
(end == 0) ifTrue:[^ false]. |
|
4215 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
4216 |
||
4217 |
start := end + 1. |
|
4218 |
end := aString indexOf:$- startingAt:start. |
|
4219 |
(end == 0) ifTrue:[^ false]. |
|
4220 |
skip := aString copyFrom:start to:(end - 1). |
|
4221 |
||
4222 |
start := end + 1. |
|
4223 |
end := aString indexOf:$- startingAt:start. |
|
4224 |
(end == 0) ifTrue:[^ false]. |
|
4225 |
fheight := aString copyFrom:start to:(end - 1). |
|
4226 |
||
4227 |
start := end + 1. |
|
4228 |
end := aString indexOf:$- startingAt:start. |
|
4229 |
(end == 0) ifTrue:[^ false]. |
|
4230 |
size := aString copyFrom:start to:(end - 1). |
|
4231 |
size := (Number readFromString:size) / 10. |
|
4232 |
||
4233 |
start := end + 1. |
|
4234 |
end := aString indexOf:$- startingAt:start. |
|
4235 |
(end == 0) ifTrue:[^ false]. |
|
4236 |
resX := aString copyFrom:start to:(end - 1). |
|
4237 |
||
4238 |
start := end + 1. |
|
4239 |
end := aString indexOf:$- startingAt:start. |
|
4240 |
(end == 0) ifTrue:[^ false]. |
|
4241 |
resY := aString copyFrom:start to:(end - 1). |
|
4242 |
||
4243 |
start := end + 1. |
|
4244 |
end := aString indexOf:$- startingAt:start. |
|
4245 |
(end == 0) ifTrue:[^ false]. |
|
4246 |
x1 := aString copyFrom:start to:(end - 1). |
|
4247 |
||
4248 |
start := end + 1. |
|
4249 |
end := aString indexOf:$- startingAt:start. |
|
4250 |
(end == 0) ifTrue:[^ false]. |
|
4251 |
x2 := aString copyFrom:start to:(end - 1). |
|
4252 |
||
4253 |
start := end + 1. |
|
4254 |
end := aString indexOf:$- startingAt:start. |
|
4255 |
(end == 0) ifTrue:[^ false]. |
|
4256 |
coding := aString copyFrom:start to:(end - 1). |
|
4257 |
||
4258 |
aBlock value:family value:face value:style value:size value:coding. |
|
4259 |
^ true |
|
4260 |
||
4261 |
"Modified: 27.9.1995 / 10:46:52 / stefan" |
|
4262 |
! |
|
4263 |
||
4264 |
descentOf:aFontId |
|
4265 |
"the normal descent" |
|
4266 |
||
4267 |
%{ /* NOCONTEXT */ |
|
4268 |
||
4269 |
XFontStruct *f; |
|
4270 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4271 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4272 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4273 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4274 |
RETURN ( __MKSMALLINT(f->descent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4275 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4276 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4277 |
%}. |
295 | 4278 |
self primitiveFailed. |
4279 |
^ nil |
|
4280 |
! |
|
4281 |
||
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4282 |
encodingOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4283 |
"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
|
4284 |
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
|
4285 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4286 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4287 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4288 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4289 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4290 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4291 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4292 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4293 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4294 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4295 |
registryAtom = XInternAtom(myDpy, "CHARSET_REGISTRY", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4296 |
encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4297 |
charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4298 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4299 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4300 |
if (ISCONNECTED) { |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4301 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4302 |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4303 |
f = _FontVal(aFontId); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4304 |
if (f) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4305 |
n = f->n_properties; |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4306 |
prop = f->properties; |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4307 |
if (prop) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4308 |
while (n--) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4309 |
cp = XGetAtomName(myDpy, prop->name); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4310 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4311 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4312 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4313 |
if (prop->name == XA_FULL_NAME) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4314 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4315 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4316 |
fullName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4317 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4318 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4319 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4320 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4321 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4322 |
if (prop->name == fontAtom) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4323 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4324 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4325 |
fontName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4326 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4327 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4328 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4329 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4330 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4331 |
if (prop->name == encodingAtom) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4332 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4333 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4334 |
encoding = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4335 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4336 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4337 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4338 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4339 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4340 |
if (prop->name == registryAtom) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4341 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4342 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4343 |
registry = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4344 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4345 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4346 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4347 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4348 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4349 |
if (prop->name == charSetCollAtom) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4350 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4351 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4352 |
charSetCollections = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4353 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4354 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4355 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4356 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4357 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4358 |
prop++; |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4359 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4360 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4361 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4362 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4363 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4364 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4365 |
^ self |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4366 |
extractEncodingFromRegistry:registry |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4367 |
encoding:encoding |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4368 |
charSetCollections:charSetCollections |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4369 |
! |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4370 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4371 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4372 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4373 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4374 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4375 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4376 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4377 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4378 |
] ifFalse:[ |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4379 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4380 |
enc := encoding asLowercase asSymbol |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4381 |
] ifFalse:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4382 |
charSets := charSetCollections. |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4383 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4384 |
charSets := charSets asUppercase asCollectionOfWords. |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4385 |
(charSets includes:'ISO8859-1') ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4386 |
enc := #iso8859 |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4387 |
] ifFalse:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4388 |
(charSets includes:'ISO8859') ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4389 |
enc := #iso8859 |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4390 |
] ifFalse:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4391 |
(charSets includes:'ASCII') ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4392 |
enc := #ascii |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4393 |
] ifFalse:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4394 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4395 |
enc := #iso8859 |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4396 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4397 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4398 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4399 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4400 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4401 |
] |
440
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 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4404 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4405 |
"Created: 17.4.1996 / 14:57:06 / cg" |
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4406 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
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 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4409 |
flushListOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4410 |
"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
|
4411 |
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
|
4412 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4413 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4414 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4415 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4416 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4417 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4418 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4419 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4420 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4421 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4422 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4423 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4424 |
fullNameOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4425 |
"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
|
4426 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4427 |
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
|
4428 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4429 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4430 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4431 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4432 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4433 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4434 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4435 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4436 |
Atom fontAtom; |
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 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
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 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4441 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4442 |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4443 |
f = _FontVal(aFontId); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4444 |
if (f) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4445 |
n = f->n_properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4446 |
prop = f->properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4447 |
if (prop) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4448 |
while (n--) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4449 |
cp = XGetAtomName(myDpy, prop->name); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4450 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4451 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4452 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4453 |
if (prop->name == XA_FULL_NAME) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4454 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4455 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4456 |
fullName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4457 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4458 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4459 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4460 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4461 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4462 |
if (prop->name == fontAtom) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4463 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4464 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4465 |
fontName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4466 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4467 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4468 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4469 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4470 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4471 |
prop++; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4472 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4473 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4474 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4475 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4476 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4477 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4478 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4479 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4480 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4481 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4482 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4483 |
|
295 | 4484 |
getAvailableFontsMatching:pattern |
4485 |
"return an Array filled with font names matching aPattern" |
|
4486 |
||
4487 |
%{ /* UNLIMITEDSTACK */ |
|
4488 |
||
4489 |
int nnames = 1500; |
|
4490 |
int available = nnames + 1; |
|
4491 |
char **fonts; |
|
4492 |
OBJ arr, str; |
|
4493 |
int i; |
|
4494 |
||
4495 |
if (ISCONNECTED) { |
|
4496 |
if (__isString(pattern)) { |
|
4497 |
for (;;) { |
|
4498 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
4499 |
if ((fonts == NULL) || (available < nnames)) break; |
|
4500 |
XFreeFontNames(fonts); |
|
4501 |
nnames = available * 2; |
|
4502 |
} |
|
4503 |
if (fonts == NULL) { |
|
4504 |
RETURN ( nil ); |
|
4505 |
} |
|
4506 |
/* |
|
4507 |
* now, that we know the number of font names, |
|
4508 |
* create the array ... |
|
4509 |
*/ |
|
4510 |
arr = __ARRAY_NEW_INT(available); |
|
4511 |
if (! arr) { |
|
4512 |
RETURN (nil); |
|
4513 |
} |
|
4514 |
/* |
|
4515 |
* ... and fill it |
|
4516 |
*/ |
|
4517 |
for (i=0; i<available; i++) { |
|
350 | 4518 |
__PROTECT__(arr); |
295 | 4519 |
str = __MKSTRING(fonts[i] COMMA_CON); |
350 | 4520 |
__UNPROTECT__(arr); |
295 | 4521 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
4522 |
} |
|
4523 |
RETURN (arr); |
|
4524 |
} |
|
4525 |
} |
|
4526 |
%}. |
|
4527 |
^ nil |
|
4528 |
! |
|
4529 |
||
4530 |
getDefaultFont |
|
4531 |
"return a default font id - used when class Font cannot |
|
4532 |
find anything usable" |
|
4533 |
||
4534 |
^ self createFontFor:'fixed' |
|
4535 |
! |
|
4536 |
||
4537 |
getFontWithFamily:familyString face:faceString |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4538 |
style:styleString size:sizeArg encoding:encodingSym |
295 | 4539 |
|
4540 |
"try to get the specified font, if not available, try next smaller |
|
4541 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
4542 |
as family and the other parameters as nil. For example, the cursor font |
|
4543 |
can be aquired that way." |
|
4544 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4545 |
|theName theId xlatedStyle id | |
295 | 4546 |
|
4547 |
"special: if face is nil, allow access to X-fonts" |
|
4548 |
faceString isNil ifTrue:[ |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4549 |
sizeArg notNil ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4550 |
theName := familyString , '-' , sizeArg printString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4551 |
] ifFalse:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4552 |
theName := familyString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4553 |
]. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4554 |
theName isNil ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4555 |
" |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4556 |
mhmh - fall back to the default font |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4557 |
" |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4558 |
theName := 'fixed' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4559 |
]. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4560 |
theId := self createFontFor:theName. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4561 |
theId isNil ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4562 |
theId := self getDefaultFont |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4563 |
]. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4564 |
^ theId |
295 | 4565 |
]. |
4566 |
||
4567 |
xlatedStyle := styleString. |
|
4568 |
xlatedStyle notNil ifTrue:[ |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4569 |
xlatedStyle := xlatedStyle first asString |
295 | 4570 |
]. |
4571 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4572 |
id := self |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4573 |
getFontWithFoundry:'*' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4574 |
family:familyString asLowercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4575 |
weight:faceString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4576 |
slant:xlatedStyle |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4577 |
spacing:'normal' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4578 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4579 |
size:sizeArg |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4580 |
registry:encodingSym |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4581 |
encoding:'*'. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4582 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4583 |
id isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4584 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4585 |
"/ too stupid: encodings come in both cases |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4586 |
"/ and X does not ignore case |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4587 |
"/ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4588 |
id := self |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4589 |
getFontWithFoundry:'*' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4590 |
family:familyString asLowercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4591 |
weight:faceString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4592 |
slant:xlatedStyle |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4593 |
spacing:'normal' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4594 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4595 |
size:sizeArg |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4596 |
registry:encodingSym asUppercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4597 |
encoding:'*'. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4598 |
id isNil ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4599 |
id := self |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4600 |
getFontWithFoundry:'*' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4601 |
family:familyString asLowercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4602 |
weight:faceString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4603 |
slant:xlatedStyle |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4604 |
spacing:'normal' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4605 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4606 |
size:sizeArg |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4607 |
registry:encodingSym asLowercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4608 |
encoding:'*'. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4609 |
] |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4610 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4611 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4612 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4613 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4614 |
"Modified: 24.2.1996 / 22:37:24 / cg" |
295 | 4615 |
! |
4616 |
||
4617 |
getFontWithFoundry:foundry family:family weight:weight |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4618 |
slant:slant spacing:spc pixelSize:pSize size:size |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4619 |
registry:registry encoding:encoding |
295 | 4620 |
|
4621 |
"get the specified font, if not available, return nil. |
|
4622 |
This is the new font creation method - all others will be changed to |
|
4623 |
use this entry. |
|
4624 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
4625 |
||
4626 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
4627 |
family: 'helvetica' 'courier' 'times' ... |
|
4628 |
weight: 'bold' 'medium' 'demi' ... |
|
4629 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
4630 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
4631 |
pixelSize: 16,18 ... usually left empty |
|
4632 |
size: size in point (1/72th of an inch) |
|
4633 |
registry: iso8859, sgi ... '*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4634 |
encoding: vendor specific encoding (usually '*') |
295 | 4635 |
" |
4636 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4637 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4638 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4639 |
pSizeMatch registryMatch encodingMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4640 |
id| |
295 | 4641 |
|
4642 |
"this works only on 'Release >= 3' - X-servers" |
|
4643 |
"name is: |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4644 |
-foundry-family -weight -slant- |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4645 |
sony helvetica bold r |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4646 |
adobe courier medium i |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4647 |
msic fixed o |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4648 |
... ... |
295 | 4649 |
" |
4650 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4651 |
size isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4652 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4653 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4654 |
sizeMatch := size printString , '0' |
457
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 |
foundry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4657 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4658 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4659 |
foundryMatch := foundry |
457
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 |
family isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4662 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4663 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4664 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4665 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4666 |
weight isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4667 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4668 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4669 |
weightMatch := weight |
457
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 |
slant isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4672 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4673 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4674 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4675 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4676 |
spc isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4677 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4678 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4679 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4680 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4681 |
pSize isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4682 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4683 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4684 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4685 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4686 |
registry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4687 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4688 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4689 |
registryMatch := registry |
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 |
encoding isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4692 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4693 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4694 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4695 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4696 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4697 |
theName := ('-' , foundryMatch, |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4698 |
'-' , familyMatch, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4699 |
'-' , weightMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4700 |
'-' , slantMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4701 |
'-' , spcMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4702 |
'-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4703 |
'-' , pSizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4704 |
'-' , sizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4705 |
'-*-*-*-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4706 |
'-' , registryMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4707 |
'-' , encodingMatch). |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4708 |
|
697 | 4709 |
"/ Transcript showCR:theName; endEntry. |
295 | 4710 |
|
4711 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4712 |
|
295 | 4713 |
|
4714 |
" |
|
4715 |
Display getFontWithFoundry:'*' |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4716 |
family:'courier' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4717 |
weight:'medium' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4718 |
slant:'r' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4719 |
spacing:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4720 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4721 |
size:13 |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4722 |
registry:'iso8859' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4723 |
encoding:'*' |
295 | 4724 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4725 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4726 |
"Modified: 24.2.1996 / 22:33:29 / cg" |
295 | 4727 |
! |
4728 |
||
4729 |
listOfAvailableFonts |
|
4730 |
"return a list with all available fonts on this display. |
|
4731 |
Since this takes a long time, keep the result of the query for the |
|
4732 |
next time. The elements of the returned collection are instances of |
|
4733 |
FontDescription." |
|
4734 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
4735 |
|"stream aName fntDescr" names| |
295 | 4736 |
|
4737 |
listOfXFonts isNil ifTrue:[ |
|
4738 |
"/ |
|
4739 |
"/ old code; using a pipe to xlsfonts |
|
4740 |
"/ |
|
4741 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
4742 |
"/ stream isNil ifTrue:[^ nil]. |
|
4743 |
"/ listOfXFonts := OrderedCollection new. |
|
4744 |
"/ [stream atEnd] whileFalse:[ |
|
4745 |
"/ aName := stream nextLine. |
|
4746 |
"/ aName notNil ifTrue:[ |
|
4747 |
"/ self decomposeXFontName:aName into: |
|
4748 |
"/ [:family :face :style :size :coding | |
|
4749 |
"/ family notNil ifTrue:[ |
|
4750 |
"/ fntDescr := FontDescription |
|
4751 |
"/ family:family |
|
4752 |
"/ face:face |
|
4753 |
"/ style:style |
|
4754 |
"/ size:size |
|
4755 |
"/ encoding:coding. |
|
4756 |
"/ listOfXFonts add:fntDescr |
|
4757 |
"/ ] |
|
4758 |
"/ ] |
|
4759 |
"/ ] |
|
4760 |
"/ ]. |
|
4761 |
"/ stream close. |
|
4762 |
"/ "if xlsfont is broken ... (hey sco)" |
|
4763 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
4764 |
"/ listOfXFonts := nil |
|
4765 |
"/ ] ifFalse:[ |
|
4766 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
4767 |
"/ ]. |
|
4768 |
||
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4769 |
"/ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4770 |
"/ new code: |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4771 |
"/ use new primitive to get font names; |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4772 |
"/ this is much faster, and also works on systems where |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4773 |
"/ a) xlsfonts is broken (sco) |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4774 |
"/ b) xlsfonts is not available (aix) |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4775 |
"/ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4776 |
names := self getAvailableFontsMatching:'*'. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4777 |
names isNil ifTrue:[ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4778 |
"no names returned ..." |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4779 |
^ nil |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4780 |
]. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4781 |
listOfXFonts := names collect:[:aName | |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4782 |
|fntDescr| |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4783 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4784 |
(self decomposeXFontName:aName into: |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4785 |
[:family :face :style :size :coding | |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4786 |
family notNil ifTrue:[ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4787 |
fntDescr := FontDescription |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4788 |
family:family |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4789 |
face:face |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4790 |
style:style |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4791 |
size:size |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4792 |
encoding:coding. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4793 |
] ifFalse:[ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4794 |
fntDescr := FontDescription |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4795 |
name:aName |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4796 |
] |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4797 |
] |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4798 |
) ifFalse:[ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4799 |
fntDescr := FontDescription name:aName. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4800 |
]. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4801 |
fntDescr |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4802 |
]. |
295 | 4803 |
|
4804 |
]. |
|
4805 |
^ listOfXFonts |
|
4806 |
||
4807 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4808 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4809 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4810 |
Display getAvailableFontsMatching:'*'. |
295 | 4811 |
" |
4812 |
||
4813 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4814 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 4815 |
! |
4816 |
||
4817 |
maxAscentOf:aFontId |
|
4818 |
"the max ascent" |
|
4819 |
||
4820 |
%{ /* NOCONTEXT */ |
|
4821 |
||
4822 |
XFontStruct *f; |
|
4823 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4824 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4825 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4826 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4827 |
RETURN ( __MKSMALLINT(f->max_bounds.ascent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4828 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4829 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4830 |
%}. |
295 | 4831 |
self primitiveFailed. |
4832 |
^ nil |
|
4833 |
! |
|
4834 |
||
4835 |
maxDescentOf:aFontId |
|
4836 |
"the max descent" |
|
4837 |
||
4838 |
%{ /* NOCONTEXT */ |
|
4839 |
||
4840 |
XFontStruct *f; |
|
4841 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4842 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4843 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4844 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4845 |
RETURN ( __MKSMALLINT(f->max_bounds.descent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4846 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4847 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4848 |
%}. |
295 | 4849 |
self primitiveFailed. |
4850 |
^ nil |
|
4851 |
! |
|
4852 |
||
4853 |
maxWidthOfFont:aFontId |
|
4854 |
"the width of the widest character" |
|
4855 |
||
4856 |
%{ /* NOCONTEXT */ |
|
4857 |
||
4858 |
XFontStruct *f; |
|
4859 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4860 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4861 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4862 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4863 |
RETURN ( __MKSMALLINT(f->max_bounds.width) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4864 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4865 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4866 |
%}. |
295 | 4867 |
self primitiveFailed. |
4868 |
^ nil |
|
4869 |
! |
|
4870 |
||
4871 |
minWidthOfFont:aFontId |
|
4872 |
||
4873 |
%{ /* NOCONTEXT */ |
|
4874 |
||
4875 |
XFontStruct *f; |
|
4876 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4877 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4878 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4879 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4880 |
RETURN ( __MKSMALLINT(f->min_bounds.width) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4881 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4882 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4883 |
%}. |
295 | 4884 |
self primitiveFailed. |
4885 |
^ nil |
|
4886 |
! |
|
4887 |
||
4888 |
releaseFont:aFontId |
|
4889 |
||
4890 |
%{ /* NOCONTEXT */ |
|
4891 |
||
4892 |
XFontStruct *f; |
|
4893 |
||
4894 |
if (ISCONNECTED) { |
|
4895 |
if (__isExternalAddress(aFontId)) { |
|
4896 |
f = _FontVal(aFontId); |
|
4897 |
BEGIN_INTERRUPTSBLOCKED |
|
4898 |
XFreeFont(myDpy, f); |
|
4899 |
END_INTERRUPTSBLOCKED |
|
4900 |
RETURN ( self ); |
|
4901 |
} |
|
4902 |
} |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4903 |
%}. |
295 | 4904 |
self primitiveFailed |
4905 |
! |
|
4906 |
||
466 | 4907 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 4908 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
4909 |
on this display. |
|
4910 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
4911 |
||
4912 |
|sizes| |
|
4913 |
||
466 | 4914 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 4915 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4916 |
"special: in X11R5 and above, size 0 means: |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4917 |
there are scaled versions in all sizes available" |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4918 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4919 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
295 | 4920 |
]. |
4921 |
^ sizes |
|
4922 |
||
4923 |
" |
|
4924 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
4925 |
" |
|
466 | 4926 |
|
4927 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 4928 |
! |
4929 |
||
4930 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
|
4931 |
||
4932 |
%{ /* NOCONTEXT */ |
|
4933 |
||
4934 |
XFontStruct *f; |
|
4935 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4936 |
int len, n, i1, i2, l; |
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
4937 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4938 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4939 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4940 |
int nInstBytes; |
295 | 4941 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4942 |
if (ISCONNECTED) { |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4943 |
if (__bothSmallInteger(index1, index2) |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4944 |
&& __isExternalAddress(aFontId) |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4945 |
&& __isNonNilObject(aString)) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4946 |
f = _FontVal(aFontId); |
555 | 4947 |
i1 = __intVal(index1) - 1; |
4948 |
cls = __qClass(aString); |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4949 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4950 |
if (i1 >= 0) { |
555 | 4951 |
i2 = __intVal(index2) - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4952 |
if (i2 < i1) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4953 |
RETURN (self); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4954 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4955 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4956 |
cp = (char *) _stringVal(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4957 |
l = i2 - i1 + 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4958 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4959 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4960 |
n = _stringSize(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4961 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4962 |
cp += i1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4963 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4964 |
len = XTextWidth(f, cp, l); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4965 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4966 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4967 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4968 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4969 |
|
555 | 4970 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4971 |
cp += nInstBytes; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4972 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4973 |
if (__isBytes(aString)) { |
555 | 4974 |
n = __byteArraySize(aString) - nInstBytes; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4975 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4976 |
cp += i1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4977 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4978 |
len = XTextWidth(f, cp, l); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4979 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4980 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4981 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4982 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4983 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4984 |
/* TWOBYTESTRINGS */ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4985 |
if (__isWords(aString)) { |
555 | 4986 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4987 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4988 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4989 |
union { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4990 |
char b[2]; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4991 |
unsigned short s; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4992 |
} u; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4993 |
int i; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4994 |
XChar2b *cp2 = (XChar2b *)0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4995 |
int mustFree = 0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4996 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4997 |
cp += (i1 * 2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4998 |
if (l > 1000) l = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4999 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5000 |
/* |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5001 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5002 |
* X expects them MSB first |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5003 |
* convert as required |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5004 |
*/ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5005 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5006 |
u.s = 0x1234; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5007 |
if (u.b[0] != 0x12) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5008 |
if (l <= NLOCALBUFFER) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5009 |
cp2 = xlatebuffer; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5010 |
} else { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5011 |
cp2 = (XChar2b *)(malloc(l * 2)); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5012 |
mustFree = 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5013 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5014 |
for (i=0; i<l; i++) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5015 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5016 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5017 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5018 |
cp = (char *) cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5019 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5020 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5021 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5022 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5023 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5024 |
if (mustFree) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5025 |
free(cp2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5026 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5027 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5028 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5029 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5030 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5031 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5032 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5033 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5034 |
#undef NLOCALBUFFER |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5035 |
%}. |
295 | 5036 |
self primitiveFailed. |
5037 |
^ nil |
|
5038 |
! |
|
5039 |
||
5040 |
widthOf:aString inFont:aFontId |
|
5041 |
||
5042 |
%{ /* NOCONTEXT */ |
|
5043 |
||
5044 |
XFontStruct *f; |
|
5045 |
char *cp; |
|
5046 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
5047 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5048 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5049 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5050 |
int nInstBytes; |
295 | 5051 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5052 |
if (ISCONNECTED) { |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5053 |
if (__isExternalAddress(aFontId) |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5054 |
&& __isNonNilObject(aString)) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5055 |
f = _FontVal(aFontId); |
555 | 5056 |
cls = __qClass(aString); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5057 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5058 |
cp = (char *)_stringVal(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5059 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5060 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5061 |
n = _stringSize(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5062 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5063 |
len = XTextWidth(f, cp, n); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5064 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5065 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5066 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5067 |
|
555 | 5068 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5069 |
cp += nInstBytes; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5070 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5071 |
if (__isBytes(aString)) { |
555 | 5072 |
n = __byteArraySize(aString) - nInstBytes; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5073 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5074 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5075 |
len = XTextWidth(f, cp, n); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5076 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5077 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5078 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5079 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5080 |
/* TWOBYTESTRINGS */ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5081 |
if (__isWords(aString)) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5082 |
union { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5083 |
char b[2]; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5084 |
unsigned short s; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5085 |
} u; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5086 |
int i; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5087 |
XChar2b *cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5088 |
int mustFree = 0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5089 |
|
555 | 5090 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5091 |
if (n > 1000) n = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5092 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5093 |
/* |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5094 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5095 |
* X expects them MSB first |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5096 |
* convert as required |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5097 |
*/ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5098 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5099 |
u.s = 0x1234; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5100 |
if (u.b[0] != 0x12) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5101 |
if (n <= NLOCALBUFFER) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5102 |
cp2 = xlatebuffer; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5103 |
} else { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5104 |
cp2 = (XChar2b *)(malloc(n * 2)); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5105 |
mustFree = 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5106 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5107 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5108 |
for (i=0; i<n; i++) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5109 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5110 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5111 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5112 |
cp = (char *) cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5113 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5114 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5115 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5116 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5117 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5118 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5119 |
if (mustFree) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5120 |
free(cp2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5121 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5122 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5123 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5124 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5125 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5126 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5127 |
#undef NLOCALBUFFER |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5128 |
%}. |
295 | 5129 |
self primitiveFailed. |
5130 |
^ nil |
|
5131 |
! ! |
|
5132 |
||
5133 |
!XWorkstation methodsFor:'grabbing '! |
|
5134 |
||
5135 |
allowEvents:mode |
|
5136 |
%{ /* NOCONTEXT */ |
|
5137 |
||
5138 |
int _mode, ok = 1; |
|
5139 |
||
5140 |
if (mode == @symbol(asyncPointer)) |
|
5141 |
_mode = AsyncPointer; |
|
5142 |
else if (mode == @symbol(syncPointer)) |
|
5143 |
_mode = SyncPointer; |
|
5144 |
else if (mode == @symbol(asyncKeyboard)) |
|
5145 |
_mode = AsyncKeyboard; |
|
5146 |
else if (mode == @symbol(syncKeyboard)) |
|
5147 |
_mode = SyncKeyboard; |
|
5148 |
else if (mode == @symbol(syncBoth)) |
|
5149 |
_mode = SyncBoth; |
|
5150 |
else if (mode == @symbol(asyncBoth)) |
|
5151 |
_mode = AsyncBoth; |
|
5152 |
else if (mode == @symbol(replayPointer)) |
|
5153 |
_mode = ReplayPointer; |
|
5154 |
else if (mode == @symbol(replayKeyboard)) |
|
5155 |
_mode = ReplayKeyboard; |
|
5156 |
else |
|
5157 |
ok = 0; |
|
5158 |
||
5159 |
if (ok) { |
|
5160 |
BEGIN_INTERRUPTSBLOCKED |
|
5161 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
5162 |
END_INTERRUPTSBLOCKED |
|
5163 |
RETURN (self); |
|
5164 |
} |
|
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5165 |
%}. |
295 | 5166 |
self primitiveFailed |
5167 |
! |
|
5168 |
||
5169 |
grabKeyboardIn:aWindowId |
|
5170 |
"grab the keyboard" |
|
5171 |
||
5172 |
%{ /* NOCONTEXT */ |
|
5173 |
int result, ok; |
|
5174 |
||
5175 |
if (__isExternalAddress(aWindowId)) { |
|
5176 |
BEGIN_INTERRUPTSBLOCKED |
|
5177 |
result = XGrabKeyboard(myDpy, |
|
5178 |
_WindowVal(aWindowId), |
|
5179 |
True /* False */, |
|
5180 |
GrabModeAsync, |
|
5181 |
GrabModeAsync, |
|
5182 |
CurrentTime); |
|
5183 |
END_INTERRUPTSBLOCKED |
|
5184 |
ok = 0; |
|
5185 |
switch(result) { |
|
5186 |
case AlreadyGrabbed: |
|
5187 |
printf("XWORKSTAT: grab keyboard: AlreadyGrabbed\n"); |
|
5188 |
break; |
|
5189 |
case GrabNotViewable: |
|
5190 |
printf("XWORKSTAT: grab keyboard: GrabNotViewable\n"); |
|
5191 |
break; |
|
5192 |
case GrabInvalidTime: |
|
5193 |
printf("XWORKSTAT: grab keyboard: InvalidTime\n"); |
|
5194 |
break; |
|
5195 |
case GrabFrozen: |
|
5196 |
printf("XWORKSTAT: grab keyboard: Frozen\n"); |
|
5197 |
break; |
|
5198 |
default: |
|
5199 |
ok = 1; |
|
5200 |
break; |
|
5201 |
} |
|
5202 |
if (! ok) { |
|
5203 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5204 |
RETURN (false); |
|
5205 |
} |
|
5206 |
||
5207 |
RETURN ( true ); |
|
5208 |
} |
|
5209 |
%} |
|
5210 |
. |
|
5211 |
self primitiveFailed |
|
5212 |
! |
|
5213 |
||
5214 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
|
5215 |
"grap the pointer - return true if ok" |
|
5216 |
||
5217 |
%{ /* NOCONTEXT */ |
|
5218 |
||
5219 |
int result, ok; |
|
5220 |
Window confineWin; |
|
5221 |
Cursor curs; |
|
5222 |
int pointer_mode, keyboard_mode; |
|
5223 |
||
5224 |
if (__isExternalAddress(aWindowId)) { |
|
5225 |
if (__isExternalAddress(confineId)) |
|
5226 |
confineWin = _WindowVal(confineId); |
|
5227 |
else |
|
5228 |
confineWin = (Window) None; |
|
5229 |
||
5230 |
if (__isExternalAddress(aCursorId)) |
|
5231 |
curs = _CursorVal(aCursorId); |
|
5232 |
else |
|
5233 |
curs = (Cursor) None; |
|
5234 |
||
5235 |
if (pMode == @symbol(sync)) |
|
5236 |
pointer_mode = GrabModeSync; |
|
5237 |
else |
|
5238 |
pointer_mode = GrabModeAsync; |
|
5239 |
||
5240 |
if (kMode == @symbol(sync)) |
|
5241 |
keyboard_mode = GrabModeSync; |
|
5242 |
else |
|
5243 |
keyboard_mode = GrabModeAsync; |
|
5244 |
||
5245 |
BEGIN_INTERRUPTSBLOCKED |
|
5246 |
result = XGrabPointer(myDpy, |
|
5247 |
_WindowVal(aWindowId), |
|
5248 |
False, |
|
5249 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
5250 |
pointer_mode, keyboard_mode, |
|
5251 |
confineWin, |
|
5252 |
curs, |
|
5253 |
CurrentTime); |
|
5254 |
END_INTERRUPTSBLOCKED |
|
5255 |
||
5256 |
ok = 0; |
|
5257 |
switch (result) { |
|
5258 |
case AlreadyGrabbed: |
|
5259 |
printf("XWORKSTAT: grab pointer: AlreadyGrabbed\n"); |
|
5260 |
break; |
|
5261 |
case GrabNotViewable: |
|
5262 |
printf("XWORKSTAT: grab pointer: GrabNotViewable\n"); |
|
5263 |
break; |
|
5264 |
case GrabInvalidTime: |
|
5265 |
printf("XWORKSTAT: grab pointer: InvalidTime\n"); |
|
5266 |
break; |
|
5267 |
case GrabFrozen: |
|
5268 |
printf("XWORKSTAT: grab pointer: Frozen\n"); |
|
5269 |
break; |
|
5270 |
default: |
|
5271 |
ok = 1; |
|
5272 |
break; |
|
5273 |
} |
|
5274 |
||
5275 |
if (! ok) { |
|
5276 |
XUngrabPointer(myDpy, CurrentTime); |
|
5277 |
RETURN (false); |
|
5278 |
} |
|
5279 |
RETURN ( true ); |
|
5280 |
} |
|
5281 |
%} |
|
5282 |
. |
|
5283 |
self primitiveFailed |
|
5284 |
! |
|
5285 |
||
5286 |
ungrabKeyboard |
|
5287 |
"release the keyboard" |
|
5288 |
||
5289 |
%{ /* NOCONTEXT */ |
|
5290 |
||
5291 |
if (ISCONNECTED) { |
|
5292 |
BEGIN_INTERRUPTSBLOCKED |
|
5293 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5294 |
XSync(myDpy, 0); |
|
5295 |
END_INTERRUPTSBLOCKED |
|
5296 |
} |
|
5297 |
%}. |
|
5298 |
activeKeyboardGrab := nil |
|
5299 |
! |
|
5300 |
||
5301 |
ungrabPointer |
|
5302 |
"release the pointer" |
|
5303 |
||
5304 |
%{ /* NOCONTEXT */ |
|
5305 |
||
5306 |
if (ISCONNECTED) { |
|
5307 |
BEGIN_INTERRUPTSBLOCKED |
|
5308 |
XUngrabPointer(myDpy, CurrentTime); |
|
5309 |
XSync(myDpy, 0); |
|
5310 |
END_INTERRUPTSBLOCKED |
|
5311 |
} |
|
5312 |
%}. |
|
5313 |
activePointerGrab := nil |
|
5314 |
! ! |
|
5315 |
||
5316 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
5317 |
||
5318 |
noClipIn:aGCId |
|
5319 |
"disable clipping rectangle" |
|
5320 |
||
5321 |
%{ /* NOCONTEXT */ |
|
5322 |
||
5323 |
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
|
5324 |
GC gc; |
295 | 5325 |
|
5326 |
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
|
5327 |
gc = _GCVal(aGCId); |
295 | 5328 |
gcv.clip_mask = None; |
5329 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
5330 |
RETURN ( self ); |
|
5331 |
} |
|
5332 |
%}. |
|
5333 |
self primitiveFailed |
|
5334 |
! |
|
5335 |
||
5336 |
setBackground:bgColorIndex in:aGCId |
|
5337 |
"set background color to be drawn with" |
|
5338 |
||
5339 |
%{ /* NOCONTEXT */ |
|
5340 |
||
5341 |
if (__isExternalAddress(aGCId) |
|
5342 |
&& __isSmallInteger(bgColorIndex)) { |
|
555 | 5343 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
295 | 5344 |
RETURN ( self ); |
5345 |
} |
|
5346 |
%}. |
|
5347 |
self primitiveFailed |
|
5348 |
! |
|
5349 |
||
5350 |
setBitmapMask:aBitmapId in:aGCId |
|
5351 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
|
5352 |
||
5353 |
%{ /* NOCONTEXT */ |
|
5354 |
||
5355 |
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
|
5356 |
GC gc; |
295 | 5357 |
Pixmap bitmap; |
5358 |
||
5359 |
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
|
5360 |
gc = _GCVal(aGCId); |
295 | 5361 |
if (__isExternalAddress(aBitmapId)) { |
5362 |
bitmap = _PixmapVal(aBitmapId); |
|
5363 |
XSetStipple(dpy, gc, bitmap); |
|
5364 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5365 |
RETURN ( self ); |
|
5366 |
} |
|
5367 |
if (aBitmapId == nil) { |
|
5368 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5369 |
RETURN ( self ); |
|
5370 |
} |
|
5371 |
} |
|
5372 |
%}. |
|
5373 |
self primitiveFailed |
|
5374 |
! |
|
5375 |
||
5376 |
setClipByChildren:aBool in:aGCId |
|
5377 |
"enable/disable drawing into child views" |
|
5378 |
||
5379 |
%{ /* NOCONTEXT */ |
|
5380 |
||
5381 |
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
|
5382 |
GC gc; |
295 | 5383 |
|
5384 |
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
|
5385 |
gc = _GCVal(aGCId); |
295 | 5386 |
if (aBool == true) |
5387 |
gcv.subwindow_mode = ClipByChildren; |
|
5388 |
else |
|
5389 |
gcv.subwindow_mode = IncludeInferiors; |
|
5390 |
||
5391 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
5392 |
RETURN ( self ); |
|
5393 |
} |
|
5394 |
%}. |
|
5395 |
self primitiveFailed |
|
5396 |
! |
|
5397 |
||
5398 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
|
5399 |
"clip to a rectangle" |
|
5400 |
||
5401 |
%{ /* NOCONTEXT */ |
|
5402 |
||
5403 |
XRectangle r; |
|
5404 |
||
5405 |
if (__isExternalAddress(aGCId) |
|
5406 |
&& __bothSmallInteger(clipX, clipY) |
|
5407 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
555 | 5408 |
r.x = __intVal(clipX); |
5409 |
r.y = __intVal(clipY); |
|
5410 |
r.width = __intVal(clipWidth); |
|
5411 |
r.height = __intVal(clipHeight); |
|
295 | 5412 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
5413 |
RETURN ( self ); |
|
5414 |
} |
|
5415 |
%}. |
|
5416 |
self primitiveFailed |
|
5417 |
! |
|
5418 |
||
788 | 5419 |
setDashes:dashList dashOffset:offset in:aGCId |
5420 |
"set line attributes" |
|
5421 |
||
5422 |
%{ /* NOCONTEXT */ |
|
5423 |
||
5424 |
if (__isExternalAddress(aGCId) |
|
5425 |
&& __isSmallInteger(offset) |
|
5426 |
&& __isByteArray(dashList)) { |
|
5427 |
XSetDashes(myDpy, _GCVal(aGCId), |
|
5428 |
__intVal(offset), |
|
5429 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
5430 |
__byteArraySize(dashList)); |
|
5431 |
RETURN ( self ); |
|
5432 |
} |
|
5433 |
bad: ; |
|
5434 |
%}. |
|
5435 |
" |
|
5436 |
either aGCId is invalid, |
|
5437 |
and/or dashList is not a byteArray |
|
5438 |
and/or offset is not a smallInteger |
|
5439 |
" |
|
5440 |
self primitiveFailed |
|
5441 |
! |
|
5442 |
||
295 | 5443 |
setFont:aFontId in:aGCId |
5444 |
"set font to be drawn in" |
|
5445 |
||
5446 |
%{ /* NOCONTEXT */ |
|
5447 |
||
5448 |
XFontStruct *f; |
|
5449 |
||
5450 |
if (__isExternalAddress(aFontId) |
|
5451 |
&& __isExternalAddress(aGCId)) { |
|
5452 |
f = (XFontStruct *) _FontVal(aFontId); |
|
5453 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
5454 |
RETURN ( self ); |
|
5455 |
} |
|
5456 |
%}. |
|
5457 |
" |
|
5458 |
aGCId and/or aFontId are invalid |
|
5459 |
" |
|
5460 |
self primitiveFailed |
|
5461 |
! |
|
5462 |
||
5463 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
|
5464 |
"set foreground and background colors to be drawn with" |
|
5465 |
||
5466 |
%{ /* NOCONTEXT */ |
|
5467 |
||
5468 |
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
|
5469 |
GC gc; |
295 | 5470 |
|
5471 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
5472 |
&& __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
|
5473 |
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
|
5474 |
|
555 | 5475 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
5476 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
295 | 5477 |
RETURN ( self ); |
5478 |
} |
|
5479 |
%}. |
|
5480 |
self primitiveFailed |
|
5481 |
! |
|
5482 |
||
5483 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId |
|
5484 |
"set foreground and background colors to be drawn with using mask or |
|
5485 |
solid (if aBitmapId is nil)" |
|
5486 |
||
5487 |
%{ /* NOCONTEXT */ |
|
5488 |
||
5489 |
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
|
5490 |
GC gc; |
295 | 5491 |
|
5492 |
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
|
5493 |
gc = _GCVal(aGCId); |
295 | 5494 |
if (__isSmallInteger(fgColor)) |
555 | 5495 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5496 |
if (__isSmallInteger(bgColor)) |
555 | 5497 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5498 |
|
5499 |
if (__isExternalAddress(aBitmapId)) { |
|
5500 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5501 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5502 |
RETURN ( self ); |
|
5503 |
} |
|
5504 |
if (aBitmapId == nil) { |
|
5505 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5506 |
RETURN ( self ); |
|
5507 |
} |
|
5508 |
} |
|
5509 |
%}. |
|
5510 |
self primitiveFailed |
|
5511 |
! |
|
5512 |
||
5513 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId |
|
5514 |
"set foreground and background colors to be drawn with using mask or |
|
5515 |
solid (if aBitmapId is nil); also set lineWidth" |
|
5516 |
||
5517 |
%{ /* NOCONTEXT */ |
|
5518 |
||
5519 |
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
|
5520 |
GC gc; |
295 | 5521 |
|
5522 |
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
|
5523 |
gc = _GCVal(aGCId); |
295 | 5524 |
if (__isSmallInteger(lw)) { |
555 | 5525 |
XSetLineAttributes(dpy, gc, __intVal(lw), |
295 | 5526 |
LineSolid, CapNotLast, JoinMiter); |
5527 |
} |
|
5528 |
if (__isSmallInteger(fgColor)) |
|
555 | 5529 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5530 |
if (__isSmallInteger(bgColor)) |
555 | 5531 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5532 |
|
5533 |
if (__isExternalAddress(aBitmapId)) { |
|
5534 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5535 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5536 |
RETURN ( self ); |
|
5537 |
} |
|
5538 |
if (aBitmapId == nil) { |
|
5539 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5540 |
RETURN ( self ); |
|
5541 |
} |
|
5542 |
} |
|
5543 |
%}. |
|
5544 |
self primitiveFailed |
|
5545 |
! |
|
5546 |
||
5547 |
setForeground:fgColorIndex in:aGCId |
|
5548 |
"set foreground color to be drawn with" |
|
5549 |
||
5550 |
%{ /* NOCONTEXT */ |
|
5551 |
||
5552 |
if (__isExternalAddress(aGCId) |
|
5553 |
&& __isSmallInteger(fgColorIndex)) { |
|
555 | 5554 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
295 | 5555 |
RETURN ( self ); |
5556 |
} |
|
5557 |
%}. |
|
5558 |
self primitiveFailed |
|
5559 |
! |
|
5560 |
||
5561 |
setFunction:aFunctionSymbol in:aGCId |
|
5562 |
"set alu function to be drawn with" |
|
5563 |
||
5564 |
%{ /* NOCONTEXT */ |
|
5565 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5566 |
GC gc; |
295 | 5567 |
int fun = -1; |
5568 |
||
5569 |
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
|
5570 |
gc = _GCVal(aGCId); |
295 | 5571 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
5572 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
5573 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
5574 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
5575 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
5576 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
5577 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
5578 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
5579 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
5580 |
if (fun != -1) { |
|
5581 |
XSetFunction(myDpy, gc, fun); |
|
5582 |
RETURN ( self ); |
|
5583 |
} |
|
5584 |
} |
|
5585 |
%}. |
|
5586 |
" |
|
5587 |
either aGCId is not an integer, or an invalid symbol |
|
5588 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
5589 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
5590 |
" |
|
5591 |
self primitiveFailed |
|
5592 |
! |
|
5593 |
||
5594 |
setGraphicsExposures:aBoolean in:aGCId |
|
5595 |
"set or clear the graphics exposures flag" |
|
5596 |
||
5597 |
%{ /* NOCONTEXT */ |
|
5598 |
||
5599 |
if (__isExternalAddress(aGCId)) { |
|
5600 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
5601 |
RETURN ( self ); |
|
5602 |
} |
|
5603 |
%} |
|
5604 |
. |
|
5605 |
self primitiveFailed |
|
5606 |
! |
|
5607 |
||
5608 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
|
5609 |
"set line attributes" |
|
5610 |
||
5611 |
%{ /* NOCONTEXT */ |
|
5612 |
||
5613 |
int x_style, x_cap, x_join; |
|
5614 |
||
5615 |
if (__isExternalAddress(aGCId) |
|
5616 |
&& __isSmallInteger(aNumber)) { |
|
5617 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
5618 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
5619 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
5620 |
else goto bad; |
|
5621 |
||
5622 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
5623 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
5624 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
5625 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
5626 |
else goto bad; |
|
5627 |
||
5628 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
5629 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
5630 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
5631 |
else goto bad; |
|
5632 |
||
5633 |
XSetLineAttributes(myDpy, |
|
555 | 5634 |
_GCVal(aGCId), __intVal(aNumber), |
295 | 5635 |
x_style, x_cap, x_join); |
5636 |
RETURN ( self ); |
|
5637 |
} |
|
5638 |
bad: ; |
|
5639 |
%}. |
|
5640 |
" |
|
5641 |
either aGCId is invalid, |
|
5642 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
|
5643 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
5644 |
and/or joinStyle is none of #miter, #bevel, #round |
|
5645 |
" |
|
5646 |
self primitiveFailed |
|
5647 |
! |
|
5648 |
||
5649 |
setMaskOriginX:orgX y:orgY in:aGCid |
|
5650 |
"set the mask origin" |
|
5651 |
||
5652 |
%{ /* NOCONTEXT */ |
|
5653 |
||
5654 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
|
555 | 5655 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
295 | 5656 |
RETURN ( self ); |
5657 |
} |
|
5658 |
%}. |
|
5659 |
self primitiveFailed |
|
5660 |
! |
|
5661 |
||
5662 |
setPixmapMask:aPixmapId in:aGCId |
|
5663 |
"set or clear the drawing mask - a pixmap mask providing full color" |
|
5664 |
||
5665 |
%{ /* NOCONTEXT */ |
|
5666 |
||
5667 |
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
|
5668 |
GC gc; |
295 | 5669 |
Pixmap pixmap; |
5670 |
||
5671 |
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
|
5672 |
gc = _GCVal(aGCId); |
295 | 5673 |
if (__isExternalAddress(aPixmapId)) { |
5674 |
pixmap = _PixmapVal(aPixmapId); |
|
5675 |
XSetTile(dpy, gc, pixmap); |
|
5676 |
XSetFillStyle(dpy, gc, FillTiled); |
|
5677 |
RETURN ( self ); |
|
5678 |
} |
|
5679 |
if (aPixmapId == nil) { |
|
5680 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5681 |
RETURN ( self ); |
|
5682 |
} |
|
5683 |
} |
|
5684 |
%}. |
|
5685 |
self primitiveFailed |
|
5686 |
! ! |
|
5687 |
||
5688 |
!XWorkstation methodsFor:'initialize / release'! |
|
5689 |
||
5690 |
close |
|
5691 |
"close down the connection to the X-server" |
|
5692 |
||
5693 |
%{ /* NOCONTEXT */ |
|
5694 |
||
5695 |
if (ISCONNECTED) { |
|
5696 |
BEGIN_INTERRUPTSBLOCKED |
|
5697 |
XCloseDisplay(myDpy); |
|
555 | 5698 |
__INST(displayId) = nil; |
295 | 5699 |
END_INTERRUPTSBLOCKED |
5700 |
} |
|
5701 |
%} |
|
5702 |
! |
|
5703 |
||
5704 |
initializeDefaultValues |
|
5705 |
buttonTranslation := ButtonTranslation. |
|
5706 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
5707 |
||
5708 |
self initializeModifierMappings |
|
5709 |
! |
|
5710 |
||
5711 |
initializeEventBuffer |
|
5712 |
|sz| |
|
5713 |
||
5714 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5715 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 5716 |
%}. |
5717 |
eventBuffer isNil ifTrue:[ |
|
5718 |
eventBuffer := ByteArray new:sz. |
|
5719 |
]. |
|
5720 |
! |
|
5721 |
||
5722 |
initializeFor:aDisplayName |
|
5723 |
"initialize the receiver for a connection to an X-Server; |
|
5724 |
the argument, aDisplayName may be nil (for the default server from |
|
5725 |
DISPLAY-variable or command line argument) or the name of the server |
|
5726 |
as hostname:number" |
|
5727 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5728 |
|dpyName index arguments| |
295 | 5729 |
|
5730 |
dpyName := aDisplayName. |
|
5731 |
dpyName isNil ifTrue:[ |
|
5732 |
"look for a '-display xxx' argument" |
|
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5733 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5734 |
index := arguments indexOf:'-display'. |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5735 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5736 |
dpyName := arguments at:index+1 |
295 | 5737 |
] |
5738 |
] |
|
5739 |
]. |
|
5740 |
%{ |
|
5741 |
int scr; |
|
5742 |
Display *dpy; |
|
5743 |
Visual *visual; |
|
5744 |
XVisualInfo viproto; |
|
5745 |
XVisualInfo *vip; /* retured info */ |
|
5746 |
int maxRGBDepth; |
|
5747 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5748 |
int rgbVisualID; |
|
5749 |
int nvi, i; |
|
5750 |
int shapeEventBase, shapeErrorBase; |
|
5751 |
int shmEventBase, shmErrorBase; |
|
5752 |
int faxEventBase, faxErrorBase; |
|
5753 |
char *type, *nm; |
|
5754 |
int dummy; |
|
5755 |
OBJ dpyID; |
|
5756 |
||
555 | 5757 |
if (__INST(displayId) != nil) { |
295 | 5758 |
/* |
5759 |
* already connected - you bad guy try to |
|
5760 |
* trick me manually ? |
|
5761 |
*/ |
|
5762 |
RETURN ( self ); |
|
5763 |
} |
|
5764 |
||
5765 |
BEGIN_INTERRUPTSBLOCKED |
|
5766 |
||
5767 |
if (__isString(dpyName)) |
|
5768 |
nm = (char *)_stringVal(dpyName); |
|
5769 |
else { |
|
5770 |
dpyName = __MKSTRING((char *)getenv("DISPLAY") COMMA_CON); |
|
5771 |
nm = NULL; |
|
5772 |
} |
|
5773 |
dpy = XOpenDisplay(nm); |
|
5774 |
||
5775 |
if (dpy) { |
|
555 | 5776 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 5777 |
|
5778 |
#ifdef SUPERDEBUG |
|
5779 |
XSynchronize(dpy, 1); |
|
5780 |
#endif |
|
5781 |
||
5782 |
XSetErrorHandler(__XErrorHandler__); |
|
5783 |
} |
|
5784 |
||
5785 |
END_INTERRUPTSBLOCKED |
|
5786 |
%}. |
|
5787 |
displayId isNil ifTrue:[ |
|
5788 |
'XWORKSTATION: cannot connect to Display.' errorPrintNL. |
|
5789 |
^ nil |
|
5790 |
]. |
|
5791 |
||
5792 |
dispatching := false. |
|
5793 |
dispatchingExpose := false. |
|
5794 |
isSlow := false. |
|
5795 |
shiftDown := false. |
|
5796 |
ctrlDown := false. |
|
5797 |
metaDown := false. |
|
5798 |
altDown := false. |
|
5799 |
motionEventCompression := true. |
|
5800 |
buttonsPressed := 0. |
|
5801 |
displayName := dpyName. |
|
5802 |
||
5803 |
protocolsAtom := nil. |
|
5804 |
deleteWindowAtom := nil. |
|
5805 |
saveYourselfAtom := nil. |
|
5806 |
quitAppAtom := nil. |
|
5807 |
||
5808 |
self initializeScreenProperties. |
|
5809 |
||
5810 |
self initializeDefaultValues. |
|
5811 |
self initializeEventBuffer. |
|
5812 |
self initializeSpecialFlags. |
|
5813 |
self initializeKeyboardMap. |
|
5814 |
||
5815 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
5816 |
! |
|
5817 |
||
5818 |
initializeModifierMappings |
|
5819 |
|map mod| |
|
5820 |
||
5821 |
"/ altModifiers := #(Alt_L Alt_R). |
|
5822 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
5823 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
5824 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
5825 |
||
5826 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
5827 |
altModifierMask := metaModifierMask := nil. |
|
5828 |
||
5829 |
map := self modifierMapping. |
|
342 | 5830 |
map isNil ifTrue:[ |
5831 |
"/ |
|
5832 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
5833 |
"/ setup some reasonable default. If that is not sufficient, |
|
5834 |
"/ you have to change things from your display.rc file. |
|
5835 |
"/ |
|
5836 |
altModifierMask := self modifier1Mask. |
|
5837 |
metaModifierMask := self modifier2Mask. |
|
5838 |
||
5839 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
5840 |
ctrlModifiers := #(Control_L Control_R Control). |
|
5841 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
5842 |
altModifiers := #(Alt_R Alt). |
|
5843 |
] ifFalse:[ |
|
5844 |
altModifierMask := 0. |
|
374 | 5845 |
metaModifierMask := 0. |
5846 |
||
5847 |
mod := map at:1. |
|
5848 |
mod notNil ifTrue:[ |
|
342 | 5849 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 5850 |
]. |
5851 |
mod := map at:3. |
|
5852 |
mod notNil ifTrue:[ |
|
342 | 5853 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 5854 |
]. |
5855 |
mod := map at:4. |
|
5856 |
mod notNil ifTrue:[ |
|
342 | 5857 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
5858 |
metaModifierMask := 1 bitShift:(4-1). |
|
374 | 5859 |
]. |
5860 |
mod := map at:5. |
|
5861 |
mod notNil ifTrue:[ |
|
342 | 5862 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
5863 |
altModifierMask := 1 bitShift:(5-1). |
|
5864 |
] |
|
295 | 5865 |
]. |
5866 |
||
5867 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
5868 |
! |
|
5869 |
||
5870 |
initializeScreenProperties |
|
5871 |
%{ /* NOCONTEXT */ |
|
5872 |
||
5873 |
Display *dpy = myDpy; |
|
5874 |
int scr; |
|
5875 |
Visual *visual; |
|
5876 |
XVisualInfo viproto; |
|
5877 |
XVisualInfo *vip; /* retured info */ |
|
5878 |
int maxRGBDepth; |
|
5879 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5880 |
int rgbVisualID; |
|
5881 |
int nvi, i; |
|
5882 |
int shapeEventBase, shapeErrorBase; |
|
5883 |
int shmEventBase, shmErrorBase; |
|
5884 |
int faxEventBase, faxErrorBase; |
|
5885 |
char *type, *nm; |
|
5886 |
int dummy; |
|
5887 |
int mask, shift, nBits; |
|
5888 |
||
5889 |
if (ISCONNECTED) { |
|
555 | 5890 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
5891 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
295 | 5892 |
|
5893 |
BEGIN_INTERRUPTSBLOCKED |
|
5894 |
||
555 | 5895 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
5896 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
5897 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
5898 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
5899 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
5900 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
5901 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
5902 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
5903 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 5904 |
|
5905 |
#ifdef SHAPE |
|
5906 |
if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase)) |
|
555 | 5907 |
__INST(hasShapeExtension) = true; |
295 | 5908 |
else |
5909 |
#endif |
|
555 | 5910 |
__INST(hasShapeExtension) = false; |
295 | 5911 |
|
5912 |
#ifdef SHM |
|
5913 |
if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase)) |
|
555 | 5914 |
__INST(hasShmExtension) = true; |
295 | 5915 |
else |
5916 |
#endif |
|
555 | 5917 |
__INST(hasShmExtension) = false; |
295 | 5918 |
|
5919 |
#ifdef FAX |
|
5920 |
if (XFAXImageQueryExtension(dpy, &faxEventBase, &faxErrorBase)) |
|
555 | 5921 |
__INST(hasFaxExtension) = true; |
295 | 5922 |
else |
5923 |
#endif |
|
555 | 5924 |
__INST(hasFaxExtension) = false; |
295 | 5925 |
|
5926 |
#ifdef DPS |
|
5927 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
|
555 | 5928 |
__INST(hasDPSExtension) = true; |
295 | 5929 |
else |
5930 |
#endif |
|
555 | 5931 |
__INST(hasDPSExtension) = false; |
295 | 5932 |
|
5933 |
#ifdef XVIDEO |
|
5934 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
|
555 | 5935 |
__INST(hasXVideoExtension) = true; |
295 | 5936 |
else |
5937 |
#endif |
|
555 | 5938 |
__INST(hasXVideoExtension) = false; |
295 | 5939 |
|
5940 |
#ifdef MBUF |
|
5941 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
|
555 | 5942 |
__INST(hasMbufExtension) = true; |
295 | 5943 |
else |
5944 |
#endif |
|
555 | 5945 |
__INST(hasMbufExtension) = false; |
295 | 5946 |
|
5947 |
#ifdef PEX5 |
|
5948 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
|
555 | 5949 |
__INST(hasPEXExtension) = true; |
295 | 5950 |
else |
5951 |
#endif |
|
555 | 5952 |
__INST(hasPEXExtension) = false; |
295 | 5953 |
|
5954 |
#ifdef XIE |
|
5955 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
|
555 | 5956 |
__INST(hasImageExtension) = true; |
295 | 5957 |
else |
5958 |
#endif |
|
555 | 5959 |
__INST(hasImageExtension) = false; |
295 | 5960 |
|
5961 |
#ifdef XI |
|
5962 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
|
555 | 5963 |
__INST(hasInputExtension) = true; |
295 | 5964 |
else |
5965 |
#endif |
|
555 | 5966 |
__INST(hasInputExtension) = false; |
295 | 5967 |
|
5968 |
/* |
|
5969 |
* look for RGB visual |
|
5970 |
*/ |
|
5971 |
nvi = 0; |
|
5972 |
viproto.screen = scr; |
|
5973 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
5974 |
maxRGBDepth = 0; |
|
5975 |
for (i = 0; i < nvi; i++) { |
|
5976 |
switch (vip[i].class) { |
|
5977 |
case TrueColor: |
|
5978 |
if (vip[i].depth > maxRGBDepth) { |
|
5979 |
maxRGBDepth = vip[i].depth; |
|
5980 |
rgbRedMask = vip[i].red_mask; |
|
5981 |
rgbGreenMask = vip[i].green_mask; |
|
5982 |
rgbBlueMask = vip[i].blue_mask; |
|
5983 |
rgbVisualID = vip[i].visualid; |
|
5984 |
} |
|
5985 |
break; |
|
5986 |
} |
|
5987 |
} |
|
5988 |
if (vip) XFree ((char *) vip); |
|
5989 |
||
5990 |
if (maxRGBDepth) { |
|
555 | 5991 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
295 | 5992 |
} |
5993 |
||
5994 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
555 | 5995 |
__INST(monitorType) = @symbol(unknown); |
5996 |
__INST(hasColors) = true; |
|
5997 |
__INST(hasGreyscales) = true; |
|
295 | 5998 |
switch (visual->class) { |
5999 |
case StaticGray: |
|
555 | 6000 |
__INST(visualType) = @symbol(StaticGray); |
6001 |
__INST(hasColors) = false; |
|
6002 |
__INST(monitorType) = @symbol(monochrome); |
|
295 | 6003 |
break; |
6004 |
case GrayScale: |
|
555 | 6005 |
__INST(visualType) = @symbol(GrayScale); |
6006 |
__INST(hasColors) = false; |
|
6007 |
__INST(monitorType) = @symbol(monochrome); |
|
295 | 6008 |
break; |
6009 |
case StaticColor: |
|
555 | 6010 |
__INST(visualType) = @symbol(StaticColor); |
295 | 6011 |
break; |
6012 |
case PseudoColor: |
|
555 | 6013 |
__INST(visualType) = @symbol(PseudoColor); |
295 | 6014 |
break; |
6015 |
case TrueColor: |
|
555 | 6016 |
__INST(visualType) = @symbol(TrueColor); |
295 | 6017 |
break; |
6018 |
case DirectColor: |
|
555 | 6019 |
__INST(visualType) = @symbol(DirectColor); |
295 | 6020 |
break; |
6021 |
} |
|
6022 |
if (DisplayCells(dpy, scr) == 2) { |
|
555 | 6023 |
__INST(hasColors) = false; |
6024 |
__INST(hasGreyscales) = false; |
|
6025 |
__INST(monitorType) = @symbol(monochrome); |
|
295 | 6026 |
} |
555 | 6027 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
6028 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
6029 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
6030 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
295 | 6031 |
switch (visual->class) { |
6032 |
case TrueColor: |
|
6033 |
/* extract number of bits and shift counts */ |
|
6034 |
mask = visual->red_mask; |
|
6035 |
shift = 0; |
|
6036 |
while (mask && ((mask & 1) == 0)) { |
|
6037 |
mask >>= 1; |
|
6038 |
shift++; |
|
6039 |
} |
|
555 | 6040 |
__INST(redShift) = __MKSMALLINT(shift); |
295 | 6041 |
nBits = 0; |
6042 |
while (mask) { |
|
6043 |
mask >>= 1; |
|
6044 |
nBits++; |
|
6045 |
} |
|
555 | 6046 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
295 | 6047 |
|
6048 |
mask = visual->green_mask; |
|
6049 |
shift = 0; |
|
6050 |
while (mask && ((mask & 1) == 0)) { |
|
6051 |
mask >>= 1; |
|
6052 |
shift++; |
|
6053 |
} |
|
555 | 6054 |
__INST(greenShift) = __MKSMALLINT(shift); |
295 | 6055 |
nBits = 0; |
6056 |
while (mask) { |
|
6057 |
mask >>= 1; |
|
6058 |
nBits++; |
|
6059 |
} |
|
555 | 6060 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
295 | 6061 |
|
6062 |
mask = visual->blue_mask; |
|
6063 |
shift = 0; |
|
6064 |
while (mask && ((mask & 1) == 0)) { |
|
6065 |
mask >>= 1; |
|
6066 |
shift++; |
|
6067 |
} |
|
555 | 6068 |
__INST(blueShift) = __MKSMALLINT(shift); |
295 | 6069 |
nBits = 0; |
6070 |
while (mask) { |
|
6071 |
mask >>= 1; |
|
6072 |
nBits++; |
|
6073 |
} |
|
555 | 6074 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
295 | 6075 |
break; |
6076 |
} |
|
6077 |
||
6078 |
#ifndef XA_PRIMARY |
|
555 | 6079 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 6080 |
#else |
555 | 6081 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 6082 |
#endif |
6083 |
#ifndef XA_SECONDARY |
|
555 | 6084 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 6085 |
#else |
555 | 6086 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 6087 |
#endif |
6088 |
#ifndef XA_CUT_BUFFER0 |
|
555 | 6089 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 6090 |
#else |
555 | 6091 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 6092 |
#endif |
6093 |
#ifndef XA_STRING |
|
555 | 6094 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 6095 |
#else |
555 | 6096 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 6097 |
#endif |
6098 |
#ifndef XA_LENGTH |
|
555 | 6099 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 6100 |
#else |
555 | 6101 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 6102 |
#endif |
6103 |
||
6104 |
END_INTERRUPTSBLOCKED |
|
6105 |
} |
|
6106 |
%} |
|
6107 |
! |
|
6108 |
||
6109 |
initializeSpecialFlags |
|
6110 |
"perform additional special server implementation flags" |
|
6111 |
||
6112 |
"/ |
|
6113 |
"/ assume we have it ... (should check) |
|
6114 |
"/ |
|
6115 |
hasSaveUnder := true. |
|
6116 |
ignoreBackingStore := false. |
|
6117 |
||
6118 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
6119 |
"/ |
|
6120 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
6121 |
"/ which does not correctly handle saveUnder |
|
6122 |
"/ |
|
6123 |
hasSaveUnder := false. |
|
6124 |
]. |
|
6125 |
! |
|
6126 |
||
6127 |
reinitialize |
|
6128 |
virtualRootId := rootId := nil. |
|
6129 |
super reinitialize. |
|
6130 |
dispatchingExpose := nil |
|
6131 |
! ! |
|
6132 |
||
6133 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
6134 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6135 |
altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6136 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6137 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6138 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6139 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6140 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6141 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6142 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6143 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6144 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6145 |
|
341 | 6146 |
altModifierMask:aSmallInteger |
6147 |
"define which key takes the role of an alt-key. |
|
6148 |
By default, this is X's modifier1, which is the ALT key on |
|
6149 |
most keyboards. However, there may be exceptions to this, |
|
6150 |
and the setting can be changed with: |
|
6151 |
Display altModifierMask:(Display modifier2Mask) |
|
6152 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
|
6153 |
" |
|
6154 |
||
6155 |
altModifierMask := aSmallInteger |
|
6156 |
! |
|
6157 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6158 |
metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6159 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6160 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6161 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6162 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6163 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6164 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6165 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6166 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6167 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6168 |
|
341 | 6169 |
metaModifierMask:aSmallInteger |
6170 |
"define which key takes the role of a meta key. |
|
6171 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
6172 |
most keyboards (if present at all). |
|
6173 |
However, there may be exceptions to this, and the setting can |
|
6174 |
be changed with: |
|
6175 |
Display metaModifierMask:(Display modifier1Mask) |
|
6176 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
|
6177 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
6178 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
6179 |
all the time. On those, you should disable the meta key by setting |
|
6180 |
the mask to 0. |
|
6181 |
" |
|
6182 |
||
6183 |
metaModifierMask := aSmallInteger |
|
6184 |
! |
|
6185 |
||
6186 |
modifier1Mask |
|
6187 |
"return the Xlib mask bit for the 1st modifier key. |
|
6188 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6189 |
this could be used." |
|
6190 |
||
6191 |
%{ /* NOCONTEXT */ |
|
6192 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
6193 |
%} |
|
6194 |
! |
|
6195 |
||
6196 |
modifier2Mask |
|
6197 |
"return the Xlib mask bit for the 2nd modifier key. |
|
6198 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6199 |
this could be used." |
|
6200 |
||
6201 |
%{ /* NOCONTEXT */ |
|
6202 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
6203 |
%} |
|
6204 |
! |
|
6205 |
||
6206 |
modifierMapping |
|
6207 |
"Get the Modifier Mapping. |
|
6208 |
We return an array of arrays of keycodes" |
|
6209 |
||
6210 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
6211 |
||
6212 |
%{ |
|
6213 |
Display *dpy = myDpy; |
|
6214 |
XModifierKeymap *modmap; |
|
6215 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
6216 |
||
6217 |
if (ISCONNECTED) { |
|
6218 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
6219 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6220 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
6221 |
if (modifierKeyMap != nil) { |
|
6222 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6223 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
6224 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
6225 |
} |
|
6226 |
XFreeModifiermap(modmap); |
|
6227 |
} |
|
6228 |
} |
|
6229 |
%}. |
|
6230 |
||
6231 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
6232 |
||
6233 |
ret := Array new:8. |
|
6234 |
nextKey := 1. |
|
6235 |
1 to:8 do:[ :i | |
|
6236 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
|
6237 |
|mod| |
|
6238 |
||
6239 |
mod := OrderedCollection new:maxKeyPerMod. |
|
6240 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
6241 |
key ~= 0 ifTrue:[ |
|
6242 |
mod add:key |
|
6243 |
]. |
|
6244 |
]. |
|
6245 |
ret at:i put:mod. |
|
6246 |
]. |
|
6247 |
nextKey := nextKey+maxKeyPerMod. |
|
6248 |
]. |
|
6249 |
||
6250 |
^ ret |
|
6251 |
||
6252 |
" |
|
6253 |
Display modifierMapping |
|
6254 |
" |
|
6255 |
! |
|
6256 |
||
6257 |
stringFromKeycode:code |
|
6258 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
|
6259 |
||
6260 |
|str| |
|
6261 |
||
6262 |
%{ |
|
6263 |
Display *dpy = myDpy; |
|
6264 |
KeySym keysym; |
|
6265 |
char *keystring; |
|
6266 |
||
6267 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
6268 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
6269 |
(keystring = XKeysymToString(keysym)) != 0) |
|
6270 |
str = __MKSTRING(keystring); |
|
6271 |
} |
|
6272 |
%}. |
|
6273 |
^ str |
|
6274 |
||
6275 |
" |
|
6276 |
Display stringFromKeycode:28 |
|
6277 |
" |
|
6278 |
! |
|
6279 |
||
295 | 6280 |
translateKey:untranslatedKey |
6281 |
"Return the key translated via the translation table. |
|
6282 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
6283 |
which gets further processed in the superclasses translation method." |
|
6284 |
||
6285 |
|key| |
|
6286 |
||
6287 |
(key := untranslatedKey) isString ifTrue:[ |
|
6288 |
key := RawKeysymTranslation at:key ifAbsent:key. |
|
6289 |
key := key asSymbol. |
|
6290 |
]. |
|
6291 |
^ super translateKey:key |
|
6292 |
! ! |
|
6293 |
||
6294 |
!XWorkstation methodsFor:'misc'! |
|
6295 |
||
6296 |
beep |
|
6297 |
"output an audible beep or bell" |
|
6298 |
||
6299 |
self beep:50 |
|
6300 |
! |
|
6301 |
||
6302 |
beep:volumeInPercent |
|
6303 |
"output an audible beep" |
|
6304 |
%{ |
|
6305 |
int volume; |
|
6306 |
||
6307 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
6308 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
|
555 | 6309 |
volume = __intVal(volumeInPercent) * 2 - 100; |
295 | 6310 |
if (volume < -100) volume = -100; |
6311 |
else if (volume > 100) volume = 100; |
|
6312 |
BEGIN_INTERRUPTSBLOCKED |
|
6313 |
XBell(myDpy, volume); |
|
6314 |
END_INTERRUPTSBLOCKED |
|
6315 |
} |
|
6316 |
%} |
|
6317 |
! |
|
6318 |
||
6319 |
buffered |
|
6320 |
"buffer drawing - do not send it immediately to the display. |
|
374 | 6321 |
This is the default anyway. |
6322 |
See #unBuffered for additional info." |
|
295 | 6323 |
|
6324 |
%{ /* NOCONTEXT */ |
|
6325 |
||
6326 |
if (ISCONNECTED) { |
|
6327 |
BEGIN_INTERRUPTSBLOCKED |
|
6328 |
XSynchronize(myDpy, 0); |
|
6329 |
END_INTERRUPTSBLOCKED |
|
6330 |
} |
|
6331 |
%} |
|
374 | 6332 |
" |
6333 |
Display buffered |
|
6334 |
" |
|
295 | 6335 |
! |
6336 |
||
6337 |
flush |
|
6338 |
"send all buffered drawing to the display. |
|
6339 |
This may be required to make certain, that all previous operations |
|
6340 |
are really sent to the display before continuing. For example, |
|
6341 |
after a cursor-change with a followup long computation. |
|
374 | 6342 |
(otherwise, the cursor change request may still be in the output buffer) |
6343 |
See also #sync, which even waits until the request has been processed." |
|
295 | 6344 |
|
6345 |
%{ /* NOCONTEXT */ |
|
6346 |
||
6347 |
if (ISCONNECTED) { |
|
6348 |
BEGIN_INTERRUPTSBLOCKED |
|
310 | 6349 |
XFlush(myDpy); |
6350 |
END_INTERRUPTSBLOCKED |
|
6351 |
} |
|
6352 |
%} |
|
6353 |
! |
|
6354 |
||
295 | 6355 |
flushDpsContext:aDPSContext |
6356 |
||
6357 |
%{ /* NOCONTEXT */ |
|
6358 |
#ifdef DPS |
|
6359 |
if (__isExternalAddress(aDPSContext)) { |
|
6360 |
BEGIN_INTERRUPTSBLOCKED |
|
6361 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
6362 |
END_INTERRUPTSBLOCKED |
|
6363 |
RETURN ( self ); |
|
6364 |
} |
|
6365 |
#endif |
|
374 | 6366 |
%}. |
295 | 6367 |
self primitiveFailed |
6368 |
! |
|
6369 |
||
6370 |
refreshKeyboardMapping:eB |
|
6371 |
%{ |
|
6372 |
XMappingEvent *ev; |
|
6373 |
||
6374 |
if (__isByteArray(eB)) { |
|
555 | 6375 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 6376 |
XRefreshKeyboardMapping(ev); |
6377 |
} |
|
6378 |
%} |
|
6379 |
! |
|
6380 |
||
6381 |
setInputFocusTo:aWindowId |
|
6382 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
|
6383 |
self setInputFocusTo:aWindowId revertTo:#root |
|
6384 |
! |
|
6385 |
||
6386 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
|
6387 |
"set the focus to the view as defined by aWindowId. |
|
6388 |
Passing nil set the focus to no window and lets the display discard all |
|
6389 |
input until a new focus is set. |
|
6390 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
6391 |
passing one of #parent, #root or nil specifies that the focus should be |
|
6392 |
given to the parent view, the root view or no view." |
|
6393 |
||
6394 |
%{ /* NOCONTEXT */ |
|
6395 |
int arg; |
|
6396 |
Window focusWindow; |
|
6397 |
||
6398 |
if (ISCONNECTED) { |
|
6399 |
if (__isExternalAddress(aWindowId)) { |
|
6400 |
focusWindow = _WindowVal(aWindowId); |
|
6401 |
} else { |
|
6402 |
focusWindow = None; |
|
6403 |
} |
|
6404 |
if (revertSymbol == @symbol(parent)) |
|
6405 |
arg = RevertToParent; |
|
6406 |
else if (revertSymbol == @symbol(root)) |
|
6407 |
arg = RevertToPointerRoot; |
|
6408 |
else |
|
6409 |
arg = RevertToNone; |
|
6410 |
||
6411 |
BEGIN_INTERRUPTSBLOCKED |
|
6412 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
6413 |
END_INTERRUPTSBLOCKED |
|
6414 |
RETURN ( self ); |
|
6415 |
} |
|
6416 |
%}. |
|
6417 |
self primitiveFailed |
|
6418 |
! |
|
6419 |
||
341 | 6420 |
sync |
6421 |
"send all buffered drawing to the display AND wait until the display |
|
6422 |
has finished drawing it. |
|
6423 |
This is almost never needed, except if you are about to read previously |
|
374 | 6424 |
drawn pixels back from the display screen, or you want to wait for a beep |
6425 |
to be finished. See also #flush." |
|
341 | 6426 |
|
6427 |
%{ /* NOCONTEXT */ |
|
6428 |
||
6429 |
if (ISCONNECTED) { |
|
6430 |
BEGIN_INTERRUPTSBLOCKED |
|
6431 |
XSync(myDpy, 0); |
|
6432 |
END_INTERRUPTSBLOCKED |
|
6433 |
} |
|
6434 |
%} |
|
6435 |
! |
|
6436 |
||
295 | 6437 |
unBuffered |
374 | 6438 |
"make all drawing be sent immediately to the display. |
6439 |
This makes all graphics synchronous and turns off any buffering |
|
6440 |
(i.e. each individual draw-request is sent immediately without |
|
6441 |
packing multiple requests into a larger message buffer). |
|
6442 |
Be prepared, that this slows down graphics considerably. |
|
6443 |
However, it allows display errors to be handled immediately and |
|
6444 |
may be useful if you get Xdisplay errors and want to find the request |
|
6445 |
which was responsiblefor it. See also #buffered." |
|
295 | 6446 |
|
6447 |
%{ /* NOCONTEXT */ |
|
6448 |
||
6449 |
if (ISCONNECTED) { |
|
6450 |
BEGIN_INTERRUPTSBLOCKED |
|
6451 |
XSynchronize(myDpy, 1); |
|
6452 |
END_INTERRUPTSBLOCKED |
|
6453 |
} |
|
6454 |
%} |
|
6455 |
"Display unbuffered" |
|
6456 |
! ! |
|
6457 |
||
6458 |
!XWorkstation methodsFor:'pointer queries '! |
|
6459 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6460 |
anyButtonStateMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6461 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6462 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6463 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6464 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6465 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6466 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6467 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6468 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6469 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6470 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6471 |
|
295 | 6472 |
buttonStates |
6473 |
"return an integer representing the state of the pointer buttons; |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6474 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6475 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6476 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 6477 |
|
6478 |
%{ /* NOCONTEXT*/ |
|
6479 |
Display *dpy = myDpy; |
|
6480 |
Window w; |
|
555 | 6481 |
int screen = __intVal(__INST(screen)); |
295 | 6482 |
Window rootRet, childRet; |
6483 |
int rootX, rootY, winX, winY; |
|
6484 |
unsigned int mask; |
|
6485 |
||
6486 |
BEGIN_INTERRUPTSBLOCKED |
|
6487 |
#ifdef VIRTUAL_ROOT |
|
6488 |
w = getRootWindow(myDpy, screen); |
|
6489 |
#else |
|
6490 |
w = RootWindow(dpy, screen); |
|
6491 |
#endif |
|
6492 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6493 |
&rootX, &rootY, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6494 |
&winX, &winY, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6495 |
&mask); |
295 | 6496 |
END_INTERRUPTSBLOCKED |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6497 |
RETURN (__MKSMALLINT(mask)); |
295 | 6498 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6499 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6500 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6501 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6502 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6503 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6504 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6505 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6506 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6507 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6508 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6509 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6510 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6511 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6512 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6513 |
" |
295 | 6514 |
! |
6515 |
||
6516 |
leftButtonStateMask |
|
6517 |
"return an integer for masking out the left button from a |
|
6518 |
buttonStates value" |
|
6519 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6520 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6521 |
|
295 | 6522 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6523 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6524 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 6525 |
! |
6526 |
||
6527 |
middleButtonStateMask |
|
6528 |
"return an integer for masking out the middle button from a |
|
6529 |
buttonStates value" |
|
6530 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6531 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6532 |
|
295 | 6533 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6534 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6535 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 6536 |
! |
6537 |
||
6538 |
pointerPosition |
|
6539 |
"return the current pointer position in root-window coordinates" |
|
6540 |
||
6541 |
|xpos ypos| |
|
6542 |
||
6543 |
%{ |
|
6544 |
Display *dpy = myDpy; |
|
6545 |
Window w; |
|
555 | 6546 |
int screen = __intVal(__INST(screen)); |
295 | 6547 |
Window rootRet, childRet; |
6548 |
int rootX, rootY, winX, winY; |
|
6549 |
unsigned int mask; |
|
6550 |
||
6551 |
BEGIN_INTERRUPTSBLOCKED |
|
6552 |
#ifdef VIRTUAL_ROOT |
|
6553 |
w = getRootWindow(myDpy, screen); |
|
6554 |
#else |
|
6555 |
w = RootWindow(dpy, screen); |
|
6556 |
#endif |
|
6557 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
6558 |
&rootX, &rootY, |
|
6559 |
&winX, &winY, |
|
6560 |
&mask); |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6561 |
xpos = __MKSMALLINT(rootX); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6562 |
ypos = __MKSMALLINT(rootY); |
295 | 6563 |
END_INTERRUPTSBLOCKED |
6564 |
%} |
|
6565 |
. |
|
6566 |
^ xpos @ ypos |
|
6567 |
! |
|
6568 |
||
6569 |
rightButtonStateMask |
|
6570 |
"return an integer for masking out the right button from a |
|
6571 |
buttonStates value" |
|
6572 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6573 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6574 |
|
295 | 6575 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6576 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6577 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 6578 |
! |
6579 |
||
6580 |
rootPositionOfLastEvent |
|
6581 |
"return the position in root-window coordinates |
|
6582 |
of the last button, key or pointer event" |
|
6583 |
||
6584 |
^ eventRootX @ eventRootY |
|
6585 |
! ! |
|
6586 |
||
6587 |
!XWorkstation methodsFor:'resources'! |
|
6588 |
||
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6589 |
atomIDOf:aStringOrSymbol |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6590 |
"return an Atoms ID; dont create if not already present. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6591 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6592 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6593 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6594 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6595 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6596 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6597 |
Display atomIDOf:'FULL_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6598 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6599 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6600 |
"Modified: 2.3.1996 / 15:09:29 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6601 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6602 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6603 |
atomIDOf:aStringOrSymbol create:create |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6604 |
"return an Atoms ID; if create is true, create it if not already present. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6605 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6606 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6607 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6608 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6609 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6610 |
if (ISCONNECTED) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6611 |
if (__isString(aStringOrSymbol) |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6612 |
|| __isSymbol(aStringOrSymbol)) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6613 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6614 |
(create == true) ? False : True); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6615 |
if (prop == None) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6616 |
RETURN (nil); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6617 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6618 |
RETURN ( __MKATOMOBJ(prop) ); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6619 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6620 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6621 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6622 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6623 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6624 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6625 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6626 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6627 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6628 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6629 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6630 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6631 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6632 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6633 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6634 |
atomIDOfCUTBUFFER0 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6635 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6636 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6637 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6638 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6639 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6640 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6641 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6642 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6643 |
atomIDOfLENGTH |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6644 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6645 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6646 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6647 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6648 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6649 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6650 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6651 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6652 |
atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6653 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6654 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6655 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6656 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6657 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6658 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6659 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6660 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6661 |
atomIDOfSECONDARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6662 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6663 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6664 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6665 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6666 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6667 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6668 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6669 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6670 |
atomIDOfSTRING |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6671 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6672 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6673 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6674 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6675 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6676 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6677 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6678 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6679 |
atomName:anAtomID |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6680 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6681 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6682 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6683 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6684 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6685 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6686 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6687 |
if (ISCONNECTED) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6688 |
if (__isAtomID(anAtomID)) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6689 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6690 |
if (name == 0) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6691 |
RETURN (nil); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6692 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6693 |
str = __MKSTRING(name COMMA_CON); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6694 |
XFree(name); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6695 |
RETURN ( str ); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6696 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6697 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6698 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6699 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6700 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6701 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6702 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6703 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6704 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6705 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6706 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6707 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6708 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6709 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6710 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6711 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6712 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6713 |
|
295 | 6714 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6715 |
"access the displays resource database for a default value |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6716 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6717 |
This is highly X specific and currently not used. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6718 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6719 |
Notice: |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6720 |
we do not plan to use X's resources for ST/X's defaults, |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6721 |
styles or resources. This would make porting of applications |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6722 |
to different platforms much more difficult (Windows has no resource |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6723 |
database). If you stay within ST/X's resource files, these can be |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6724 |
easily transported to other platforms. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6725 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6726 |
This method is provided for special applications which want to access |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6727 |
existing X resources and are not planned to be ever ported to other |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6728 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6729 |
|
295 | 6730 |
%{ |
6731 |
char *rslt; |
|
6732 |
||
6733 |
if ((__isString(name) || __isSymbol(name)) |
|
6734 |
&& (__isString(cls) || __isSymbol(cls)) |
|
6735 |
&& ISCONNECTED) { |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6736 |
BEGIN_INTERRUPTSBLOCKED |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6737 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6738 |
(char *)_stringVal(name)); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6739 |
END_INTERRUPTSBLOCKED |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6740 |
RETURN (rslt ? __MKSTRING(rslt COMMA_CON) : nil ); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6741 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6742 |
%}. |
295 | 6743 |
self primitiveFailed. |
6744 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6745 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6746 |
"if your ~/.Xdefaults contains an entry such as: |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6747 |
OpenWindows.Beep: notices |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6748 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6749 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6750 |
Display getResource:'Beep' class:'OpenWindows' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6751 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6752 |
if your ~/.Xdefaults contains an entry such as: |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6753 |
*.beNiceToColormap: false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6754 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6755 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6756 |
Display getResource:'beNiceToColormap' class:'any' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6757 |
Display getResource:'beNiceToColormap' class:'' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6758 |
" |
295 | 6759 |
! ! |
6760 |
||
6761 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
6762 |
||
6763 |
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
|
6764 |
"get bits from a drawable into the imageBits. The storage for the bits |
|
6765 |
must be big enough for the data to fit. If ok, returns an array with some |
|
6766 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
6767 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
6768 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
6769 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6770 |
|rawInfo info| |
295 | 6771 |
|
6772 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
6773 |
self primitiveFailed. |
|
6774 |
^ nil |
|
6775 |
]. |
|
6776 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6777 |
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
|
6778 |
"1 -> bit order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6779 |
"2 -> depth" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6780 |
"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
|
6781 |
"4 -> byte_order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6782 |
"5 -> format" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6783 |
"6 -> bitmap_unit" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6784 |
"7 -> bitmap_pad" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6785 |
"8 -> bits_per_pixel" |
295 | 6786 |
|
6787 |
"/ had to extract the getPixel call into a separate method, to specify |
|
6788 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
6789 |
"/ of temporary stack space |
|
6790 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6791 |
(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
|
6792 |
info := IdentityDictionary new. |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6793 |
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
|
6794 |
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
|
6795 |
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
|
6796 |
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
|
6797 |
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
|
6798 |
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
|
6799 |
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
|
6800 |
info at:#bitsPerPixel put:(rawInfo at:8). |
295 | 6801 |
^ info |
6802 |
]. |
|
6803 |
" |
|
6804 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
6805 |
or is too small to hold the bits |
|
6806 |
" |
|
6807 |
^ self primitiveFailed |
|
6808 |
! |
|
6809 |
||
6810 |
getPixelX:x y:y from:aDrawableId |
|
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6811 |
"return the pixel value at x/y; coordinates start at 0/0 for the upper left. |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6812 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 6813 |
|
6814 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
6815 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6816 |
Window win; |
295 | 6817 |
XImage *img; |
6818 |
int ret; |
|
6819 |
int xpos, ypos; |
|
6820 |
||
6821 |
if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6822 |
win = _WindowVal(aDrawableId); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6823 |
xpos = __intVal(x); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6824 |
ypos = __intVal(y); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6825 |
if ((xpos < 0) || (ypos < 0)) { |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6826 |
RETURN ( __MKSMALLINT(0) ); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6827 |
} |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6828 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6829 |
if (img != 0) { |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6830 |
ret = XGetPixel(img, 0, 0); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6831 |
XDestroyImage(img); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6832 |
RETURN ( __MKSMALLINT(ret) ); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6833 |
} |
295 | 6834 |
} |
6835 |
%}. |
|
6836 |
^ nil |
|
6837 |
! |
|
6838 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6839 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 6840 |
"since XGetImage may allocate huge amount of stack space |
6841 |
(some implementations use alloca), this must run with unlimited stack." |
|
6842 |
||
6843 |
%{ /* UNLIMITEDSTACK */ |
|
6844 |
||
6845 |
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
|
6846 |
Window win; |
295 | 6847 |
XImage *image = (XImage *)0; |
6848 |
int pad, bytes_per_line, numBytes; |
|
6849 |
||
6850 |
if (__isExternalAddress(aDrawableId) |
|
6851 |
&& __bothSmallInteger(srcx, srcy) |
|
6852 |
&& __bothSmallInteger(w, h) |
|
6853 |
&& __isArray(info) |
|
6854 |
&& __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
|
6855 |
win = _WindowVal(aDrawableId); |
555 | 6856 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
6857 |
__intVal(w), __intVal(h), |
|
295 | 6858 |
(unsigned)AllPlanes, ZPixmap); |
6859 |
||
378 | 6860 |
if (! image) { |
6861 |
RETURN ( false ); |
|
6862 |
} |
|
6863 |
||
295 | 6864 |
pad = image->bitmap_pad; |
6865 |
#ifdef SUPERDEBUG |
|
6866 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
|
6867 |
#endif |
|
6868 |
switch (image->depth) { |
|
6869 |
case 1: |
|
6870 |
case 2: |
|
6871 |
case 4: |
|
6872 |
case 8: |
|
6873 |
case 16: |
|
6874 |
case 24: |
|
6875 |
case 32: |
|
6876 |
numBytes = image->bytes_per_line * image->height; |
|
6877 |
break; |
|
6878 |
default: |
|
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6879 |
/* unsupported depth ? */ |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6880 |
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
|
6881 |
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
|
6882 |
break; |
295 | 6883 |
} |
6884 |
||
6885 |
#ifdef SUPERDEBUG |
|
555 | 6886 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 6887 |
#endif |
6888 |
||
555 | 6889 |
if (numBytes > __byteArraySize(imageBits)) { |
295 | 6890 |
/* imageBits too small */ |
378 | 6891 |
printf("provided byteArray too small\n"); |
295 | 6892 |
goto fail; |
6893 |
} |
|
6894 |
if (image->bitmap_bit_order == MSBFirst) |
|
555 | 6895 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
295 | 6896 |
else |
555 | 6897 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
6898 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
6899 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
295 | 6900 |
if (image->byte_order == MSBFirst) |
555 | 6901 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
295 | 6902 |
else |
555 | 6903 |
__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
|
6904 |
if (image->format == XYBitmap) |
555 | 6905 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6906 |
else if (image->format == XYPixmap) |
555 | 6907 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6908 |
else if (image->format == ZPixmap) |
555 | 6909 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
6910 |
|
555 | 6911 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
6912 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
6913 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
6914 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
295 | 6915 |
XDestroyImage(image); |
6916 |
RETURN ( true ); |
|
6917 |
} |
|
6918 |
fail: |
|
6919 |
if (image) { |
|
6920 |
XDestroyImage(image); |
|
6921 |
} |
|
6922 |
%}. |
|
6923 |
^ false |
|
6924 |
! ! |
|
6925 |
||
6926 |
!XWorkstation methodsFor:'selections'! |
|
6927 |
||
6928 |
getObjectProperty:propertyID from:aWindowID |
|
6929 |
"get an object property; return object or nil" |
|
6930 |
||
6931 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
6932 |
type == stringAtom ifTrue:[ |
|
6933 |
^ value |
|
6934 |
]. |
|
6935 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
6936 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
6937 |
] |
|
6938 |
]. |
|
6939 |
^ nil |
|
6940 |
! |
|
6941 |
||
6942 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
6943 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
6944 |
||
6945 |
|val typeID cls| |
|
6946 |
||
6947 |
cls := ByteArray. |
|
6948 |
%{ |
|
6949 |
Display *dpy = myDpy; |
|
6950 |
Window window; |
|
6951 |
Atom property; |
|
6952 |
char *cp, *cp2; |
|
6953 |
Atom actual_type; |
|
6954 |
int actual_format,i; |
|
6955 |
unsigned long nitems, bytes_after, nread; |
|
6956 |
unsigned char *data; |
|
6957 |
int ok = 1; |
|
6958 |
# define PROP_SIZE 2048 |
|
6959 |
||
6960 |
if (__isAtomID(propertyID)) { |
|
6961 |
property = _AtomVal(propertyID); |
|
6962 |
if (__isExternalAddress(aWindowID)) { |
|
6963 |
window = _WindowVal(aWindowID); |
|
6964 |
} else { |
|
6965 |
window = DefaultRootWindow(dpy); |
|
6966 |
} |
|
6967 |
||
6968 |
nread = 0; |
|
6969 |
cp = 0; |
|
6970 |
/* |
|
6971 |
fprintf(stderr, "getProperty: "); |
|
6972 |
*/ |
|
6973 |
do { |
|
6974 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
6975 |
AnyPropertyType,&actual_type,&actual_format, |
|
6976 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
6977 |
!= Success) { |
|
6978 |
ok = 0; |
|
6979 |
break; |
|
6980 |
} |
|
6981 |
typeID = __MKATOMOBJ(actual_type); |
|
6982 |
if (! cp) { |
|
6983 |
cp = cp2 = (char *)malloc(nitems+1); |
|
6984 |
} else { |
|
6985 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
6986 |
cp2 = cp + nread; |
|
6987 |
} |
|
6988 |
if (! cp) goto fail; |
|
6989 |
||
6990 |
nread += nitems; |
|
6991 |
bcopy(data, cp2, nitems); |
|
6992 |
XFree(data); |
|
6993 |
/* |
|
6994 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
6995 |
*/ |
|
6996 |
} while (bytes_after > 0); |
|
6997 |
/* |
|
6998 |
fprintf(stderr, "\n"); |
|
6999 |
*/ |
|
7000 |
||
7001 |
if (ok) { |
|
7002 |
if (actual_type == XA_STRING) { |
|
7003 |
cp[nread] = '\0'; |
|
7004 |
val = __MKSTRING_L(cp, nread COMMA_CON); |
|
7005 |
} else { |
|
7006 |
val = __new(nread + OHDR_SIZE); |
|
7007 |
val->o_class = cls; |
|
555 | 7008 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
295 | 7009 |
} |
7010 |
} |
|
7011 |
if (cp) |
|
7012 |
free(cp); |
|
7013 |
} |
|
7014 |
fail: ; |
|
7015 |
%}. |
|
7016 |
typeID isNil ifTrue:[ |
|
7017 |
^ false |
|
7018 |
]. |
|
7019 |
aTwoArgBlock value:typeID value:val. |
|
7020 |
^ true |
|
7021 |
! |
|
7022 |
||
7023 |
getSelectionFor:drawableId |
|
7024 |
"get the object selection - either immediate, or asynchronous. |
|
7025 |
Returns nil, if async request is on its way" |
|
7026 |
||
7027 |
|selProp sel| |
|
7028 |
||
7029 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7030 |
"no primary selection - use cut buffer" |
|
7031 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
7032 |
^ sel |
|
7033 |
]. |
|
7034 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
7035 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
7036 |
^ nil |
|
7037 |
! |
|
7038 |
||
7039 |
getSelectionOwnerOf:selectionAtomID |
|
7040 |
"get the owner of a selection" |
|
7041 |
||
7042 |
%{ /* NOCONTEXT */ |
|
7043 |
Display *dpy = myDpy; |
|
7044 |
Atom selection; |
|
7045 |
Window window; |
|
7046 |
||
7047 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
7048 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
7049 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
7050 |
} |
|
7051 |
%}. |
|
7052 |
self primitiveFailed. |
|
7053 |
^ nil |
|
7054 |
! |
|
7055 |
||
7056 |
getTextProperty:propertyID from:aWindowID |
|
7057 |
"get a text property; return string or nil" |
|
7058 |
||
7059 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7060 |
type == stringAtom ifTrue:[ |
|
7061 |
^ value |
|
7062 |
] |
|
7063 |
]. |
|
7064 |
^ nil |
|
7065 |
! |
|
7066 |
||
7067 |
getTextSelectionFor:drawableId |
|
7068 |
"get the text selection - either immediate, or asynchronous. |
|
7069 |
Returns nil, if async request is on its way" |
|
7070 |
||
7071 |
|selProp sel| |
|
7072 |
||
7073 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7074 |
"no primary selection - use cut buffer" |
|
7075 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
7076 |
^ sel |
|
7077 |
]. |
|
7078 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
7079 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
7080 |
^ nil |
|
7081 |
! |
|
7082 |
||
7083 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
|
7084 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7085 |
will later receive a SelectionNotify event for it." |
|
7086 |
||
7087 |
^ self requestSelection:selectionID |
|
7088 |
property:propertyID |
|
7089 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7090 |
for:aWindowId |
|
7091 |
! |
|
7092 |
||
7093 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
7094 |
"ask the server to send us the selection - the view with id aWindowID |
|
7095 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
7096 |
with the selections value)." |
|
7097 |
||
7098 |
%{ /* NOCONTEXT */ |
|
7099 |
Display *dpy = myDpy; |
|
7100 |
Atom sel_prop; |
|
7101 |
char *cp; |
|
7102 |
||
7103 |
if (__isExternalAddress(aWindowId) |
|
7104 |
&& ISCONNECTED |
|
7105 |
&& __isSmallInteger(typeID) |
|
7106 |
&& __isAtomID(selectionID)) { |
|
7107 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
7108 |
/* |
|
7109 |
* no owner of primary selection |
|
7110 |
*/ |
|
7111 |
RETURN (false); |
|
7112 |
} |
|
7113 |
/* |
|
7114 |
* PRIMARY selection |
|
7115 |
*/ |
|
7116 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
7117 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
7118 |
RETURN (true); |
|
7119 |
} |
|
7120 |
%}. |
|
7121 |
self primitiveFailed. |
|
7122 |
^ false |
|
7123 |
||
7124 |
" |
|
7125 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
7126 |
property:(Display atomIDOf:'VT_SELECTION') |
|
7127 |
for:0 |
|
7128 |
" |
|
7129 |
! |
|
7130 |
||
7131 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
|
7132 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7133 |
will later receive a SelectionNotify event for it." |
|
7134 |
||
7135 |
^ self requestSelection:selectionID |
|
7136 |
property:propertyID |
|
7137 |
type:stringAtom |
|
7138 |
for:aWindowId |
|
7139 |
! |
|
7140 |
||
7141 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
7142 |
"send aString back from a SelectionRequest" |
|
7143 |
||
7144 |
self |
|
7145 |
sendSelection:something |
|
7146 |
selection:primaryAtom |
|
7147 |
property:propertyID |
|
7148 |
target:targetID |
|
7149 |
from:windowID |
|
7150 |
to:requestorID |
|
7151 |
! |
|
7152 |
||
7153 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7154 |
"send aString back from a SelectionRequest" |
|
7155 |
||
7156 |
self |
|
7157 |
setProperty:propertyID |
|
7158 |
type:targetID |
|
7159 |
value:something |
|
7160 |
for:requestorID. |
|
7161 |
self |
|
7162 |
sendSelectionNotifySelection:selectionID |
|
7163 |
property:propertyID |
|
7164 |
target:targetID |
|
7165 |
from:requestorID |
|
7166 |
to:requestorID. |
|
7167 |
! |
|
7168 |
||
7169 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7170 |
"send a selectionNotify back from a SelectionRequest" |
|
7171 |
||
7172 |
%{ /* NOCONTEXT */ |
|
7173 |
Display *dpy = myDpy; |
|
7174 |
||
7175 |
if (__isAtomID(propertyID) |
|
7176 |
&& __isExternalAddress(requestorID) |
|
7177 |
&& ISCONNECTED |
|
7178 |
&& __isAtomID(targetID) |
|
7179 |
&& __isAtomID(selectionID)) { |
|
7180 |
XEvent ev; |
|
7181 |
Window requestor = _WindowVal(requestorID); |
|
7182 |
Atom property = _AtomVal(propertyID); |
|
7183 |
Atom target = _AtomVal(targetID); |
|
7184 |
Atom selection = _AtomVal(selectionID); |
|
7185 |
Status result; |
|
7186 |
||
7187 |
ev.xselection.type = SelectionNotify; |
|
7188 |
ev.xselection.selection = selection; |
|
7189 |
ev.xselection.target = target; |
|
7190 |
if (__isExternalAddress(windowID)) |
|
7191 |
ev.xselection.requestor = _WindowVal(windowID); |
|
7192 |
else |
|
7193 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
7194 |
ev.xselection.time = CurrentTime; |
|
7195 |
if (property == None) |
|
7196 |
ev.xselection.property = target; |
|
7197 |
else |
|
7198 |
ev.xselection.property = property; |
|
7199 |
||
7200 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
7201 |
ev.xselection.selection, |
|
7202 |
ev.xselection.property, |
|
7203 |
ev.xselection.target, |
|
7204 |
ev.xselection.requestor, |
|
7205 |
requestor)); |
|
7206 |
||
7207 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
7208 |
if ((result == BadValue) || (result == BadWindow)) { |
|
7209 |
DPRINTF(("bad status\n")); |
|
382 | 7210 |
RETURN (false); |
295 | 7211 |
} |
382 | 7212 |
RETURN (true) |
7213 |
} |
|
7214 |
%}. |
|
7215 |
self primitiveFailed. |
|
7216 |
^ false |
|
295 | 7217 |
! |
7218 |
||
7219 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
7220 |
^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID |
|
7221 |
! |
|
7222 |
||
7223 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
7224 |
|s| |
|
7225 |
||
7226 |
(anObject isMemberOf:String) ifTrue:[ |
|
7227 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
|
7228 |
]. |
|
7229 |
s := WriteStream on:(ByteArray new:200). |
|
7230 |
anObject storeBinaryOn:s. |
|
7231 |
^ self |
|
7232 |
setProperty:propertyID |
|
7233 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7234 |
value:(s contents) |
|
7235 |
for:aWindowID |
|
7236 |
! |
|
7237 |
||
7238 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
7239 |
||
7240 |
%{ /* UNLIMITEDSTACK */ |
|
7241 |
||
7242 |
Display *dpy = myDpy; |
|
7243 |
Atom prop, type; |
|
7244 |
Window window; |
|
7245 |
unsigned int value; |
|
7246 |
||
7247 |
if (__isAtomID(propertyID) |
|
7248 |
&& __isAtomID(typeID) |
|
7249 |
&& ISCONNECTED |
|
7250 |
&& (__isString(anObject) |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7251 |
|| __isSmallInteger(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7252 |
|| __isSymbol(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7253 |
|| __isByteArray(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7254 |
|| __isWords(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7255 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7256 |
prop = _AtomVal(propertyID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7257 |
type = _AtomVal(typeID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7258 |
if (__isExternalAddress(aWindowID)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7259 |
window = _WindowVal(aWindowID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7260 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7261 |
window = DefaultRootWindow(dpy); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7262 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7263 |
if (__isSmallInteger(anObject)) { |
555 | 7264 |
value = __intVal(anObject); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7265 |
XChangeProperty(dpy, window, prop, type, 32, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7266 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7267 |
(unsigned char *)(&value), sizeof(unsigned int)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7268 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7269 |
if (__isByteArray(anObject)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7270 |
XChangeProperty(dpy, window, prop, type, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7271 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7272 |
__ByteArrayInstPtr(anObject)->ba_element, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7273 |
__byteArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7274 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7275 |
/* string or symbol or wordArray-like (16bit-string) object */ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7276 |
if (__isWords(__qClass(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7277 |
XChangeProperty(dpy, window, prop, XA_STRING, 16, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7278 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7279 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7280 |
__wordArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7281 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7282 |
XChangeProperty(dpy, window, prop, XA_STRING, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7283 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7284 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7285 |
strlen(__stringVal(anObject))); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7286 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7287 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7288 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7289 |
RETURN (true); |
295 | 7290 |
} |
7291 |
%}. |
|
7292 |
^ false |
|
7293 |
! |
|
7294 |
||
7295 |
setSelection:anObject owner:aWindowId |
|
7296 |
"set the object selection, and make aWindowId be the owner. |
|
7297 |
This can be used by other Smalltalk(X) applications only." |
|
7298 |
||
7299 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7300 |
^ false |
|
7301 |
]. |
|
7302 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
7303 |
^ true |
|
7304 |
! |
|
7305 |
||
7306 |
setSelectionOwner:aWindowId of:selectionID |
|
7307 |
"set the owner of a selection; return false if failed" |
|
7308 |
||
7309 |
%{ /* NOCONTEXT */ |
|
7310 |
Display *dpy = myDpy; |
|
7311 |
Window win; |
|
7312 |
||
7313 |
if (__isExternalAddress(aWindowId) |
|
7314 |
&& __isAtomID(selectionID) |
|
7315 |
&& ISCONNECTED) { |
|
7316 |
win = _WindowVal(aWindowId); |
|
7317 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
7318 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
7319 |
RETURN (false); |
|
7320 |
} |
|
7321 |
RETURN (true); |
|
7322 |
} |
|
7323 |
%} |
|
7324 |
. |
|
7325 |
self primitiveFailed. |
|
7326 |
^ nil |
|
7327 |
! |
|
7328 |
||
7329 |
setTextProperty:propertyID value:aString for:aWindowID |
|
7330 |
^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID |
|
7331 |
! |
|
7332 |
||
7333 |
setTextSelection:aString owner:aWindowId |
|
7334 |
"set the text selection, and make aWindowId be the owner. |
|
7335 |
This can be used by any other X application." |
|
7336 |
||
7337 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7338 |
'ownerchange failed' errorPrintNL. |
|
7339 |
]. |
|
7340 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
7341 |
! ! |
|
7342 |
||
7343 |
!XWorkstation methodsFor:'window stuff'! |
|
7344 |
||
7345 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
|
7346 |
"clear a rectangular area to viewbackground" |
|
7347 |
||
7348 |
%{ /* NOCONTEXT */ |
|
7349 |
||
7350 |
int w, h; |
|
7351 |
||
7352 |
if (__isExternalAddress(aWindowId) |
|
7353 |
&& __bothSmallInteger(x, y) |
|
7354 |
&& __bothSmallInteger(width, height)) { |
|
555 | 7355 |
w = __intVal(width); |
7356 |
h = __intVal(height); |
|
295 | 7357 |
if (w < 0) w = 0; |
7358 |
if (h < 0) h = 0; |
|
555 | 7359 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
295 | 7360 |
RETURN ( self ); |
7361 |
} |
|
7362 |
%} |
|
7363 |
. |
|
7364 |
self primitiveFailed |
|
7365 |
! |
|
7366 |
||
7367 |
clearWindow:aWindowId |
|
7368 |
"clear a window to viewbackground" |
|
7369 |
||
7370 |
%{ /* NOCONTEXT */ |
|
7371 |
||
7372 |
if (__isExternalAddress(aWindowId)) { |
|
7373 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
7374 |
RETURN ( self ); |
|
7375 |
} |
|
7376 |
%} |
|
7377 |
. |
|
7378 |
self primitiveFailed |
|
7379 |
! |
|
7380 |
||
7381 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
|
7382 |
"configure stacking operation of aWindowId w.r.t siblingId" |
|
7383 |
||
7384 |
%{ /* NOCONTEXT */ |
|
7385 |
||
7386 |
XWindowChanges chg; |
|
7387 |
int mask = CWSibling | CWStackMode; |
|
7388 |
||
7389 |
if (__isExternalAddress(aWindowId) |
|
7390 |
&& __isExternalAddress(siblingId)) { |
|
7391 |
if (modeSymbol == @symbol(above)) { |
|
7392 |
chg.stack_mode = Above; |
|
7393 |
} else if (modeSymbol == @symbol(below)) { |
|
7394 |
chg.stack_mode = Below; |
|
7395 |
} else if (modeSymbol == @symbol(topIf)) { |
|
7396 |
chg.stack_mode = TopIf; |
|
7397 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
7398 |
chg.stack_mode = BottomIf; |
|
7399 |
} else if (modeSymbol == @symbol(opposite)) { |
|
7400 |
chg.stack_mode = Opposite; |
|
7401 |
} else { |
|
7402 |
mask = CWSibling; |
|
7403 |
} |
|
7404 |
||
7405 |
chg.sibling = _WindowVal(siblingId); |
|
7406 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
7407 |
mask, &chg); |
|
7408 |
RETURN ( self ); |
|
7409 |
} |
|
7410 |
bad: ; |
|
7411 |
%} |
|
7412 |
. |
|
7413 |
self primitiveFailed |
|
7414 |
! |
|
7415 |
||
7416 |
lowerWindow:aWindowId |
|
7417 |
"bring a window to back" |
|
7418 |
||
7419 |
%{ /* NOCONTEXT */ |
|
7420 |
||
7421 |
if (__isExternalAddress(aWindowId)) { |
|
7422 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
|
7423 |
RETURN ( self ); |
|
7424 |
} |
|
7425 |
%} |
|
7426 |
. |
|
7427 |
self primitiveFailed |
|
7428 |
! |
|
7429 |
||
7430 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
|
7431 |
"make a window visible - either as icon or as a real view - needed for restart" |
|
7432 |
||
7433 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
7434 |
||
7435 |
aBoolean ifTrue:[ |
|
7436 |
wicon := aView icon. |
|
7437 |
wicon notNil ifTrue:[ |
|
7438 |
wiconId := wicon id |
|
7439 |
]. |
|
7440 |
wiconView := aView iconView. |
|
7441 |
wiconView notNil ifTrue:[ |
|
7442 |
wiconViewId := wiconView id |
|
7443 |
]. |
|
7444 |
wlabel := aView label. |
|
7445 |
]. |
|
7446 |
%{ |
|
7447 |
||
7448 |
XWMHints wmhints; |
|
7449 |
XSizeHints szhints; |
|
7450 |
Display *dpy = myDpy; |
|
7451 |
Window win; |
|
7452 |
||
7453 |
if (__isExternalAddress(aWindowId)) { |
|
7454 |
win = _WindowVal(aWindowId); |
|
7455 |
||
7456 |
szhints.flags = 0; |
|
7457 |
if (__bothSmallInteger(xPos, yPos)) { |
|
555 | 7458 |
szhints.x = __intVal(xPos); |
7459 |
szhints.y = __intVal(yPos); |
|
295 | 7460 |
szhints.flags |= USPosition; |
7461 |
} |
|
7462 |
if (__bothSmallInteger(w, h)) { |
|
555 | 7463 |
szhints.width = __intVal(w); |
7464 |
szhints.height = __intVal(h); |
|
295 | 7465 |
szhints.flags |= USSize; |
7466 |
} |
|
7467 |
||
7468 |
if (aBoolean == true) { |
|
7469 |
char *windowName; |
|
7470 |
Pixmap iconBitmap = (Pixmap)0; |
|
7471 |
Window iconWindow; |
|
7472 |
||
7473 |
if (__isExternalAddress(wiconId)) |
|
7474 |
iconBitmap = _PixmapVal(wiconId); |
|
7475 |
else |
|
7476 |
iconBitmap = (Pixmap)0; |
|
7477 |
||
7478 |
if (__isExternalAddress(wiconViewId)) |
|
7479 |
iconWindow = _WindowVal(wiconViewId); |
|
7480 |
else |
|
7481 |
iconWindow = (Window)0; |
|
7482 |
||
7483 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
7484 |
windowName = (char *)_stringVal(wlabel); |
|
7485 |
else |
|
7486 |
windowName = ""; |
|
7487 |
||
7488 |
if (iconBitmap || windowName) { |
|
7489 |
XSetStandardProperties(dpy, win, |
|
7490 |
windowName, windowName, |
|
7491 |
iconBitmap, |
|
7492 |
0, 0, &szhints); |
|
7493 |
} |
|
7494 |
||
7495 |
wmhints.flags = 0; |
|
7496 |
if (iconBitmap) { |
|
7497 |
wmhints.flags |= IconPixmapHint; |
|
7498 |
wmhints.icon_pixmap = iconBitmap; |
|
7499 |
} |
|
7500 |
if (iconWindow) { |
|
7501 |
wmhints.flags |= IconWindowHint; |
|
7502 |
wmhints.icon_window = iconWindow; |
|
7503 |
} |
|
7504 |
||
7505 |
wmhints.initial_state = IconicState; |
|
7506 |
wmhints.flags |= StateHint; |
|
7507 |
XSetWMHints(dpy, win, &wmhints); |
|
7508 |
} |
|
7509 |
||
7510 |
if (szhints.flags) { |
|
7511 |
XSetNormalHints(dpy, win, &szhints); |
|
7512 |
} |
|
7513 |
||
7514 |
XMapWindow(dpy, win); |
|
7515 |
RETURN ( self ); |
|
7516 |
} |
|
7517 |
%} |
|
7518 |
. |
|
7519 |
self primitiveFailed |
|
7520 |
! |
|
7521 |
||
7522 |
mapWindow:aWindowId |
|
7523 |
"make a window visible" |
|
7524 |
||
7525 |
%{ /* NOCONTEXT */ |
|
7526 |
||
7527 |
if (__isExternalAddress(aWindowId)) { |
|
7528 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
|
7529 |
RETURN ( self ); |
|
7530 |
} |
|
7531 |
%} |
|
7532 |
. |
|
7533 |
self primitiveFailed |
|
7534 |
! |
|
7535 |
||
7536 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
|
7537 |
"move and resize a window" |
|
7538 |
||
7539 |
%{ /* NOCONTEXT */ |
|
7540 |
||
7541 |
int newWidth, newHeight; |
|
7542 |
||
7543 |
if (__isExternalAddress(aWindowId) |
|
7544 |
&& __bothSmallInteger(w, h) |
|
7545 |
&& __bothSmallInteger(x, y)) { |
|
555 | 7546 |
newWidth = __intVal(w); |
7547 |
newHeight = __intVal(h); |
|
295 | 7548 |
if (newWidth < 1) newWidth = 1; |
7549 |
if (newHeight < 1) newHeight = 1; |
|
7550 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
555 | 7551 |
__intVal(x), __intVal(y), |
295 | 7552 |
newWidth, newHeight); |
7553 |
RETURN ( self ); |
|
7554 |
} |
|
7555 |
%} |
|
7556 |
. |
|
7557 |
self primitiveFailed |
|
7558 |
! |
|
7559 |
||
7560 |
moveWindow:aWindowId x:x y:y |
|
7561 |
"move a window" |
|
7562 |
||
7563 |
%{ /* NOCONTEXT */ |
|
7564 |
||
7565 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
|
555 | 7566 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
295 | 7567 |
RETURN ( self ); |
7568 |
} |
|
7569 |
%} |
|
7570 |
. |
|
7571 |
self primitiveFailed |
|
7572 |
! |
|
7573 |
||
7574 |
raiseWindow:aWindowId |
|
7575 |
"bring a window to front" |
|
7576 |
||
7577 |
%{ /* NOCONTEXT */ |
|
7578 |
||
7579 |
if (__isExternalAddress(aWindowId)) { |
|
7580 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
|
7581 |
RETURN ( self ); |
|
7582 |
} |
|
7583 |
%} |
|
7584 |
. |
|
7585 |
self primitiveFailed |
|
7586 |
! |
|
7587 |
||
7588 |
resizeWindow:aWindowId width:w height:h |
|
7589 |
"resize a window" |
|
7590 |
||
7591 |
%{ /* NOCONTEXT */ |
|
7592 |
||
7593 |
int newWidth, newHeight; |
|
7594 |
||
7595 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
|
555 | 7596 |
newWidth = __intVal(w); |
7597 |
newHeight = __intVal(h); |
|
295 | 7598 |
if (newWidth < 1) newWidth = 1; |
7599 |
if (newHeight < 1) newHeight = 1; |
|
7600 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
7601 |
RETURN ( self ); |
|
7602 |
} |
|
7603 |
%} |
|
7604 |
. |
|
7605 |
self primitiveFailed |
|
7606 |
! |
|
7607 |
||
7608 |
setBackingStore:how in:aWindowId |
|
7609 |
"turn on/off backing-store for a window" |
|
7610 |
||
7611 |
%{ /* NOCONTEXT */ |
|
7612 |
||
7613 |
XSetWindowAttributes wa; |
|
7614 |
||
7615 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7616 |
if (__INST(ignoreBackingStore) != true) { |
295 | 7617 |
if (how == @symbol(always)) wa.backing_store = Always; |
7618 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
7619 |
else if (how == true) wa.backing_store = Always; |
|
7620 |
else wa.backing_store = 0; |
|
7621 |
BEGIN_INTERRUPTSBLOCKED |
|
7622 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
7623 |
END_INTERRUPTSBLOCKED |
|
7624 |
} |
|
7625 |
RETURN ( self ); |
|
7626 |
} |
|
7627 |
%}. |
|
7628 |
self primitiveFailed |
|
7629 |
! |
|
7630 |
||
7631 |
setBitGravity:how in:aWindowId |
|
7632 |
"set bit gravity for a window" |
|
7633 |
||
7634 |
%{ /* NOCONTEXT */ |
|
7635 |
||
7636 |
XSetWindowAttributes wa; |
|
7637 |
||
7638 |
if (__isExternalAddress(aWindowId)) { |
|
7639 |
if (how == @symbol(NorthWest)) { |
|
7640 |
wa.bit_gravity = NorthWestGravity; |
|
7641 |
} else if (how == @symbol(NorthEast)) { |
|
7642 |
wa.bit_gravity = NorthEastGravity; |
|
7643 |
} else if (how == @symbol(SouthWest)) { |
|
7644 |
wa.bit_gravity = SouthWestGravity; |
|
7645 |
} else if (how == @symbol(SouthEast)) { |
|
7646 |
wa.bit_gravity = SouthEastGravity; |
|
7647 |
} else if (how == @symbol(Center)) { |
|
7648 |
wa.bit_gravity = CenterGravity; |
|
7649 |
} else if (how == @symbol(North)) { |
|
7650 |
wa.bit_gravity = NorthGravity; |
|
7651 |
} else if (how == @symbol(South)) { |
|
7652 |
wa.bit_gravity = SouthGravity; |
|
7653 |
} else if (how == @symbol(West)) { |
|
7654 |
wa.bit_gravity = WestGravity; |
|
7655 |
} else if (how == @symbol(East)) { |
|
7656 |
wa.bit_gravity = EastGravity; |
|
7657 |
} else { |
|
7658 |
wa.bit_gravity = NorthWestGravity; |
|
7659 |
} |
|
7660 |
||
7661 |
BEGIN_INTERRUPTSBLOCKED |
|
7662 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
7663 |
END_INTERRUPTSBLOCKED |
|
7664 |
RETURN ( self ); |
|
7665 |
} |
|
7666 |
%}. |
|
7667 |
self primitiveFailed |
|
7668 |
! |
|
7669 |
||
7670 |
setCursor:aCursorId in:aWindowId |
|
7671 |
"define a windows cursor" |
|
7672 |
||
7673 |
%{ /* NOCONTEXT */ |
|
7674 |
||
7675 |
Display *dpy = myDpy; |
|
7676 |
||
7677 |
if (__isExternalAddress(aWindowId) |
|
7678 |
&& __isExternalAddress(aCursorId)) { |
|
7679 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
|
7680 |
RETURN ( self ); |
|
7681 |
} |
|
7682 |
%}. |
|
7683 |
self primitiveFailed |
|
7684 |
! |
|
7685 |
||
7686 |
setIconName:aString in:aWindowId |
|
7687 |
"define a windows iconname" |
|
7688 |
||
7689 |
%{ /* NOCONTEXT */ |
|
7690 |
||
7691 |
if (__isExternalAddress(aWindowId) |
|
7692 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
7693 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
7694 |
RETURN ( self ); |
|
7695 |
} |
|
7696 |
%}. |
|
7697 |
self primitiveFailed |
|
7698 |
! |
|
7699 |
||
7700 |
setSaveUnder:yesOrNo in:aWindowId |
|
7701 |
"turn on/off save-under for a window" |
|
7702 |
||
7703 |
%{ /* NOCONTEXT */ |
|
7704 |
||
7705 |
XSetWindowAttributes wa; |
|
7706 |
||
7707 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7708 |
if (__INST(hasSaveUnder) == true) { |
295 | 7709 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
7710 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
7711 |
} |
|
7712 |
RETURN ( self ); |
|
7713 |
} |
|
7714 |
%}. |
|
7715 |
self primitiveFailed |
|
7716 |
! |
|
7717 |
||
7718 |
setTransient:aWindowId for:aMainWindowId |
|
7719 |
"set aWindowId to be a transient of aMainWindow" |
|
7720 |
||
7721 |
%{ /* NOCONTEXT */ |
|
7722 |
||
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7723 |
if (__isExternalAddress(aWindowId)) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7724 |
Window w; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7725 |
|
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7726 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7727 |
w = (Window) 0; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7728 |
} else { |
374 | 7729 |
if (__isExternalAddress(aMainWindowId)) { |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7730 |
w = _WindowVal(aMainWindowId); |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7731 |
} else { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7732 |
goto getOutOfHere; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7733 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7734 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7735 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
295 | 7736 |
RETURN ( self ); |
7737 |
} |
|
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7738 |
getOutOfHere: ; |
295 | 7739 |
%}. |
7740 |
self primitiveFailed |
|
7741 |
! |
|
7742 |
||
7743 |
setWindowBackground:aColorIndex in:aWindowId |
|
7744 |
"set the windows background color. This is the color with which |
|
7745 |
the view is filled whenever exposed. Do not confuse this with |
|
7746 |
the background drawing color, which is used with opaque drawing." |
|
7747 |
||
7748 |
%{ /* NOCONTEXT */ |
|
7749 |
||
7750 |
if (__isExternalAddress(aWindowId) |
|
7751 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7752 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7753 |
RETURN ( self ); |
7754 |
} |
|
7755 |
%}. |
|
7756 |
self primitiveFailed |
|
7757 |
! |
|
7758 |
||
7759 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
|
7760 |
"set the windows background pattern to be a form. |
|
7761 |
This is the pattern with which the view is filled whenever exposed. |
|
7762 |
Do not confuse this with the background drawing color, which is used |
|
7763 |
with opaque drawing." |
|
7764 |
||
7765 |
%{ /* NOCONTEXT */ |
|
7766 |
||
7767 |
if (__isExternalAddress(aWindowId) |
|
7768 |
&& __isExternalAddress(aPixmapId)) { |
|
7769 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7770 |
RETURN ( self ); |
|
7771 |
} |
|
7772 |
%}. |
|
7773 |
self primitiveFailed |
|
7774 |
! |
|
7775 |
||
7776 |
setWindowBorderColor:aColorIndex in:aWindowId |
|
7777 |
"set the windows border color" |
|
7778 |
||
7779 |
%{ /* NOCONTEXT */ |
|
7780 |
||
7781 |
if (__isExternalAddress(aWindowId) |
|
7782 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7783 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7784 |
RETURN ( self ); |
7785 |
} |
|
7786 |
%}. |
|
7787 |
self primitiveFailed |
|
7788 |
! |
|
7789 |
||
7790 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
|
7791 |
"set the windows border pattern" |
|
7792 |
||
7793 |
%{ /* NOCONTEXT */ |
|
7794 |
||
7795 |
if (__isExternalAddress(aWindowId) |
|
7796 |
&& __isExternalAddress(aPixmapId)) { |
|
7797 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7798 |
RETURN ( self ); |
|
7799 |
} |
|
7800 |
%} |
|
7801 |
. |
|
7802 |
self primitiveFailed |
|
7803 |
! |
|
7804 |
||
7805 |
setWindowBorderShape:aPixmapId in:aWindowId |
|
7806 |
"set the windows border shape" |
|
7807 |
||
7808 |
hasShapeExtension ifFalse:[^ self]. |
|
7809 |
||
7810 |
%{ /* NOCONTEXT */ |
|
7811 |
||
7812 |
#ifdef SHAPE |
|
7813 |
if (__isExternalAddress(aWindowId) |
|
7814 |
&& __isExternalAddress(aPixmapId)) { |
|
7815 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
|
7816 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
7817 |
RETURN ( self ); |
|
7818 |
} |
|
7819 |
#endif |
|
7820 |
%}. |
|
7821 |
self primitiveFailed |
|
7822 |
! |
|
7823 |
||
7824 |
setWindowBorderWidth:aNumber in:aWindowId |
|
7825 |
"set the windows border width" |
|
7826 |
||
7827 |
%{ /* NOCONTEXT */ |
|
7828 |
||
7829 |
if (__isExternalAddress(aWindowId) |
|
7830 |
&& __isSmallInteger(aNumber)) { |
|
555 | 7831 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
295 | 7832 |
RETURN ( self ); |
7833 |
} |
|
7834 |
%}. |
|
7835 |
self primitiveFailed |
|
7836 |
! |
|
7837 |
||
7838 |
setWindowGravity:how in:aWindowId |
|
7839 |
"set window gravity for a window" |
|
7840 |
||
7841 |
%{ /* NOCONTEXT */ |
|
7842 |
||
7843 |
XSetWindowAttributes wa; |
|
7844 |
||
7845 |
if (__isExternalAddress(aWindowId)) { |
|
7846 |
if (how == @symbol(NorthWest)) { |
|
7847 |
wa.win_gravity = NorthWestGravity; |
|
7848 |
} else if (how == @symbol(NorthEast)) { |
|
7849 |
wa.win_gravity = NorthEastGravity; |
|
7850 |
} else if (how == @symbol(SouthWest)) { |
|
7851 |
wa.win_gravity = SouthWestGravity; |
|
7852 |
} else if (how == @symbol(SouthEast)) { |
|
7853 |
wa.win_gravity = SouthEastGravity; |
|
7854 |
} else if (how == @symbol(Center)) { |
|
7855 |
wa.win_gravity = CenterGravity; |
|
7856 |
} else if (how == @symbol(North)) { |
|
7857 |
wa.win_gravity = NorthGravity; |
|
7858 |
} else if (how == @symbol(South)) { |
|
7859 |
wa.win_gravity = SouthGravity; |
|
7860 |
} else if (how == @symbol(West)) { |
|
7861 |
wa.win_gravity = WestGravity; |
|
7862 |
} else if (how == @symbol(East)) { |
|
7863 |
wa.win_gravity = EastGravity; |
|
7864 |
} else { |
|
7865 |
wa.win_gravity = NorthWestGravity; |
|
7866 |
} |
|
7867 |
||
7868 |
BEGIN_INTERRUPTSBLOCKED |
|
7869 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
7870 |
END_INTERRUPTSBLOCKED |
|
7871 |
RETURN ( self ); |
|
7872 |
} |
|
7873 |
%}. |
|
7874 |
self primitiveFailed |
|
7875 |
! |
|
7876 |
||
7877 |
setWindowIcon:aForm in:aWindowId |
|
7878 |
"define a bitmap to be used as icon" |
|
7879 |
||
7880 |
|iconId| |
|
7881 |
||
7882 |
aForm notNil ifTrue:[ |
|
7883 |
iconId := aForm id |
|
7884 |
]. |
|
7885 |
%{ |
|
7886 |
if (__isExternalAddress(iconId) |
|
7887 |
&& __isExternalAddress(aWindowId)) { |
|
7888 |
XWMHints hints; |
|
7889 |
||
7890 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
7891 |
hints.flags = IconPixmapHint; |
|
7892 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
7893 |
RETURN ( self ); |
|
7894 |
} |
|
7895 |
%}. |
|
7896 |
self primitiveFailed |
|
7897 |
! |
|
7898 |
||
7899 |
setWindowIconWindow:aView in:aWindowId |
|
7900 |
"define a window to be used as icon" |
|
7901 |
||
7902 |
|iconWindowId| |
|
7903 |
||
7904 |
aView notNil ifTrue:[ |
|
7905 |
iconWindowId := aView id |
|
7906 |
]. |
|
7907 |
%{ |
|
7908 |
if (__isExternalAddress(iconWindowId) |
|
7909 |
&& __isExternalAddress(aWindowId)) { |
|
7910 |
XWMHints wmhints; |
|
7911 |
||
7912 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
7913 |
wmhints.flags = IconWindowHint; |
|
7914 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
7915 |
RETURN ( self ); |
|
7916 |
} |
|
7917 |
%}. |
|
7918 |
self primitiveFailed |
|
7919 |
! |
|
7920 |
||
7921 |
setWindowName:aString in:aWindowId |
|
7922 |
"define a windows name" |
|
7923 |
||
7924 |
%{ /* NOCONTEXT */ |
|
7925 |
||
7926 |
if (__isExternalAddress(aWindowId) |
|
7927 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
7928 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
7929 |
RETURN ( self ); |
|
7930 |
} |
|
7931 |
%}. |
|
7932 |
self primitiveFailed |
|
7933 |
! |
|
7934 |
||
7935 |
setWindowShape:aPixmapId in:aWindowId |
|
7936 |
"set the windows shape" |
|
7937 |
||
7938 |
hasShapeExtension ifFalse:[^ self]. |
|
7939 |
||
7940 |
%{ /* NOCONTEXT */ |
|
7941 |
||
7942 |
#ifdef SHAPE |
|
7943 |
if (__isExternalAddress(aWindowId) |
|
7944 |
&& __isExternalAddress(aPixmapId)) { |
|
7945 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
|
7946 |
0, 0, |
|
7947 |
_PixmapVal(aPixmapId), ShapeSet); |
|
7948 |
RETURN ( self ); |
|
7949 |
} |
|
7950 |
#endif |
|
7951 |
%}. |
|
7952 |
self primitiveFailed |
|
7953 |
! |
|
7954 |
||
7955 |
unmapWindow:aWindowId |
|
7956 |
"make a window invisible" |
|
7957 |
||
7958 |
%{ /* NOCONTEXT */ |
|
7959 |
||
7960 |
if (__isExternalAddress(aWindowId)) { |
|
7961 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
|
7962 |
RETURN ( self ); |
|
7963 |
} |
|
7964 |
%} |
|
7965 |
. |
|
7966 |
self primitiveFailed |
|
7967 |
! ! |
|
7968 |
||
7969 |
!XWorkstation class methodsFor:'documentation'! |
|
7970 |
||
7971 |
version |
|
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
7972 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.135 1996-06-05 14:01:41 cg Exp $' |
295 | 7973 |
! ! |
7974 |
XWorkstation initialize! |