author | Claus Gittinger <cg@exept.de> |
Wed, 05 Mar 1997 13:18:51 +0100 | |
changeset 1416 | 85b4e23ecd86 |
parent 1375 | df3d3e894ee1 |
child 1418 | d21112d621a1 |
permissions | -rw-r--r-- |
1127 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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:#WinWorkstation |
|
14 |
instanceVariableNames:'blackpixel whitepixel |
|
15 |
listOfFonts rootWin rootDC |
|
16 |
buttonsPressed eventTrace |
|
17 |
eventBuffer |
|
18 |
usingSystemPalette |
|
19 |
resizeFrameWidth resizeFrameHeight' |
|
20 |
classVariableNames:'RawKeysymTranslation BeepFrequency BeepDuration' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-Graphics' |
|
23 |
! |
|
24 |
||
25 |
!WinWorkstation primitiveDefinitions! |
|
26 |
%{ |
|
27 |
||
28 |
# undef INT |
|
29 |
# define INT WIN_INT |
|
30 |
# undef Array |
|
31 |
# define Array WIN_Array |
|
32 |
# undef Number |
|
33 |
# define Number WIN_Number |
|
34 |
# undef Method |
|
35 |
# define Method WIN_Method |
|
36 |
# undef Point |
|
37 |
# define Point WIN_Point |
|
38 |
# undef Rectangle |
|
39 |
# define Rectangle WIN_Rectangle |
|
40 |
# undef True |
|
41 |
# define True WIN_True |
|
42 |
# undef False |
|
43 |
# define False WIN_False |
|
44 |
# undef Block |
|
45 |
||
46 |
# undef xxCONTEXT |
|
47 |
# define xxCONTEXT WIN_CONTEXT |
|
48 |
# undef _xxCONTEXT |
|
49 |
# define _xxCONTEXT _WIN_CONTEXT |
|
50 |
||
51 |
||
52 |
||
53 |
#include <stdio.h> |
|
54 |
/* #include <malloc.h> */ |
|
55 |
/* #include <math.h> */ |
|
56 |
/* #include <string.h> */ |
|
57 |
||
58 |
#include <stdarg.h> |
|
59 |
||
60 |
/* #include <h/windows.h> */ |
|
61 |
||
62 |
# include <windef.h> |
|
63 |
# include <winbase.h> |
|
64 |
# include <wingdi.h> |
|
65 |
# include <winuser.h> |
|
66 |
||
67 |
||
68 |
# ifdef __DEF_Array |
|
69 |
# undef Array |
|
70 |
# define Array __DEF_Array |
|
71 |
# endif |
|
72 |
# ifdef __DEF_Number |
|
73 |
# undef Number |
|
74 |
# define Number __DEF_Number |
|
75 |
# endif |
|
76 |
# ifdef __DEF_Method |
|
77 |
# undef Method |
|
78 |
# define Method __DEF_Method |
|
79 |
# endif |
|
80 |
# ifdef __DEF_Point |
|
81 |
# undef Point |
|
82 |
# define Point __DEF_Point |
|
83 |
# endif |
|
84 |
# ifdef __DEF_Block |
|
85 |
# define Block __DEF_Block |
|
86 |
# endif |
|
87 |
||
88 |
/* |
|
89 |
* some defines - tired of typing ... |
|
90 |
*/ |
|
91 |
#define _HANDLEVal(o) (HANDLE)(__MKCP(o)) |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
92 |
#define _HBITMAPVAL(o) (HBITMAP)(__MKCP(o)) |
1127 | 93 |
#define _HWNDVal(o) (HWND)(__MKCP(o)) |
94 |
#define _HPALETTEVal(o) (HPALETTE)(__MKCP(o)) |
|
95 |
#define _HCURSORVal(o) (HCURSOR)(__MKCP(o)) |
|
96 |
#define _HGDIOBJVal(o) (HGDIOBJ)(__MKCP(o)) |
|
97 |
#define _LOGPALETTEVal(o) (LOGPALETTE *)(__MKCP(o)) |
|
98 |
#define _COLORREFVal(o) (COLORREF)(__MKCP(o)) |
|
99 |
||
100 |
#define _GCDATA(o) ((struct gcData *)(__MKCP(o))) |
|
101 |
#define _HDCVal(o) (_GCDATA(o)->hDC) |
|
102 |
#define _HPENVal(o) (_GCDATA(o)->hPen) |
|
103 |
#define _HBRUSHVal(o) (_GCDATA(o)->hBrush) |
|
104 |
||
105 |
#define __rootDC (HDC)(__MKCP(__INST(rootDC))) |
|
106 |
#define ISCONNECTED (__INST(rootDC) != nil) |
|
107 |
||
108 |
struct gcData { |
|
109 |
HDC hDC; |
|
110 |
HPEN hPen; |
|
111 |
HBRUSH hBrush; |
|
112 |
COLORREF fgColor; |
|
113 |
COLORREF bgColor; |
|
114 |
int brushType; |
|
115 |
int lineWidth; |
|
116 |
int lineStyle; |
|
117 |
int joinStyle; |
|
118 |
int capStyle; |
|
119 |
int fontAscent; |
|
120 |
}; |
|
121 |
||
122 |
/* |
|
123 |
* some synthetic values |
|
124 |
*/ |
|
125 |
# define Button1MotionMask 1 |
|
126 |
# define Button2MotionMask 2 |
|
127 |
# define Button3MotionMask 4 |
|
128 |
||
129 |
# define Button1Mask Button1MotionMask |
|
130 |
# define Button2Mask Button2MotionMask |
|
131 |
# define Button3Mask Button3MotionMask |
|
132 |
||
133 |
# define ControlMask 8 |
|
134 |
# define ShiftMask 16 |
|
135 |
# define LeftAltMask 32 |
|
136 |
# define RightAltMask 64 |
|
137 |
||
138 |
# define TRANSLATED_KEY 256 |
|
139 |
||
140 |
int AltMask = RightAltMask; |
|
141 |
int MetaMask = LeftAltMask; |
|
142 |
||
143 |
# define WhitePixel RGB(0xFF, 0xFF, 0xFF) |
|
144 |
# define BlackPixel RGB(0, 0, 0) |
|
145 |
||
146 |
#ifdef DEBUG |
|
147 |
# define DPRINTF(x) printf x |
|
148 |
# define DDPRINTF(x) /* nothing */ |
|
149 |
# define EVENT_PRINTF(x) printf x |
|
150 |
# define EVENT_PRINTF1(x) /* */ |
|
151 |
# define EVENT_PRINTF2(x) printf x |
|
152 |
#else |
|
153 |
# define DPRINTF(x) /* */ |
|
154 |
# define DDPRINTF(x) /* */ |
|
155 |
# define EVENT_PRINTF(x) /* */ |
|
156 |
# define EVENT_PRINTF1(x) /* */ |
|
157 |
# define EVENT_PRINTF2(x) /* */ |
|
158 |
#endif |
|
159 |
||
160 |
# define BR_SOLID 0 |
|
161 |
# define BR_PATTERN 1 |
|
162 |
||
163 |
# define LINE_SOLID 0 |
|
164 |
# define LINE_DASH 1 |
|
165 |
# define LINE_DDASH 2 |
|
166 |
||
167 |
# define _C_ARROW 1 |
|
168 |
# define _C_CROSS 2 |
|
169 |
# define _C_IBEAM 3 |
|
170 |
# define _C_ICON 4 |
|
171 |
# define _C_NO 5 |
|
172 |
# define _C_SIZE 6 |
|
173 |
# define _C_SIZEALL 7 |
|
174 |
# define _C_SIZENESW 8 |
|
175 |
# define _C_SIZENS 9 |
|
176 |
# define _C_SIZENWSE 10 |
|
177 |
# define _C_UPARROW 11 |
|
178 |
# define _C_WAIT 12 |
|
179 |
||
180 |
static HCURSOR H_C_ARROW = (HCURSOR)0; |
|
181 |
static HCURSOR H_C_CROSS = (HCURSOR)0; |
|
182 |
static HCURSOR H_C_IBEAM = (HCURSOR)0; |
|
183 |
static HCURSOR H_C_ICON = (HCURSOR)0; |
|
184 |
static HCURSOR H_C_NO = (HCURSOR)0; |
|
185 |
static HCURSOR H_C_SIZE = (HCURSOR)0; |
|
186 |
static HCURSOR H_C_SIZEALL = (HCURSOR)0; |
|
187 |
static HCURSOR H_C_SIZENESW = (HCURSOR)0; |
|
188 |
static HCURSOR H_C_SIZENS = (HCURSOR)0; |
|
189 |
static HCURSOR H_C_SIZENWSE = (HCURSOR)0; |
|
190 |
static HCURSOR H_C_UPARROW = (HCURSOR)0; |
|
191 |
static HCURSOR H_C_WAIT = (HCURSOR)0; |
|
192 |
||
193 |
static int evRootX, evRootY; |
|
194 |
static HWND buttonWindow = (HWND)0; |
|
195 |
||
196 |
%} |
|
197 |
! ! |
|
198 |
||
199 |
!WinWorkstation primitiveVariables! |
|
200 |
%{ |
|
201 |
||
202 |
static HANDLE hInstance = (HANDLE)0, |
|
203 |
hPrevInstance = (HANDLE)0; |
|
204 |
static int firstInstance = 1; |
|
205 |
static char *app_name = "ST/X"; |
|
206 |
static int __debug__ = 0; |
|
207 |
||
208 |
static int __inCreate = 0; |
|
209 |
static int create_topView; |
|
210 |
static int create_minWidth; |
|
211 |
static int create_maxWidth; |
|
212 |
static int create_minHeight; |
|
213 |
static int create_maxHeight; |
|
214 |
||
215 |
||
216 |
%} |
|
217 |
! ! |
|
218 |
||
219 |
!WinWorkstation primitiveFunctions! |
|
220 |
||
221 |
%{ |
|
222 |
||
223 |
struct queuedEvent { |
|
224 |
struct queuedEvent *ev_next; |
|
225 |
HWND ev_hWnd; |
|
226 |
UINT ev_message; |
|
227 |
UINT ev_wParam; |
|
228 |
int ev_arg1; |
|
229 |
int ev_arg2; |
|
230 |
int ev_arg3; |
|
231 |
int ev_arg4; |
|
232 |
int filler; |
|
233 |
}; |
|
234 |
||
235 |
#define ev_x ev_arg1 |
|
236 |
#define ev_y ev_arg2 |
|
237 |
#define ev_w ev_arg3 |
|
238 |
#define ev_h ev_arg4 |
|
239 |
||
240 |
#define ev_keyCode ev_wParam |
|
241 |
#define ev_scanCode ev_arg3 |
|
242 |
#define ev_modifiers ev_arg4 |
|
243 |
||
244 |
#define EV_CHUNK_SZ 1024 |
|
245 |
#define EV_CHUNK_CNT (1024/sizeof(struct queuedEvent)) |
|
246 |
struct queuedEvent *eventFreeList = (struct queuedEvent *)0; |
|
247 |
struct queuedEvent *eventQueueHead = (struct queuedEvent *)0; |
|
248 |
struct queuedEvent *eventQueueTail = (struct queuedEvent *)0; |
|
249 |
||
250 |
static |
|
251 |
enqEvent(hWnd, message, wParam, arg1, arg2, arg3, arg4) |
|
252 |
HWND hWnd; |
|
253 |
UINT message; |
|
254 |
UINT wParam; |
|
255 |
{ |
|
256 |
struct queuedEvent *ev; |
|
257 |
struct queuedEvent *bulk; |
|
258 |
int i; |
|
259 |
||
260 |
ev = eventFreeList; |
|
261 |
if (ev) { |
|
262 |
eventFreeList = ev->ev_next; |
|
263 |
} else { |
|
264 |
bulk = (struct queuedEvent *) malloc(EV_CHUNK_SZ); |
|
265 |
for (i=1; i<EV_CHUNK_CNT; i++) { |
|
266 |
bulk[i-1].ev_next = &(bulk[i]); |
|
267 |
} |
|
268 |
bulk[EV_CHUNK_CNT-1].ev_next = (struct queuedEvent *)0; |
|
269 |
ev = bulk; |
|
270 |
eventFreeList = &(bulk[1]); |
|
271 |
} |
|
272 |
ev->ev_next = (struct queuedEvent *)0; |
|
273 |
ev->ev_hWnd = hWnd; |
|
274 |
ev->ev_message = message; |
|
275 |
ev->ev_wParam = wParam; |
|
276 |
ev->ev_arg1 = arg1; |
|
277 |
ev->ev_arg2 = arg2; |
|
278 |
ev->ev_arg3 = arg3; |
|
279 |
ev->ev_arg4 = arg4; |
|
280 |
||
281 |
if (eventQueueTail) { |
|
282 |
eventQueueTail->ev_next = ev; |
|
283 |
} else { |
|
284 |
eventQueueHead = ev; |
|
285 |
} |
|
286 |
eventQueueTail = ev; |
|
287 |
} |
|
288 |
||
289 |
static |
|
290 |
struct queuedEvent * |
|
291 |
deqEvent() { |
|
292 |
struct queuedEvent *ev; |
|
293 |
||
294 |
ev = eventQueueHead; |
|
295 |
if (ev) { |
|
296 |
eventQueueHead = ev->ev_next; |
|
297 |
if (! eventQueueHead) { |
|
298 |
eventQueueTail = (struct queuedEvent *)0; |
|
299 |
} |
|
300 |
} |
|
301 |
return ev; |
|
302 |
} |
|
303 |
||
304 |
static |
|
305 |
freeEvent(ev) |
|
306 |
struct queuedEvent *ev; |
|
307 |
{ |
|
308 |
ev->ev_next = eventFreeList; |
|
309 |
eventFreeList = ev; |
|
310 |
} |
|
311 |
||
312 |
static |
|
313 |
getModifiers() |
|
314 |
{ |
|
315 |
int modifiers; |
|
316 |
||
317 |
modifiers = 0; |
|
318 |
if (GetKeyState(VK_SHIFT) & 0x8000) |
|
319 |
modifiers |= ShiftMask; |
|
320 |
if (GetKeyState(VK_CONTROL) & 0x8000) |
|
321 |
modifiers |= ControlMask; |
|
322 |
if (GetKeyState(VK_RMENU) & 0x8000) |
|
323 |
modifiers |= RightAltMask; |
|
324 |
if (GetKeyState(VK_LMENU) & 0x8000) |
|
325 |
modifiers |= LeftAltMask; |
|
326 |
if (GetKeyState(VK_LBUTTON) & 0x8000) |
|
327 |
modifiers |= Button1Mask; |
|
328 |
if (GetKeyState(VK_MBUTTON) & 0x8000) |
|
329 |
modifiers |= Button2Mask; |
|
330 |
if (GetKeyState(VK_RBUTTON) & 0x8000) |
|
331 |
modifiers |= Button3Mask; |
|
332 |
||
333 |
return modifiers; |
|
334 |
} |
|
335 |
||
336 |
static |
|
337 |
getAllWinEvents() |
|
338 |
{ |
|
339 |
MSG msg; |
|
340 |
int more; |
|
341 |
||
342 |
if (PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE)) { |
|
343 |
more = 1; |
|
344 |
while (more) { |
|
345 |
GetMessage(&msg, (HWND)0, 0, 0); |
|
346 |
||
347 |
if ((msg.message == WM_KEYDOWN) || (msg.message == WM_KEYUP) |
|
348 |
|| (msg.message == WM_SYSKEYDOWN) || (msg.message == WM_SYSKEYUP)) { |
|
349 |
if (((msg.wParam >= '0') && (msg.wParam <= 'Z')) |
|
350 |
|| (msg.wParam == 0x20) |
|
351 |
|| (msg.wParam >= 0xB0)) { |
|
352 |
/* |
|
353 |
* translate to a WM_CHAR message |
|
354 |
*/ |
|
355 |
if (TranslateMessage(&msg)) |
|
356 |
continue; |
|
357 |
} |
|
358 |
} |
|
359 |
||
360 |
evRootX = msg.pt.x; |
|
361 |
evRootY = msg.pt.y; |
|
362 |
DispatchMessage(&msg); |
|
363 |
more = PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE); |
|
364 |
} |
|
365 |
} |
|
366 |
} |
|
367 |
||
368 |
static |
|
369 |
winEventProcessing(hWnd, message, wParam, lParam, pDefault) |
|
370 |
HWND hWnd; /* window handle */ |
|
371 |
UINT message; /* type of message */ |
|
372 |
UINT wParam; /* additional information */ |
|
373 |
LONG lParam; /* additional information */ |
|
374 |
int *pDefault; |
|
375 |
{ |
|
376 |
LPMINMAXINFO lpmmi; |
|
377 |
WINDOWPOS *posStruct; |
|
378 |
int modifiers; |
|
379 |
int x, y, w, h; |
|
380 |
||
381 |
/* |
|
382 |
EVENT_PRINTF(("winEvent hWin=0x%x message=0x%x wP=0x%x lP=0x%x\n", |
|
383 |
hWnd, message, wParam, lParam)); |
|
384 |
*/ |
|
385 |
||
386 |
/* |
|
387 |
* messages which are handled right here |
|
388 |
*/ |
|
389 |
if (__inCreate) { |
|
390 |
EVENT_PRINTF(("in create\n")); |
|
391 |
||
392 |
switch (message) { |
|
393 |
case WM_GETMINMAXINFO: |
|
394 |
if (create_topView) { |
|
395 |
lpmmi = (LPMINMAXINFO) lParam; |
|
396 |
||
397 |
DPRINTF(("WM_GETMINMAXINFO handle=%x got min: %d/%d\n", |
|
398 |
hWnd, |
|
399 |
lpmmi->ptMinTrackSize.x, |
|
400 |
lpmmi->ptMinTrackSize.y)); |
|
401 |
||
402 |
||
403 |
lpmmi->ptMaxSize.x = create_maxWidth; |
|
404 |
lpmmi->ptMaxSize.y = create_maxHeight; |
|
405 |
lpmmi->ptMaxTrackSize.x = create_maxWidth; |
|
406 |
lpmmi->ptMaxTrackSize.y = create_maxHeight; |
|
407 |
lpmmi->ptMinTrackSize.x = create_minWidth; |
|
408 |
lpmmi->ptMinTrackSize.y = create_minHeight; |
|
409 |
DPRINTF(("WM_GETMINMAXINFO handle=%x return min: %d/%d max: %d/%d\n", |
|
410 |
hWnd, |
|
411 |
create_minWidth, create_minHeight, |
|
412 |
create_maxWidth, create_maxHeight)); |
|
413 |
*pDefault = 0; |
|
414 |
return 0; |
|
415 |
} |
|
416 |
break; |
|
417 |
} |
|
418 |
} |
|
419 |
||
420 |
/* |
|
421 |
* messages which are enqueued to be handled by the view thread |
|
422 |
*/ |
|
423 |
||
424 |
switch (message) { |
|
425 |
case WM_SETCURSOR: |
|
426 |
*pDefault = 1; |
|
427 |
return 0; |
|
428 |
||
429 |
case WM_WINDOWPOSCHANGED: |
|
430 |
EVENT_PRINTF(("WM_WINDOWPOSCHANGED\n")); |
|
431 |
||
432 |
posStruct = (WINDOWPOS *)lParam; |
|
433 |
if (! posStruct) { |
|
434 |
DPRINTF(("oops - no posStruct passed\n")); |
|
435 |
break; |
|
436 |
} |
|
437 |
||
438 |
{ |
|
439 |
RECT rct; |
|
440 |
||
441 |
GetClientRect(hWnd, &rct); |
|
442 |
enqEvent(hWnd, message, wParam, |
|
443 |
rct.left, rct.top, |
|
444 |
rct.right-rct.left+1, |
|
445 |
rct.bottom-rct.top+1); |
|
446 |
} |
|
447 |
#if 0 |
|
448 |
enqEvent(hWnd, message, wParam, |
|
449 |
posStruct->x, posStruct->y, |
|
450 |
posStruct->cx, posStruct->cy); |
|
451 |
#endif |
|
452 |
||
453 |
*pDefault = 0; |
|
454 |
return 0; |
|
455 |
||
456 |
case WM_ERASEBKGND: |
|
457 |
EVENT_PRINTF(("WM_ERASEBKGND\n")); |
|
458 |
goto paint; |
|
459 |
||
460 |
case WM_PAINT: |
|
461 |
EVENT_PRINTF(("WM_PAINT\n")); |
|
462 |
paint: |
|
463 |
{ |
|
464 |
RECT upd; |
|
465 |
||
466 |
if (GetUpdateRect(hWnd, &upd, 0)) { |
|
467 |
if ((upd.left == upd.right) && (upd.top == upd.bottom)) { |
|
468 |
DPRINTF(("WM_PAINT: null rectangle\n")); |
|
469 |
ValidateRect(hWnd, NULL); |
|
470 |
break; |
|
471 |
} |
|
472 |
||
473 |
x = upd.left; |
|
474 |
y = upd.top; |
|
475 |
w = upd.right - upd.left + 1; |
|
476 |
h = upd.bottom - upd.top + 1; |
|
477 |
||
478 |
ValidateRect(hWnd, NULL); |
|
479 |
||
480 |
enqEvent(hWnd, message, wParam, x, y, w, h); |
|
481 |
||
482 |
*pDefault = 0; |
|
483 |
return 0; |
|
484 |
} |
|
485 |
} |
|
486 |
||
487 |
*pDefault = 0; |
|
488 |
return 0; |
|
489 |
break; |
|
490 |
||
491 |
case WM_SHOWWINDOW: |
|
492 |
EVENT_PRINTF(("WM_SHOWWINDOW\n")); |
|
493 |
enqEvent(hWnd, message, wParam, 0, 0, 0, 0); |
|
494 |
*pDefault = 0; |
|
495 |
return 0; |
|
496 |
||
497 |
case WM_DESTROY: |
|
498 |
EVENT_PRINTF2(("WM_DESTROY\n")); |
|
499 |
enqEvent(hWnd, message, wParam, 0, 0, 0, 0); |
|
500 |
*pDefault = 0; |
|
501 |
return 0; |
|
502 |
||
503 |
case WM_MOUSEACTIVATE: |
|
504 |
EVENT_PRINTF2(("WM_MOUSEACTIVATE h=%x\n", hWnd)); |
|
505 |
SetFocus(hWnd); |
|
506 |
enqEvent(hWnd, message, wParam, 0, 0, 0, 0); |
|
507 |
*pDefault = 0; |
|
508 |
return MA_ACTIVATE; |
|
509 |
||
510 |
case WM_ACTIVATE: |
|
511 |
EVENT_PRINTF2(("WM_ACTIVATE %s h=%x\n", |
|
512 |
LOWORD(wParam) ? "active" : "inactive", |
|
513 |
hWnd)); |
|
514 |
||
515 |
switch (LOWORD(wParam)) { |
|
516 |
case WA_INACTIVE: |
|
517 |
EVENT_PRINTF2(("WM_ACTIVATE inactive h=%x\n", hWnd)); |
|
518 |
break; |
|
519 |
case WA_ACTIVE: |
|
520 |
EVENT_PRINTF2(("WM_ACTIVATE active h=%x\n", hWnd)); |
|
521 |
break; |
|
522 |
case WA_CLICKACTIVE: |
|
523 |
EVENT_PRINTF2(("WM_ACTIVATE clkactive h=%x\n", hWnd)); |
|
524 |
break; |
|
525 |
default: |
|
526 |
EVENT_PRINTF2(("WM_ACTIVATE ? h=%x\n", hWnd)); |
|
527 |
break; |
|
528 |
} |
|
529 |
enqEvent(hWnd, message, wParam, 0, 0, 0, 0); |
|
530 |
break; |
|
531 |
||
532 |
case WM_SYSCHAR: |
|
533 |
EVENT_PRINTF2(("WM_SYSCHAR h=%x %x\n", hWnd, wParam)); |
|
534 |
goto commonChar; |
|
535 |
||
536 |
case WM_CHAR: |
|
537 |
EVENT_PRINTF2(("WM_CHAR h=%x %x\n", hWnd, wParam)); |
|
538 |
commonChar: |
|
539 |
modifiers = getModifiers(); |
|
540 |
{ |
|
541 |
POINT p; |
|
542 |
||
543 |
p.x = evRootX; |
|
544 |
p.y = evRootY; |
|
545 |
ScreenToClient(hWnd, &p); |
|
546 |
x = p.x; |
|
547 |
y = p.y; |
|
548 |
} |
|
549 |
enqEvent(hWnd, WM_KEYDOWN, wParam, x, y, lParam, modifiers | TRANSLATED_KEY); |
|
550 |
enqEvent(hWnd, WM_KEYUP, wParam, x, y, lParam, modifiers | TRANSLATED_KEY); |
|
551 |
*pDefault = 0; |
|
552 |
return 0; |
|
553 |
||
554 |
case WM_SYSKEYUP: |
|
555 |
EVENT_PRINTF2(("WM_SYSKEYUP %x\n, wParam")); |
|
556 |
goto commonKey; |
|
557 |
||
558 |
case WM_SYSKEYDOWN: |
|
559 |
EVENT_PRINTF2(("WM_SYSKEYDOWN %x\n, wParam")); |
|
560 |
goto commonKey; |
|
561 |
||
562 |
case WM_KEYUP: |
|
563 |
EVENT_PRINTF2(("WM_KEYUP h=%x %x\n", hWnd, wParam)); |
|
564 |
goto commonKey; |
|
565 |
||
566 |
case WM_KEYDOWN: |
|
567 |
EVENT_PRINTF2(("WM_KEYDOWN h=%x %x\n", hWnd, wParam)); |
|
568 |
commonKey: |
|
569 |
modifiers = getModifiers(); |
|
570 |
{ |
|
571 |
POINT p; |
|
572 |
||
573 |
p.x = evRootX; |
|
574 |
p.y = evRootY; |
|
575 |
ScreenToClient(hWnd, &p); |
|
576 |
x = p.x; |
|
577 |
y = p.y; |
|
578 |
} |
|
579 |
||
580 |
enqEvent(hWnd, message, wParam, x, y, lParam, modifiers); |
|
581 |
*pDefault = 0; |
|
582 |
return 0; |
|
583 |
||
584 |
case WM_MOUSEMOVE: |
|
585 |
EVENT_PRINTF2(("WM_MOUSEMOVE h=%x\n", hWnd)); |
|
586 |
{ |
|
587 |
short x, y; |
|
588 |
||
589 |
x = LOWORD(lParam); |
|
590 |
y = HIWORD(lParam); |
|
591 |
enqEvent(hWnd, message, wParam, x, y, 0, 0); |
|
592 |
} |
|
593 |
*pDefault = 0; |
|
594 |
return 0; |
|
595 |
||
596 |
case WM_LBUTTONDOWN: |
|
597 |
case WM_MBUTTONDOWN: |
|
598 |
case WM_RBUTTONDOWN: |
|
599 |
SetCapture(hWnd); |
|
600 |
goto commonButton; |
|
601 |
||
602 |
case WM_LBUTTONUP: |
|
603 |
case WM_MBUTTONUP: |
|
604 |
case WM_RBUTTONUP: |
|
605 |
ReleaseCapture(); |
|
606 |
goto commonButton; |
|
607 |
||
608 |
case WM_LBUTTONDBLCLK: |
|
609 |
case WM_MBUTTONDBLCLK: |
|
610 |
case WM_RBUTTONDBLCLK: |
|
611 |
commonButton: |
|
612 |
modifiers = getModifiers(); |
|
613 |
EVENT_PRINTF2(("WM_BUTTONUP/DOWN h=%x pos=%d/%d\n", |
|
614 |
hWnd, LOWORD(lParam), HIWORD(lParam))); |
|
615 |
enqEvent(hWnd, message, wParam, LOWORD(lParam), |
|
616 |
HIWORD(lParam), |
|
617 |
wParam, |
|
618 |
modifiers); |
|
619 |
*pDefault = 0; |
|
620 |
return 0; |
|
621 |
||
622 |
case WM_KILLFOCUS: |
|
623 |
EVENT_PRINTF(("WM_KILLFOCUS\n")); |
|
624 |
enqEvent(hWnd, message, wParam, 0, 0, 0, 0); |
|
625 |
break; |
|
626 |
||
627 |
case WM_SETFOCUS: |
|
628 |
EVENT_PRINTF(("WM_SETFOCUS\n")); |
|
629 |
enqEvent(hWnd, message, wParam, 0, 0, 0, 0); |
|
630 |
break; |
|
631 |
} |
|
632 |
||
633 |
switch (message) { |
|
634 |
case WM_GETTEXT: |
|
635 |
EVENT_PRINTF(("WM_GETTEXT\n")); |
|
636 |
break; |
|
637 |
||
638 |
case WM_GETTEXTLENGTH: |
|
639 |
EVENT_PRINTF(("WM_GETTEXTLENGTH\n")); |
|
640 |
break; |
|
641 |
||
642 |
case WM_NCCREATE: |
|
643 |
EVENT_PRINTF(("WM_NCCREATE\n")); |
|
644 |
break; |
|
645 |
||
646 |
case WM_GETMINMAXINFO: |
|
647 |
EVENT_PRINTF(("WM_GETMINMAXINFO\n")); |
|
648 |
break; |
|
649 |
||
650 |
case WM_NCHITTEST: |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
651 |
EVENT_PRINTF2(("WM_NCHITTEST\n")); |
1127 | 652 |
break; |
653 |
||
654 |
case WM_NCMOUSEMOVE: |
|
655 |
EVENT_PRINTF(("WM_NCMOUSEMOVE\n")); |
|
656 |
break; |
|
657 |
||
658 |
case WM_PARENTNOTIFY: |
|
659 |
EVENT_PRINTF2(("WM_PARENTNOTIFY h=%x hChild=%x %d\n", |
|
660 |
hWnd, lParam, LOWORD(wParam))); |
|
661 |
break; |
|
662 |
||
663 |
case WM_SETCURSOR: |
|
664 |
EVENT_PRINTF(("WM_SETCURSOR\n")); |
|
665 |
break; |
|
666 |
||
667 |
case WM_NCLBUTTONDOWN: |
|
668 |
EVENT_PRINTF(("WM_NCLBUTTONDOWN\n")); |
|
669 |
break; |
|
670 |
||
671 |
case WM_SETTEXT: |
|
672 |
EVENT_PRINTF(("WM_SETTEXT\n")); |
|
673 |
break; |
|
674 |
||
675 |
case 0x88: |
|
676 |
EVENT_PRINTF(("0x88 (undoc)\n")); |
|
677 |
break; |
|
678 |
||
679 |
case 0x231: |
|
680 |
EVENT_PRINTF(("0x231 (undoc)\n")); |
|
681 |
break; |
|
682 |
||
683 |
case 0x232: |
|
684 |
EVENT_PRINTF(("0x232 (undoc)\n")); |
|
685 |
break; |
|
686 |
||
687 |
case WM_SIZE: |
|
688 |
EVENT_PRINTF(("WM_SIZE\n")); |
|
689 |
break; |
|
690 |
||
691 |
case WM_CREATE: |
|
692 |
EVENT_PRINTF(("WM_CREATE\n")); |
|
693 |
break; |
|
694 |
||
695 |
case WM_NCCALCSIZE: |
|
696 |
EVENT_PRINTF(("WM_NCCALCSIZE\n")); |
|
697 |
break; |
|
698 |
||
699 |
case WM_NCPAINT: |
|
700 |
EVENT_PRINTF(("WM_NCPAINT\n")); |
|
701 |
break; |
|
702 |
||
703 |
case WM_SYSCOMMAND: |
|
704 |
EVENT_PRINTF2(("WM_SYSCOMMAND\n")); |
|
705 |
break; |
|
706 |
||
707 |
case WM_INITMENU: |
|
708 |
EVENT_PRINTF(("WM_INITMENU\n")); |
|
709 |
break; |
|
710 |
||
711 |
case WM_INITMENUPOPUP: |
|
712 |
EVENT_PRINTF(("WM_INITMENUPOPUP\n")); |
|
713 |
break; |
|
714 |
||
715 |
case WM_ENTERIDLE: |
|
716 |
EVENT_PRINTF(("WM_ENTERIDLE\n")); |
|
717 |
break; |
|
718 |
||
719 |
case WM_ENTERMENULOOP: |
|
720 |
EVENT_PRINTF(("WM_ENTERMENULOOP\n")); |
|
721 |
break; |
|
722 |
||
723 |
case WM_EXITMENULOOP: |
|
724 |
EVENT_PRINTF(("WM_EXITMENULOOP\n")); |
|
725 |
break; |
|
726 |
||
727 |
case WM_MENUSELECT: |
|
728 |
EVENT_PRINTF(("WM_MENUSELECT\n")); |
|
729 |
break; |
|
730 |
||
731 |
case WM_QUIT: |
|
732 |
EVENT_PRINTF(("WM_QUIT\n")); |
|
733 |
break; |
|
734 |
||
735 |
case WM_CLOSE: |
|
736 |
EVENT_PRINTF(("WM_CLOSE\n")); |
|
737 |
break; |
|
738 |
||
739 |
case WM_NCDESTROY: |
|
740 |
EVENT_PRINTF(("WM_NCDESTROY\n")); |
|
741 |
break; |
|
742 |
||
743 |
case WM_QUERYNEWPALETTE: |
|
744 |
EVENT_PRINTF(("WM_QUERYNEWPALETTE\n")); |
|
745 |
break; |
|
746 |
||
747 |
case WM_PALETTECHANGED: |
|
748 |
EVENT_PRINTF(("WM_PALETTECHANGED\n")); |
|
749 |
break; |
|
750 |
||
751 |
case WM_NCACTIVATE: |
|
752 |
EVENT_PRINTF(("WM_NCACTIVATE\n")); |
|
753 |
break; |
|
754 |
||
755 |
case WM_ACTIVATEAPP: |
|
756 |
EVENT_PRINTF1(("WM_ACTIVATEAPP %s\n", wParam ? "active" : "inactive")); |
|
757 |
break; |
|
758 |
||
759 |
case WM_MOVE: |
|
760 |
EVENT_PRINTF(("WM_MOVE\n")); |
|
761 |
break; |
|
762 |
||
763 |
case WM_SYSDEADCHAR: |
|
764 |
EVENT_PRINTF2(("WM_SYSDEADCHAR %x\n, wParam")); |
|
765 |
break; |
|
766 |
||
767 |
case WM_DEADCHAR: |
|
768 |
EVENT_PRINTF2(("WM_DEADCHAR %x\n, wParam")); |
|
769 |
break; |
|
770 |
||
771 |
case WM_PAINTICON: |
|
772 |
EVENT_PRINTF(("WM_PAINTICON\n")); |
|
773 |
break; |
|
774 |
||
775 |
case WM_ICONERASEBKGND: |
|
776 |
EVENT_PRINTF(("WM_ICONERASEBKGND\n")); |
|
777 |
break; |
|
778 |
||
779 |
case WM_WINDOWPOSCHANGING: |
|
780 |
EVENT_PRINTF(("WM_WINDOWPOSCHANGING\n")); |
|
781 |
break; |
|
782 |
||
783 |
case WM_QUERYOPEN: |
|
784 |
EVENT_PRINTF(("WM_QUERYOPEN\n")); |
|
785 |
break; |
|
786 |
||
787 |
case WM_QUERYENDSESSION: |
|
788 |
EVENT_PRINTF(("WM_QUERYENDSESSION\n")); |
|
789 |
break; |
|
790 |
||
791 |
default: |
|
792 |
EVENT_PRINTF(("msg = %x\n", message)); |
|
793 |
break; |
|
794 |
} |
|
795 |
return 0; |
|
796 |
} |
|
797 |
||
798 |
LONG APIENTRY |
|
799 |
MainWndProc(hWnd, message, wParam, lParam) |
|
800 |
HWND hWnd; /* window handle */ |
|
801 |
UINT message; /* type of message */ |
|
802 |
UINT wParam; /* additional information */ |
|
803 |
LONG lParam; /* additional information */ |
|
804 |
{ |
|
805 |
int wantDefault = 1; |
|
806 |
int retVal; |
|
807 |
||
808 |
DDPRINTF((">> MainWndProc\n")); |
|
809 |
||
810 |
retVal = winEventProcessing(hWnd, message, wParam, lParam, &wantDefault); |
|
811 |
if (wantDefault) { |
|
812 |
DDPRINTF(("DefWindowProc\n")); |
|
813 |
retVal = DefWindowProc(hWnd, message, wParam, lParam); |
|
814 |
} |
|
815 |
DDPRINTF(("<< MainWndProc (%d)\n", retVal)); |
|
816 |
return retVal; |
|
817 |
} |
|
818 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
819 |
int CALLBACK |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
820 |
EnumFPTypeFace( lplf, lptm, dwType, lpData ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
821 |
LOGFONT* lplf; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
822 |
TEXTMETRIC* lptm; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
823 |
DWORD dwType; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
824 |
LPARAM lpData; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
825 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
826 |
OBJ t; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
827 |
OBJ* refToList; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
828 |
OBJ typeFaceList; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
829 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
830 |
t = __MKSTRING( lplf->lfFaceName ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
831 |
refToList = (OBJ*) lpData; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
832 |
typeFaceList = *refToList; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
833 |
__SSEND1( typeFaceList, @symbol(add:), 0, t ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
834 |
return 1; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
835 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
836 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
837 |
int CALLBACK |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
838 |
EnumFontsProc( lplf, lptm, dwType, lpData ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
839 |
LOGFONT* lplf; /* address of logical-font data */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
840 |
TEXTMETRIC* lptm; /* address of physical font data */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
841 |
DWORD dwType; /* font type */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
842 |
LPARAM lpData; /* address of application supplied data */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
843 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
844 |
OBJ newArray, t; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
845 |
OBJ *refToList; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
846 |
OBJ list; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
847 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
848 |
DPRINTF(("EnumFontProc\n\n\n\n")); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
849 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
850 |
if( lplf ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
851 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
852 |
DPRINTF((" lfHeight %d\n", lplf->lfHeight )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
853 |
DPRINTF((" lfWidth %d\n", lplf->lfWidth )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
854 |
DPRINTF((" lfEscapement %d\n", lplf->lfEscapement )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
855 |
DPRINTF((" lfOrientation %d\n", lplf->lfOrientation )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
856 |
DPRINTF((" lfWeight %d\n", lplf->lfWeight )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
857 |
DPRINTF((" lfItalic %d\n", lplf->lfItalic )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
858 |
DPRINTF((" lfUnderline %d\n", lplf->lfUnderline )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
859 |
DPRINTF((" lfStrikeOut %d\n", lplf->lfStrikeOut )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
860 |
DPRINTF((" lfCharSet %d\n", lplf->lfCharSet )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
861 |
DPRINTF((" lfOutPrecision %d\n", lplf->lfOutPrecision )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
862 |
DPRINTF((" lfClipPrecision %d\n", lplf->lfClipPrecision )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
863 |
DPRINTF((" lfQuality %d\n", lplf->lfQuality )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
864 |
DPRINTF((" lfPitchAndFamily %d\n", lplf->lfPitchAndFamily )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
865 |
DPRINTF((" lfFaceName %s\n\n", lplf->lfFaceName )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
866 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
867 |
newArray = __ARRAY_NEW_INT(16); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
868 |
__AT_PUT_(newArray, __MKSMALLINT(1), __MKSMALLINT(lplf->lfHeight)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
869 |
__AT_PUT_(newArray, __MKSMALLINT(2), __MKSMALLINT(lplf->lfWidth)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
870 |
__AT_PUT_(newArray, __MKSMALLINT(3), __MKSMALLINT(lplf->lfEscapement)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
871 |
__AT_PUT_(newArray, __MKSMALLINT(4), __MKSMALLINT(lplf->lfOrientation)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
872 |
__PROTECT__(newArray); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
873 |
if( lplf->lfWeight == FW_NORMAL ) t = __MKSTRING("normal"); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
874 |
if( lplf->lfWeight == FW_BOLD ) t = __MKSTRING("bold"); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
875 |
if( lplf->lfWeight == FW_MEDIUM ) t = __MKSTRING("medium"); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
876 |
if( lplf->lfWeight == FW_LIGHT ) t = __MKSTRING("demi"); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
877 |
__UNPROTECT__(newArray); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
878 |
__AT_PUT_(newArray, __MKSMALLINT(5), t ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
879 |
__PROTECT__(newArray); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
880 |
if( lplf->lfItalic == TRUE ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
881 |
if( lplf->lfUnderline == TRUE ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
882 |
if( lplf->lfStrikeOut == TRUE ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
883 |
t = __MKSTRING( "italic-underline-strikeOut" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
884 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
885 |
t = __MKSTRING( "italic-underline" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
886 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
887 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
888 |
if( lplf->lfStrikeOut == TRUE ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
889 |
t = __MKSTRING( "italic-strikeOut" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
890 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
891 |
t = __MKSTRING( "italic" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
892 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
893 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
894 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
895 |
if( lplf->lfUnderline == TRUE ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
896 |
if( lplf->lfStrikeOut == TRUE ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
897 |
t = __MKSTRING( "underline-strikeOut" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
898 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
899 |
t = __MKSTRING( "underline" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
900 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
901 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
902 |
if( lplf->lfStrikeOut == TRUE ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
903 |
t = __MKSTRING( "strikeOut" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
904 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
905 |
t = __MKSTRING( "normal" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
906 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
907 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
908 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
909 |
__UNPROTECT__(newArray); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
910 |
__AT_PUT_(newArray, __MKSMALLINT(16), t ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
911 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
912 |
__AT_PUT_(newArray, __MKSMALLINT(6), __MKSMALLINT(lplf->lfItalic)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
913 |
__AT_PUT_(newArray, __MKSMALLINT(7), __MKSMALLINT(lplf->lfUnderline)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
914 |
__AT_PUT_(newArray, __MKSMALLINT(8), __MKSMALLINT(lplf->lfStrikeOut)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
915 |
__AT_PUT_(newArray, __MKSMALLINT(9), __MKSMALLINT(lplf->lfCharSet)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
916 |
__AT_PUT_(newArray, __MKSMALLINT(10), __MKSMALLINT(lplf->lfOutPrecision)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
917 |
__AT_PUT_(newArray, __MKSMALLINT(11), __MKSMALLINT(lplf->lfClipPrecision)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
918 |
__AT_PUT_(newArray, __MKSMALLINT(12), __MKSMALLINT(lplf->lfQuality)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
919 |
__AT_PUT_(newArray, __MKSMALLINT(13), __MKSMALLINT(lplf->lfPitchAndFamily)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
920 |
/* ... */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
921 |
__PROTECT__(newArray); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
922 |
t = __MKSTRING(lplf->lfFaceName); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
923 |
__UNPROTECT__(newArray); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
924 |
__AT_PUT_(newArray, __MKSMALLINT(14), t); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
925 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
926 |
__PROTECT__(newArray); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
927 |
if( dwType == DEVICE_FONTTYPE ) t = __MKSTRING( "device" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
928 |
if( dwType == RASTER_FONTTYPE ) t = __MKSTRING( "raster" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
929 |
if( dwType == TRUETYPE_FONTTYPE ) t = __MKSTRING( "typetype" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
930 |
__UNPROTECT__(newArray); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
931 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
932 |
__AT_PUT_(newArray, __MKSMALLINT(15), t); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
933 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
934 |
refToList = (OBJ*) lpData; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
935 |
list = *refToList; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
936 |
__SSEND1(list, @symbol(add:), 0, newArray); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
937 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
938 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
939 |
DPRINTF((" dwType %d\n", dwType )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
940 |
return 1; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
941 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
942 |
|
1127 | 943 |
%} |
944 |
! ! |
|
945 |
||
946 |
||
947 |
!WinWorkstation class methodsFor:'documentation'! |
|
948 |
||
949 |
copyright |
|
950 |
" |
|
951 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
952 |
All Rights Reserved |
|
953 |
||
954 |
This software is furnished under a license and may be used |
|
955 |
only in accordance with the terms of that license and with the |
|
956 |
inclusion of the above copyright notice. This software may not |
|
957 |
be provided or otherwise made available to, or used by, any |
|
958 |
other person. No title to or ownership of the software is |
|
959 |
hereby transferred. |
|
960 |
" |
|
961 |
! |
|
962 |
||
963 |
documentation |
|
964 |
" |
|
965 |
See more documentation in my superclass, DeviceWorkstation. |
|
966 |
||
967 |
[author:] |
|
968 |
Claus Gittinger |
|
969 |
" |
|
970 |
! ! |
|
971 |
||
972 |
!WinWorkstation class methodsFor:'initialization'! |
|
973 |
||
974 |
initialize |
|
975 |
|d| |
|
976 |
||
977 |
super initialize. |
|
978 |
||
979 |
BeepFrequency := 440. "/ Hertz |
|
980 |
BeepDuration := 200. "/ millis |
|
981 |
||
982 |
RawKeysymTranslation := d := Dictionary new. |
|
983 |
d at:'Right Alt' put:#'Alt_R'. |
|
984 |
d at:'Left Alt' put:#'Alt_L'. |
|
985 |
d at:'Right Shift' put:#'Shift_R'. |
|
986 |
d at:'Left Shift' put:#'Shift_L'. |
|
987 |
d at:'Right Control' put:#'Ctrl_R'. |
|
988 |
d at:'Left Control' put:#'Ctrl_L'. |
|
989 |
d at:'Control' put:#'Ctrl'. |
|
990 |
||
991 |
d at:'Backspace' put:#'BackSpace'. |
|
992 |
d at:'Up' put:#'CursorUp'. |
|
993 |
d at:'Down' put:#'CursorDown'. |
|
994 |
d at:'Right' put:#'CursorRight'. |
|
995 |
d at:'Left' put:#'CursorLeft'. |
|
996 |
d at:'Page Up' put:#'PreviousPage'. |
|
997 |
d at:'Page Down' put:#'NextPage'. |
|
998 |
d at:'Prnt Scrn' put:#'Print'. |
|
999 |
||
1000 |
(self getSystemMetrics:#swapButton) ifTrue:[ |
|
1001 |
ButtonTranslation := #(2 2 1) |
|
1002 |
] ifFalse:[ |
|
1003 |
ButtonTranslation := #(1 2 2) |
|
1004 |
] |
|
1005 |
! ! |
|
1006 |
||
1007 |
!WinWorkstation class methodsFor:'error handling'! |
|
1008 |
||
1009 |
debug:aBoolean |
|
1010 |
%{ /* NOCONTEXT */ |
|
1011 |
||
1012 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
1013 |
%} |
|
1014 |
! ! |
|
1015 |
||
1016 |
!WinWorkstation class methodsFor:'queries'! |
|
1017 |
||
1018 |
platformName |
|
1019 |
"ST-80 compatibility. |
|
1020 |
Return a string describing the display systems platform." |
|
1021 |
||
1022 |
^ 'WIN32' |
|
1023 |
||
1024 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
1025 |
! |
|
1026 |
||
1027 |
getSystemMetrics:aSymbol |
|
1028 |
%{ |
|
1029 |
int info = 0; |
|
1030 |
int isBool = 0; |
|
1031 |
int arg; |
|
1032 |
||
1033 |
if (aSymbol == @symbol(swapButton)) { |
|
1034 |
arg = SM_SWAPBUTTON; |
|
1035 |
isBool = 1; |
|
1036 |
} else if (aSymbol == @symbol(mouseButtons)) { |
|
1037 |
arg = SM_CMOUSEBUTTONS; |
|
1038 |
} else if (aSymbol == @symbol(iconWidth)) { |
|
1039 |
arg = SM_CXICON; |
|
1040 |
} else if (aSymbol == @symbol(iconHeight)) { |
|
1041 |
arg = SM_CYICON; |
|
1042 |
} else if (aSymbol == @symbol(cursorWidth)) { |
|
1043 |
arg = SM_CXCURSOR; |
|
1044 |
} else if (aSymbol == @symbol(cursorHeight)) { |
|
1045 |
arg = SM_CYCURSOR; |
|
1046 |
} else if (aSymbol == @symbol(captionHeight)) { |
|
1047 |
arg = SM_CYCAPTION; |
|
1048 |
} else if (aSymbol == @symbol(resizeFrameWidth)) { |
|
1049 |
arg = SM_CXFRAME; |
|
1050 |
} else if (aSymbol == @symbol(resizeFrameHeight)) { |
|
1051 |
arg = SM_CYFRAME; |
|
1052 |
} else if (aSymbol == @symbol(borderFrameWidth)) { |
|
1053 |
arg = SM_CXBORDER; |
|
1054 |
} else if (aSymbol == @symbol(borderFrameHeight)) { |
|
1055 |
arg = SM_CYBORDER; |
|
1056 |
} else if (aSymbol == @symbol(fullScreenWindowWidth)) { |
|
1057 |
arg = SM_CXFULLSCREEN; |
|
1058 |
} else if (aSymbol == @symbol(fullScreenWindowHeight)) { |
|
1059 |
arg = SM_CYFULLSCREEN; |
|
1060 |
} else { |
|
1061 |
RETURN (nil); |
|
1062 |
} |
|
1063 |
info = GetSystemMetrics(arg); |
|
1064 |
if (isBool) { |
|
1065 |
RETURN (info ? true : false); |
|
1066 |
} |
|
1067 |
RETURN (__MKSMALLINT(info)); |
|
1068 |
%} |
|
1069 |
! ! |
|
1070 |
||
1071 |
!WinWorkstation methodsFor:'accessing & queries'! |
|
1072 |
||
1073 |
anyButtonMotionMask |
|
1074 |
"return the state-mask for any button in motion events' state-field. |
|
1075 |
This is the devices mask." |
|
1076 |
||
1077 |
%{ /* NOCONTEXT */ |
|
1078 |
RETURN ( __MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
|
1079 |
%}. |
|
1080 |
^ nil |
|
1081 |
! |
|
1082 |
||
1083 |
blackpixel |
|
1084 |
"return the colornumber of black" |
|
1085 |
||
1086 |
^ blackpixel |
|
1087 |
! |
|
1088 |
||
1089 |
button1MotionMask |
|
1090 |
"return the state-mask for button1 in motion events' state-field. |
|
1091 |
For backward compatibility." |
|
1092 |
||
1093 |
%{ /* NOCONTEXT */ |
|
1094 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
|
1095 |
%} |
|
1096 |
||
1097 |
" |
|
1098 |
Display button1MotionMask |
|
1099 |
" |
|
1100 |
! |
|
1101 |
||
1102 |
button2MotionMask |
|
1103 |
"return the state-mask for button2 in motion events' state-field |
|
1104 |
For backward compatibility." |
|
1105 |
||
1106 |
%{ /* NOCONTEXT */ |
|
1107 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
|
1108 |
%} |
|
1109 |
! |
|
1110 |
||
1111 |
button3MotionMask |
|
1112 |
"return the state-mask for button3 in motion events' state-field |
|
1113 |
For backward compatibility." |
|
1114 |
||
1115 |
%{ /* NOCONTEXT */ |
|
1116 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
|
1117 |
%} |
|
1118 |
! |
|
1119 |
||
1120 |
buttonMotionMask:aButton |
|
1121 |
"return the state-mask for button1 in motion events state-field. |
|
1122 |
This is the devices mask." |
|
1123 |
||
1124 |
%{ /* NOCONTEXT */ |
|
1125 |
if (aButton == __MKSMALLINT(1)) { |
|
1126 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
|
1127 |
} |
|
1128 |
if (aButton == __MKSMALLINT(2)) { |
|
1129 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
|
1130 |
} |
|
1131 |
if (aButton == __MKSMALLINT(3)) { |
|
1132 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
|
1133 |
} |
|
1134 |
%}. |
|
1135 |
^ nil |
|
1136 |
! |
|
1137 |
||
1138 |
controlMask |
|
1139 |
"return the state-mask for the CTRL modified in motion events' state-field." |
|
1140 |
||
1141 |
%{ /* NOCONTEXT */ |
|
1142 |
RETURN (__MKSMALLINT(ControlMask)); |
|
1143 |
%} |
|
1144 |
! |
|
1145 |
||
1146 |
defaultEventMask |
|
1147 |
"return a mask to enable some events by default." |
|
1148 |
||
1149 |
%{ /* NOCONTEXT */ |
|
1150 |
#ifdef XXX |
|
1151 |
RETURN (__MKSMALLINT(ExposureMask | StructureNotifyMask | |
|
1152 |
KeyPressMask | KeyReleaseMask | |
|
1153 |
EnterWindowMask | LeaveWindowMask | |
|
1154 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
1155 |
#endif |
|
1156 |
%}. |
|
1157 |
^ 0 |
|
1158 |
! |
|
1159 |
||
1160 |
displayFileDescriptor |
|
1161 |
"return the displays fileNumber - for select" |
|
1162 |
||
1163 |
%{ /* NOCONTEXT */ |
|
1164 |
RETURN (nil); |
|
1165 |
%} |
|
1166 |
! |
|
1167 |
||
1168 |
displayName |
|
1169 |
"return the X-connections display name. |
|
1170 |
This is (currently) nil for the default display, |
|
1171 |
something like foo:0 for any other remote display. |
|
1172 |
Future versions may return non-nil strings for the default display as well." |
|
1173 |
||
1174 |
^ 'local' |
|
1175 |
! |
|
1176 |
||
1177 |
protocolVersion |
|
1178 |
"return the X-servers protocol version - should normally not be of |
|
1179 |
any interest" |
|
1180 |
||
1181 |
^ '1' |
|
1182 |
||
1183 |
" |
|
1184 |
Display protocolVersion |
|
1185 |
" |
|
1186 |
! |
|
1187 |
||
1188 |
serverVendor |
|
1189 |
"return the X-server vendor string - this should normally not be of |
|
1190 |
any interest, but can be for special cases |
|
1191 |
(to avoid bugs in certain implementations)" |
|
1192 |
||
1193 |
^ 'microsoft' |
|
1194 |
||
1195 |
" |
|
1196 |
Display serverVendor |
|
1197 |
" |
|
1198 |
! |
|
1199 |
||
1200 |
shiftMask |
|
1201 |
"return the state-mask for the SHIFT modified in motion events' state-field." |
|
1202 |
||
1203 |
%{ /* NOCONTEXT */ |
|
1204 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
1205 |
%} |
|
1206 |
! |
|
1207 |
||
1208 |
translatePoint:aPoint from:windowId1 to:windowId2 |
|
1209 |
"given a point in window1, return the coordinate in window2. |
|
1210 |
This expects a device coordinate (relative to the first views origin) |
|
1211 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
1212 |
- use to xlate points from a window to rootwindow" |
|
1213 |
||
1214 |
|x1 y1 x2 y2| |
|
1215 |
||
1216 |
x1 := x2 := aPoint x truncated. |
|
1217 |
y1 := y2 := aPoint y truncated. |
|
1218 |
%{ |
|
1219 |
int xpos, ypos; |
|
1220 |
HWND w1, w2; |
|
1221 |
RECT srcRect, dstRect; |
|
1222 |
||
1223 |
if (__isExternalAddress(windowId1) |
|
1224 |
&& __isExternalAddress(windowId2) |
|
1225 |
&& __bothSmallInteger(x1, y1)) { |
|
1226 |
w1 = _HWNDVal(windowId1); |
|
1227 |
w2 = _HWNDVal(windowId2); |
|
1228 |
||
1229 |
GetWindowRect(w1, &srcRect); |
|
1230 |
GetWindowRect(w2, &dstRect); |
|
1231 |
||
1232 |
printf("srcRect: %d/%d -> %d/%d dstRect: %d/%d -> %d/%d\n", |
|
1233 |
srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, |
|
1234 |
dstRect.left, dstRect.top, dstRect.right, dstRect.bottom); |
|
1235 |
||
1236 |
xpos = srcRect.left - dstRect.left + __intVal(x1); |
|
1237 |
ypos = srcRect.top - dstRect.top + __intVal(y1); |
|
1238 |
||
1239 |
x2 = __MKSMALLINT(xpos); |
|
1240 |
y2 = __MKSMALLINT(ypos); |
|
1241 |
} |
|
1242 |
%}. |
|
1243 |
'translated ' print. aPoint print. ' from ' print. windowId1 address print. |
|
1244 |
' -> ' print. (x2@y2) print. ' in ' print. windowId2 address printCR. |
|
1245 |
^ (x2 @ y2) |
|
1246 |
! |
|
1247 |
||
1248 |
vendorRelease |
|
1249 |
"return the X-servers vendor release - should normally not be of |
|
1250 |
any interest, but can be for special cases. |
|
1251 |
(to avoid bugs in certain implementations)" |
|
1252 |
||
1253 |
^ 1 |
|
1254 |
||
1255 |
" |
|
1256 |
Display vendorRelease |
|
1257 |
" |
|
1258 |
! |
|
1259 |
||
1260 |
whitepixel |
|
1261 |
"return the colornumber of white" |
|
1262 |
||
1263 |
^ whitepixel |
|
1264 |
! ! |
|
1265 |
||
1266 |
!WinWorkstation methodsFor:'accessing display capabilities'! |
|
1267 |
||
1268 |
iconSizes |
|
1269 |
"Get the preferred/supported icon sizes." |
|
1270 |
||
1271 |
|d| |
|
1272 |
||
1273 |
d := IdentityDictionary new. |
|
1274 |
d at:#minWidth put:32. |
|
1275 |
d at:#maxWidth put:32. |
|
1276 |
d at:#widthStep put:1. |
|
1277 |
d at:#minHeight put:32. |
|
1278 |
d at:#maxHeight put:32. |
|
1279 |
d at:#heightStep put:1. |
|
1280 |
||
1281 |
^ OrderedCollection with:d |
|
1282 |
||
1283 |
" |
|
1284 |
Display iconSizes |
|
1285 |
" |
|
1286 |
! |
|
1287 |
||
1288 |
supportsIconViews |
|
1289 |
"return true, if this device supports views as icons. |
|
1290 |
Only Xservers (currently) support this." |
|
1291 |
||
1292 |
^ true |
|
1293 |
||
1294 |
" |
|
1295 |
Display supportsIconViews |
|
1296 |
" |
|
1297 |
||
1298 |
"Modified: 10.6.1996 / 20:11:48 / cg" |
|
1299 |
"Created: 10.6.1996 / 21:08:18 / cg" |
|
1300 |
! ! |
|
1301 |
||
1302 |
!WinWorkstation methodsFor:'bitmap/window creation'! |
|
1303 |
||
1304 |
createBitmapFromArray:anArray width:w height:h |
|
1305 |
|bitmapId| |
|
1306 |
||
1307 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1308 |
|
1127 | 1309 |
bitmapId isNil ifTrue:[ |
1310 |
'WINWORKSTATION: cannot create bitmap' errorPrintCR. |
|
1311 |
]. |
|
1312 |
^ bitmapId |
|
1313 |
! |
|
1314 |
||
1315 |
createBitmapWidth:w height:h |
|
1316 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1317 |
(i.e. random). Return a bitmap id or nil" |
|
1318 |
||
1319 |
%{ /* NOCONTEXT */ |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1320 |
HANDLE newBitmapHandle; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1321 |
int b_width, b_height; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1322 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1323 |
if (__bothSmallInteger(w, h)) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1324 |
b_width = __intVal(w); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1325 |
b_height = __intVal(h); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1326 |
newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, NULL); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1327 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1328 |
DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1329 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1330 |
RETURN ( (newBitmapHandle != NULL) ? __MKOBJ(newBitmapHandle) : nil ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1331 |
} |
1127 | 1332 |
%}. |
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1333 |
"/ invalid (non-smallInteger) arguments |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1334 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1335 |
self primitiveFailed. |
1127 | 1336 |
^ nil |
1337 |
! |
|
1338 |
||
1339 |
createPixmapWidth:w height:h depth:d |
|
1340 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1341 |
(i.e. random). Return a bitmap id or nil" |
|
1342 |
||
1343 |
%{ /* NOCONTEXT */ |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1344 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1345 |
HANDLE newBitmapHandle; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1346 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1347 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1348 |
newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h), 1, 16, NULL ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1349 |
#ifdef COUNT_RESOURCES |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1350 |
if (newBitmapHandle) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1351 |
__cnt_bitmap++; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1352 |
#endif |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1353 |
RETURN ( (newBitmapHandle != NULL) ? __MKOBJ(newBitmapHandle) : nil ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1354 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1355 |
|
1127 | 1356 |
%}. |
1357 |
^ nil |
|
1358 |
! |
|
1359 |
||
1360 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
|
1361 |
"will vanish - for compatibility with previous versions" |
|
1362 |
||
1363 |
^ self |
|
1364 |
createWindowFor:aView |
|
1365 |
origin:(xpos @ ypos) |
|
1366 |
extent:(wwidth @ wheight) |
|
1367 |
minExtent:(aView minExtent) |
|
1368 |
maxExtent:(aView maxExtent) |
|
1369 |
borderWidth:(aView borderWidth) |
|
1370 |
subViewOf:(aView superView) |
|
1371 |
onTop:(aView isPopUpView) |
|
1372 |
inputOnly:(aView isInputOnly) |
|
1373 |
label:(aView label) |
|
1374 |
cursor:(aView cursor) |
|
1375 |
icon:(aView icon) |
|
1376 |
iconView:(aView iconView) |
|
1377 |
||
1378 |
"Modified: 1.6.1996 / 13:22:48 / cg" |
|
1379 |
! |
|
1380 |
||
1381 |
createWindowFor:aView |
|
1382 |
origin:origin |
|
1383 |
extent:extent |
|
1384 |
minExtent:minExt |
|
1385 |
maxExtent:maxExt |
|
1386 |
borderWidth:bWidth |
|
1387 |
subViewOf:wsuperView |
|
1388 |
onTop:wisPopUpView |
|
1389 |
inputOnly:winputOnly |
|
1390 |
label:wlabel |
|
1391 |
cursor:wcursor |
|
1392 |
icon:wicon |
|
1393 |
iconView:wiconView |
|
1394 |
||
1395 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1396 |
bColorId wsuperViewId wcursorId wiconId windowId |
|
1397 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1398 |
vBgForm deepForm preferredVisual preferredDepth wiconHeight |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1399 |
wiconWidth| |
1127 | 1400 |
|
1401 |
displayId isNil ifTrue:[ |
|
1402 |
self primitiveFailed. |
|
1403 |
^ nil |
|
1404 |
]. |
|
1405 |
||
1406 |
origin notNil ifTrue:[ |
|
1407 |
xpos := origin x. |
|
1408 |
ypos := origin y. |
|
1409 |
] ifFalse:[ |
|
1410 |
xpos := ypos := 0. |
|
1411 |
]. |
|
1412 |
extent notNil ifTrue:[ |
|
1413 |
wwidth := extent x. |
|
1414 |
wheight := extent y. |
|
1415 |
] ifFalse:[ |
|
1416 |
wwidth := wheight := 100. |
|
1417 |
]. |
|
1418 |
minExt notNil ifTrue:[ |
|
1419 |
minWidth := minExt x. |
|
1420 |
minHeight := minExt y |
|
1421 |
]. |
|
1422 |
maxExt notNil ifTrue:[ |
|
1423 |
maxWidth := maxExt x. |
|
1424 |
maxHeight := maxExt y |
|
1425 |
]. |
|
1426 |
||
1427 |
wsuperView notNil ifTrue:[ |
|
1428 |
wsuperViewId := wsuperView id |
|
1429 |
]. |
|
1430 |
wcursor isNil ifTrue:[ |
|
1431 |
'XWORKSTATION: cursor nil - defaulted' errorPrintNL |
|
1432 |
] ifFalse:[ |
|
1433 |
wcursorId := wcursor id |
|
1434 |
]. |
|
1435 |
||
1436 |
wicon notNil ifTrue:[ |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1437 |
wiconId := wicon id. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1438 |
wiconHeight := wicon height. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1439 |
wiconWidth := wicon width. |
1127 | 1440 |
]. |
1441 |
wiconView notNil ifTrue:[ |
|
1442 |
wiconViewId := wiconView id |
|
1443 |
]. |
|
1444 |
weventMask := aView eventMask. |
|
1445 |
||
1446 |
%{ /* STACK:16000 */ |
|
1447 |
extern void *__getHInstance(), *__getHPrevInstance(); |
|
1448 |
||
1449 |
WNDCLASS wc; |
|
1450 |
long bg, bd, bw; |
|
1451 |
int winStyle; |
|
1452 |
int w, h, x, y; |
|
1453 |
int ncW, ncH; |
|
1454 |
int min_width, min_height; |
|
1455 |
int max_width, max_height; |
|
1456 |
HANDLE parentHandle; |
|
1457 |
HANDLE newWinHandle; |
|
1458 |
char *windowName = NULL; |
|
1459 |
int isTopWindow = 0; |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1460 |
int iconFlag = 0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1461 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1462 |
unsigned char* cp; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1463 |
unsigned char* ep; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1464 |
HBITMAP xBitMap; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1465 |
int height, width; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1466 |
int nBytes, nBits; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1467 |
int index; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1468 |
HICON xIcon; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1469 |
|
1127 | 1470 |
|
1471 |
bg = WhitePixel; |
|
1472 |
bd = BlackPixel; |
|
1473 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1474 |
/* get bitmap for icon */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1475 |
if( __isExternalAddress(wiconId) ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1476 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1477 |
xBitMap = _HBITMAPVAL( wiconId ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1478 |
if( xBitMap != 0 ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1479 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1480 |
height = __intVal( wiconHeight ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1481 |
width = __intVal( wiconWidth ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1482 |
nBytes = height * 2 * ( width + 15 ) / 16; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1483 |
if( nBytes != 0 ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1484 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1485 |
cp = (unsigned char *) malloc(nBytes); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1486 |
ep = (unsigned char *) malloc(nBytes); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1487 |
if( ( cp != 0 ) && ( ep != 0 ) ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1488 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1489 |
for( index = 0; index < nBytes; index++ ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1490 |
*ep++ = 0x00; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1491 |
nBits = GetBitmapBits( xBitMap, nBytes, cp ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1492 |
xIcon = CreateIcon( (HANDLE) __getHInstance(), |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1493 |
width, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1494 |
height, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1495 |
1, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1496 |
1, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1497 |
ep, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1498 |
cp ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1499 |
if( xIcon != 0 ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1500 |
iconFlag = 1; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1501 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1502 |
else |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1503 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1504 |
DPRINTF(( " malloc failed\n" )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1505 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1506 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1507 |
else |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1508 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1509 |
DPRINTF(( " nBytes is zero \n" )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1510 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1511 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1512 |
else |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1513 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1514 |
DPRINTF((" xBitMap is zero \n" )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1515 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1516 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1517 |
else |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1518 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1519 |
DPRINTF((" wiconId is not an external address\n")); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1520 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1521 |
|
1127 | 1522 |
if (firstInstance) { |
1523 |
DPRINTF(("first create - registerClass\n")); |
|
1524 |
||
1525 |
hInstance = (HANDLE) __getHInstance(); |
|
1526 |
hPrevInstance = (HANDLE) __getHPrevInstance(); |
|
1527 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1528 |
wc.style = /* CS_HREDRAW | CS_VREDRAW |*/ CS_OWNDC | CS_DBLCLKS; |
1127 | 1529 |
wc.lpfnWndProc = (WNDPROC) MainWndProc; |
1530 |
wc.cbClsExtra = 0; |
|
1531 |
wc.cbWndExtra = 0; |
|
1532 |
wc.hInstance = hInstance; |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1533 |
if( iconFlag != 0 ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1534 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1535 |
wc.hIcon = xIcon; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1536 |
/* wc.hIconSm = wiconId; */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1537 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1538 |
else wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); |
1127 | 1539 |
wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
1540 |
||
1541 |
wc.hbrBackground = CreateSolidBrush (bg); |
|
1542 |
||
1543 |
wc.lpszMenuName = NULL; |
|
1544 |
wc.lpszClassName = app_name; |
|
1545 |
||
1546 |
if (!RegisterClass(&wc)) { |
|
1547 |
DPRINTF(("RegisterClass failed\n")); |
|
1548 |
/* return NULL; */ |
|
1549 |
} |
|
1550 |
firstInstance = 0; |
|
1551 |
} |
|
1552 |
||
1553 |
if (__bothSmallInteger(wwidth, wheight)) { |
|
1554 |
w = __intVal(wwidth); |
|
1555 |
h = __intVal(wheight); |
|
1556 |
} else { |
|
1557 |
w = h = 100; |
|
1558 |
} |
|
1559 |
||
1560 |
if (__bothSmallInteger(xpos, ypos)) { |
|
1561 |
x = __intVal(xpos); |
|
1562 |
y = __intVal(ypos); |
|
1563 |
} else { |
|
1564 |
x = y = 0; |
|
1565 |
} |
|
1566 |
||
1567 |
if (__bothSmallInteger(minWidth, minHeight)) { |
|
1568 |
min_width = __intVal(minWidth); |
|
1569 |
min_height = __intVal(minHeight); |
|
1570 |
} else { |
|
1571 |
min_width = min_height = 0; |
|
1572 |
} |
|
1573 |
||
1574 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
|
1575 |
max_width = __intVal(maxWidth); |
|
1576 |
max_height = __intVal(maxHeight); |
|
1577 |
} else { |
|
1578 |
max_width = max_height = 10000; |
|
1579 |
} |
|
1580 |
||
1581 |
winStyle = 0; |
|
1582 |
||
1583 |
if (__isSmallInteger(bWidth)) { |
|
1584 |
bw = __intVal(bWidth); |
|
1585 |
if (bw) { |
|
1586 |
winStyle |= WS_BORDER; |
|
1587 |
bw = 1; |
|
1588 |
} |
|
1589 |
} else { |
|
1590 |
bw = 0; |
|
1591 |
} |
|
1592 |
||
1593 |
if (__isExternalAddress(wsuperViewId)) { |
|
1594 |
/* |
|
1595 |
* a child window |
|
1596 |
*/ |
|
1597 |
parentHandle = _HANDLEVal(wsuperViewId); |
|
1598 |
winStyle |= WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; |
|
1599 |
DPRINTF(("parent handle=%x\n", parentHandle)); |
|
1600 |
||
1601 |
create_topView = 0; |
|
1602 |
ncW = bw * 2; |
|
1603 |
ncH = bw * 2; |
|
1604 |
} else { |
|
1605 |
/* |
|
1606 |
* a top window |
|
1607 |
*/ |
|
1608 |
parentHandle = NULL; |
|
1609 |
isTopWindow = 1; |
|
1610 |
DPRINTF(("topview\n")); |
|
1611 |
||
1612 |
create_topView = 1; |
|
1613 |
create_minWidth = min_width; |
|
1614 |
create_maxWidth = max_width; |
|
1615 |
create_minHeight = min_height; |
|
1616 |
create_maxHeight = max_height; |
|
1617 |
||
1618 |
winStyle |= WS_CLIPCHILDREN; |
|
1619 |
if (wisPopUpView == true) { |
|
1620 |
winStyle |= WS_POPUP; |
|
1621 |
ncW = bw * 2; |
|
1622 |
ncH = bw * 2; |
|
1623 |
} else { |
|
1624 |
winStyle |= WS_OVERLAPPEDWINDOW; |
|
1625 |
ncW = __intVal(__INST(resizeFrameWidth)); |
|
1626 |
ncH = 32 + 4 + 4; /* __intVal(__INST(resizeFrameHeight)) */; |
|
1627 |
DPRINTF(("fW=%d fH=%d\n", |
|
1628 |
__intVal(__INST(resizeFrameWidth)), |
|
1629 |
__intVal(__INST(resizeFrameHeight)) )); |
|
1630 |
} |
|
1631 |
} |
|
1632 |
||
1633 |
DPRINTF(("create%s pos==%d/%d size=%d/%d bw=%d ...\n", |
|
1634 |
(wisPopUpView ? " popUp" : ""), x, y, w, h, bw)); |
|
1635 |
||
1636 |
__inCreate = 1; |
|
1637 |
newWinHandle = CreateWindow(app_name, |
|
1638 |
"", /* window class name */ |
|
1639 |
winStyle, |
|
1640 |
x, y, |
|
1641 |
w + ncW, h + ncH, |
|
1642 |
parentHandle, |
|
1643 |
NULL, hInstance, NULL); |
|
1644 |
__inCreate = 0; |
|
1645 |
||
1646 |
DPRINTF(("handle = %x\n", newWinHandle)); |
|
1647 |
||
1648 |
if (! newWinHandle) { |
|
1649 |
RETURN ( nil ); |
|
1650 |
} |
|
1651 |
||
1652 |
/* |
|
1653 |
* define its icon and name |
|
1654 |
* (only makes sense for topWindows) |
|
1655 |
*/ |
|
1656 |
if (isTopWindow) { |
|
1657 |
if (__isString(wlabel) || __isSymbol(wlabel)) { |
|
1658 |
windowName = (char *) __stringVal(wlabel); |
|
1659 |
DPRINTF(("title = %s\n", windowName)); |
|
1660 |
(void) SetWindowText(newWinHandle, windowName); |
|
1661 |
} |
|
1662 |
} |
|
1663 |
||
1664 |
windowId = __MKOBJ(newWinHandle); |
|
1665 |
DPRINTF(("done - create\n")); |
|
1666 |
%}. |
|
1667 |
self addKnownView:aView withId:windowId. |
|
1668 |
^ windowId |
|
1669 |
! |
|
1670 |
||
1671 |
destroyGC:aGCId |
|
1672 |
%{ |
|
1673 |
if (__isExternalAddress(aGCId)) { |
|
1674 |
struct gcData *gcData = _GCDATA(aGCId); |
|
1675 |
||
1676 |
if (gcData->hDC) { |
|
1677 |
DeleteDC(gcData->hDC); |
|
1678 |
gcData->hDC = (HDC)0; |
|
1679 |
} |
|
1680 |
if (gcData->hPen) { |
|
1681 |
DeleteObject(gcData->hPen); |
|
1682 |
gcData->hPen = (HPEN)0; |
|
1683 |
} |
|
1684 |
if (gcData->hBrush) { |
|
1685 |
DeleteObject(gcData->hBrush); |
|
1686 |
gcData->hBrush = (HPEN)0; |
|
1687 |
} |
|
1688 |
free(gcData); |
|
1689 |
} |
|
1690 |
%}. |
|
1691 |
^ self |
|
1692 |
! |
|
1693 |
||
1694 |
destroyPixmap:aDrawableId |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1695 |
%{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1696 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1697 |
HANDLE bitmapHandle = _HANDLEVal(aDrawableId); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1698 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1699 |
if (bitmapHandle) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1700 |
DeleteObject(bitmapHandle); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1701 |
#ifdef COUNT_RESOURCES |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1702 |
__cnt_bitmap--; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1703 |
#endif |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1704 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1705 |
RETURN ( self ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1706 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1707 |
%}. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1708 |
"/ invalid argument or not yet opened |
1127 | 1709 |
self primitiveFailed |
1710 |
! |
|
1711 |
||
1712 |
destroyView:aView withId:aWindowId |
|
1713 |
%{ |
|
1714 |
if (__isExternalAddress(aWindowId)) { |
|
1715 |
HWND win = _HWNDVal(aWindowId); |
|
1716 |
||
1717 |
if (win) { |
|
1718 |
DestroyWindow(win); |
|
1719 |
} |
|
1720 |
} |
|
1721 |
%}. |
|
1722 |
self removeKnownView:aView |
|
1723 |
! |
|
1724 |
||
1725 |
gcFor:aDrawableId |
|
1726 |
||
1727 |
%{ /* NOCONTEXT */ |
|
1728 |
HDC dc; |
|
1729 |
struct gcData *gcData; |
|
1730 |
||
1731 |
if (__isExternalAddress(aDrawableId)) { |
|
1732 |
dc = GetDC(_HWNDVal(aDrawableId)); |
|
1733 |
if (! dc) { |
|
1734 |
RETURN (nil); |
|
1735 |
} |
|
1736 |
gcData = (struct gcData *)malloc(sizeof(struct gcData)); |
|
1737 |
if (! gcData) { |
|
1738 |
RETURN (nil); |
|
1739 |
} |
|
1740 |
gcData->hDC = dc; |
|
1741 |
gcData->hPen = (HPEN)0; |
|
1742 |
gcData->hBrush = (HBRUSH)0; |
|
1743 |
gcData->fgColor = (COLORREF)0; |
|
1744 |
gcData->bgColor = (COLORREF)0; |
|
1745 |
gcData->brushType = BR_SOLID; |
|
1746 |
gcData->lineWidth = 1; |
|
1747 |
gcData->lineStyle = PS_SOLID; |
|
1748 |
gcData->joinStyle = PS_JOIN_MITER; |
|
1749 |
gcData->capStyle = PS_ENDCAP_FLAT; |
|
1750 |
||
1751 |
RETURN ( __MKOBJ(gcData) ); |
|
1752 |
} |
|
1753 |
%}. |
|
1754 |
self primitiveFailed. |
|
1755 |
^ nil |
|
1756 |
! |
|
1757 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1758 |
gcForBitmap:aDrawableId |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1759 |
%{ /* NOCONTEXT */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1760 |
HDC dc; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1761 |
HDC rootDC; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1762 |
struct gcData *gcData; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1763 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1764 |
if (__isExternalAddress(aDrawableId)) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1765 |
rootDC = __rootDC; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1766 |
dc = CreateCompatibleDC(rootDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1767 |
if (! dc) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1768 |
RETURN (nil); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1769 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1770 |
gcData = (struct gcData *)malloc(sizeof(struct gcData)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1771 |
if (! gcData) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1772 |
RETURN (nil); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1773 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1774 |
gcData->hDC = dc; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1775 |
gcData->hPen = (HPEN)0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1776 |
gcData->hBrush = (HBRUSH)0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1777 |
gcData->fgColor = (COLORREF)0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1778 |
gcData->bgColor = (COLORREF)0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1779 |
gcData->brushType = BR_SOLID; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1780 |
gcData->lineWidth = 1; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1781 |
gcData->lineStyle = PS_SOLID; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1782 |
gcData->joinStyle = PS_JOIN_MITER; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1783 |
gcData->capStyle = PS_ENDCAP_FLAT; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1784 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1785 |
RETURN ( __MKOBJ(gcData) ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1786 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1787 |
%}. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1788 |
self primitiveFailed. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1789 |
^ nil |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1790 |
! |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1791 |
|
1127 | 1792 |
primCreateBitmapFromArray:anArray width:w height:h |
1793 |
||
1794 |
%{ /* UNLIMITEDSTACK */ |
|
1795 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1796 |
HBITMAP newBitmapHandle; |
1136 | 1797 |
unsigned char fastBits[10000]; |
1798 |
int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
|
1799 |
int row, col; |
|
1800 |
unsigned char *cp, *bPits; |
|
1801 |
unsigned char *b_bits, *allocatedBits; |
|
1137 | 1802 |
unsigned char *pBits; |
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1803 |
int index; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1804 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1805 |
if (! ISCONNECTED) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1806 |
RETURN (nil); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1807 |
} |
1136 | 1808 |
|
1809 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
1810 |
b_width = __intVal(w); |
|
1811 |
b_height = __intVal(h); |
|
1812 |
bytesPerRowST = (b_width + 7) / 8; |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1813 |
bytesPerRowWN = (b_width + 15) / 16 * 2; |
1136 | 1814 |
padding = bytesPerRowWN - bytesPerRowST; |
1815 |
nBytes = b_height * bytesPerRowWN; |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1816 |
|
1136 | 1817 |
if (nBytes < sizeof(fastBits)) { |
1818 |
cp = b_bits = fastBits; |
|
1819 |
allocatedBits = 0; |
|
1820 |
} else { |
|
1821 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
1822 |
if (! cp) goto fail; |
|
1823 |
} |
|
1824 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1825 |
|
1136 | 1826 |
if (__qClass(anArray) == @global(Array)) { |
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1827 |
DPRINTF(("Array not supported\n")); |
1136 | 1828 |
goto fail; |
1829 |
} else { |
|
1830 |
if (__qClass(anArray) == @global(ByteArray)) { |
|
1831 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
|
1832 |
for (row = b_height; row; row--) { |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1833 |
for (col = bytesPerRowST; col; col--) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1834 |
*cp++ = ( *pBits++ ^ 0xFF ); |
1136 | 1835 |
} |
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1836 |
cp += padding; |
1136 | 1837 |
} |
1838 |
} else { |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1839 |
DPRINTF(("not a ByteArray\n")); |
1136 | 1840 |
goto fail; |
1841 |
} |
|
1842 |
} |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1843 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1844 |
DPRINTF(("create bitmap ...\n")); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1845 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1846 |
newBitmapHandle = CreateBitmap(b_width, b_height, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1847 |
1, 1, b_bits ); |
1136 | 1848 |
|
1849 |
fail: ; |
|
1850 |
if (allocatedBits) |
|
1851 |
free(allocatedBits); |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1852 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1853 |
RETURN ( (newBitmapHandle != NULL) ? __MKOBJ(newBitmapHandle) : nil ); |
1136 | 1854 |
} |
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1855 |
DPRINTF(("returning nil ...\n")); |
1127 | 1856 |
RETURN ( nil ); |
1857 |
%} |
|
1858 |
! |
|
1859 |
||
1860 |
rootWindowId |
|
1861 |
"return the id of the root window. |
|
1862 |
This is the window you see as background, |
|
1863 |
however, it may or may not be the real physical root window, |
|
1864 |
since some window managers install a virtual root window on top |
|
1865 |
of the real one. If this is the case, that views id is returned here." |
|
1866 |
||
1867 |
^ rootWin |
|
1868 |
! ! |
|
1869 |
||
1870 |
!WinWorkstation methodsFor:'color stuff'! |
|
1871 |
||
1872 |
colorRed:redVal green:greenVal blue:blueVal |
|
1873 |
"allocate a color with rgb values (0..100) - return the color index (i.e. colorID). |
|
1874 |
This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:" |
|
1875 |
||
1876 |
|r g b| |
|
1877 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1878 |
r := self percentToDeviceColorValue:redVal. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1879 |
g := self percentToDeviceColorValue:greenVal. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1880 |
b := self percentToDeviceColorValue:blueVal. |
1127 | 1881 |
^ self colorScaledRed:r scaledGreen:g scaledBlue:b |
1882 |
! |
|
1883 |
||
1884 |
colorScaledRed:r scaledGreen:g scaledBlue:b |
|
1885 |
"allocate a color with rgb values (0..16rFFFF) - return the color index |
|
1886 |
(i.e. colorID)" |
|
1887 |
%{ |
|
1888 |
int id, ir, ig, ib; |
|
1889 |
||
1890 |
if (__bothSmallInteger(r, g) |
|
1891 |
&& __isSmallInteger(b)) { |
|
1892 |
ir = __intVal(r) >> 8; |
|
1893 |
ig = __intVal(g) >> 8; |
|
1894 |
ib = __intVal(b) >> 8; |
|
1895 |
||
1896 |
id = RGB ( ir, ig, ib); |
|
1897 |
DDPRINTF(("alloc color %d/%d/%d -> %x\n", ir, ig, ib, id)); |
|
1898 |
RETURN ( __MKSMALLINT(id) ); |
|
1899 |
} |
|
1900 |
%}. |
|
1901 |
self primitiveFailed. |
|
1902 |
^ nil |
|
1903 |
! |
|
1904 |
||
1905 |
freeColor:colorIndex |
|
1906 |
"free a display color when its no longer needed" |
|
1907 |
||
1908 |
^ self |
|
1909 |
! |
|
1910 |
||
1911 |
getRGBFrom:index into:aBlock |
|
1912 |
"get rgb components (0..100) of color in map at:index, |
|
1913 |
and evaluate the 3-arg block, aBlock with them" |
|
1914 |
||
1915 |
|val| |
|
1916 |
||
1917 |
self getScaledRGBFrom:index into:[:r :g :b | |
|
1918 |
val := aBlock |
|
1919 |
value:(r * 100.0 / 16rFFFF) |
|
1920 |
value:(g * 100.0 / 16rFFFF) |
|
1921 |
value:(b * 100.0 / 16rFFFF) |
|
1922 |
]. |
|
1923 |
^ val |
|
1924 |
! |
|
1925 |
||
1926 |
getScaledRGBFrom:index into:aBlock |
|
1927 |
"get rgb components (0 .. 16rFFFF) of color in map at:index, |
|
1928 |
and evaluate the 3-arg block, aBlock with them" |
|
1929 |
||
1930 |
|r g b| |
|
1931 |
%{ |
|
1932 |
int id = __intVal(index); |
|
1933 |
int iR, iG, iB; |
|
1934 |
||
1935 |
if (__INST(usingSystemPalette) == true) { |
|
1936 |
r = g = b = __MKSMALLINT(0); |
|
1937 |
} else { |
|
1938 |
iR = id & 0xFF; |
|
1939 |
iG = (id >> 8) & 0xFF; |
|
1940 |
iB = (id >> 16) & 0xFF; |
|
1941 |
iR = (iR << 8) | iR; |
|
1942 |
iG = (iG << 8) | iG; |
|
1943 |
iB = (iB << 8) | iB; |
|
1944 |
||
1945 |
r = __MKSMALLINT(iR); |
|
1946 |
g = __MKSMALLINT(iG); |
|
1947 |
b = __MKSMALLINT(iB); |
|
1948 |
} |
|
1949 |
%}. |
|
1950 |
^ aBlock value:r value:g value:b |
|
1951 |
! |
|
1952 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
1953 |
percentToDeviceColorValue:aPercentage |
1127 | 1954 |
"given a color-component value in percent (0..100), return the corresponding |
1955 |
WIN-component value (0..16rFFFF) as an integer" |
|
1956 |
||
1957 |
%{ /* NOCONTEXT */ |
|
1958 |
||
1959 |
if (__isSmallInteger(aPercentage)) { |
|
1960 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
|
1961 |
} |
|
1962 |
if (__isFloat(aPercentage)) { |
|
1963 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
|
1964 |
} |
|
1965 |
%}. |
|
1966 |
^ (16rFFFF * aPercentage / 100) rounded |
|
1967 |
! ! |
|
1968 |
||
1969 |
!WinWorkstation methodsFor:'cursor stuff'! |
|
1970 |
||
1971 |
createCursorShape:aShape |
|
1972 |
"create a cursor given a shape-symbol" |
|
1973 |
||
1974 |
|number id| |
|
1975 |
||
1976 |
number := self shapeNumberFromSymbol:aShape. |
|
1977 |
%{ |
|
1978 |
HCURSOR newCursor; |
|
1979 |
LPCTSTR cId; |
|
1980 |
||
1981 |
if (__isSmallInteger(number)) { |
|
1982 |
cId = (LPCTSTR)(__intVal(number)); |
|
1983 |
newCursor = LoadCursor(NULL, cId); |
|
1984 |
if (newCursor) { |
|
1985 |
if (cId == IDC_ARROW) |
|
1986 |
H_C_ARROW = newCursor; |
|
1987 |
else if (cId == IDC_CROSS) |
|
1988 |
H_C_CROSS = newCursor; |
|
1989 |
else if (cId == IDC_IBEAM) |
|
1990 |
H_C_IBEAM = newCursor; |
|
1991 |
else if (cId == IDC_ICON) |
|
1992 |
H_C_ICON = newCursor; |
|
1993 |
else if (cId == IDC_NO) |
|
1994 |
H_C_NO = newCursor; |
|
1995 |
else if (cId == IDC_SIZE) |
|
1996 |
H_C_SIZE = newCursor; |
|
1997 |
else if (cId == IDC_SIZEALL) |
|
1998 |
H_C_SIZEALL = newCursor; |
|
1999 |
else if (cId == IDC_SIZENESW) |
|
2000 |
H_C_SIZENESW = newCursor; |
|
2001 |
else if (cId == IDC_SIZENS) |
|
2002 |
H_C_SIZENS = newCursor; |
|
2003 |
else if (cId == IDC_SIZENWSE) |
|
2004 |
H_C_SIZENWSE = newCursor; |
|
2005 |
else if (cId == IDC_UPARROW) |
|
2006 |
H_C_UPARROW = newCursor; |
|
2007 |
else if (cId == IDC_WAIT) |
|
2008 |
H_C_WAIT = newCursor; |
|
2009 |
||
2010 |
id = __MKOBJ(newCursor); |
|
2011 |
} |
|
2012 |
} |
|
2013 |
%}. |
|
2014 |
^ id |
|
2015 |
! |
|
2016 |
||
2017 |
createCursorSourceForm:sourceBytes maskForm:maskBytes hotX:hx hotY:hy width:w height:h |
|
2018 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
|
2019 |
||
2020 |
|id| |
|
2021 |
||
2022 |
%{ |
|
2023 |
HCURSOR newCursor; |
|
2024 |
||
2025 |
if (__isByteArray(sourceBytes) |
|
2026 |
&& __isByteArray(maskBytes) |
|
2027 |
&& __bothSmallInteger(hx, hy) |
|
2028 |
&& __bothSmallInteger(w, h)) { |
|
2029 |
||
2030 |
newCursor = CreateCursor(hInstance, |
|
2031 |
__intVal(hx), __intVal(hy), |
|
2032 |
__intVal(w), __intVal(h), |
|
2033 |
__ByteArrayInstPtr(maskBytes)->ba_element, |
|
2034 |
__ByteArrayInstPtr(sourceBytes)->ba_element); |
|
2035 |
if (newCursor) { |
|
2036 |
id = __MKOBJ(newCursor); |
|
2037 |
} |
|
2038 |
} |
|
2039 |
%}. |
|
2040 |
^ id |
|
2041 |
! |
|
2042 |
||
2043 |
destroyCursor:aCursorId |
|
2044 |
||
2045 |
%{ /* NOCONTEXT */ |
|
2046 |
||
2047 |
if (ISCONNECTED) { |
|
2048 |
if (__isExternalAddress(aCursorId)) { |
|
2049 |
HCURSOR curs = _HCURSORVal(aCursorId); |
|
2050 |
||
2051 |
if (curs) { |
|
2052 |
if ((curs != H_C_ARROW) |
|
2053 |
&& (curs != H_C_CROSS) |
|
2054 |
&& (curs != H_C_IBEAM) |
|
2055 |
&& (curs != H_C_ICON) |
|
2056 |
&& (curs != H_C_NO) |
|
2057 |
&& (curs != H_C_SIZE) |
|
2058 |
&& (curs != H_C_SIZEALL) |
|
2059 |
&& (curs != H_C_SIZENESW) |
|
2060 |
&& (curs != H_C_SIZENS) |
|
2061 |
&& (curs != H_C_SIZENWSE) |
|
2062 |
&& (curs != H_C_UPARROW) |
|
2063 |
&& (curs != H_C_WAIT)) { |
|
2064 |
DestroyCursor(curs); |
|
2065 |
} |
|
2066 |
} |
|
2067 |
RETURN ( self ); |
|
2068 |
} |
|
2069 |
} |
|
2070 |
%}. |
|
2071 |
self primitiveFailed |
|
2072 |
! |
|
2073 |
||
2074 |
needDeviceFormsForCursor |
|
2075 |
^ false |
|
2076 |
! |
|
2077 |
||
2078 |
shapeNumberFromSymbol:shape |
|
2079 |
"given a shape-symbol, return the corresponding cursor-number, |
|
2080 |
or nil if no such standard cursor exists." |
|
2081 |
||
2082 |
"this is pure Win-knowlegde - but you may easily add more" |
|
2083 |
||
2084 |
%{ /* NOCONTEXT */ |
|
2085 |
if (shape == @symbol(upLeftArrow)) { |
|
2086 |
RETURN ( __MKSMALLINT( (INT)IDC_ARROW)); |
|
2087 |
} |
|
2088 |
if (shape == @symbol(upDownArrow)) { |
|
2089 |
RETURN ( __MKSMALLINT( (INT)IDC_SIZENS)); |
|
2090 |
} |
|
2091 |
if (shape == @symbol(leftRightArrow)) { |
|
2092 |
RETURN ( __MKSMALLINT( (INT)IDC_SIZEWE)); |
|
2093 |
} |
|
2094 |
if (shape == @symbol(text)) { |
|
2095 |
RETURN ( __MKSMALLINT( (INT)IDC_IBEAM)); |
|
2096 |
} |
|
2097 |
if (shape == @symbol(wait)) { |
|
2098 |
RETURN ( __MKSMALLINT( (INT)IDC_WAIT)); |
|
2099 |
} |
|
2100 |
if (shape == @symbol(crossHair)) { |
|
2101 |
RETURN ( __MKSMALLINT( (INT)IDC_CROSS)); |
|
2102 |
} |
|
2103 |
if (shape == @symbol(fourWay)) { |
|
2104 |
RETURN ( __MKSMALLINT( (INT)IDC_SIZE)); |
|
2105 |
} |
|
2106 |
%}. |
|
2107 |
"/ ('WINWORKSTATION: invalid cursorShape:' , shape printString) infoPrintNL. |
|
2108 |
^ nil |
|
2109 |
! ! |
|
2110 |
||
2111 |
!WinWorkstation methodsFor:'drawing'! |
|
2112 |
||
2113 |
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId |
|
2114 |
width:w height:h |
|
2115 |
"do a bit-blt; copy bits from the rectangle defined by |
|
2116 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2117 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2118 |
argument is not integer." |
|
2119 |
||
2120 |
%{ /* NOCONTEXT */ |
|
2121 |
||
2122 |
HDC srcDC, dstDC; |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2123 |
HDC rootDC; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2124 |
int deleteSrcDC =0, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2125 |
deleteDstDC = 0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2126 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2127 |
if (__isExternalAddress(srcGCId)) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2128 |
srcDC = _HDCVal(srcGCId); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2129 |
printf("srcDC = %x\n", srcDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2130 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2131 |
if (__isExternalAddress(sourceId)) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2132 |
rootDC = __rootDC; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2133 |
srcDC = CreateCompatibleDC(rootDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2134 |
SelectObject(srcDC, _HWNDVal(sourceId)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2135 |
deleteSrcDC = 1; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2136 |
printf("created srcDC = %x\n", srcDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2137 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2138 |
goto fail; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2139 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2140 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2141 |
if (! srcDC) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2142 |
goto fail; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2143 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2144 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2145 |
if (__isExternalAddress(dstGCId)) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2146 |
dstDC = _HDCVal(dstGCId); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2147 |
printf("dstDC = %x\n", dstDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2148 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2149 |
if (__isExternalAddress(destId)) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2150 |
rootDC = __rootDC; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2151 |
dstDC = CreateCompatibleDC(rootDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2152 |
SelectObject(dstDC, _HWNDVal(destId)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2153 |
deleteDstDC = 1; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2154 |
printf("created dstDC = %x\n", dstDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2155 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2156 |
goto fail; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2157 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2158 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2159 |
if (! dstDC) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2160 |
goto fail; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2161 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2162 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2163 |
if (__bothSmallInteger(w, h) |
1127 | 2164 |
&& __bothSmallInteger(srcX, srcY) |
2165 |
&& __bothSmallInteger(dstX, dstY)) { |
|
2166 |
||
2167 |
BitBlt(dstDC, |
|
2168 |
__intVal(dstX), __intVal(dstY), |
|
2169 |
__intVal(w), __intVal(h), |
|
2170 |
srcDC, |
|
2171 |
__intVal(srcX), __intVal(srcY), |
|
2172 |
SRCCOPY); |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2173 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2174 |
if (deleteDstDC) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2175 |
DeleteObject(dstDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2176 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2177 |
if (deleteSrcDC) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2178 |
DeleteObject(srcDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2179 |
} |
1127 | 2180 |
RETURN ( self ); |
2181 |
} |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2182 |
fail: ; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2183 |
if (deleteDstDC) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2184 |
DeleteObject(dstDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2185 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2186 |
if (deleteSrcDC) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2187 |
DeleteObject(srcDC); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2188 |
} |
1127 | 2189 |
%}. |
2190 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2191 |
or any non integer coordinate" |
|
2192 |
||
2193 |
self primitiveFailed |
|
2194 |
! |
|
2195 |
||
2196 |
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcDCId to:destId x:dstX y:dstY gc:dstDCId |
|
2197 |
width:w height:h |
|
2198 |
"do a bit-blt, but only copy the low-bit plane; |
|
2199 |
copy bits from the rectangle defined by |
|
2200 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2201 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2202 |
argument is not integer." |
|
2203 |
||
2204 |
^ self |
|
2205 |
copyFromId:sourceId |
|
2206 |
x:srcX y:srcY gc:srcDCId |
|
2207 |
to:destId x:dstX y:dstY gc:dstDCId |
|
2208 |
width:w height:h |
|
2209 |
! |
|
2210 |
||
2211 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
|
2212 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
|
2213 |
The angles may be floats or integer - they are given in degrees." |
|
2214 |
||
2215 |
%{ /* NOCONTEXT */ |
|
2216 |
||
2217 |
int w, h, angle1, angle2; |
|
2218 |
double f; |
|
2219 |
||
2220 |
if (__isSmallInteger(startAngle)) |
|
2221 |
angle1 = __intVal(startAngle) * 64; |
|
2222 |
else if (__isFloat(startAngle)) { |
|
2223 |
f = __floatVal(startAngle); |
|
2224 |
angle1 = f * 64; |
|
2225 |
} |
|
2226 |
if (__isSmallInteger(angle)) |
|
2227 |
angle2 = __intVal(angle) * 64; |
|
2228 |
else if (__isFloat(angle)) { |
|
2229 |
f = __floatVal(angle); |
|
2230 |
angle2 = f * 64; |
|
2231 |
} |
|
2232 |
if (__isExternalAddress(aGCId) |
|
2233 |
&& __isExternalAddress(aDrawableId) |
|
2234 |
&& __bothSmallInteger(x, y) |
|
2235 |
&& __bothSmallInteger(width, height)) { |
|
2236 |
w = __intVal(width); |
|
2237 |
h = __intVal(height); |
|
2238 |
RETURN ( self ); |
|
2239 |
} |
|
2240 |
%}. |
|
2241 |
"badGC, badDrawable or coordinates not integer" |
|
2242 |
self primitiveFailed |
|
2243 |
! |
|
2244 |
||
2245 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
|
2246 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2247 |
||
2248 |
%{ /* NOCONTEXT */ |
|
2249 |
if (__isExternalAddress(aGCId) |
|
2250 |
&& __isExternalAddress(aDrawableId) |
|
2251 |
&& __bothSmallInteger(x0, y0) |
|
2252 |
&& __bothSmallInteger(x1, y1)) { |
|
2253 |
struct gcData *gcData = _GCDATA(aGCId); |
|
2254 |
HDC hDC; |
|
2255 |
HBRUSH hBrush; |
|
2256 |
HPEN hPen; |
|
2257 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2258 |
/* DPRINTF(("displayLine: %d/%d -> %d/%d\n", __intVal(x0), __intVal(y0), __intVal(x1), __intVal(y1))); */ |
1127 | 2259 |
|
2260 |
hDC = _HDCVal(aGCId); |
|
2261 |
hPen = gcData->hPen; |
|
2262 |
||
2263 |
if (! hPen) { |
|
2264 |
hPen = gcData->hPen = CreatePen(gcData->lineStyle, |
|
2265 |
gcData->lineWidth, |
|
2266 |
gcData->fgColor); |
|
2267 |
} |
|
2268 |
||
2269 |
if (! hPen) { |
|
2270 |
DPRINTF(("displayLine: no pen\n")); |
|
2271 |
} else { |
|
2272 |
MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL); |
|
2273 |
LineTo(hDC, __intVal(x1), __intVal(y1)); |
|
2274 |
} |
|
2275 |
||
2276 |
RETURN ( self ); |
|
2277 |
} |
|
2278 |
%}. |
|
2279 |
"badGC, badDrawable or coordinates not integer" |
|
2280 |
self primitiveFailed |
|
2281 |
! |
|
2282 |
||
2283 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2284 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2285 |
||
2286 |
%{ /* NOCONTEXT */ |
|
2287 |
if (__isExternalAddress(aGCId) |
|
2288 |
&& __isExternalAddress(aDrawableId) |
|
2289 |
&& __bothSmallInteger(x, y)) { |
|
2290 |
RETURN ( self ); |
|
2291 |
} |
|
2292 |
%}. |
|
2293 |
"badGC, badDrawable or x/y not integer" |
|
2294 |
self primitiveFailed |
|
2295 |
! |
|
2296 |
||
2297 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2298 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2299 |
define the polygon. |
|
2300 |
If any coordinate is not integer, an error is triggered." |
|
2301 |
||
2302 |
|numberOfPoints newPoints| |
|
2303 |
||
2304 |
numberOfPoints := aPolygon size. |
|
2305 |
%{ |
|
2306 |
OBJ point, x, y; |
|
2307 |
int i, num; |
|
2308 |
||
2309 |
if (__isExternalAddress(aGCId) |
|
2310 |
&& __isExternalAddress(aDrawableId) |
|
2311 |
&& __isSmallInteger(numberOfPoints)) { |
|
2312 |
num = __intVal(numberOfPoints); |
|
2313 |
||
2314 |
for (i=0; i<num; i++) { |
|
2315 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
2316 |
if (! __isPoint(point)) goto fail; |
|
2317 |
x = _point_X(point); |
|
2318 |
y = _point_Y(point); |
|
2319 |
if (! __bothSmallInteger(x, y)) |
|
2320 |
goto fail; |
|
2321 |
} |
|
2322 |
RETURN ( self ); |
|
2323 |
} |
|
2324 |
fail: ; |
|
2325 |
%}. |
|
2326 |
"badGC, badDrawable or coordinates not integer" |
|
2327 |
self primitiveFailed |
|
2328 |
! |
|
2329 |
||
2330 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2331 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2332 |
||
2333 |
%{ /* NOCONTEXT */ |
|
2334 |
int w, h; |
|
2335 |
int xL, yT; |
|
2336 |
||
2337 |
if (__isExternalAddress(aGCId) |
|
2338 |
&& __isExternalAddress(aDrawableId) |
|
2339 |
&& __bothSmallInteger(x, y) |
|
2340 |
&& __bothSmallInteger(width, height)) { |
|
2341 |
struct gcData *gcData = _GCDATA(aGCId); |
|
2342 |
HDC hDC; |
|
2343 |
HBRUSH hBrush; |
|
2344 |
HPEN hPen; |
|
2345 |
||
2346 |
xL = __intVal(x); |
|
2347 |
yT = __intVal(y); |
|
2348 |
w = __intVal(width); |
|
2349 |
h = __intVal(height); |
|
2350 |
||
2351 |
DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", |
|
2352 |
xL, yT, w, h)); |
|
2353 |
/* |
|
2354 |
* need this check here: some servers simply dump core with bad args |
|
2355 |
*/ |
|
2356 |
if ((w >= 0) && (h >= 0)) { |
|
2357 |
hPen = gcData->hPen; |
|
2358 |
||
2359 |
if (! hPen) { |
|
2360 |
hPen = gcData->hPen = CreatePen(gcData->lineStyle, |
|
2361 |
gcData->lineWidth, |
|
2362 |
gcData->fgColor); |
|
2363 |
} |
|
2364 |
||
2365 |
if (! hPen) { |
|
2366 |
DPRINTF(("displayRect: no pen\n")); |
|
2367 |
} else { |
|
2368 |
MoveToEx(hDC, xL, yT, NULL); |
|
2369 |
LineTo(hDC, xL+w-1, yT); |
|
2370 |
LineTo(hDC, xL+w-1, yT+h-1); |
|
2371 |
LineTo(hDC, xL, yT+h-1); |
|
2372 |
LineTo(hDC, xL, yT); |
|
2373 |
} |
|
2374 |
} |
|
2375 |
RETURN ( self ); |
|
2376 |
} |
|
2377 |
%}. |
|
2378 |
"badGC, badDrawable or coordinates not integer" |
|
2379 |
self primitiveFailed |
|
2380 |
! |
|
2381 |
||
2382 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2383 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2384 |
foreground and background characters. |
|
2385 |
If the coordinates are not integers, an error is triggered." |
|
2386 |
||
2387 |
%{ /* NOCONTEXT */ |
|
2388 |
unsigned char *cp; |
|
2389 |
OBJ cls; |
|
2390 |
int i1, i2, l, n; |
|
2391 |
# define NLOCALBUFFER 200 |
|
2392 |
short xlatebuffer[NLOCALBUFFER]; |
|
2393 |
int nInstBytes; |
|
2394 |
||
2395 |
if (__isExternalAddress(aGCId) |
|
2396 |
&& __isExternalAddress(aDrawableId) |
|
2397 |
&& __isNonNilObject(aString) |
|
2398 |
&& __bothSmallInteger(index1, index2) |
|
2399 |
&& __bothSmallInteger(x, y)) { |
|
2400 |
struct gcData *gcData = _GCDATA(aGCId); |
|
2401 |
int pX, pY; |
|
2402 |
HDC hDC; |
|
2403 |
||
2404 |
hDC = gcData->hDC; |
|
2405 |
||
2406 |
pX = __intVal(x); |
|
2407 |
pY = __intVal(y); |
|
2408 |
pY -= gcData->fontAscent; |
|
2409 |
||
2410 |
cls = __qClass(aString); |
|
2411 |
||
2412 |
i1 = __intVal(index1) - 1; |
|
2413 |
if (i1 >= 0) { |
|
2414 |
i2 = __intVal(index2) - 1; |
|
2415 |
if (i2 < i1) { |
|
2416 |
RETURN (self); |
|
2417 |
} |
|
2418 |
||
2419 |
cp = _stringVal(aString); |
|
2420 |
l = i2 - i1 + 1; |
|
2421 |
||
2422 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2423 |
n = _stringSize(aString); |
|
2424 |
if (i2 < n) { |
|
2425 |
cp += i1; |
|
2426 |
if (l > 1000) l = 1000; |
|
2427 |
DDPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY)); |
|
2428 |
if (opaque == true) { |
|
2429 |
SetBkMode(hDC, OPAQUE); |
|
2430 |
} else { |
|
2431 |
SetBkMode(hDC, TRANSPARENT); |
|
2432 |
} |
|
2433 |
TextOut(hDC, pX, pY, (char *)cp, l); |
|
2434 |
RETURN ( self ); |
|
2435 |
} |
|
2436 |
} |
|
2437 |
||
2438 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2439 |
cp += nInstBytes; |
|
2440 |
||
2441 |
if (__isBytes(aString)) { |
|
2442 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2443 |
||
2444 |
if (i2 < n) { |
|
2445 |
cp += i1; |
|
2446 |
if (l > 1000) l = 1000; |
|
2447 |
DDPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY)); |
|
2448 |
if (opaque == true) { |
|
2449 |
SetBkMode(hDC, OPAQUE); |
|
2450 |
} else { |
|
2451 |
SetBkMode(hDC, TRANSPARENT); |
|
2452 |
} |
|
2453 |
TextOut(hDC, pX, pY, (char *)cp, l); |
|
2454 |
RETURN ( self ); |
|
2455 |
} |
|
2456 |
} |
|
2457 |
||
2458 |
#ifdef NOTDEF |
|
2459 |
/* TWOBYTESTRINGS */ |
|
2460 |
if (__isWords(aString)) { |
|
2461 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2462 |
||
2463 |
if (i2 < n) { |
|
2464 |
union { |
|
2465 |
char b[2]; |
|
2466 |
unsigned short s; |
|
2467 |
} u; |
|
2468 |
int i; |
|
2469 |
XChar2b *cp2 = (XChar2b *)0; |
|
2470 |
int mustFree = 0; |
|
2471 |
||
2472 |
cp += (i1 * 2); |
|
2473 |
if (l > 1000) l = 1000; |
|
2474 |
||
2475 |
/* |
|
2476 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2477 |
* X expects them MSB first |
|
2478 |
* convert as required |
|
2479 |
*/ |
|
2480 |
||
2481 |
u.s = 0x1234; |
|
2482 |
if (u.b[0] != 0x12) { |
|
2483 |
if (l <= NLOCALBUFFER) { |
|
2484 |
cp2 = xlatebuffer; |
|
2485 |
} else { |
|
2486 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
2487 |
mustFree = 1; |
|
2488 |
} |
|
2489 |
for (i=0; i<l; i++) { |
|
2490 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2491 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2492 |
} |
|
2493 |
cp = (char *) cp2; |
|
2494 |
} |
|
2495 |
||
2496 |
if (opaque == true) |
|
2497 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2498 |
else |
|
2499 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2500 |
||
2501 |
if (mustFree) { |
|
2502 |
free(cp2); |
|
2503 |
} |
|
2504 |
||
2505 |
RETURN ( self ); |
|
2506 |
} |
|
2507 |
} |
|
2508 |
#endif |
|
2509 |
} |
|
2510 |
} |
|
2511 |
#undef NLOCALBUFFER |
|
2512 |
%}. |
|
2513 |
"x/y not integer, badGC or drawable, or not a string" |
|
2514 |
self primitiveFailed |
|
2515 |
! |
|
2516 |
||
2517 |
xxxdisplayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2518 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
2519 |
foreground and background characters. |
|
2520 |
If the coordinates are not integers, an error is triggered." |
|
2521 |
||
2522 |
%{ /* NOCONTEXT */ |
|
2523 |
#ifdef NOTDEF |
|
2524 |
GC gc; |
|
2525 |
Window win; |
|
2526 |
unsigned char *cp; |
|
2527 |
int n; |
|
2528 |
OBJ cls; |
|
2529 |
# define NLOCALBUFFER 200 |
|
2530 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
|
2531 |
int nInstBytes; |
|
2532 |
||
2533 |
if (__isExternalAddress(aGCId) |
|
2534 |
&& __isExternalAddress(aDrawableId) |
|
2535 |
&& __isNonNilObject(aString) |
|
2536 |
&& __bothSmallInteger(x, y)) { |
|
2537 |
gc = _GCVal(aGCId); |
|
2538 |
win = _WindowVal(aDrawableId); |
|
2539 |
cls = __qClass(aString); |
|
2540 |
||
2541 |
cp = _stringVal(aString); |
|
2542 |
||
2543 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2544 |
n = _stringSize(aString); |
|
2545 |
if (n > 1000) n = 1000; |
|
2546 |
if (opaque == true) |
|
2547 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2548 |
else |
|
2549 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2550 |
RETURN ( self ); |
|
2551 |
} |
|
2552 |
||
2553 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2554 |
cp += nInstBytes; |
|
2555 |
||
2556 |
if (__isBytes(aString)) { |
|
2557 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2558 |
||
2559 |
if (n > 1000) n = 1000; |
|
2560 |
if (opaque == true) |
|
2561 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2562 |
else |
|
2563 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2564 |
RETURN ( self ); |
|
2565 |
} |
|
2566 |
||
2567 |
/* TWOBYTESTRINGS */ |
|
2568 |
if (__isWords(aString)) { |
|
2569 |
union { |
|
2570 |
char b[2]; |
|
2571 |
unsigned short s; |
|
2572 |
} u; |
|
2573 |
int i; |
|
2574 |
XChar2b *cp2; |
|
2575 |
int mustFree = 0; |
|
2576 |
||
2577 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2578 |
if (n > 1000) n = 1000; |
|
2579 |
||
2580 |
/* |
|
2581 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2582 |
* X expects them MSB first |
|
2583 |
* convert as required |
|
2584 |
*/ |
|
2585 |
||
2586 |
u.s = 0x1234; |
|
2587 |
if (u.b[0] != 0x12) { |
|
2588 |
if (n <= NLOCALBUFFER) { |
|
2589 |
cp2 = xlatebuffer; |
|
2590 |
} else { |
|
2591 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
2592 |
mustFree = 1; |
|
2593 |
} |
|
2594 |
||
2595 |
for (i=0; i<n; i++) { |
|
2596 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2597 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2598 |
} |
|
2599 |
cp = (char *) cp2; |
|
2600 |
} |
|
2601 |
||
2602 |
if (opaque == true) |
|
2603 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2604 |
else |
|
2605 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2606 |
||
2607 |
||
2608 |
if (mustFree) { |
|
2609 |
free(cp2); |
|
2610 |
} |
|
2611 |
||
2612 |
RETURN ( self ); |
|
2613 |
} |
|
2614 |
} |
|
2615 |
#undef NLOCALBUFFER |
|
2616 |
#endif |
|
2617 |
%}. |
|
2618 |
"x/y not integer, badGC or drawable, or not a string" |
|
2619 |
self primitiveFailed |
|
2620 |
! |
|
2621 |
||
2622 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2623 |
width:imageWidth height:imageHeight |
|
2624 |
x:srcx y:srcy |
|
2625 |
into:aDrawableId |
|
2626 |
x:dstx y:dsty |
|
2627 |
width:w height:h |
|
2628 |
with:aGCId |
|
2629 |
||
2630 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2631 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2632 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
2633 |
depth and pixel-units to be different. |
|
2634 |
It has to be checked elsewhere, that the server can do it with the given |
|
2635 |
depth - otherwise, primitive failure will be signalled. |
|
2636 |
Also it is assumed, that the colormap is setup correctly and the |
|
2637 |
colors are allocated - otherwise the colors may be wrong." |
|
2638 |
||
2639 |
" |
|
2640 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
2641 |
an unlimited stack, and thus cannot send primitiveFailed |
|
2642 |
" |
|
2643 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2644 |
width:imageWidth height:imageHeight |
|
2645 |
x:srcx y:srcy |
|
2646 |
into:aDrawableId |
|
2647 |
x:dstx y:dsty |
|
2648 |
width:w height:h |
|
2649 |
with:aGCId) |
|
2650 |
ifFalse:[ |
|
2651 |
" |
|
2652 |
also happens, if a segmentation violation occurs in the |
|
2653 |
XPutImage ... |
|
2654 |
" |
|
2655 |
self primitiveFailed |
|
2656 |
]. |
|
2657 |
! |
|
2658 |
||
2659 |
drawBits:imageBits depth:imageDepth |
|
2660 |
width:imageWidth height:imageHeight |
|
2661 |
x:srcx y:srcy |
|
2662 |
into:aDrawableId |
|
2663 |
x:dstx y:dsty |
|
2664 |
width:w height:h |
|
2665 |
with:aGCId |
|
2666 |
||
2667 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2668 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2669 |
Individual source pixels must have imageDepth bits. |
|
2670 |
It has to be checked elsewhere, that the server can do it with the given |
|
2671 |
depth - otherwise, primitive failure will be signalled. |
|
2672 |
Also it is assumed, that the colormap is setup correctly and the |
|
2673 |
colors are allocated - otherwise the colors may be wrong." |
|
2674 |
||
2675 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
2676 |
width:imageWidth height:imageHeight |
|
2677 |
x:srcx y:srcy |
|
2678 |
into:aDrawableId |
|
2679 |
x:dstx y:dsty |
|
2680 |
width:w height:h |
|
2681 |
with:aGCId |
|
2682 |
||
2683 |
! |
|
2684 |
||
2685 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
|
2686 |
in:aDrawableId with:aGCId |
|
2687 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
|
2688 |
The angles may be floats or integer - they are given in degrees." |
|
2689 |
||
2690 |
%{ /* NOCONTEXT */ |
|
2691 |
||
2692 |
int w, h, angle1, angle2; |
|
2693 |
double f; |
|
2694 |
||
2695 |
if (__isSmallInteger(startAngle)) |
|
2696 |
angle1 = __intVal(startAngle) * 64; |
|
2697 |
else if (__isFloat(startAngle)) { |
|
2698 |
f = __floatVal(startAngle); |
|
2699 |
angle1 = f * 64; |
|
2700 |
} |
|
2701 |
if (__isSmallInteger(angle)) |
|
2702 |
angle2 = __intVal(angle) * 64; |
|
2703 |
else if (__isFloat(angle)) { |
|
2704 |
f = __floatVal(angle); |
|
2705 |
angle2 = f * 64; |
|
2706 |
} |
|
2707 |
if (__isExternalAddress(aGCId) |
|
2708 |
&& __isExternalAddress(aDrawableId) |
|
2709 |
&& __bothSmallInteger(x, y) |
|
2710 |
&& __bothSmallInteger(width, height)) { |
|
2711 |
w = __intVal(width); |
|
2712 |
h = __intVal(height); |
|
2713 |
/* |
|
2714 |
* need this check here: some servers simply dump core with bad args |
|
2715 |
*/ |
|
2716 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2717 |
} |
|
2718 |
RETURN ( self ); |
|
2719 |
} |
|
2720 |
%}. |
|
2721 |
"badGC, badDrawable or coordinates not integer" |
|
2722 |
self primitiveFailed |
|
2723 |
! |
|
2724 |
||
2725 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
2726 |
"fill a polygon given by its points. |
|
2727 |
If any coordinate is not integer, an error is triggered." |
|
2728 |
||
2729 |
|numberOfPoints| |
|
2730 |
||
2731 |
numberOfPoints := aPolygon size. |
|
2732 |
%{ |
|
2733 |
OBJ point, x, y; |
|
2734 |
int i, num; |
|
2735 |
||
2736 |
if (__isExternalAddress(aGCId) |
|
2737 |
&& __isExternalAddress(aDrawableId) |
|
2738 |
&& __isSmallInteger(numberOfPoints)) { |
|
2739 |
num = __intVal(numberOfPoints); |
|
2740 |
if (num < 3) { |
|
2741 |
RETURN ( self ); |
|
2742 |
} |
|
2743 |
for (i=0; i<num; i++) { |
|
2744 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
2745 |
if (! __isPoint(point)) goto fail; |
|
2746 |
x = _point_X(point); |
|
2747 |
y = _point_Y(point); |
|
2748 |
if (! __bothSmallInteger(x, y)) |
|
2749 |
goto fail; |
|
2750 |
} |
|
2751 |
RETURN ( self ); |
|
2752 |
||
2753 |
fail: ; |
|
2754 |
} |
|
2755 |
%}. |
|
2756 |
"badGC, badDrawable or coordinates not integer" |
|
2757 |
self primitiveFailed |
|
2758 |
! |
|
2759 |
||
2760 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2761 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
2762 |
||
2763 |
%{ /* NOCONTEXT */ |
|
2764 |
||
2765 |
int w, h; |
|
2766 |
||
2767 |
if (__isExternalAddress(aGCId) |
|
2768 |
&& __isExternalAddress(aDrawableId) |
|
2769 |
&& __bothSmallInteger(x, y) |
|
2770 |
&& __bothSmallInteger(width, height)) { |
|
2771 |
w = __intVal(width); |
|
2772 |
h = __intVal(height); |
|
2773 |
||
2774 |
DDPRINTF(("fillRect %d/%d -> %d/%d\n", __intVal(x), __intVal(y), w, h)); |
|
2775 |
||
2776 |
/* |
|
2777 |
* need this check here: some servers simply dump core with bad args |
|
2778 |
*/ |
|
2779 |
if ((w >= 0) && (h >= 0)) { |
|
2780 |
struct gcData *gcData = _GCDATA(aGCId); |
|
2781 |
HDC hDC; |
|
2782 |
HBRUSH hBrush; |
|
2783 |
RECT rct; |
|
2784 |
||
2785 |
hDC = _HDCVal(aGCId); |
|
2786 |
hBrush = gcData->hBrush; |
|
2787 |
||
2788 |
if (! hBrush) { |
|
2789 |
hBrush = gcData->hBrush = CreateSolidBrush(gcData->fgColor); |
|
2790 |
} |
|
2791 |
||
2792 |
if (! hBrush) { |
|
2793 |
DPRINTF(("fillRectangle: no brush\n")); |
|
2794 |
} else { |
|
2795 |
rct.left = __intVal(x); |
|
2796 |
rct.top = __intVal(y); |
|
2797 |
rct.right = rct.left + w; /* FillRect excludes right/bottom */ |
|
2798 |
rct.bottom = rct.top + h; |
|
2799 |
||
2800 |
FillRect(hDC, &rct, hBrush); |
|
2801 |
} |
|
2802 |
} |
|
2803 |
RETURN ( self ); |
|
2804 |
} |
|
2805 |
%}. |
|
2806 |
"badGC, badDrawable or coordinates not integer" |
|
2807 |
self primitiveFailed |
|
2808 |
! |
|
2809 |
||
2810 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2811 |
width:imageWidth height:imageHeight |
|
2812 |
x:srcx y:srcy |
|
2813 |
into:aDrawableId |
|
2814 |
x:dstx y:dsty |
|
2815 |
width:w height:h |
|
2816 |
with:aGCId |
|
2817 |
||
2818 |
"since XPutImage may allocate huge amount of stack space |
|
2819 |
(some implementations use alloca), this must run with unlimited stack." |
|
2820 |
||
2821 |
%{ /* UNLIMITEDSTACK */ |
|
2822 |
||
2823 |
||
2824 |
fail: ; |
|
2825 |
%} |
|
2826 |
. |
|
2827 |
^ false |
|
2828 |
! ! |
|
2829 |
||
2830 |
!WinWorkstation methodsFor:'win32 event handling'! |
|
2831 |
||
2832 |
clearX:x y:y width:w height:h view:aView |
|
2833 |
"erase part of a view to its background color" |
|
2834 |
||
2835 |
|oldPaint| |
|
2836 |
||
2837 |
oldPaint := aView paint. |
|
2838 |
aView paint:(aView viewBackground). |
|
2839 |
aView fillRectangleX:x y:y width:w height:h. |
|
2840 |
aView paint:oldPaint |
|
2841 |
! ! |
|
2842 |
||
2843 |
!WinWorkstation methodsFor:'event handling'! |
|
2844 |
||
2845 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
2846 |
"central event handling method: |
|
2847 |
get next event and send appropriate message to the sensor or view. |
|
2848 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
2849 |
otherwise only events for the view with given id are processed. |
|
2850 |
If the argument aMask is nonNil, only events for this eventMask are |
|
2851 |
handled." |
|
2852 |
||
2853 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
|
2854 |
AbortSignal catch:[ |
|
2855 |
self dispatchLastEvent. |
|
2856 |
] |
|
2857 |
]. |
|
2858 |
! |
|
2859 |
||
2860 |
dispatchExposeEventFor:aViewIdOrNil |
|
2861 |
"get next expose event and send appropriate message to the sensor or view. |
|
2862 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
2863 |
otherwise only events for the view with given id are processed." |
|
2864 |
||
2865 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
2866 |
! |
|
2867 |
||
2868 |
dispatchLastEvent |
|
2869 |
|theView symS arg butt sibling windowID siblingID propertyID selectionID targetID requestorID |
|
2870 |
eventType| |
|
2871 |
||
2872 |
%{ /* STACK: 8000 */ |
|
2873 |
struct queuedEvent *ev; |
|
2874 |
struct inlineCache *ipS; |
|
2875 |
||
2876 |
static struct inlineCache vid = _ILC1; |
|
2877 |
static struct inlineCache confS = _ILC5; |
|
2878 |
static struct inlineCache skpS = _ILC4; |
|
2879 |
static struct inlineCache skrS = _ILC4; |
|
2880 |
static struct inlineCache expS = _ILC5; |
|
2881 |
static struct inlineCache clrS = _ILC5; |
|
2882 |
static struct inlineCache bpS = _ILC4; |
|
2883 |
static struct inlineCache brS = _ILC4; |
|
2884 |
static struct inlineCache bmpS = _ILC4; |
|
2885 |
static struct inlineCache bspS = _ILC4; |
|
2886 |
static struct inlineCache motS = _ILC4; |
|
2887 |
static struct inlineCache unmapS = _ILC1; |
|
2888 |
static struct inlineCache mapS = _ILC1; |
|
2889 |
static struct inlineCache destrS = _ILC1; |
|
2890 |
static struct inlineCache focOutS = _ILC1; |
|
2891 |
static struct inlineCache focInS = _ILC1; |
|
2892 |
||
2893 |
||
2894 |
int x, y, w, h; |
|
2895 |
int keyCode, modifiers, isDoubleClick = 0; |
|
2896 |
int isDown = 1; |
|
2897 |
int state; |
|
2898 |
OBJ upDown; |
|
2899 |
char nameBuffer[100]; |
|
2900 |
||
2901 |
DDPRINTF(("dispatchLast\n")); |
|
2902 |
||
2903 |
ev = deqEvent(); |
|
2904 |
if (! ev) { |
|
2905 |
DPRINTF(("no event in dispatchEvent\n")); |
|
2906 |
RETURN (false); |
|
2907 |
} |
|
2908 |
||
2909 |
if (ev->ev_hWnd) { |
|
2910 |
windowID = __MKOBJ(ev->ev_hWnd); |
|
2911 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, windowID); |
|
2912 |
} |
|
2913 |
||
2914 |
if (theView == nil) { |
|
2915 |
DPRINTF(("nil view [hWnd=%x] in dispatchEvent\n", ev->ev_hWnd)); |
|
2916 |
||
2917 |
freeEvent(ev); |
|
2918 |
RETURN (false); |
|
2919 |
} |
|
2920 |
||
2921 |
if (ev) { |
|
2922 |
switch (ev->ev_message) { |
|
2923 |
case WM_WINDOWPOSCHANGED: |
|
2924 |
DPRINTF(("got WM_WINDOWPOSCHANGED -> configureX:y:width:height:view:\n")); |
|
2925 |
||
2926 |
x = ev->ev_x; |
|
2927 |
y = ev->ev_y; |
|
2928 |
w = ev->ev_w; |
|
2929 |
h = ev->ev_h; |
|
2930 |
freeEvent(ev); ev = NULL; |
|
2931 |
(*confS.ilc_func)(self, |
|
2932 |
@symbol(configureX:y:width:height:view:), |
|
2933 |
nil, &confS, |
|
2934 |
__MKSMALLINT(x), |
|
2935 |
__MKSMALLINT(y), |
|
2936 |
__MKSMALLINT(w), |
|
2937 |
__MKSMALLINT(h), |
|
2938 |
theView); |
|
2939 |
break; |
|
2940 |
||
2941 |
case WM_SHOWWINDOW: |
|
2942 |
if (ev->ev_wParam == TRUE) { |
|
2943 |
DPRINTF(("got WM_SHOWWINDOW -> mappedView:\n")); |
|
2944 |
(*mapS.ilc_func)(self, |
|
2945 |
@symbol(mappedView:), |
|
2946 |
nil, &mapS, theView); |
|
2947 |
} else { |
|
2948 |
DPRINTF(("got WM_SHOWWINDOW -> unMappedView:\n")); |
|
2949 |
(*unmapS.ilc_func)(self, |
|
2950 |
@symbol(unmappedView:), |
|
2951 |
nil, &unmapS, theView); |
|
2952 |
} |
|
2953 |
break; |
|
2954 |
||
2955 |
case WM_DESTROY: |
|
2956 |
DPRINTF(("got WM_DESTROY -> destroyedView\n")); |
|
2957 |
(*destrS.ilc_func)(self, |
|
2958 |
@symbol(destroyedView:), |
|
2959 |
nil, &destrS, theView); |
|
2960 |
break; |
|
2961 |
||
2962 |
case WM_ACTIVATE: |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
2963 |
DPRINTF(("got WM_ACTIVATE h=%x\n", ev->ev_hWnd)); |
1127 | 2964 |
switch (LOWORD(ev->ev_wParam)) { |
2965 |
case WA_INACTIVE: |
|
2966 |
(*focOutS.ilc_func)(self, |
|
2967 |
@symbol(focusOutView:), |
|
2968 |
nil, |
|
2969 |
&focOutS, |
|
2970 |
theView); |
|
2971 |
break; |
|
2972 |
case WA_ACTIVE: |
|
2973 |
case WA_CLICKACTIVE: |
|
2974 |
(*focInS.ilc_func)(self, |
|
2975 |
@symbol(focusInView:), |
|
2976 |
nil, |
|
2977 |
&focInS, |
|
2978 |
theView); |
|
2979 |
break; |
|
2980 |
default: |
|
2981 |
break; |
|
2982 |
} |
|
2983 |
break; |
|
2984 |
||
2985 |
case WM_MOUSEACTIVATE: |
|
2986 |
(*focInS.ilc_func)(self, |
|
2987 |
@symbol(focusInView:), |
|
2988 |
nil, |
|
2989 |
&focInS, |
|
2990 |
theView); |
|
2991 |
break; |
|
2992 |
||
2993 |
case WM_SETFOCUS: |
|
2994 |
(*focInS.ilc_func)(self, |
|
2995 |
@symbol(focusInView:), |
|
2996 |
nil, |
|
2997 |
&focInS, |
|
2998 |
theView); |
|
2999 |
break; |
|
3000 |
||
3001 |
case WM_KILLFOCUS: |
|
3002 |
(*focOutS.ilc_func)(self, |
|
3003 |
@symbol(focusOutView:), |
|
3004 |
nil, |
|
3005 |
&focOutS, |
|
3006 |
theView); |
|
3007 |
break; |
|
3008 |
||
3009 |
case WM_ERASEBKGND: |
|
3010 |
x = ev->ev_x; |
|
3011 |
y = ev->ev_y; |
|
3012 |
w = ev->ev_w; |
|
3013 |
h = ev->ev_h; |
|
3014 |
||
3015 |
DPRINTF(("WM_ERASEBK -> clear %d/%d -> %d/%d\n", x, y, w, h)); |
|
3016 |
(*clrS.ilc_func)(self, |
|
3017 |
@symbol(clearX:y:width:height:view:), |
|
3018 |
nil, &clrS, |
|
3019 |
__MKSMALLINT(x), |
|
3020 |
__MKSMALLINT(y), |
|
3021 |
__MKSMALLINT(w), |
|
3022 |
__MKSMALLINT(h), |
|
3023 |
theView); |
|
3024 |
goto expose; |
|
3025 |
break; |
|
3026 |
||
3027 |
case WM_PAINT: |
|
3028 |
x = ev->ev_x; |
|
3029 |
y = ev->ev_y; |
|
3030 |
w = ev->ev_w; |
|
3031 |
h = ev->ev_h; |
|
3032 |
||
3033 |
expose: |
|
3034 |
DPRINTF(("WM_PAINT -> expose %d/%d -> %d/%d\n", x, y, w, h)); |
|
3035 |
(*expS.ilc_func)(self, |
|
3036 |
@symbol(exposeX:y:width:height:view:), |
|
3037 |
nil, &expS, |
|
3038 |
__MKSMALLINT(x), |
|
3039 |
__MKSMALLINT(y), |
|
3040 |
__MKSMALLINT(w), |
|
3041 |
__MKSMALLINT(h), |
|
3042 |
theView); |
|
3043 |
break; |
|
3044 |
||
3045 |
case WM_LBUTTONDBLCLK: |
|
3046 |
isDoubleClick = 1; |
|
3047 |
butt = __MKSMALLINT(1); |
|
3048 |
goto commonButtonDown; |
|
3049 |
||
3050 |
case WM_LBUTTONUP: |
|
3051 |
isDown = 0; |
|
3052 |
butt = __MKSMALLINT(1); |
|
3053 |
goto commonButtonDown; |
|
3054 |
||
3055 |
case WM_LBUTTONDOWN: |
|
3056 |
butt = __MKSMALLINT(1); |
|
3057 |
goto commonButtonDown; |
|
3058 |
||
3059 |
case WM_MBUTTONDBLCLK: |
|
3060 |
isDoubleClick = 1; |
|
3061 |
butt = __MKSMALLINT(2); |
|
3062 |
goto commonButtonDown; |
|
3063 |
||
3064 |
case WM_MBUTTONUP: |
|
3065 |
isDown = 0; |
|
3066 |
butt = __MKSMALLINT(2); |
|
3067 |
goto commonButtonDown; |
|
3068 |
||
3069 |
case WM_MBUTTONDOWN: |
|
3070 |
butt = __MKSMALLINT(2); |
|
3071 |
goto commonButtonDown; |
|
3072 |
||
3073 |
case WM_RBUTTONDBLCLK: |
|
3074 |
isDoubleClick = 1; |
|
3075 |
butt = __MKSMALLINT(3); |
|
3076 |
goto commonButtonDown; |
|
3077 |
||
3078 |
case WM_RBUTTONUP: |
|
3079 |
isDown = 0; |
|
3080 |
butt = __MKSMALLINT(3); |
|
3081 |
goto commonButtonDown; |
|
3082 |
||
3083 |
case WM_RBUTTONDOWN: |
|
3084 |
butt = __MKSMALLINT(3); |
|
3085 |
goto commonButtonDown; |
|
3086 |
||
3087 |
commonButtonDown: |
|
3088 |
x = ev->ev_x; |
|
3089 |
y = ev->ev_y; |
|
3090 |
modifiers = ev->ev_modifiers; |
|
3091 |
||
3092 |
if (isDown) { |
|
3093 |
buttonWindow = ev->ev_hWnd; |
|
3094 |
} else { |
|
3095 |
buttonWindow = (HWND)0; |
|
3096 |
} |
|
3097 |
||
3098 |
if (__INST(buttonTranslation) != nil) { |
|
3099 |
butt = __AT_(__INST(buttonTranslation), butt); |
|
3100 |
} |
|
3101 |
arg = butt; |
|
3102 |
||
3103 |
__INST(altDown) = (modifiers & AltMask) ? true : false; |
|
3104 |
__INST(metaDown) = (modifiers & MetaMask) ? true : false; |
|
3105 |
__INST(shiftDown) = (modifiers & ShiftMask) ? true : false; |
|
3106 |
__INST(ctrlDown) = (modifiers & ControlMask) ? true : false; |
|
3107 |
||
3108 |
freeEvent(ev); ev = NULL; |
|
3109 |
||
3110 |
if (isDoubleClick) { |
|
3111 |
ipS = &bmpS; |
|
3112 |
symS = @symbol(buttonMultiPress:x:y:view:); |
|
3113 |
} else { |
|
3114 |
if (isDown) { |
|
3115 |
if (modifiers & ShiftMask) { |
|
3116 |
ipS = &bspS; |
|
3117 |
symS = @symbol(buttonShiftPress:x:y:view:); |
|
3118 |
} else { |
|
3119 |
ipS = &bpS; |
|
3120 |
symS = @symbol(buttonPress:x:y:view:); |
|
3121 |
} |
|
3122 |
} else { |
|
3123 |
ipS = &brS; |
|
3124 |
symS = @symbol(buttonRelease:x:y:view:); |
|
3125 |
} |
|
3126 |
} |
|
3127 |
||
3128 |
if (__isSymbol(arg)) { |
|
3129 |
DPRINTF(("buttonPress/buttonRelease: %s %d/%d\n", |
|
3130 |
__stringVal(arg), x, y)); |
|
3131 |
} else { |
|
3132 |
DPRINTF(("buttonPress/buttonRelease: %d %d/%d\n", |
|
3133 |
__intVal(arg), x, y)); |
|
3134 |
} |
|
3135 |
||
3136 |
(*(*ipS).ilc_func)(self, symS, nil, ipS, |
|
3137 |
arg, |
|
3138 |
__MKSMALLINT(x), |
|
3139 |
__MKSMALLINT(y), |
|
3140 |
theView); |
|
3141 |
break; |
|
3142 |
||
3143 |
case WM_MOUSEMOVE: |
|
3144 |
x = ev->ev_x; |
|
3145 |
y = ev->ev_y; |
|
3146 |
state = 0; |
|
3147 |
if (ev->ev_wParam & MK_CONTROL) |
|
3148 |
state |= ControlMask; |
|
3149 |
if (ev->ev_wParam & MK_LBUTTON) |
|
3150 |
state |= Button1Mask; |
|
3151 |
if (ev->ev_wParam & MK_MBUTTON) |
|
3152 |
state |= Button2Mask; |
|
3153 |
if (ev->ev_wParam & MK_RBUTTON) |
|
3154 |
state |= Button3Mask; |
|
3155 |
if (ev->ev_wParam & MK_SHIFT) |
|
3156 |
state |= ShiftMask; |
|
3157 |
DPRINTF(("buttonMotion: %d/%d\n", x, y)); |
|
3158 |
||
3159 |
#ifdef NOTDEF |
|
3160 |
if (buttonWindow) { |
|
3161 |
if (buttonWindow != ev->ev_hWnd) { |
|
3162 |
/* |
|
3163 |
* translate for window, where button was pressed |
|
3164 |
* originally (X motion semantics) |
|
3165 |
*/ |
|
3166 |
{ |
|
3167 |
POINT p; |
|
3168 |
||
3169 |
p.x = x; |
|
3170 |
p.y = y; |
|
3171 |
MapWindowPoints(ev->ev_hWnd, buttonWindow, &p, 1); |
|
3172 |
x = p.x; |
|
3173 |
y = p.y; |
|
3174 |
DPRINTF(("xlated to %d/%d for %x\n", |
|
3175 |
x, y, buttonWindow)); |
|
3176 |
} |
|
3177 |
windowID = __MKOBJ(buttonWindow); |
|
3178 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:), |
|
3179 |
nil, &vid, windowID); |
|
3180 |
} |
|
3181 |
} |
|
3182 |
#endif |
|
3183 |
||
3184 |
(*motS.ilc_func)(self, @symbol(buttonMotion:x:y:view:), |
|
3185 |
nil, &motS, |
|
3186 |
__MKSMALLINT(state), |
|
3187 |
__MKSMALLINT(x), |
|
3188 |
__MKSMALLINT(y), |
|
3189 |
theView); |
|
3190 |
break; |
|
3191 |
||
3192 |
case WM_CHAR: |
|
3193 |
symS = @symbol(keyPress:x:y:view:); |
|
3194 |
ipS = &skpS; |
|
3195 |
upDown = true; |
|
3196 |
goto keyPressAndRelease; |
|
3197 |
||
3198 |
case WM_SYSKEYUP: |
|
3199 |
case WM_KEYUP: |
|
3200 |
symS = @symbol(keyRelease:x:y:view:); |
|
3201 |
ipS = &skrS; |
|
3202 |
upDown = false; |
|
3203 |
goto keyPressAndRelease; |
|
3204 |
||
3205 |
case WM_SYSKEYDOWN: |
|
3206 |
case WM_KEYDOWN: |
|
3207 |
symS = @symbol(keyPress:x:y:view:); |
|
3208 |
ipS = &skpS; |
|
3209 |
upDown = true; |
|
3210 |
/* FALL INTO */ |
|
3211 |
||
3212 |
keyPressAndRelease: ; |
|
3213 |
||
3214 |
x = ev->ev_x; |
|
3215 |
y = ev->ev_y; |
|
3216 |
||
3217 |
#ifdef NOTDEF |
|
3218 |
{ |
|
3219 |
BYTE vKeyState[256]; |
|
3220 |
char buff[5]; |
|
3221 |
||
3222 |
` GetKeyboardState(vKeyState); |
|
3223 |
ToAscii(ev->ev_keyCode, ev->ev_scanCode, vKeyState, &buff; 0); |
|
3224 |
} |
|
3225 |
#endif |
|
3226 |
||
3227 |
keyCode = ev->ev_keyCode; |
|
3228 |
modifiers = ev->ev_modifiers; |
|
3229 |
||
3230 |
if (modifiers & TRANSLATED_KEY) { |
|
3231 |
if (modifiers & ControlMask) { |
|
3232 |
if (keyCode < 0x20) { |
|
3233 |
keyCode = keyCode + 'a' - 1; |
|
3234 |
if (modifiers & ShiftMask) { |
|
3235 |
keyCode = keyCode - 'a' + 'A'; |
|
3236 |
} |
|
3237 |
} |
|
3238 |
} else if (modifiers & (MetaMask | AltMask)) { |
|
3239 |
if (! (modifiers & ShiftMask)) { |
|
3240 |
if ((keyCode >= 'A') && (keyCode <= 'Z')) { |
|
3241 |
keyCode = keyCode - 'A' + 'a'; |
|
3242 |
} |
|
3243 |
} |
|
3244 |
} |
|
3245 |
arg = __MKCHARACTER(keyCode & 0xFF); |
|
3246 |
} else { |
|
3247 |
switch (keyCode) { |
|
3248 |
case '\t': |
|
3249 |
arg = @symbol(Tab); |
|
3250 |
break; |
|
3251 |
||
3252 |
case '\b': |
|
3253 |
arg = @symbol(BackSpace); |
|
3254 |
break; |
|
3255 |
||
3256 |
case '\r': |
|
3257 |
arg = @symbol(Return); |
|
3258 |
break; |
|
3259 |
||
3260 |
case 0x1b: |
|
3261 |
arg = @symbol(Escape); |
|
3262 |
break; |
|
3263 |
||
3264 |
default: |
|
3265 |
nameBuffer[0] = 0; |
|
3266 |
GetKeyNameText(ev->ev_scanCode, nameBuffer, sizeof(nameBuffer)); |
|
3267 |
DPRINTF(("char is <%s>\n", nameBuffer)); |
|
3268 |
if (strlen(nameBuffer) == 1) { |
|
3269 |
arg = __MKCHARACTER(keyCode & 0xFF); |
|
3270 |
} else { |
|
3271 |
arg = __MKSYMBOL(nameBuffer); |
|
3272 |
} |
|
3273 |
break; |
|
3274 |
} |
|
3275 |
} |
|
3276 |
||
3277 |
DPRINTF(("%s: code=%x mod=%x\n", __stringVal(symS), |
|
3278 |
keyCode, modifiers)); |
|
3279 |
||
3280 |
__INST(altDown) = (modifiers & AltMask) ? true : false; |
|
3281 |
__INST(metaDown) = (modifiers & MetaMask) ? true : false; |
|
3282 |
__INST(shiftDown) = (modifiers & ShiftMask) ? true : false; |
|
3283 |
__INST(ctrlDown) = (modifiers & ControlMask) ? true : false; |
|
3284 |
||
3285 |
freeEvent(ev); ev = NULL; |
|
3286 |
||
3287 |
(*(*ipS).ilc_func)(self, symS, nil, ipS, |
|
3288 |
arg, |
|
3289 |
__MKSMALLINT(x), |
|
3290 |
__MKSMALLINT(y), |
|
3291 |
theView); |
|
3292 |
||
3293 |
break; |
|
3294 |
||
3295 |
default: |
|
3296 |
DPRINTF(("unhandled event: %x\n", ev->ev_message)); |
|
3297 |
break; |
|
3298 |
} |
|
3299 |
} |
|
3300 |
||
3301 |
if (ev) { |
|
3302 |
freeEvent(ev); |
|
3303 |
} |
|
3304 |
%}. |
|
3305 |
^ true |
|
3306 |
! |
|
3307 |
||
3308 |
dispatchPendingEvents |
|
3309 |
"central event handling method for modal operation. |
|
3310 |
(i.e. this is now only used in the modal debugger) |
|
3311 |
This code is somewhat special, since X has a concept of graphic |
|
3312 |
expose events (which are sent after a bitblt). After such a bitblt, |
|
3313 |
we only handle exposes until the graphicsExpose arrives. |
|
3314 |
Other systems may not need such a kludge" |
|
3315 |
||
3316 |
[self eventPendingWithSync:false] whileTrue:[ |
|
3317 |
self dispatchEventFor:nil withMask:nil |
|
3318 |
] |
|
3319 |
! |
|
3320 |
||
3321 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
|
3322 |
"dispose (throw away) specific events. If aWindowId is nil, |
|
3323 |
events matching the mask are thrown away regardless of which |
|
3324 |
view they are for. Otherwise, only matching events for that |
|
3325 |
view are flushed." |
|
3326 |
||
3327 |
%{ /* NOCONTEXT */ |
|
3328 |
||
3329 |
%}. |
|
3330 |
self primitiveFailed |
|
3331 |
! |
|
3332 |
||
3333 |
eventMaskFor:anEventSymbol |
|
3334 |
"return the eventMask bit-constant corresponding to an event symbol" |
|
3335 |
||
3336 |
%{ /* NOCONTEXT */ |
|
3337 |
||
3338 |
int m = 0; |
|
3339 |
||
3340 |
#ifdef NOTDEF |
|
3341 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
3342 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
3343 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
3344 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
3345 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
3346 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
3347 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
3348 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
3349 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
3350 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
3351 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
3352 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
3353 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
3354 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
3355 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
3356 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
3357 |
#endif |
|
3358 |
RETURN (__MKSMALLINT(m)); |
|
3359 |
%} |
|
3360 |
! |
|
3361 |
||
3362 |
eventPending |
|
3363 |
"return true, if any event is pending. |
|
3364 |
This looks for both the internal queue and the display connection." |
|
3365 |
||
3366 |
^ self eventPendingWithSync:false |
|
3367 |
! |
|
3368 |
||
3369 |
eventPending:anEventSymbol for:aWindowIdOrNil |
|
3370 |
"return true, if a specific event is pending" |
|
3371 |
||
3372 |
^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil withSync:false |
|
3373 |
! |
|
3374 |
||
3375 |
eventPendingWithSync:doSync |
|
3376 |
"return true, if any event is pending. |
|
3377 |
If doSync is true, do a sync output buffer before checking |
|
3378 |
(i.e. send all to the display and wait until its processed)." |
|
3379 |
||
3380 |
%{ /* UNLIMITEDSTACK */ |
|
3381 |
||
3382 |
DDPRINTF(("peek\n")); |
|
3383 |
getAllWinEvents(); |
|
3384 |
if (eventQueueHead) { |
|
3385 |
DDPRINTF(("peek - true\n")); |
|
3386 |
RETURN (true); |
|
3387 |
} |
|
3388 |
DDPRINTF(("peek - false\n")); |
|
3389 |
RETURN ( false ); |
|
3390 |
%} |
|
3391 |
! |
|
3392 |
||
3393 |
eventQueued |
|
3394 |
"return true, if any event is queued" |
|
3395 |
||
3396 |
^ self eventQueuedAlready |
|
3397 |
||
3398 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
3399 |
! |
|
3400 |
||
3401 |
eventQueuedAlready |
|
3402 |
"return true, if any event is queued internally. |
|
3403 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
3404 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
3405 |
the display connection)." |
|
3406 |
||
3407 |
%{ /* NOCONTEXT */ |
|
3408 |
||
3409 |
DDPRINTF(("peek q - ")); |
|
3410 |
if (eventQueueHead) { |
|
3411 |
DDPRINTF(("true\n")); |
|
3412 |
RETURN (true); |
|
3413 |
} |
|
3414 |
DDPRINTF(("false\n")); |
|
3415 |
RETURN ( false ); |
|
3416 |
%} |
|
3417 |
! |
|
3418 |
||
3419 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
|
3420 |
"return true, if any of the masked events is pending" |
|
3421 |
||
3422 |
%{ /* NOCONTEXT */ |
|
3423 |
||
3424 |
getAllWinEvents(); |
|
3425 |
DPRINTF(("peek mask %x - false\n", __intVal(anEventMask))); |
|
3426 |
||
3427 |
%}. |
|
3428 |
^ false |
|
3429 |
! |
|
3430 |
||
3431 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
|
3432 |
"return true, if any expose event is pending for a specific view, |
|
3433 |
or any view (if the arg is nil). |
|
3434 |
This is an X specific, only required after a scroll operation." |
|
3435 |
||
3436 |
%{ /* NOCONTEXT */ |
|
3437 |
||
3438 |
getAllWinEvents(); |
|
3439 |
DPRINTF(("peek view - false\n")); |
|
3440 |
%}. |
|
3441 |
^ false |
|
3442 |
! |
|
3443 |
||
3444 |
getEventFor:aViewIdOrNil withMask:eventMask |
|
3445 |
"read next event - put into local eventBuffer. |
|
3446 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
3447 |
otherwise only events for that specific view will be fetched. |
|
3448 |
Returns true, if there was an event, false otherwise." |
|
3449 |
||
3450 |
%{ /* NOCONTEXT */ |
|
3451 |
||
3452 |
getAllWinEvents(); |
|
3453 |
if (eventQueueHead) { |
|
3454 |
/* no need to copy into buffer */ |
|
3455 |
DDPRINTF(("get event - true\n")); |
|
3456 |
RETURN (true); |
|
3457 |
} |
|
3458 |
DPRINTF(("get event - false\n")); |
|
3459 |
%}. |
|
3460 |
^ false |
|
3461 |
! |
|
3462 |
||
3463 |
handleAllEvents |
|
3464 |
"from now on, handle any kind of event" |
|
3465 |
||
3466 |
! |
|
3467 |
||
3468 |
handleExposeOnlyFor:aView |
|
3469 |
"from now on, handle expose events only" |
|
3470 |
||
3471 |
! |
|
3472 |
||
3473 |
mappingChanged:what event:eB |
|
3474 |
"One of Keyboard-, Modifier- or PointerMap has change, probably by xmodmap. |
|
3475 |
Tell xlib about the fact." |
|
3476 |
||
3477 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
|
3478 |
self refreshKeyboardMapping:eB. |
|
3479 |
"Maybe some of our modifiers have been changed" |
|
3480 |
self initializeModifierMappings. |
|
3481 |
]. |
|
3482 |
||
3483 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
|
3484 |
! |
|
3485 |
||
3486 |
setEventMask:aMask in:aWindowId |
|
3487 |
"tell X that we are only interested in events from aMask, which |
|
3488 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
|
3489 |
||
3490 |
^ self |
|
3491 |
! ! |
|
3492 |
||
3493 |
!WinWorkstation methodsFor:'event sending'! |
|
3494 |
||
3495 |
sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId |
|
3496 |
"send a keyPress/Release or buttonPress/Release event to some (possibly alien) view. |
|
3497 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
|
3498 |
For buttonEvents, the keySymCodeOrButtonNr must be the buttons number (1, 2 ...); |
|
3499 |
for key events, it can be either a symbol (as listen in X's keySyms) |
|
3500 |
or a numeric keysym code. If state is nil, the modifier bits (shift & control) |
|
3501 |
are computed from the keyboardMap - if non-nil, these are passed as modifierbits. |
|
3502 |
The non-nil case is the lowlevel entry, where state must include any shift/ctrl information |
|
3503 |
(not very user friendly)" |
|
3504 |
||
3505 |
^ false |
|
3506 |
! |
|
3507 |
||
3508 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
|
3509 |
"send input to some other view, by simulating keyPress/keyRelease |
|
3510 |
events. |
|
3511 |
Only a few control characters are supported. |
|
3512 |
Notice: not all alien views allow this kind of synthetic input; |
|
3513 |
some simply ignore it." |
|
3514 |
||
3515 |
|control code state| |
|
3516 |
||
3517 |
aCharacterOrString isString ifTrue:[ |
|
3518 |
aCharacterOrString do:[:char | |
|
3519 |
self simulateKeyboardInput:char inViewId:viewId |
|
3520 |
]. |
|
3521 |
^ self |
|
3522 |
]. |
|
3523 |
||
3524 |
control := false. |
|
3525 |
code := aCharacterOrString asciiValue. |
|
3526 |
||
3527 |
(aCharacterOrString == Character cr) ifTrue:[ |
|
3528 |
code := #Return |
|
3529 |
] ifFalse:[ |
|
3530 |
(aCharacterOrString == Character tab) ifTrue:[ |
|
3531 |
code := #Tab |
|
3532 |
] ifFalse:[ |
|
3533 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
3534 |
code := #Escape |
|
3535 |
] |
|
3536 |
] |
|
3537 |
]. |
|
3538 |
||
3539 |
control ifTrue:[ |
|
3540 |
state := self controlMask |
|
3541 |
]. |
|
3542 |
||
3543 |
||
3544 |
"/ the stuff below should not be needed |
|
3545 |
"/ (sendKeyOrButtonevent should be able to figure out things itself) |
|
3546 |
"/ however, on some linux systems it seems to not work correctly. |
|
3547 |
"/ Hopefully, this is correct ... |
|
3548 |
||
3549 |
code isNumber ifTrue:[ |
|
3550 |
code >= $A asciiValue ifTrue:[ |
|
3551 |
code <= $Z asciiValue ifTrue:[ |
|
3552 |
state := self shiftMask |
|
3553 |
] |
|
3554 |
] |
|
3555 |
]. |
|
3556 |
||
3557 |
self sendKeyOrButtonEvent:#keyPress x:0 y:0 keyOrButton:code state:state toViewId:viewId. |
|
3558 |
self sendKeyOrButtonEvent:#keyRelease x:0 y:0 keyOrButton:code state:state toViewId:viewId |
|
3559 |
||
3560 |
" |
|
3561 |
sending input to some (possibly alien) view: |
|
3562 |
||
3563 |
|point id| |
|
3564 |
||
3565 |
point := Display pointFromUser. |
|
3566 |
id := Display viewIdFromPoint:point. |
|
3567 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
|
3568 |
" |
|
3569 |
||
3570 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
|
3571 |
! ! |
|
3572 |
||
3573 |
!WinWorkstation methodsFor:'font stuff'! |
|
3574 |
||
3575 |
createFontFor:aFontName |
|
3576 |
"a basic method for font allocation; this method allows |
|
3577 |
any font to be aquired (even those not conforming to |
|
3578 |
standard naming conventions, such as cursor, fixed or k14)" |
|
3579 |
||
3580 |
%{ |
|
3581 |
HGDIOBJ hFont; |
|
3582 |
char *fn; |
|
3583 |
||
3584 |
if (__isString(aFontName)) { |
|
3585 |
fn = __stringVal(aFontName); |
|
3586 |
if (strcmp(fn, "fixed") == 0) { |
|
3587 |
hFont = GetStockObject(ANSI_FIXED_FONT); |
|
3588 |
} else if (strcmp(fn, "variable") == 0) { |
|
3589 |
hFont = GetStockObject(ANSI_VAR_FONT); |
|
3590 |
} else { |
|
3591 |
hFont = (HGDIOBJ)0; |
|
3592 |
hFont = GetStockObject(ANSI_FIXED_FONT); |
|
3593 |
} |
|
3594 |
if (hFont) { |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3595 |
DPRINTF(("createFontFor:aFontName: %s -> %x\n", fn, hFont)); |
1127 | 3596 |
RETURN ( __MKOBJ(hFont) ); |
3597 |
} |
|
3598 |
} |
|
3599 |
%}. |
|
3600 |
^ nil |
|
3601 |
! |
|
3602 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3603 |
fontsInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3604 |
"return a set of all available font in aFamily/aFace/aStyle |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3605 |
on this display. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3606 |
On WinWorkStations there is curently no style or Face |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3607 |
But only those matching filter (if nonNIl)." |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3608 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3609 |
|allFonts fonts| |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3610 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3611 |
allFonts := self listOfAvailableFonts. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3612 |
allFonts isNil ifTrue:[^ nil]. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3613 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3614 |
fonts := Set new. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3615 |
allFonts do:[:fntDescr | |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3616 |
(aFamilyName sameAs:(fntDescr family)) ifTrue:[ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3617 |
(filter isNil or:[filter value:fntDescr]) ifTrue:[ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3618 |
fonts add:fntDescr |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3619 |
] |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3620 |
] |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3621 |
]. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3622 |
^ fonts |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3623 |
! |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3624 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3625 |
fontsInFamily:aFamilyName face:aFaceName filtering:filter |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3626 |
"return a set of all available fonts in aFamily/aFace on this display. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3627 |
On WinWorkStations there is curently Face |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3628 |
But only thise matching filter (if nonNil)." |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3629 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3630 |
|allFonts fonts| |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3631 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3632 |
allFonts := self listOfAvailableFonts. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3633 |
allFonts isNil ifTrue:[^ nil]. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3634 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3635 |
fonts := Set new. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3636 |
allFonts do:[:fntDescr | |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3637 |
(aFamilyName sameAs:(fntDescr family)) ifTrue:[ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3638 |
(filter isNil or:[filter value:fntDescr]) ifTrue:[ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3639 |
fonts add:fntDescr |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3640 |
] |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3641 |
] |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3642 |
]. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3643 |
^ fonts |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3644 |
! |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3645 |
|
1127 | 3646 |
fontMetricsOf:fontId into:aBlock |
3647 |
"evaluate aBlock, passing a fonts metrics as arguments" |
|
3648 |
||
3649 |
|encoding avgAscent avgDescent |
|
3650 |
maxAscent maxDescent minWidth maxWidth avgWidth| |
|
3651 |
||
3652 |
%{ |
|
3653 |
HGDIOBJ hFont; |
|
3654 |
HGDIOBJ prevFont; |
|
3655 |
HDC rootDC; |
|
3656 |
TEXTMETRIC tmet; |
|
3657 |
int len; |
|
3658 |
||
3659 |
if (ISCONNECTED) { |
|
3660 |
if (__isExternalAddress(fontId)) { |
|
3661 |
hFont = _HGDIOBJVal(fontId); |
|
3662 |
/* |
|
3663 |
* temporarily set this font in the root context |
|
3664 |
*/ |
|
3665 |
rootDC = __rootDC; |
|
3666 |
prevFont = SelectObject(rootDC, hFont); |
|
3667 |
GetTextMetrics(rootDC, &tmet); |
|
3668 |
SelectObject(rootDC, prevFont); |
|
3669 |
||
3670 |
avgAscent = __MKSMALLINT(tmet.tmAscent); |
|
3671 |
avgDescent = __MKSMALLINT(tmet.tmDescent); |
|
3672 |
maxAscent = __MKSMALLINT(tmet.tmAscent); |
|
3673 |
maxDescent = __MKSMALLINT(tmet.tmDescent); |
|
3674 |
minWidth = __MKSMALLINT(tmet.tmAveCharWidth); |
|
3675 |
maxWidth = __MKSMALLINT(tmet.tmMaxCharWidth); |
|
3676 |
avgWidth = __MKSMALLINT(tmet.tmAveCharWidth); |
|
3677 |
DPRINTF(("textMetrics h=%x avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n", |
|
3678 |
hFont, tmet.tmAscent, tmet.tmDescent, tmet.tmAveCharWidth, tmet.tmMaxCharWidth, |
|
3679 |
tmet.tmAveCharWidth)); |
|
3680 |
} |
|
3681 |
} |
|
3682 |
%}. |
|
3683 |
encoding := #iso8859. |
|
3684 |
aBlock value:encoding |
|
3685 |
value:avgAscent |
|
3686 |
value:avgDescent |
|
3687 |
value:maxAscent |
|
3688 |
value:maxDescent |
|
3689 |
value:minWidth |
|
3690 |
value:maxWidth |
|
3691 |
value:avgWidth |
|
3692 |
! |
|
3693 |
||
3694 |
fullNameOf:aFontId |
|
3695 |
"the fonts fullName - this is very device specific and should only be |
|
3696 |
used for user feed-back (for example: in the fontPanel). |
|
3697 |
If the display/font do not provide that info, return nil." |
|
3698 |
||
3699 |
^ nil |
|
3700 |
! |
|
3701 |
||
3702 |
getAvailableFontsMatching:pattern |
|
3703 |
"return an Array filled with font names matching aPattern" |
|
3704 |
||
3705 |
^ nil |
|
3706 |
! |
|
3707 |
||
3708 |
getDefaultFont |
|
3709 |
"return a default font id - used when class Font cannot |
|
3710 |
find anything usable" |
|
3711 |
||
3712 |
^ self createFontFor:'fixed' |
|
3713 |
! |
|
3714 |
||
3715 |
getFontWithFamily:familyString face:faceString |
|
3716 |
style:styleArgString size:sizeArg encoding:encodingSym |
|
3717 |
||
3718 |
"try to get the specified font, if not available, try next smaller |
|
3719 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
3720 |
as family and the other parameters as nil. For example, the cursor font |
|
3721 |
can be aquired that way." |
|
3722 |
||
3723 |
|styleString theName theId xlatedStyle id spacing| |
|
3724 |
||
3725 |
styleString := styleArgString. |
|
3726 |
||
3727 |
"special: if face is nil, allow access to X-fonts" |
|
3728 |
faceString isNil ifTrue:[ |
|
3729 |
sizeArg notNil ifTrue:[ |
|
3730 |
theName := familyString , '-' , sizeArg printString |
|
3731 |
] ifFalse:[ |
|
3732 |
theName := familyString |
|
3733 |
]. |
|
3734 |
theName isNil ifTrue:[ |
|
3735 |
" |
|
3736 |
mhmh - fall back to the default font |
|
3737 |
" |
|
3738 |
theName := 'fixed' |
|
3739 |
]. |
|
3740 |
theId := self createFontFor:theName. |
|
3741 |
theId isNil ifTrue:[ |
|
3742 |
theId := self getDefaultFont |
|
3743 |
]. |
|
3744 |
^ theId |
|
3745 |
]. |
|
3746 |
||
3747 |
"/ spacing other than 'normal' is contained as last component |
|
3748 |
"/ in style |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3749 |
styleString notNil ifTrue:[ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3750 |
((styleString endsWith:'-narrow') |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3751 |
or:[styleString endsWith:'-semicondensed']) ifTrue:[ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3752 |
|i| |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3753 |
i := styleString lastIndexOf:$-. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3754 |
spacing := styleString copyFrom:(i+1). |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3755 |
styleString := styleString copyTo:(i-1). |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3756 |
] ifFalse:[ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3757 |
spacing := 'normal'. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3758 |
]. |
1127 | 3759 |
]. |
3760 |
||
3761 |
xlatedStyle := styleString. |
|
3762 |
xlatedStyle notNil ifTrue:[ |
|
3763 |
xlatedStyle := xlatedStyle first asString |
|
3764 |
]. |
|
3765 |
||
3766 |
id := self |
|
3767 |
getFontWithFoundry:'*' |
|
3768 |
family:familyString asLowercase |
|
3769 |
weight:faceString |
|
3770 |
slant:xlatedStyle |
|
3771 |
spacing:spacing |
|
3772 |
pixelSize:nil |
|
3773 |
size:sizeArg |
|
3774 |
registry:encodingSym |
|
3775 |
encoding:'*'. |
|
3776 |
||
3777 |
id isNil ifTrue:[ |
|
3778 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
|
3779 |
"/ too stupid: encodings come in both cases |
|
3780 |
"/ and X does not ignore case |
|
3781 |
"/ |
|
3782 |
id := self |
|
3783 |
getFontWithFoundry:'*' |
|
3784 |
family:familyString asLowercase |
|
3785 |
weight:faceString |
|
3786 |
slant:xlatedStyle |
|
3787 |
spacing:spacing |
|
3788 |
pixelSize:nil |
|
3789 |
size:sizeArg |
|
3790 |
registry:encodingSym asUppercase |
|
3791 |
encoding:'*'. |
|
3792 |
id isNil ifTrue:[ |
|
3793 |
id := self |
|
3794 |
getFontWithFoundry:'*' |
|
3795 |
family:familyString asLowercase |
|
3796 |
weight:faceString |
|
3797 |
slant:xlatedStyle |
|
3798 |
spacing:spacing |
|
3799 |
pixelSize:nil |
|
3800 |
size:sizeArg |
|
3801 |
registry:encodingSym asLowercase |
|
3802 |
encoding:'*'. |
|
3803 |
] |
|
3804 |
] |
|
3805 |
]. |
|
3806 |
^ id |
|
3807 |
||
3808 |
"Modified: 24.2.1996 / 22:37:24 / cg" |
|
3809 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
|
3810 |
! |
|
3811 |
||
3812 |
getFontWithFoundry:foundry family:family weight:weight |
|
3813 |
slant:slant spacing:spc pixelSize:pSize size:size |
|
3814 |
registry:registry encoding:encoding |
|
3815 |
||
3816 |
"get the specified font, if not available, return nil. |
|
3817 |
This is the new font creation method - all others will be changed to |
|
3818 |
use this entry. |
|
3819 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
3820 |
||
3821 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
3822 |
family: 'helvetica' 'courier' 'times' ... |
|
3823 |
weight: 'bold' 'medium' 'demi' ... |
|
3824 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
3825 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
3826 |
pixelSize: 16,18 ... usually left empty |
|
3827 |
size: size in point (1/72th of an inch) |
|
3828 |
registry: iso8859, sgi ... '*' |
|
3829 |
encoding: vendor specific encoding (usually '*') |
|
3830 |
" |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3831 |
" |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3832 |
Windows 95 allows the creation of a font with the following parameters |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3833 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3834 |
nHeight |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3835 |
nWidth |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3836 |
nEscapement |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3837 |
nOrientation |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3838 |
fnWeight FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ... |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3839 |
fdwItalic TRUE or FALSE |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3840 |
fdwUnderline TRUE or FALSE |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3841 |
fdwStrikeOut TRUE or FALSE |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3842 |
fdwCharSet ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,... |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3843 |
fdwOutputPrecision DEFAULT, STRING, CHAR, ... |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3844 |
fdwClipPrecision DEFAULT, CHAR, STROKE, MASK, ... |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3845 |
fdwQuality DEFAULT, DRAFT, or PROOF. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3846 |
fdwPitchAndFamily |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3847 |
DEFAULT, FIXED or VARIABLE pitch |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3848 |
DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3849 |
lpszFace |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3850 |
Typeface Name |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3851 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3852 |
These two above descriptions will be matched as follows: |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3853 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3854 |
foundry - ignored |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3855 |
family - mapped to type face name. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3856 |
weight - mapped to fnWeight |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3857 |
slant - NOT USED INITIALLY user for style |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3858 |
spacing - NOT USED INITIALLY |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3859 |
pixelSize - NOT USED INITIALLY |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3860 |
size - mapped to nHeight |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3861 |
registry - NOT USED INITIALLY |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3862 |
encoding - NOT USED INITIALLY used for dwType device, raster or truetype |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3863 |
" |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3864 |
%{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3865 |
HGDIOBJ hFont; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3866 |
int nHeight, nWidth, nEscapement, nOrientation; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3867 |
char* work; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3868 |
char* work2; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3869 |
DWORD fnWeight; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3870 |
DWORD fdwItalic; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3871 |
DWORD fdwUnderline; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3872 |
DWORD fdwStrikeOut; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3873 |
DWORD fdwCharSet; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3874 |
DWORD fdwOutputPrecision; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3875 |
DWORD fdwClipPrecision; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3876 |
DWORD fdwQuality; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3877 |
DWORD fdwPitchAndFamily; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3878 |
LPCTSTR lpszFace; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3879 |
static char temp[33]; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3880 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3881 |
/* INITIALIZE */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3882 |
strcpy( temp, " " ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3883 |
lpszFace = &temp[0]; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3884 |
strcpy( lpszFace, "NULL" ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3885 |
nHeight = 0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3886 |
nWidth = 0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3887 |
nEscapement = 0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3888 |
nOrientation = 0; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3889 |
fnWeight = FW_NORMAL; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3890 |
fdwItalic = FALSE; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3891 |
fdwUnderline = FALSE; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3892 |
fdwStrikeOut = FALSE; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3893 |
fdwCharSet = ANSI_CHARSET; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3894 |
fdwOutputPrecision = OUT_DEFAULT_PRECIS; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3895 |
fdwClipPrecision = CLIP_DEFAULT_PRECIS; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3896 |
fdwQuality = DEFAULT_QUALITY; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3897 |
fdwPitchAndFamily = FF_DONTCARE; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3898 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3899 |
/* SET VALUES */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3900 |
if ( __isString( family ) ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3901 |
work = __stringVal( family ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3902 |
if ( strcmp( work, "nil" ) != 0 ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3903 |
strncpy( lpszFace, work, 32 ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3904 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3905 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3906 |
if( __isString( weight ) ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3907 |
work = __stringVal( weight ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3908 |
if( strcmp( work, "bold" ) == 0 ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3909 |
fnWeight = FW_BOLD; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3910 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3911 |
if( strcmp( work, "medium" ) == 0 ) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3912 |
fnWeight = FW_MEDIUM; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3913 |
} else { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3914 |
if( strcmp( work, "demi" ) == 0 ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3915 |
fnWeight = FW_LIGHT; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3916 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3917 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3918 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3919 |
if(__isSmallInteger( size ) ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3920 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3921 |
nHeight = __intVal( size ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3922 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3923 |
work2 = __stringVal( slant ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3924 |
work = __stringVal( slant ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3925 |
if( strncmp( work2, "italic", 6 ) == 0 ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3926 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3927 |
fdwItalic = TRUE; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3928 |
if( work2[6] = '-' ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3929 |
strncpy( work, &work2[7], ( strlen( work2 ) - 7 ) ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3930 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3931 |
if( strncmp( work, "underline", 9 ) == 0 ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3932 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3933 |
fdwUnderline = TRUE; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3934 |
if( work[10] == '-' ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3935 |
strncpy( work2, &work[11], ( strlen( work ) - 10 ) ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3936 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3937 |
if( strncmp( work2, "strikeOut", 9 ) == 0 ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3938 |
fdwStrikeOut = TRUE; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3939 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3940 |
hFont = CreateFont( nHeight, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3941 |
nWidth, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3942 |
nEscapement, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3943 |
nOrientation, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3944 |
fnWeight, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3945 |
fdwItalic, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3946 |
fdwUnderline, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3947 |
fdwStrikeOut, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3948 |
fdwCharSet, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3949 |
fdwOutputPrecision, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3950 |
fdwClipPrecision, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3951 |
fdwQuality, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3952 |
fdwPitchAndFamily, |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3953 |
lpszFace ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3954 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3955 |
if( hFont != NULL ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3956 |
{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3957 |
DPRINTF(("createFontWithFoundry: %x\n", hFont)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3958 |
RETURN ( __MKOBJ(hFont) ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3959 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3960 |
DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" )); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3961 |
%}. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3962 |
^ nil |
1127 | 3963 |
|
3964 |
" |
|
3965 |
Display getFontWithFoundry:'*' |
|
3966 |
family:'courier' |
|
3967 |
weight:'medium' |
|
3968 |
slant:'r' |
|
3969 |
spacing:nil |
|
3970 |
pixelSize:nil |
|
3971 |
size:13 |
|
3972 |
registry:'iso8859' |
|
3973 |
encoding:'*' |
|
3974 |
" |
|
3975 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3976 |
"new NT Version: 20.2.1997 / 22:33:29 / dq" |
1127 | 3977 |
! |
3978 |
||
3979 |
listOfAvailableFonts |
|
3980 |
"return a list with all available fonts on this display. |
|
3981 |
Since this takes a long time, keep the result of the query for the |
|
3982 |
next time. The elements of the returned collection are instances of |
|
3983 |
FontDescription." |
|
3984 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3985 |
|list typeFaceList| |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3986 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3987 |
listOfFonts isNil ifTrue:[ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3988 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3989 |
list := OrderedCollection new. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3990 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3991 |
typeFaceList := OrderedCollection new. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3992 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3993 |
%{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3994 |
HDC dc; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3995 |
HDC rootDC; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3996 |
rootDC = __rootDC; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3997 |
dc = CreateCompatibleDC( rootDC ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3998 |
if( EnumFonts( dc, NULL, EnumFPTypeFace, &(typeFaceList) ) ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
3999 |
DPRINTF(("EnumFants Successful - TypeFaces \n")); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4000 |
%}. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4001 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4002 |
Transcript showCR:typeFaceList. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4003 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4004 |
typeFaceList do:[:typeFace | |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4005 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4006 |
%{ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4007 |
HDC dc; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4008 |
HDC rootDC; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4009 |
char *cp; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4010 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4011 |
if (__isString(typeFace)) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4012 |
rootDC = __rootDC; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4013 |
dc = CreateCompatibleDC( rootDC ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4014 |
if( EnumFonts( dc, __stringVal(typeFace), EnumFontsProc, &(list) ) ) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4015 |
DPRINTF(("EnumFonts Successful\n")); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4016 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4017 |
%}. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4018 |
0 |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4019 |
]. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4020 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4021 |
Transcript showCR:list. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4022 |
listOfFonts := list collect:[ :anArray | |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4023 |
| fntDescr family face style size encoding | |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4024 |
family := anArray at:14. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4025 |
face := anArray at:5. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4026 |
style := anArray at:16. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4027 |
size := anArray at:1. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4028 |
encoding := anArray at:15. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4029 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4030 |
fntDescr := FontDescription |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4031 |
family:family |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4032 |
face:face |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4033 |
style:style |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4034 |
size:size |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4035 |
encoding:encoding. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4036 |
fntDescr |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4037 |
]. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4038 |
]. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4039 |
|
1127 | 4040 |
^ listOfFonts |
4041 |
||
4042 |
" |
|
4043 |
Display listOfAvailableFonts. |
|
4044 |
||
4045 |
Display getAvailableFontsMatching:'*'. |
|
4046 |
" |
|
4047 |
||
4048 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
|
4049 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
|
4050 |
! |
|
4051 |
||
4052 |
releaseFont:aFontId |
|
4053 |
||
4054 |
^ self |
|
4055 |
! |
|
4056 |
||
4057 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
|
4058 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
|
4059 |
on this display. |
|
4060 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
4061 |
||
4062 |
|sizes| |
|
4063 |
||
4064 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
|
4065 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
|
4066 |
"special: in X11R5 and above, size 0 means: |
|
4067 |
there are scaled versions in all sizes available" |
|
4068 |
||
4069 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
|
4070 |
]. |
|
4071 |
^ sizes |
|
4072 |
||
4073 |
" |
|
4074 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
4075 |
" |
|
4076 |
||
4077 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
4078 |
! |
|
4079 |
||
4080 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
|
4081 |
||
4082 |
%{ /* NOCONTEXT */ |
|
4083 |
char *cp; |
|
4084 |
int len, n, i1, i2, l; |
|
4085 |
OBJ cls; |
|
4086 |
int nInstBytes; |
|
4087 |
||
4088 |
if (ISCONNECTED) { |
|
4089 |
if (__bothSmallInteger(index1, index2) |
|
4090 |
&& __isExternalAddress(aFontId) |
|
4091 |
&& __isNonNilObject(aString)) { |
|
4092 |
HDC rootDC; |
|
4093 |
HGDIOBJ hFont; |
|
4094 |
SIZE tsize; |
|
4095 |
||
4096 |
rootDC = __rootDC; |
|
4097 |
hFont = _HGDIOBJVal(aFontId); |
|
4098 |
||
4099 |
i1 = __intVal(index1) - 1; |
|
4100 |
cls = __qClass(aString); |
|
4101 |
||
4102 |
if (i1 >= 0) { |
|
4103 |
i2 = __intVal(index2) - 1; |
|
4104 |
if (i2 < i1) { |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4105 |
RETURN ( __MKSMALLINT( 0 ) ); |
1127 | 4106 |
} |
4107 |
||
4108 |
cp = (char *) _stringVal(aString); |
|
4109 |
l = i2 - i1 + 1; |
|
4110 |
||
4111 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
4112 |
n = _stringSize(aString); |
|
4113 |
if (i2 < n) { |
|
4114 |
cp += i1; |
|
4115 |
||
4116 |
SelectObject(rootDC, hFont); |
|
4117 |
GetTextExtentPoint(rootDC, cp, l, &tsize); |
|
4118 |
RETURN ( __MKSMALLINT(tsize.cx) ); |
|
4119 |
} |
|
4120 |
} |
|
4121 |
||
4122 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
4123 |
cp += nInstBytes; |
|
4124 |
||
4125 |
if (__isBytes(aString)) { |
|
4126 |
n = __byteArraySize(aString) - nInstBytes; |
|
4127 |
if (i2 < n) { |
|
4128 |
cp += i1; |
|
4129 |
||
4130 |
SelectObject(rootDC, hFont); |
|
4131 |
GetTextExtentPoint(rootDC, cp, l, &tsize); |
|
4132 |
RETURN ( __MKSMALLINT(tsize.cx) ); |
|
4133 |
} |
|
4134 |
} |
|
4135 |
||
4136 |
#ifdef NOTDEF |
|
4137 |
/* TWOBYTESTRINGS */ |
|
4138 |
if (__isWords(aString)) { |
|
4139 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
4140 |
||
4141 |
if (i2 < n) { |
|
4142 |
union { |
|
4143 |
char b[2]; |
|
4144 |
unsigned short s; |
|
4145 |
} u; |
|
4146 |
int i; |
|
4147 |
XChar2b *cp2 = (XChar2b *)0; |
|
4148 |
int mustFree = 0; |
|
4149 |
||
4150 |
cp += (i1 * 2); |
|
4151 |
if (l > 1000) l = 1000; |
|
4152 |
||
4153 |
/* |
|
4154 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
4155 |
* X expects them MSB first |
|
4156 |
* convert as required |
|
4157 |
*/ |
|
4158 |
||
4159 |
u.s = 0x1234; |
|
4160 |
if (u.b[0] != 0x12) { |
|
4161 |
if (l <= NLOCALBUFFER) { |
|
4162 |
cp2 = xlatebuffer; |
|
4163 |
} else { |
|
4164 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
4165 |
mustFree = 1; |
|
4166 |
} |
|
4167 |
for (i=0; i<l; i++) { |
|
4168 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
4169 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
4170 |
} |
|
4171 |
cp = (char *) cp2; |
|
4172 |
} |
|
4173 |
BEGIN_INTERRUPTSBLOCKED |
|
4174 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
|
4175 |
END_INTERRUPTSBLOCKED |
|
4176 |
||
4177 |
if (mustFree) { |
|
4178 |
free(cp2); |
|
4179 |
} |
|
4180 |
||
4181 |
RETURN ( __MKSMALLINT(len) ); |
|
4182 |
} |
|
4183 |
} |
|
4184 |
#endif |
|
4185 |
} |
|
4186 |
} |
|
4187 |
} |
|
4188 |
#undef NLOCALBUFFER |
|
4189 |
%}. |
|
4190 |
self primitiveFailed. |
|
4191 |
^ nil |
|
4192 |
! ! |
|
4193 |
||
4194 |
!WinWorkstation methodsFor:'grabbing '! |
|
4195 |
||
4196 |
allowEvents:mode |
|
4197 |
! |
|
4198 |
||
4199 |
grabKeyboardIn:aWindowId |
|
4200 |
"grab the keyboard" |
|
4201 |
||
4202 |
! |
|
4203 |
||
4204 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
|
4205 |
"grap the pointer - return true if ok" |
|
4206 |
%{ |
|
4207 |
if (__isExternalAddress(aWindowId)) { |
|
4208 |
HWND hWnd = _HWNDVal(aWindowId); |
|
4209 |
||
4210 |
SetCapture(hWnd); |
|
4211 |
} |
|
4212 |
%}. |
|
4213 |
activePointerGrab := aWindowId. |
|
4214 |
^ true |
|
4215 |
! |
|
4216 |
||
4217 |
ungrabKeyboard |
|
4218 |
"release the keyboard" |
|
4219 |
||
4220 |
activeKeyboardGrab := nil |
|
4221 |
! |
|
4222 |
||
4223 |
ungrabPointer |
|
4224 |
"release the pointer" |
|
4225 |
||
4226 |
%{ |
|
4227 |
ReleaseCapture(); |
|
4228 |
%}. |
|
4229 |
activePointerGrab := nil |
|
4230 |
! ! |
|
4231 |
||
4232 |
!WinWorkstation methodsFor:'graphic context stuff'! |
|
4233 |
||
4234 |
noClipIn:aGCId |
|
4235 |
"disable clipping rectangle" |
|
4236 |
||
4237 |
%{ /* NOCONTEXT */ |
|
4238 |
||
4239 |
HDC hDC; |
|
4240 |
||
4241 |
if (__isExternalAddress(aGCId)) { |
|
4242 |
hDC = _HDCVal(aGCId); |
|
4243 |
RETURN (self); |
|
4244 |
} |
|
4245 |
%}. |
|
4246 |
self primitiveFailed |
|
4247 |
! |
|
4248 |
||
4249 |
setBackground:bgColorIndex in:aGCId |
|
4250 |
"set background color to be drawn with" |
|
4251 |
||
4252 |
%{ /* NOCONTEXT */ |
|
4253 |
||
4254 |
HDC hDC; |
|
4255 |
||
4256 |
if (__isExternalAddress(aGCId)) { |
|
4257 |
struct gcData *gcData = _GCDATA(aGCId); |
|
4258 |
COLORREF bgColor; |
|
4259 |
||
4260 |
hDC = _HDCVal(aGCId); |
|
4261 |
bgColor = (COLORREF)(__intVal(bgColorIndex)); |
|
4262 |
if (bgColor != gcData->bgColor) { |
|
4263 |
gcData->bgColor = bgColor; |
|
4264 |
SetBkColor(hDC, bgColor); |
|
4265 |
} |
|
4266 |
||
4267 |
DPRINTF(("setBackground: %x\n", bgColor)); |
|
4268 |
RETURN (self); |
|
4269 |
} |
|
4270 |
%}. |
|
4271 |
self primitiveFailed |
|
4272 |
! |
|
4273 |
||
4274 |
setBitmapMask:aBitmapId in:aGCId |
|
4275 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
|
4276 |
||
4277 |
%{ /* NOCONTEXT */ |
|
4278 |
||
4279 |
HDC hDC; |
|
4280 |
||
4281 |
if (__isExternalAddress(aGCId)) { |
|
4282 |
hDC = _HDCVal(aGCId); |
|
4283 |
RETURN (self); |
|
4284 |
} |
|
4285 |
%}. |
|
4286 |
self primitiveFailed |
|
4287 |
! |
|
4288 |
||
4289 |
setClipByChildren:aBool in:aGCId |
|
4290 |
"enable/disable drawing into child views" |
|
4291 |
||
4292 |
%{ /* NOCONTEXT */ |
|
4293 |
||
4294 |
HDC hDC; |
|
4295 |
||
4296 |
if (__isExternalAddress(aGCId)) { |
|
4297 |
hDC = _HDCVal(aGCId); |
|
4298 |
RETURN (self); |
|
4299 |
} |
|
4300 |
%}. |
|
4301 |
self primitiveFailed |
|
4302 |
! |
|
4303 |
||
4304 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
|
4305 |
"clip to a rectangle" |
|
4306 |
||
4307 |
%{ /* NOCONTEXT */ |
|
4308 |
||
4309 |
HDC hDC; |
|
4310 |
||
4311 |
if (__isExternalAddress(aGCId)) { |
|
4312 |
hDC = _HDCVal(aGCId); |
|
4313 |
RETURN (self); |
|
4314 |
} |
|
4315 |
%}. |
|
4316 |
self primitiveFailed |
|
4317 |
! |
|
4318 |
||
4319 |
setDashes:dashList dashOffset:offset in:aGCId |
|
4320 |
"set line attributes" |
|
4321 |
||
4322 |
%{ /* NOCONTEXT */ |
|
4323 |
||
4324 |
HDC hDC; |
|
4325 |
||
4326 |
if (__isExternalAddress(aGCId)) { |
|
4327 |
hDC = _HDCVal(aGCId); |
|
4328 |
RETURN (self); |
|
4329 |
} |
|
4330 |
%}. |
|
4331 |
self primitiveFailed |
|
4332 |
! |
|
4333 |
||
4334 |
setFont:aFontId in:aGCId |
|
4335 |
"set font to be drawn in" |
|
4336 |
||
4337 |
%{ /* NOCONTEXT */ |
|
4338 |
||
4339 |
if (__isExternalAddress(aGCId) |
|
4340 |
&& __isExternalAddress(aFontId)) { |
|
4341 |
struct gcData *gcData = _GCDATA(aGCId); |
|
4342 |
HDC hDC; |
|
4343 |
HGDIOBJ hFont; |
|
4344 |
TEXTMETRIC tmet; |
|
4345 |
||
4346 |
hDC = gcData->hDC; |
|
4347 |
hFont = _HGDIOBJVal(aFontId); |
|
4348 |
||
4349 |
SelectObject(hDC, hFont); |
|
4350 |
GetTextMetrics(hDC, &tmet); |
|
4351 |
gcData->fontAscent = tmet.tmAscent; |
|
4352 |
DPRINTF(("setFont: %x\n", hFont)); |
|
4353 |
RETURN ( self ); |
|
4354 |
} |
|
4355 |
%}. |
|
4356 |
self primitiveFailed |
|
4357 |
! |
|
4358 |
||
4359 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
|
4360 |
"set foreground and background colors to be drawn with" |
|
4361 |
||
4362 |
%{ /* NOCONTEXT */ |
|
4363 |
||
4364 |
HDC hDC; |
|
4365 |
||
4366 |
if (__isExternalAddress(aGCId)) { |
|
4367 |
struct gcData *gcData = _GCDATA(aGCId); |
|
4368 |
COLORREF fgColor, bgColor; |
|
4369 |
||
4370 |
hDC = gcData->hDC; |
|
4371 |
fgColor = (COLORREF)(__intVal(fgColorIndex)); |
|
4372 |
if (fgColor != gcData->fgColor) { |
|
4373 |
gcData->fgColor = fgColor; |
|
4374 |
if (gcData->hBrush) { |
|
4375 |
DeleteObject(gcData->hBrush); |
|
4376 |
gcData->hBrush = (HBRUSH)0; |
|
4377 |
} |
|
4378 |
SetTextColor(hDC, fgColor); |
|
4379 |
} |
|
4380 |
||
4381 |
bgColor = (COLORREF)(__intVal(bgColorIndex)); |
|
4382 |
if (bgColor != gcData->bgColor) { |
|
4383 |
gcData->bgColor = bgColor; |
|
4384 |
SetBkColor(hDC, bgColor); |
|
4385 |
} |
|
4386 |
||
4387 |
DDPRINTF(("setForeground: %x background: %x\n", fgColor, bgColor)); |
|
4388 |
RETURN (self); |
|
4389 |
} |
|
4390 |
%}. |
|
4391 |
self primitiveFailed |
|
4392 |
! |
|
4393 |
||
4394 |
setForeground:fgColorIndex background:bgColorIndex mask:aBitmapId in:aGCId |
|
4395 |
"set foreground and background colors to be drawn with using mask or |
|
4396 |
solid (if aBitmapId is nil)" |
|
4397 |
||
4398 |
%{ /* NOCONTEXT */ |
|
4399 |
||
4400 |
HDC hDC; |
|
4401 |
||
4402 |
if (__isExternalAddress(aGCId)) { |
|
4403 |
struct gcData *gcData = _GCDATA(aGCId); |
|
4404 |
COLORREF fgColor, bgColor; |
|
4405 |
||
4406 |
hDC = _HDCVal(aGCId); |
|
4407 |
||
4408 |
fgColor = (COLORREF)(__intVal(fgColorIndex)); |
|
4409 |
if (fgColor != gcData->fgColor) { |
|
4410 |
gcData->fgColor = fgColor; |
|
4411 |
if (gcData->hBrush) { |
|
4412 |
DeleteObject(gcData->hBrush); |
|
4413 |
gcData->hBrush = (HBRUSH)0; |
|
4414 |
} |
|
4415 |
SetTextColor(hDC, fgColor); |
|
4416 |
} |
|
4417 |
bgColor = (COLORREF)(__intVal(bgColorIndex)); |
|
4418 |
if (bgColor != gcData->bgColor) { |
|
4419 |
gcData->bgColor = bgColor; |
|
4420 |
SetBkColor(hDC, bgColor); |
|
4421 |
} |
|
4422 |
||
4423 |
DDPRINTF(("setForeground: %x background: %x\n", fgColor, bgColor)); |
|
4424 |
RETURN (self); |
|
4425 |
} |
|
4426 |
%}. |
|
4427 |
self primitiveFailed |
|
4428 |
! |
|
4429 |
||
4430 |
setForeground:fgColorIndex background:bgColorIndex mask:aBitmapId lineWidth:lw in:aGCId |
|
4431 |
"set foreground and background colors to be drawn with using mask or |
|
4432 |
solid (if aBitmapId is nil); also set lineWidth" |
|
4433 |
||
4434 |
%{ /* NOCONTEXT */ |
|
4435 |
||
4436 |
HDC hDC; |
|
4437 |
||
4438 |
if (__isExternalAddress(aGCId)) { |
|
4439 |
struct gcData *gcData = _GCDATA(aGCId); |
|
4440 |
COLORREF fgColor, bgColor; |
|
4441 |
||
4442 |
hDC = _HDCVal(aGCId); |
|
4443 |
||
4444 |
fgColor = (COLORREF)(__intVal(fgColorIndex)); |
|
4445 |
if (fgColor != gcData->fgColor) { |
|
4446 |
gcData->fgColor = fgColor; |
|
4447 |
if (gcData->hBrush) { |
|
4448 |
DeleteObject(gcData->hBrush); |
|
4449 |
gcData->hBrush = (HBRUSH)0; |
|
4450 |
} |
|
4451 |
SetTextColor(hDC, fgColor); |
|
4452 |
} |
|
4453 |
bgColor = (COLORREF)(__intVal(bgColorIndex)); |
|
4454 |
if (bgColor != gcData->bgColor) { |
|
4455 |
gcData->bgColor = bgColor; |
|
4456 |
SetBkColor(hDC, bgColor); |
|
4457 |
} |
|
4458 |
||
4459 |
if (__intVal(lw) != gcData->lineWidth) { |
|
4460 |
if (gcData->hPen) { |
|
4461 |
DeleteObject(gcData->hPen); |
|
4462 |
gcData->hPen = (HPEN)0; |
|
4463 |
} |
|
4464 |
gcData->lineWidth = __intVal(lw); |
|
4465 |
} |
|
4466 |
||
4467 |
DDPRINTF(("setForeground: %x background: %x\n", fgColor, bgColor)); |
|
4468 |
RETURN (self); |
|
4469 |
} |
|
4470 |
%}. |
|
4471 |
self primitiveFailed |
|
4472 |
! |
|
4473 |
||
4474 |
setForeground:fgColorIndex in:aGCId |
|
4475 |
"set foreground color to be drawn with" |
|
4476 |
||
4477 |
%{ /* NOCONTEXT */ |
|
4478 |
||
4479 |
HDC hDC; |
|
4480 |
||
4481 |
if (__isExternalAddress(aGCId)) { |
|
4482 |
struct gcData *gcData = _GCDATA(aGCId); |
|
4483 |
COLORREF fgColor; |
|
4484 |
||
4485 |
hDC = _HDCVal(aGCId); |
|
4486 |
||
4487 |
fgColor = (COLORREF)(__intVal(fgColorIndex)); |
|
4488 |
if (fgColor != gcData->fgColor) { |
|
4489 |
gcData->fgColor = fgColor; |
|
4490 |
if (gcData->hBrush) { |
|
4491 |
DeleteObject(gcData->hBrush); |
|
4492 |
gcData->hBrush = (HBRUSH)0; |
|
4493 |
} |
|
4494 |
SetTextColor(hDC, fgColor); |
|
4495 |
} |
|
4496 |
||
4497 |
DDPRINTF(("setForeground: %x\n", fgColor)); |
|
4498 |
RETURN (self); |
|
4499 |
} |
|
4500 |
%}. |
|
4501 |
self primitiveFailed |
|
4502 |
! |
|
4503 |
||
4504 |
setFunction:aFunctionSymbol in:aGCId |
|
4505 |
"set alu function to be drawn with" |
|
4506 |
||
4507 |
%{ /* NOCONTEXT */ |
|
4508 |
||
4509 |
HDC hDC; |
|
4510 |
int fun; |
|
4511 |
||
4512 |
if (__isExternalAddress(aGCId)) { |
|
4513 |
hDC = _HDCVal(aGCId); |
|
4514 |
if (aFunctionSymbol == @symbol(copy)) fun = R2_COPYPEN; |
|
4515 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = R2_NOTCOPYPEN; |
|
4516 |
else if (aFunctionSymbol == @symbol(xor)) fun = R2_XORPEN; |
|
4517 |
else if (aFunctionSymbol == @symbol(and)) fun = R2_MASKPEN; |
|
4518 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = R2_MASKPENNOT; |
|
4519 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = R2_NOTMASKPEN; |
|
4520 |
else if (aFunctionSymbol == @symbol(or)) fun = R2_MERGEPEN; |
|
4521 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = R2_MERGEPENNOT; |
|
4522 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = R2_NOTMERGEPEN; |
|
4523 |
if (fun != -1) { |
|
4524 |
SetROP2(hDC, fun); |
|
4525 |
} |
|
4526 |
RETURN (self); |
|
4527 |
} |
|
4528 |
%}. |
|
4529 |
self primitiveFailed |
|
4530 |
! |
|
4531 |
||
4532 |
setGraphicsExposures:aBoolean in:aGCId |
|
4533 |
"set or clear the graphics exposures flag" |
|
4534 |
||
4535 |
! |
|
4536 |
||
4537 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
|
4538 |
"set line attributes" |
|
4539 |
||
4540 |
%{ /* NOCONTEXT */ |
|
4541 |
||
4542 |
HDC hDC; |
|
4543 |
||
4544 |
if (__isExternalAddress(aGCId) |
|
4545 |
&& __isSmallInteger(aNumber)) { |
|
4546 |
struct gcData *gcData = _GCDATA(aGCId); |
|
4547 |
hDC = _HDCVal(aGCId); |
|
4548 |
||
4549 |
if (gcData->hPen) { |
|
4550 |
DeleteObject(gcData->hPen); |
|
4551 |
gcData->hPen = (HBRUSH)0; |
|
4552 |
} |
|
4553 |
||
4554 |
gcData->lineWidth = __intVal(aNumber); |
|
4555 |
if (lineStyle == @symbol(solid)) { |
|
4556 |
gcData->lineStyle = PS_SOLID; |
|
4557 |
} else if (lineStyle == @symbol(dashed)) { |
|
4558 |
gcData->lineStyle = PS_DASH; |
|
4559 |
} else |
|
4560 |
gcData->lineStyle = PS_DASH; |
|
4561 |
||
4562 |
if (capStyle == @symbol(round)) { |
|
4563 |
gcData->capStyle = PS_ENDCAP_ROUND; |
|
4564 |
} else if (capStyle == @symbol(square)) { |
|
4565 |
gcData->capStyle = PS_ENDCAP_SQUARE; |
|
4566 |
} else if (capStyle == @symbol(flat)) { |
|
4567 |
gcData->capStyle = PS_ENDCAP_FLAT; |
|
4568 |
} else |
|
4569 |
gcData->capStyle = PS_ENDCAP_FLAT; |
|
4570 |
||
4571 |
if (joinStyle == @symbol(bevel)) { |
|
4572 |
gcData->joinStyle = PS_JOIN_BEVEL; |
|
4573 |
} else if (joinStyle == @symbol(miter)) { |
|
4574 |
gcData->joinStyle = PS_JOIN_MITER; |
|
4575 |
} else if (joinStyle == @symbol(round)) { |
|
4576 |
gcData->joinStyle = PS_JOIN_ROUND; |
|
4577 |
} else |
|
4578 |
gcData->joinStyle = PS_JOIN_MITER; |
|
4579 |
||
4580 |
RETURN (self); |
|
4581 |
} |
|
4582 |
%}. |
|
4583 |
self primitiveFailed |
|
4584 |
! |
|
4585 |
||
4586 |
setMaskOriginX:orgX y:orgY in:aGCId |
|
4587 |
"set the mask origin" |
|
4588 |
||
4589 |
%{ /* NOCONTEXT */ |
|
4590 |
||
4591 |
HDC hDC; |
|
4592 |
||
4593 |
if (__isExternalAddress(aGCId)) { |
|
4594 |
hDC = _HDCVal(aGCId); |
|
4595 |
RETURN (self); |
|
4596 |
} |
|
4597 |
%}. |
|
4598 |
self primitiveFailed |
|
4599 |
! |
|
4600 |
||
4601 |
setPixmapMask:aPixmapId in:aGCId |
|
4602 |
"set or clear the drawing mask - a pixmap mask providing full color" |
|
4603 |
||
4604 |
%{ /* NOCONTEXT */ |
|
4605 |
||
4606 |
HDC hDC; |
|
4607 |
||
4608 |
if (__isExternalAddress(aGCId)) { |
|
4609 |
hDC = _HDCVal(aGCId); |
|
4610 |
RETURN (self); |
|
4611 |
} |
|
4612 |
%}. |
|
4613 |
self primitiveFailed |
|
4614 |
! ! |
|
4615 |
||
4616 |
!WinWorkstation methodsFor:'initialize / release'! |
|
4617 |
||
4618 |
close |
|
4619 |
"close down the connection to the X-server" |
|
4620 |
||
4621 |
! |
|
4622 |
||
4623 |
initializeDefaultValues |
|
4624 |
buttonTranslation := ButtonTranslation. |
|
4625 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
4626 |
||
4627 |
self initializeModifierMappings |
|
4628 |
! |
|
4629 |
||
4630 |
initializeEventBuffer |
|
4631 |
! |
|
4632 |
||
4633 |
initializeFor:aDisplayName |
|
4634 |
"initialize the receiver for a connection to an X-Server; |
|
4635 |
the argument, aDisplayName may be nil (for the default server from |
|
4636 |
DISPLAY-variable or command line argument) or the name of the server |
|
4637 |
as hostname:number" |
|
4638 |
||
4639 |
%{ |
|
4640 |
int maxRGBDepth; |
|
4641 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
4642 |
int rgbVisualID; |
|
4643 |
int nvi, i; |
|
4644 |
int shapeEventBase, shapeErrorBase; |
|
4645 |
int shmEventBase, shmErrorBase; |
|
4646 |
int faxEventBase, faxErrorBase; |
|
4647 |
char *type, *nm; |
|
4648 |
int dummy; |
|
4649 |
OBJ dpyID; |
|
4650 |
||
4651 |
if (__INST(displayId) != nil) { |
|
4652 |
/* |
|
4653 |
* already connected - you bad guy try to |
|
4654 |
* trick me manually ? |
|
4655 |
*/ |
|
4656 |
RETURN ( self ); |
|
4657 |
} |
|
4658 |
||
4659 |
__INST(displayId) = __MKSMALLINT(1); |
|
4660 |
||
4661 |
%}. |
|
4662 |
||
4663 |
dispatching := false. |
|
4664 |
isSlow := false. |
|
4665 |
shiftDown := false. |
|
4666 |
ctrlDown := false. |
|
4667 |
metaDown := false. |
|
4668 |
altDown := false. |
|
4669 |
motionEventCompression := true. |
|
4670 |
buttonsPressed := 0. |
|
4671 |
||
4672 |
self initializeScreenProperties. |
|
4673 |
||
4674 |
self initializeDefaultValues. |
|
4675 |
self initializeEventBuffer. |
|
4676 |
self initializeSpecialFlags. |
|
4677 |
self initializeKeyboardMap. |
|
4678 |
! |
|
4679 |
||
4680 |
initializeModifierMappings |
|
4681 |
shiftModifiers := #(#'Shift_L' #'Shift_R' #'Shift'). |
|
4682 |
ctrlModifiers := #(#'Ctrl_L' #'Ctrl_R' #'Ctrl'). |
|
4683 |
metaModifiers := #(#'Alt_L' #'Alt'). |
|
4684 |
altModifiers := #(#'Alt_R'). |
|
4685 |
! |
|
4686 |
||
4687 |
initializeScreenProperties |
|
4688 |
super initializeScreenProperties. |
|
4689 |
||
4690 |
%{ /* NOCONTEXT */ |
|
4691 |
||
4692 |
int scr; |
|
4693 |
int maxRGBDepth; |
|
4694 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
4695 |
int nvi, i, val, capabilities, __depth; |
|
4696 |
char *type, *nm; |
|
4697 |
int dummy; |
|
4698 |
int mask, shift, nBits; |
|
4699 |
HWND _rootWin = NULL; |
|
4700 |
RECT rect; |
|
4701 |
HDC _rootDC; |
|
4702 |
OBJ id; |
|
4703 |
||
4704 |
_rootWin = GetDesktopWindow(); |
|
4705 |
__INST(rootWin) = id = __MKOBJ(_rootWin); __STORE(self, id); |
|
4706 |
||
4707 |
_rootDC = CreateDC("DISPLAY", NULL, NULL, NULL); |
|
4708 |
__INST(rootDC) = id = __MKOBJ(_rootDC); __STORE(self, id); |
|
4709 |
||
4710 |
GetWindowRect(_rootWin, &rect); |
|
4711 |
__INST(width) = __MKSMALLINT(rect.right-rect.left); |
|
4712 |
__INST(height) = __MKSMALLINT(rect.bottom-rect.top); |
|
4713 |
printf("screen is %d/%d\n", __intVal(__INST(width)), __intVal(__INST(height))); |
|
4714 |
||
4715 |
__depth = GetDeviceCaps(_rootDC, BITSPIXEL); |
|
4716 |
||
4717 |
__INST(depth) = __MKSMALLINT(__depth); |
|
4718 |
__INST(ncells) = __MKSMALLINT(1<<__depth); |
|
4719 |
||
4720 |
val = GetDeviceCaps(_rootDC, HORZSIZE); |
|
4721 |
__INST(widthMM) = __MKSMALLINT(val); |
|
4722 |
val = GetDeviceCaps(_rootDC, VERTSIZE); |
|
4723 |
__INST(heightMM) = __MKSMALLINT(val); |
|
4724 |
||
4725 |
||
4726 |
capabilities = GetDeviceCaps(_rootDC, RASTERCAPS); |
|
4727 |
||
4728 |
__INST(whitepixel) = __MKSMALLINT(RGB(0xFF, 0xFF, 0xFF)); |
|
4729 |
__INST(blackpixel) = __MKSMALLINT(RGB(0,0,0)); |
|
4730 |
||
4731 |
if (! (capabilities & RC_PALETTE)) { |
|
4732 |
DPRINTF(("no palette\n")); |
|
4733 |
if (__depth == 1) { |
|
4734 |
__INST(visualType) = @symbol(GrayScale); |
|
4735 |
__INST(hasColors) = false; |
|
4736 |
__INST(hasGreyscales) = false; |
|
4737 |
__INST(monitorType) = @symbol(monochrome); |
|
4738 |
} else { |
|
4739 |
__INST(visualType) = @symbol(StaticColor); |
|
4740 |
__INST(hasColors) = true; |
|
4741 |
__INST(hasGreyscales) = true; |
|
4742 |
} |
|
4743 |
} else { |
|
4744 |
val = GetDeviceCaps(_rootDC, SIZEPALETTE); /* First two entries are black and white. */ |
|
4745 |
||
4746 |
__INST(ncells) = __MKSMALLINT(val); |
|
4747 |
__INST(blackpixel) = __MKSMALLINT(0); |
|
4748 |
__INST(whitepixel) = __MKSMALLINT(1); |
|
4749 |
__INST(hasColors) = true; |
|
4750 |
__INST(hasGreyscales) = true; |
|
4751 |
} |
|
4752 |
||
4753 |
__INST(monitorType) = @symbol(unknown); |
|
4754 |
||
4755 |
__INST(redShift) = __MKSMALLINT(0); |
|
4756 |
__INST(greenShift) = __MKSMALLINT(8); |
|
4757 |
__INST(blueShift) = __MKSMALLINT(16); |
|
4758 |
__INST(bitsRed) = __INST(bitsGreen) = __INST(bitsBlue) = __MKSMALLINT(8); |
|
4759 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4760 |
__INST(resizeFrameWidth) = __MKSMALLINT(GetSystemMetrics(SM_CXSCREEN) - GetSystemMetrics(SM_CXFULLSCREEN)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
4761 |
__INST(resizeFrameHeight) = __MKSMALLINT(GetSystemMetrics(SM_CYSCREEN) - GetSystemMetrics(SM_CYFULLSCREEN)); |
1127 | 4762 |
DPRINTF(("fW=%d fH=%d\n", |
4763 |
__intVal(__INST(resizeFrameWidth)), |
|
4764 |
__intVal(__INST(resizeFrameHeight)) )); |
|
4765 |
%}. |
|
4766 |
! |
|
4767 |
||
4768 |
initializeSpecialFlags |
|
4769 |
"perform additional special server implementation flags" |
|
4770 |
! |
|
4771 |
||
4772 |
reinitialize |
|
4773 |
rootWin := rootDC := nil. |
|
4774 |
super reinitialize. |
|
4775 |
! ! |
|
4776 |
||
4777 |
!WinWorkstation methodsFor:'keyboard mapping'! |
|
4778 |
||
4779 |
altModifierMask |
|
4780 |
"return the mask (in motionEvents) for the alt-key modifier. |
|
4781 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
|
4782 |
therefore return a variable here, which can be changed during startup." |
|
4783 |
||
4784 |
%{ /* NOCONTEXT */ |
|
4785 |
RETURN (__MKSMALLINT(AltMask)); |
|
4786 |
%} |
|
4787 |
||
4788 |
"Created: 23.3.1996 / 12:43:22 / cg" |
|
4789 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
|
4790 |
! |
|
4791 |
||
4792 |
metaModifierMask |
|
4793 |
"return the mask (in motionEvents) for the meta-key modifier. |
|
4794 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
|
4795 |
therefore return a variable here, which can be changed during startup." |
|
4796 |
||
4797 |
%{ /* NOCONTEXT */ |
|
4798 |
RETURN (__MKSMALLINT(MetaMask)); |
|
4799 |
%} |
|
4800 |
||
4801 |
"Created: 23.3.1996 / 12:43:39 / cg" |
|
4802 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
|
4803 |
! |
|
4804 |
||
4805 |
leftAltMask |
|
4806 |
"return the mask bit for the left Alt modifier key. |
|
4807 |
See comment in altModifierMask: / metaModifierMask: for what |
|
4808 |
this could be used." |
|
4809 |
||
4810 |
%{ /* NOCONTEXT */ |
|
4811 |
RETURN (__MKSMALLINT(LeftAltMask)); |
|
4812 |
%} |
|
4813 |
! |
|
4814 |
||
4815 |
rightAltMask |
|
4816 |
"return the mask bit for the right Alt modifier key. |
|
4817 |
See comment in altModifierMask: / metaModifierMask: for what |
|
4818 |
this could be used." |
|
4819 |
||
4820 |
%{ /* NOCONTEXT */ |
|
4821 |
RETURN (__MKSMALLINT(RightAltMask)); |
|
4822 |
%} |
|
4823 |
! |
|
4824 |
||
4825 |
modifierMapping |
|
4826 |
"Get the Modifier Mapping. |
|
4827 |
We return an array of arrays of keycodes" |
|
4828 |
||
4829 |
^ nil |
|
4830 |
! |
|
4831 |
||
4832 |
stringFromKeycode:code |
|
4833 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
|
4834 |
||
4835 |
^ '' |
|
4836 |
||
4837 |
" |
|
4838 |
Display stringFromKeycode:28 |
|
4839 |
" |
|
4840 |
! |
|
4841 |
||
4842 |
translateKey:untranslatedKey |
|
4843 |
|key| |
|
4844 |
||
4845 |
(key := untranslatedKey) isCharacter ifFalse:[ |
|
4846 |
key := RawKeysymTranslation at:key ifAbsent:key. |
|
4847 |
key := key asSymbol. |
|
4848 |
'xlated: ' print. untranslatedKey print. ' to: ' print. key printCR. |
|
4849 |
]. |
|
4850 |
^ super translateKey:key |
|
4851 |
! ! |
|
4852 |
||
4853 |
!WinWorkstation methodsFor:'misc'! |
|
4854 |
||
4855 |
beep |
|
4856 |
"output an audible beep or bell" |
|
4857 |
||
4858 |
self beep:50 |
|
4859 |
! |
|
4860 |
||
4861 |
beep:volumeInPercent |
|
4862 |
"output an audible beep" |
|
4863 |
%{ |
|
4864 |
Beep(__intVal(@global(BeepFrequency)), __intVal(@global(BeepDuration))); |
|
4865 |
%} |
|
4866 |
! |
|
4867 |
||
4868 |
refreshKeyboardMapping:eB |
|
4869 |
! |
|
4870 |
||
4871 |
setInputFocusTo:aWindowId |
|
4872 |
self setInputFocusTo:aWindowId revertTo:nil |
|
4873 |
! |
|
4874 |
||
4875 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
|
4876 |
"set the focus to the view as defined by aWindowId. |
|
4877 |
Passing nil set the focus to no window and lets the display discard all |
|
4878 |
input until a new focus is set. |
|
4879 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
4880 |
passing one of #parent, #root or nil specifies that the focus should be |
|
4881 |
given to the parent view, the root view or no view." |
|
4882 |
||
4883 |
%{ |
|
4884 |
if (__isExternalAddress(aWindowId)) { |
|
4885 |
HWND hWnd = _HWNDVal(aWindowId); |
|
4886 |
||
4887 |
if (hWnd) { |
|
4888 |
SetFocus(hWnd); |
|
4889 |
} |
|
4890 |
RETURN ( self ); |
|
4891 |
} |
|
4892 |
%} |
|
4893 |
! ! |
|
4894 |
||
4895 |
!WinWorkstation methodsFor:'pointer queries '! |
|
4896 |
||
4897 |
anyButtonStateMask |
|
4898 |
"return an integer for masking out any button from a |
|
4899 |
buttonStates value." |
|
4900 |
||
4901 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
|
4902 |
||
4903 |
^ 256 + 512 + 1024 |
|
4904 |
||
4905 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
|
4906 |
"Created: 23.3.1996 / 12:46:35 / cg" |
|
4907 |
! |
|
4908 |
||
4909 |
buttonStates |
|
4910 |
"return an integer representing the state of the pointer buttons; |
|
4911 |
a one-bit in positions 0.. represent a pressed button. |
|
4912 |
See the button1Mask/button2Mask/button3Mask, |
|
4913 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
|
4914 |
||
4915 |
^ 0 |
|
4916 |
||
4917 |
||
4918 |
" |
|
4919 |
Display buttonStates |
|
4920 |
" |
|
4921 |
||
4922 |
"is the control-key pressed ? |
|
4923 |
||
4924 |
Display buttonStates bitTest:(Display controlMask) |
|
4925 |
" |
|
4926 |
||
4927 |
"is the alt/meta-key pressed ? |
|
4928 |
||
4929 |
Display buttonStates bitTest:(Display altModifierMask) |
|
4930 |
Display buttonStates bitTest:(Display metaModifierMask) |
|
4931 |
" |
|
4932 |
! |
|
4933 |
||
4934 |
leftButtonStateMask |
|
4935 |
"return an integer for masking out the left button from a |
|
4936 |
buttonStates value" |
|
4937 |
||
4938 |
"/ should use ``Display button1MotionMask'' |
|
4939 |
||
4940 |
^ 256 |
|
4941 |
||
4942 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
|
4943 |
! |
|
4944 |
||
4945 |
middleButtonStateMask |
|
4946 |
"return an integer for masking out the middle button from a |
|
4947 |
buttonStates value" |
|
4948 |
||
4949 |
"/ should use ``Display button2MotionMask'' |
|
4950 |
||
4951 |
^ 512 |
|
4952 |
||
4953 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
|
4954 |
! |
|
4955 |
||
4956 |
pointerPosition |
|
4957 |
"return the current pointer position in root-window coordinates" |
|
4958 |
||
4959 |
|xpos ypos| |
|
4960 |
||
4961 |
%{ |
|
4962 |
POINT p; |
|
4963 |
||
4964 |
if (GetCursorPos(&p)) { |
|
4965 |
xpos = __MKSMALLINT(p.x); |
|
4966 |
ypos = __MKSMALLINT(p.y); |
|
4967 |
} else { |
|
4968 |
xpos = ypos = __MKSMALLINT(0); |
|
4969 |
} |
|
4970 |
%}. |
|
4971 |
^ xpos @ ypos |
|
4972 |
! |
|
4973 |
||
4974 |
rightButtonStateMask |
|
4975 |
"return an integer for masking out the right button from a |
|
4976 |
buttonStates value" |
|
4977 |
||
4978 |
"/ should use ``Display button3MotionMask'' |
|
4979 |
||
4980 |
^ 1024 |
|
4981 |
||
4982 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
|
4983 |
! |
|
4984 |
||
4985 |
rootPositionOfLastEvent |
|
4986 |
"return the position in root-window coordinates |
|
4987 |
of the last button, key or pointer event" |
|
4988 |
||
4989 |
|x y| |
|
4990 |
||
4991 |
%{ |
|
4992 |
x = __MKSMALLINT(evRootX); |
|
4993 |
y = __MKSMALLINT(evRootY); |
|
4994 |
%}. |
|
4995 |
^ x @ y |
|
4996 |
! ! |
|
4997 |
||
4998 |
!WinWorkstation methodsFor:'retrieving pixels'! |
|
4999 |
||
5000 |
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
|
5001 |
"get bits from a drawable into the imageBits. The storage for the bits |
|
5002 |
must be big enough for the data to fit. If ok, returns an array with some |
|
5003 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
5004 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
5005 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
5006 |
||
5007 |
|rawInfo info| |
|
5008 |
||
5009 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
5010 |
self primitiveFailed. |
|
5011 |
^ nil |
|
5012 |
]. |
|
5013 |
||
5014 |
rawInfo := Array new:8. |
|
5015 |
"1 -> bit order" |
|
5016 |
"2 -> depth" |
|
5017 |
"3 -> bytes_per_line" |
|
5018 |
"4 -> byte_order" |
|
5019 |
"5 -> format" |
|
5020 |
"6 -> bitmap_unit" |
|
5021 |
"7 -> bitmap_pad" |
|
5022 |
"8 -> bits_per_pixel" |
|
5023 |
||
5024 |
"/ had to extract the getPixel call into a separate method, to specify |
|
5025 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
5026 |
"/ of temporary stack space |
|
5027 |
||
5028 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
|
5029 |
info := IdentityDictionary new. |
|
5030 |
info at:#bitOrder put:(rawInfo at:1). |
|
5031 |
info at:#depth put:(rawInfo at:2). |
|
5032 |
info at:#bytesPerLine put:(rawInfo at:3). |
|
5033 |
info at:#byteOrder put:(rawInfo at:4). |
|
5034 |
info at:#format put:(rawInfo at:5). |
|
5035 |
info at:#bitmapUnit put:(rawInfo at:6). |
|
5036 |
info at:#bitmapPad put:(rawInfo at:7). |
|
5037 |
info at:#bitsPerPixel put:(rawInfo at:8). |
|
5038 |
^ info |
|
5039 |
]. |
|
5040 |
" |
|
5041 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
5042 |
or is too small to hold the bits |
|
5043 |
" |
|
5044 |
^ self primitiveFailed |
|
5045 |
! |
|
5046 |
||
5047 |
getPixelX:x y:y from:aDrawableId |
|
5048 |
"return the pixel value at x/y; coordinates start at 0/0 for the upper left. |
|
5049 |
Nil is returned for invalid coordinates or if any other problem arises." |
|
5050 |
||
5051 |
^ nil |
|
5052 |
! |
|
5053 |
||
5054 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
|
5055 |
"since XGetImage may allocate huge amount of stack space |
|
5056 |
(some implementations use alloca), this must run with unlimited stack." |
|
5057 |
||
5058 |
^ false |
|
5059 |
! ! |
|
5060 |
||
5061 |
!WinWorkstation methodsFor:'window stuff'! |
|
5062 |
||
5063 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
|
5064 |
"clear a rectangular area to viewbackground" |
|
5065 |
%{ |
|
5066 |
DPRINTF(("clearRect\n")); |
|
5067 |
%}. |
|
5068 |
super clearRectangleX:x y:y width:width height:height in:aWindowId |
|
5069 |
! |
|
5070 |
||
5071 |
clearWindow:aWindowId |
|
5072 |
"clear a window to viewbackground" |
|
5073 |
||
5074 |
%{ |
|
5075 |
DPRINTF(("clearWin\n")); |
|
5076 |
%}. |
|
5077 |
super clearWindow:aWindowId |
|
5078 |
! |
|
5079 |
||
5080 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
|
5081 |
"configure stacking operation of aWindowId w.r.t siblingId" |
|
5082 |
||
5083 |
! |
|
5084 |
||
5085 |
lowerWindow:aWindowId |
|
5086 |
"bring a window to back" |
|
5087 |
||
5088 |
%{ /* NOCONTEXT */ |
|
5089 |
||
5090 |
if (__isExternalAddress(aWindowId)) { |
|
5091 |
HWND win = _HWNDVal(aWindowId); |
|
5092 |
||
5093 |
if (win) { |
|
5094 |
SetWindowPos(win, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); |
|
5095 |
||
5096 |
BringWindowToTop(win); |
|
5097 |
} |
|
5098 |
RETURN ( self ); |
|
5099 |
} |
|
5100 |
%}. |
|
5101 |
||
5102 |
! |
|
5103 |
||
5104 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
|
5105 |
"make a window visible - either as icon or as a real view - needed for restart" |
|
5106 |
||
5107 |
! |
|
5108 |
||
5109 |
mapWindow:aWindowId |
|
5110 |
"make a window visible" |
|
5111 |
||
5112 |
%{ /* NOCONTEXT */ |
|
5113 |
||
5114 |
if (__isExternalAddress(aWindowId)) { |
|
5115 |
HWND win = _HWNDVal(aWindowId); |
|
5116 |
||
5117 |
if (win) { |
|
5118 |
ShowWindow(win, SW_SHOW); |
|
5119 |
} |
|
5120 |
RETURN ( self ); |
|
5121 |
} |
|
5122 |
%}. |
|
5123 |
self primitiveFailed |
|
5124 |
! |
|
5125 |
||
5126 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
|
5127 |
"move and resize a window" |
|
5128 |
||
5129 |
%{ /* NOCONTEXT */ |
|
5130 |
||
5131 |
if (__isExternalAddress(aWindowId) |
|
5132 |
&& __bothSmallInteger(x, y) |
|
5133 |
&& __bothSmallInteger(w, h)) { |
|
5134 |
HWND win = _HWNDVal(aWindowId); |
|
5135 |
||
5136 |
if (win) { |
|
5137 |
SetWindowPos(win, (HWND)0, |
|
5138 |
__intVal(x), __intVal(y), |
|
5139 |
__intVal(w), __intVal(h), |
|
5140 |
SWP_NOACTIVATE | SWP_NOZORDER); |
|
5141 |
} |
|
5142 |
RETURN ( self ); |
|
5143 |
} |
|
5144 |
%}. |
|
5145 |
self primitiveFailed |
|
5146 |
! |
|
5147 |
||
5148 |
moveWindow:aWindowId x:x y:y |
|
5149 |
"move a window" |
|
5150 |
||
5151 |
%{ /* NOCONTEXT */ |
|
5152 |
||
5153 |
if (__isExternalAddress(aWindowId) |
|
5154 |
&& __bothSmallInteger(x, y)) { |
|
5155 |
HWND win = _HWNDVal(aWindowId); |
|
5156 |
||
5157 |
if (win) { |
|
5158 |
SetWindowPos(win, (HWND)0, |
|
5159 |
__intVal(x), __intVal(y), |
|
5160 |
0, 0, |
|
5161 |
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); |
|
5162 |
} |
|
5163 |
RETURN ( self ); |
|
5164 |
} |
|
5165 |
%}. |
|
5166 |
self primitiveFailed |
|
5167 |
! |
|
5168 |
||
5169 |
raiseWindow:aWindowId |
|
5170 |
"bring a window to front" |
|
5171 |
||
5172 |
%{ /* NOCONTEXT */ |
|
5173 |
||
5174 |
if (__isExternalAddress(aWindowId)) { |
|
5175 |
HWND hWnd = _HWNDVal(aWindowId); |
|
5176 |
||
5177 |
if (hWnd) { |
|
5178 |
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); |
|
5179 |
} |
|
5180 |
RETURN ( self ); |
|
5181 |
} |
|
5182 |
%}. |
|
5183 |
self primitiveFailed |
|
5184 |
! |
|
5185 |
||
5186 |
resizeWindow:aWindowId width:w height:h |
|
5187 |
"resize a window" |
|
5188 |
||
5189 |
%{ /* NOCONTEXT */ |
|
5190 |
||
5191 |
if (__isExternalAddress(aWindowId) |
|
5192 |
&& __bothSmallInteger(w, h)) { |
|
5193 |
HWND hWnd = _HWNDVal(aWindowId); |
|
5194 |
||
5195 |
if (hWnd) { |
|
5196 |
SetWindowPos(hWnd, (HWND)0, |
|
5197 |
0, 0, |
|
5198 |
__intVal(w), __intVal(h), |
|
5199 |
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); |
|
5200 |
} |
|
5201 |
RETURN ( self ); |
|
5202 |
} |
|
5203 |
%}. |
|
5204 |
self primitiveFailed |
|
5205 |
! |
|
5206 |
||
5207 |
setBackingStore:how in:aWindowId |
|
5208 |
"turn on/off backing-store for a window" |
|
5209 |
||
5210 |
! |
|
5211 |
||
5212 |
setBitGravity:how in:aWindowId |
|
5213 |
"set bit gravity for a window" |
|
5214 |
||
5215 |
! |
|
5216 |
||
5217 |
setCursor:aCursorId in:aWindowId |
|
5218 |
"define a windows cursor" |
|
5219 |
||
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5220 |
%{ /* NOCONTEXT */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5221 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5222 |
HCURSOR newCursor; |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5223 |
|
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5224 |
if (ISCONNECTED |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5225 |
&& __isExternalAddress(aWindowId) |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5226 |
&& __isExternalAddress(aCursorId)) { |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5227 |
/* XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); */ |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5228 |
newCursor = SetCursor(_HCURSORVal(aCursorId)); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5229 |
RETURN ( self ); |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5230 |
} |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5231 |
%}. |
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5232 |
self primitiveFailed |
1127 | 5233 |
! |
5234 |
||
5235 |
setIconName:aString in:aWindowId |
|
5236 |
"define a windows iconname" |
|
5237 |
||
5238 |
! |
|
5239 |
||
5240 |
setSaveUnder:yesOrNo in:aWindowId |
|
5241 |
"turn on/off save-under for a window" |
|
5242 |
||
5243 |
! |
|
5244 |
||
5245 |
setTransient:aWindowId for:aMainWindowId |
|
5246 |
"set aWindowId to be a transient of aMainWindow" |
|
5247 |
||
5248 |
! |
|
5249 |
||
5250 |
setWindowBackground:aColorIndex in:aWindowId |
|
5251 |
"set the windows background color. This is the color with which |
|
5252 |
the view is filled whenever exposed. Do not confuse this with |
|
5253 |
the background drawing color, which is used with opaque drawing." |
|
5254 |
||
5255 |
! |
|
5256 |
||
5257 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
|
5258 |
"set the windows background pattern to be a form. |
|
5259 |
This is the pattern with which the view is filled whenever exposed. |
|
5260 |
Do not confuse this with the background drawing color, which is used |
|
5261 |
with opaque drawing." |
|
5262 |
||
5263 |
! |
|
5264 |
||
5265 |
setWindowBorderColor:aColorIndex in:aWindowId |
|
5266 |
"set the windows border color" |
|
5267 |
||
5268 |
! |
|
5269 |
||
5270 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
|
5271 |
"set the windows border pattern" |
|
5272 |
||
5273 |
! |
|
5274 |
||
5275 |
setWindowBorderWidth:aNumber in:aWindowId |
|
5276 |
"set the windows border width" |
|
5277 |
||
5278 |
! |
|
5279 |
||
5280 |
setWindowClass:wClass name:wName in:aWindowId |
|
5281 |
"define class and name of a window. |
|
5282 |
This may be used by the window manager to |
|
5283 |
select client specific resources." |
|
5284 |
||
5285 |
! |
|
5286 |
||
5287 |
setWindowGravity:how in:aWindowId |
|
5288 |
"set window gravity for a window" |
|
5289 |
||
5290 |
! |
|
5291 |
||
5292 |
setWindowIcon:aForm in:aWindowId |
|
5293 |
"define a bitmap to be used as icon" |
|
5294 |
||
5295 |
! |
|
5296 |
||
5297 |
setWindowIconWindow:aView in:aWindowId |
|
5298 |
"define a window to be used as icon" |
|
5299 |
||
5300 |
! |
|
5301 |
||
5302 |
setWindowName:aString in:aWindowId |
|
5303 |
"define a windows name" |
|
5304 |
||
5305 |
%{ /* NOCONTEXT */ |
|
5306 |
||
5307 |
if (__isExternalAddress(aWindowId) |
|
5308 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
5309 |
HWND win = _HWNDVal(aWindowId); |
|
5310 |
||
5311 |
SetWindowText(win, __stringVal(aString)); |
|
5312 |
RETURN (self); |
|
5313 |
} |
|
5314 |
%}. |
|
5315 |
self primitiveFailed |
|
5316 |
! |
|
5317 |
||
5318 |
unmapWindow:aWindowId |
|
5319 |
"make a window invisible" |
|
5320 |
||
5321 |
%{ /* NOCONTEXT */ |
|
5322 |
||
5323 |
if (__isExternalAddress(aWindowId)) { |
|
5324 |
HWND win = _HWNDVal(aWindowId); |
|
5325 |
||
5326 |
if (win) { |
|
5327 |
ShowWindow(win, SW_HIDE); |
|
5328 |
} |
|
5329 |
RETURN ( self ); |
|
5330 |
} |
|
5331 |
%}. |
|
5332 |
self primitiveFailed |
|
5333 |
! ! |
|
5334 |
||
5335 |
!WinWorkstation class methodsFor:'documentation'! |
|
5336 |
||
5337 |
version |
|
1416
85b4e23ecd86
davids bitmap & font changes
Claus Gittinger <cg@exept.de>
parents:
1375
diff
changeset
|
5338 |
^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.19 1997-03-05 12:18:51 cg Exp $' |
1127 | 5339 |
! ! |
5340 |
||
5341 |
WinWorkstation initialize! |