--- a/WinWorkstation.st Wed Apr 12 19:30:34 2017 +0200
+++ b/WinWorkstation.st Wed Apr 12 20:05:59 2017 +0200
@@ -10738,22 +10738,22 @@
colors are allocated - otherwise the colors may be wrong."
(self
- primDrawBits:imageBits
- bitsPerPixel:bitsPerPixel
- depth:imageDepth
- width:imageWidth height:imageHeight
- x:srcx y:srcy
- into:ignoredDrawableId
- x:dstx y:dsty
- width:w height:h
- with:aGCId
- parameters:(Array with:nil with:padd with:nil with:nil with:nil)
- "/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
+ primDrawBits:imageBits
+ bitsPerPixel:bitsPerPixel
+ depth:imageDepth
+ width:imageWidth height:imageHeight
+ x:srcx y:srcy
+ into:ignoredDrawableId
+ x:dstx y:dsty
+ width:w height:h
+ with:aGCId
+ parameters:(Array with:nil with:padd with:nil with:nil with:nil)
+ "/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
) ifFalse:[
- "
- also happens, if a segmentation violation occurs in primitive code...
- "
- self primitiveFailed
+ "
+ also happens, if a segmentation violation occurs in primitive code...
+ "
+ self primitiveFailed
].
!
@@ -10778,22 +10778,22 @@
colors are allocated - otherwise the colors may be wrong."
(self
- primDrawBits:imageBits
- bitsPerPixel:bitsPerPixel
- depth:imageDepth
- width:imageWidth height:imageHeight
- x:srcx y:srcy
- into:ignoredDrawableId
- x:dstx y:dsty
- width:w height:h
- with:aGCId
- parameters:parameters
- "/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
+ primDrawBits:imageBits
+ bitsPerPixel:bitsPerPixel
+ depth:imageDepth
+ width:imageWidth height:imageHeight
+ x:srcx y:srcy
+ into:ignoredDrawableId
+ x:dstx y:dsty
+ width:w height:h
+ with:aGCId
+ parameters:parameters
+ "/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
) ifFalse:[
- "
- also happens, if a segmentation violation occurs in primitive code...
- "
- self primitiveFailed
+ "
+ also happens, if a segmentation violation occurs in primitive code...
+ "
+ self primitiveFailed
].
!
@@ -11005,14 +11005,14 @@
!
primDrawBits:imageBits
- bitsPerPixel:bitsPerPixel depth:imageDepth
- width:imageWidth height:imageHeight
- x:srcx y:srcy
- into:ignoredDrawableId
- x:dstx y:dsty
- width:w height:h
- with:aGCId
- parameters:params
+ bitsPerPixel:bitsPerPixel depth:imageDepth
+ width:imageWidth height:imageHeight
+ x:srcx y:srcy
+ into:ignoredDrawableId
+ x:dstx y:dsty
+ width:w height:h
+ with:aGCId
+ parameters:params
|sourceAlphaOrNil padd redMask greenMask blueMask|
@@ -11034,9 +11034,9 @@
int _doAlphaBlend = 0;
if (__isByteArray(imageBits)) {
- __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
+ __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
} else if (__isExternalBytesLike(imageBits)) {
- __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
+ __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
}
if (ISCONNECTED
@@ -11049,207 +11049,207 @@
&& __isSmallInteger(padd)
&& __imageBits)
{
- struct
- {
- BITMAPINFOHEADER bmiHeader;
- DWORD r;
- DWORD g;
- DWORD b;
- DWORD a;
- } bitmap;
- int _padd = __intVal(padd);
-
- gcData = _GCDATA(aGCId);
- if (! gcData )
- goto fail;
- hDC = _getDC(gcData);
- DDDDPRINTF(("hDC = %x\n", hDC));
-
- if (_padd != WIN32PADDING) {
- int row, col;
- unsigned char *cp;
- unsigned char *pBits;
- int b_width, b_height, bytesPerRowST, bytesPerRowWIN, padding, nBytes;
- int bi = __intVal(bitsPerPixel);
-
- b_width = __intVal(imageWidth);
- b_height = __intVal(imageHeight);
- bytesPerRowST = (b_width * bi + (_padd-1)) / _padd;
- bytesPerRowWIN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
- padding = bytesPerRowWIN - bytesPerRowST;
- /* console_printf("padd %d bs %d bw %d p %d\n",_padd,bytesPerRowST,bytesPerRowWN,padding); */
- if (padding) {
- nBytes = b_height * bytesPerRowWIN;
- if (nBytes < sizeof(fastBits)) {
- cp = b_bits = fastBits;
- } else {
- cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
- }
- if (cp) {
- pBits = __imageBits;
- for (row = b_height; row; row--) {
- for (col = bytesPerRowST; col; col--) {
- *cp++ = *pBits++;
- }
- cp += padding;
- }
- } else
- goto fail;
- }
- }
-
- if (b_bits == 0) {
- b_bits = __imageBits;
- }
-
- bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmap.bmiHeader.biPlanes = 1;
- switch (__intVal(imageDepth)) {
- case 16:
- /* notice the default r/g/b (STX order here) */
+ struct
+ {
+ BITMAPINFOHEADER bmiHeader;
+ DWORD r;
+ DWORD g;
+ DWORD b;
+ DWORD a;
+ } bitmap;
+ int _padd = __intVal(padd);
+
+ gcData = _GCDATA(aGCId);
+ if (! gcData )
+ goto fail;
+ hDC = _getDC(gcData);
+ DDDDPRINTF(("hDC = %x\n", hDC));
+
+ if (_padd != WIN32PADDING) {
+ int row, col;
+ unsigned char *cp;
+ unsigned char *pBits;
+ int b_width, b_height, bytesPerRowST, bytesPerRowWIN, padding, nBytes;
+ int bi = __intVal(bitsPerPixel);
+
+ b_width = __intVal(imageWidth);
+ b_height = __intVal(imageHeight);
+ bytesPerRowST = (b_width * bi + (_padd-1)) / _padd;
+ bytesPerRowWIN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
+ padding = bytesPerRowWIN - bytesPerRowST;
+ /* console_printf("padd %d bs %d bw %d p %d\n",_padd,bytesPerRowST,bytesPerRowWN,padding); */
+ if (padding) {
+ nBytes = b_height * bytesPerRowWIN;
+ if (nBytes < sizeof(fastBits)) {
+ cp = b_bits = fastBits;
+ } else {
+ cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
+ }
+ if (cp) {
+ pBits = __imageBits;
+ for (row = b_height; row; row--) {
+ for (col = bytesPerRowST; col; col--) {
+ *cp++ = *pBits++;
+ }
+ cp += padding;
+ }
+ } else
+ goto fail;
+ }
+ }
+
+ if (b_bits == 0) {
+ b_bits = __imageBits;
+ }
+
+ bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bitmap.bmiHeader.biPlanes = 1;
+ switch (__intVal(imageDepth)) {
+ case 16:
+ /* notice the default r/g/b (STX order here) */
#if 1
- bitmap.bmiHeader.biCompression = BI_BITFIELDS;
- bitmap.r = redMask == nil ? 0xf800 : __intVal(redMask);
- bitmap.g = greenMask == nil ? 0x07e0 : __intVal(greenMask);
- bitmap.b = blueMask == nil ? 0x001f : __intVal(blueMask);
-#endif
- break;
-
- case 24:
- /* notice the default b/g/r (WIN32 order here) */
-#if 0
- bitmap.bmiHeader.biCompression = BI_BITFIELDS;
- bitmap.r = redMask == nil ? 0xff0000 : __intVal(redMask);
- bitmap.g = greenMask == nil ? 0x00ff00 : __intVal(greenMask);
- bitmap.b = blueMask == nil ? 0x0000ff : __intVal(blueMask);
-#endif
- bitmap.bmiHeader.biCompression = BI_RGB;
- break;
-
- case 32:
- /* notice the default r/g/b (STX order here) */
- bitmap.bmiHeader.biCompression = BI_RGB;
+ bitmap.bmiHeader.biCompression = BI_BITFIELDS;
+ bitmap.r = redMask == nil ? 0xf800 : __intVal(redMask);
+ bitmap.g = greenMask == nil ? 0x07e0 : __intVal(greenMask);
+ bitmap.b = blueMask == nil ? 0x001f : __intVal(blueMask);
+#endif
+ break;
+
+ case 24:
+ /* notice the default b/g/r (WIN32 order here) */
+#if 0
+ bitmap.bmiHeader.biCompression = BI_BITFIELDS;
+ bitmap.r = redMask == nil ? 0xff0000 : __intVal(redMask);
+ bitmap.g = greenMask == nil ? 0x00ff00 : __intVal(greenMask);
+ bitmap.b = blueMask == nil ? 0x0000ff : __intVal(blueMask);
+#endif
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ break;
+
+ case 32:
+ /* notice the default r/g/b (STX order here) */
+ bitmap.bmiHeader.biCompression = BI_RGB;
#if 1
- bitmap.bmiHeader.biCompression = BI_BITFIELDS;
- bitmap.r = redMask == nil ? 0x0000ff : __intVal(redMask);
- bitmap.g = greenMask == nil ? 0x00ff00 : __intVal(greenMask);
- bitmap.b = blueMask == nil ? 0xff0000 : __intVal(blueMask);
- bitmap.a = 0xff000000;
-#endif
- break;
- }
-
- if (sourceAlphaOrNil != nil) {
+ bitmap.bmiHeader.biCompression = BI_BITFIELDS;
+ bitmap.r = redMask == nil ? 0x0000ff : __intVal(redMask);
+ bitmap.g = greenMask == nil ? 0x00ff00 : __intVal(greenMask);
+ bitmap.b = blueMask == nil ? 0xff0000 : __intVal(blueMask);
+ bitmap.a = 0xff000000;
+#endif
+ break;
+ }
+
+ if (sourceAlphaOrNil != nil) {
console_printf("sourceAlphaOrNil = %x\n", sourceAlphaOrNil);
- _sourceAlpha = __intVal(sourceAlphaOrNil);
- _doAlphaBlend = 1;
- }
-
- bitmap.bmiHeader.biSizeImage = 0;
- bitmap.bmiHeader.biXPelsPerMeter = 0;
- bitmap.bmiHeader.biYPelsPerMeter = 0;
- bitmap.bmiHeader.biClrUsed = 0;
- bitmap.bmiHeader.biClrImportant = 0;
- bitmap.bmiHeader.biWidth = __intVal(imageWidth);
- bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
- bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
- /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
-
- if (! _doAlphaBlend) {
- SetDIBitsToDevice(hDC,
- __intVal(dstx), __intVal(dsty),
- __intVal(w), __intVal(h),
- __intVal(srcx), __intVal(srcy),
- 0, __intVal(h),
- (void *)b_bits,
- (BITMAPINFO*)&bitmap,
- DIB_RGB_COLORS);
- } else {
- HDC ahdc;
- HBITMAP ahbitmap;
- void *pvBits;
- BLENDFUNCTION bf;
- static BOOL (__stdcall *P_AlphaBlend)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION );
-
- if (P_AlphaBlend == 0) {
- /* as I don't have AlphaBlend in the inport32.lib (bcc sucks),
- * fetch its address dynamically...
- */
- HINSTANCE hWinGDI = LoadLibrary("msimg32.dll");
- if (hWinGDI) {
- P_AlphaBlend = (BOOL (__stdcall *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION ))
- GetProcAddress(hWinGDI, "AlphaBlend");
- }
- }
- if (P_AlphaBlend != 0) {
+ _sourceAlpha = __intVal(sourceAlphaOrNil);
+ _doAlphaBlend = 1;
+ }
+
+ bitmap.bmiHeader.biSizeImage = 0;
+ bitmap.bmiHeader.biXPelsPerMeter = 0;
+ bitmap.bmiHeader.biYPelsPerMeter = 0;
+ bitmap.bmiHeader.biClrUsed = 0;
+ bitmap.bmiHeader.biClrImportant = 0;
+ bitmap.bmiHeader.biWidth = __intVal(imageWidth);
+ bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
+ bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
+ /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
+
+ if (! _doAlphaBlend) {
+ SetDIBitsToDevice(hDC,
+ __intVal(dstx), __intVal(dsty),
+ __intVal(w), __intVal(h),
+ __intVal(srcx), __intVal(srcy),
+ 0, __intVal(h),
+ (void *)b_bits,
+ (BITMAPINFO*)&bitmap,
+ DIB_RGB_COLORS);
+ } else {
+ HDC ahdc;
+ HBITMAP ahbitmap;
+ void *pvBits;
+ BLENDFUNCTION bf;
+ static BOOL (__stdcall *P_AlphaBlend)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION );
+
+ if (P_AlphaBlend == 0) {
+ /* as I don't have AlphaBlend in the inport32.lib (bcc sucks),
+ * fetch its address dynamically...
+ */
+ HINSTANCE hWinGDI = LoadLibrary("msimg32.dll");
+ if (hWinGDI) {
+ P_AlphaBlend = (BOOL (__stdcall *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION ))
+ GetProcAddress(hWinGDI, "AlphaBlend");
+ }
+ }
+ if (P_AlphaBlend != 0) {
console_printf("***********************************\n");
console_printf("_sourceAlpha = %d\n", _sourceAlpha);
- ahdc = CreateCompatibleDC(hDC);
-
- ahbitmap = CreateCompatibleBitmap(hDC, __intVal(imageWidth), __intVal(imageHeight));
- SelectObject(ahdc, ahbitmap);
- SetDIBitsToDevice(ahdc,
- 0, 0, /* dstx, dsty */
- __intVal(imageWidth), __intVal(imageHeight),
- __intVal(srcx), __intVal(srcy),
- 0, __intVal(imageHeight),
- (void *)b_bits,
- (BITMAPINFO*)&bitmap,
- DIB_RGB_COLORS);
-
- bf.BlendOp = AC_SRC_OVER;
- bf.BlendFlags = 0;
- bf.SourceConstantAlpha = _sourceAlpha;
- bf.AlphaFormat = AC_SRC_ALPHA;
+ ahdc = CreateCompatibleDC(hDC);
+
+ ahbitmap = CreateCompatibleBitmap(hDC, __intVal(imageWidth), __intVal(imageHeight));
+ SelectObject(ahdc, ahbitmap);
+ SetDIBitsToDevice(ahdc,
+ 0, 0, /* dstx, dsty */
+ __intVal(imageWidth), __intVal(imageHeight),
+ __intVal(srcx), __intVal(srcy),
+ 0, __intVal(imageHeight),
+ (void *)b_bits,
+ (BITMAPINFO*)&bitmap,
+ DIB_RGB_COLORS);
+
+ bf.BlendOp = AC_SRC_OVER;
+ bf.BlendFlags = 0;
+ bf.SourceConstantAlpha = _sourceAlpha;
+ bf.AlphaFormat = AC_SRC_ALPHA;
#if 1
- (*P_AlphaBlend) (hDC,
- __intVal(dstx), __intVal(dsty),
- __intVal(imageWidth), __intVal(imageHeight),
- ahdc,
- 0, 0, /* srcx, srcy */
- __intVal(imageWidth), __intVal(imageHeight),
- bf);
-#else
- bf.SourceConstantAlpha = 255-_sourceAlpha;
- bf.AlphaFormat = 0;
- bf.BlendOp = 0;
- (*P_AlphaBlend) (ahdc,
- 0, 0, /* dstx, dsty */
- __intVal(imageWidth), __intVal(imageHeight),
- hDC,
- __intVal(dstx), __intVal(dsty), /* srcx, srcy */
- __intVal(imageWidth), __intVal(imageHeight),
- bf);
-
- BitBlt (hDC,
- __intVal(dstx), __intVal(dsty),
- __intVal(imageWidth), __intVal(imageHeight),
- ahdc,
- 0, 0, /* srcx, srcy */
- SRCCOPY);
-#endif
- DeleteObject(ahbitmap);
- DeleteDC(ahdc);
- }
- }
- if (allocatedBits) {
- free(allocatedBits);
- }
+ (*P_AlphaBlend) (hDC,
+ __intVal(dstx), __intVal(dsty),
+ __intVal(imageWidth), __intVal(imageHeight),
+ ahdc,
+ 0, 0, /* srcx, srcy */
+ __intVal(imageWidth), __intVal(imageHeight),
+ bf);
+#else
+ bf.SourceConstantAlpha = 255-_sourceAlpha;
+ bf.AlphaFormat = 0;
+ bf.BlendOp = 0;
+ (*P_AlphaBlend) (ahdc,
+ 0, 0, /* dstx, dsty */
+ __intVal(imageWidth), __intVal(imageHeight),
+ hDC,
+ __intVal(dstx), __intVal(dsty), /* srcx, srcy */
+ __intVal(imageWidth), __intVal(imageHeight),
+ bf);
+
+ BitBlt (hDC,
+ __intVal(dstx), __intVal(dsty),
+ __intVal(imageWidth), __intVal(imageHeight),
+ ahdc,
+ 0, 0, /* srcx, srcy */
+ SRCCOPY);
+#endif
+ DeleteObject(ahbitmap);
+ DeleteDC(ahdc);
+ }
+ }
+ if (allocatedBits) {
+ free(allocatedBits);
+ }
#ifndef CACHE_LAST_DC
- _releaseDC(gcData);
-#endif
- RETURN ( true );
+ _releaseDC(gcData);
+#endif
+ RETURN ( true );
}
fail: ;
PRINTF(("create temp bitmap FAILED!!!\n"));
if (allocatedBits) {
- PRINTF(("freeing up temp bitmap bits ...\n"));
- free(allocatedBits);
+ PRINTF(("freeing up temp bitmap bits ...\n"));
+ free(allocatedBits);
}
#ifndef CACHE_LAST_DC
if (hDC) {
- _releaseDC(gcData);
+ _releaseDC(gcData);
}
#endif
%}
@@ -12990,7 +12990,7 @@
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease.
For buttonEvents, the keySymCodeOrButtonNr must be the buttons number (1, 2 ...);
for key events, it can be either a symbol (as listen in X's keySyms)
- or a numeric keysym code or a character.
+ or a numeric keysym code or a character.
If state is nil, the modifier bits (shift & control)
are computed from the keyboardMap - if non-nil, these are passed as modifierbits.
The non-nil case is the lowlevel entry, where state must include any shift/ctrl information
@@ -12999,12 +12999,12 @@
|ok xLog yLog targetId|
(xPos notNil and:[yPos notNil]) ifTrue:[
- "/ scale 0..width to 0..16rFFFF
- xLog := xPos * 16rFFFF // self width.
- yLog := yPos * 16rFFFF // self height.
+ "/ scale 0..width to 0..16rFFFF
+ xLog := xPos * 16rFFFF // self width.
+ yLog := yPos * 16rFFFF // self height.
].
(targetIdArg notNil and:[targetIdArg ~= self rootWindowId]) ifTrue:[
- targetId := targetIdArg.
+ targetId := targetIdArg.
].
ok := false.
@@ -13019,189 +13019,190 @@
int _isKeyEvent = 0;
int _keyCodeOrButtonNr = -1;
int _shifted = 0;
- int _x = 0, _y = 0;
+ int _xP = 0;
+ int _yP = 0;
if (__isExternalAddress(targetId)) {
- hWnd = _HWNDVal(targetId);
+ hWnd = _HWNDVal(targetId);
}
if (__isSmallInteger(keySymCodeOrButtonNr)) {
- _keyCodeOrButtonNr = __intVal(keySymCodeOrButtonNr);
+ _keyCodeOrButtonNr = __intVal(keySymCodeOrButtonNr);
} else {
- if (__isCharacter(keySymCodeOrButtonNr)) {
-
- _keyCodeOrButtonNr = __intVal(__characterVal(keySymCodeOrButtonNr));
+ if (__isCharacter(keySymCodeOrButtonNr)) {
+
+ _keyCodeOrButtonNr = __intVal(__characterVal(keySymCodeOrButtonNr));
console_printf("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr);
- if ((_keyCodeOrButtonNr >= 'a') && (_keyCodeOrButtonNr <= 'z')) {
- _keyCodeOrButtonNr -= 0x20;
+ if ((_keyCodeOrButtonNr >= 'a') && (_keyCodeOrButtonNr <= 'z')) {
+ _keyCodeOrButtonNr -= 0x20;
console_printf("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr);
- } else {
- if ((_keyCodeOrButtonNr >= 'A') && (_keyCodeOrButtonNr <= 'Z')) {
+ } else {
+ if ((_keyCodeOrButtonNr >= 'A') && (_keyCodeOrButtonNr <= 'Z')) {
console_printf("code: shifted %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr);
- _shifted = 1;
- }
- }
- } else if (keySymCodeOrButtonNr == @symbol(Return)) {
- _keyCodeOrButtonNr = VK_RETURN;
- } else if (keySymCodeOrButtonNr == @symbol(Enter)) {
- _keyCodeOrButtonNr = VK_RETURN;
- } else if (keySymCodeOrButtonNr == @symbol(BackSpace)) {
- _keyCodeOrButtonNr = VK_BACK;
- } else if (keySymCodeOrButtonNr == @symbol(Tab)) {
- _keyCodeOrButtonNr = VK_TAB;
- } else if (keySymCodeOrButtonNr == @symbol(Shift)) {
- _keyCodeOrButtonNr = VK_SHIFT;
- } else if (keySymCodeOrButtonNr == @symbol(Ctrl)) {
- _keyCodeOrButtonNr = VK_CONTROL;
- } else if (keySymCodeOrButtonNr == @symbol(Menu)) {
- _keyCodeOrButtonNr = VK_MENU;
- } else if (keySymCodeOrButtonNr == @symbol(Escape)) {
- _keyCodeOrButtonNr = VK_ESCAPE;
- } else if (keySymCodeOrButtonNr == @symbol(Space)) {
- _keyCodeOrButtonNr = VK_SPACE;
- } else if (keySymCodeOrButtonNr == @symbol(Prior)) {
- _keyCodeOrButtonNr = VK_PRIOR;
- } else if (keySymCodeOrButtonNr == @symbol(Next)) {
- _keyCodeOrButtonNr = VK_NEXT;
- } else if (keySymCodeOrButtonNr == @symbol(End)) {
- _keyCodeOrButtonNr = VK_END;
- } else if (keySymCodeOrButtonNr == @symbol(Home)) {
- _keyCodeOrButtonNr = VK_HOME;
- } else if (keySymCodeOrButtonNr == @symbol(Left)) {
- _keyCodeOrButtonNr = VK_LEFT;
- } else if (keySymCodeOrButtonNr == @symbol(Right)) {
- _keyCodeOrButtonNr = VK_RIGHT;
- } else if (keySymCodeOrButtonNr == @symbol(Down)) {
- _keyCodeOrButtonNr = VK_DOWN;
- } else if (keySymCodeOrButtonNr == @symbol(Up)) {
- _keyCodeOrButtonNr = VK_UP;
- } else if (keySymCodeOrButtonNr == @symbol(Insert)) {
- _keyCodeOrButtonNr = VK_INSERT;
- } else if (keySymCodeOrButtonNr == @symbol(Delete)) {
- _keyCodeOrButtonNr = VK_DELETE;
- } else if (keySymCodeOrButtonNr == @symbol(Help)) {
- _keyCodeOrButtonNr = VK_HELP;
- } else if (keySymCodeOrButtonNr == @symbol(F1)) {
- _keyCodeOrButtonNr = VK_F1;
- } else if (keySymCodeOrButtonNr == @symbol(F2)) {
- _keyCodeOrButtonNr = VK_F2;
- } else if (keySymCodeOrButtonNr == @symbol(F3)) {
- _keyCodeOrButtonNr = VK_F3;
- } else if (keySymCodeOrButtonNr == @symbol(F4)) {
- _keyCodeOrButtonNr = VK_F4;
- } else if (keySymCodeOrButtonNr == @symbol(F5)) {
- _keyCodeOrButtonNr = VK_F5;
- } else if (keySymCodeOrButtonNr == @symbol(F6)) {
- _keyCodeOrButtonNr = VK_F6;
- } else if (keySymCodeOrButtonNr == @symbol(F7)) {
- _keyCodeOrButtonNr = VK_F7;
- } else if (keySymCodeOrButtonNr == @symbol(F8)) {
- _keyCodeOrButtonNr = VK_F8;
- } else if (keySymCodeOrButtonNr == @symbol(F9)) {
- _keyCodeOrButtonNr = VK_F9;
- } else if (keySymCodeOrButtonNr == @symbol(F10)) {
- _keyCodeOrButtonNr = VK_F10;
- } else if (keySymCodeOrButtonNr == @symbol(F11)) {
- _keyCodeOrButtonNr = VK_F11;
- } else if (keySymCodeOrButtonNr == @symbol(F12)) {
- _keyCodeOrButtonNr = VK_F12;
- } else {
- console_printf("bad key\n");
- goto getOutOfHere;
- }
+ _shifted = 1;
+ }
+ }
+ } else if (keySymCodeOrButtonNr == @symbol(Return)) {
+ _keyCodeOrButtonNr = VK_RETURN;
+ } else if (keySymCodeOrButtonNr == @symbol(Enter)) {
+ _keyCodeOrButtonNr = VK_RETURN;
+ } else if (keySymCodeOrButtonNr == @symbol(BackSpace)) {
+ _keyCodeOrButtonNr = VK_BACK;
+ } else if (keySymCodeOrButtonNr == @symbol(Tab)) {
+ _keyCodeOrButtonNr = VK_TAB;
+ } else if (keySymCodeOrButtonNr == @symbol(Shift)) {
+ _keyCodeOrButtonNr = VK_SHIFT;
+ } else if (keySymCodeOrButtonNr == @symbol(Ctrl)) {
+ _keyCodeOrButtonNr = VK_CONTROL;
+ } else if (keySymCodeOrButtonNr == @symbol(Menu)) {
+ _keyCodeOrButtonNr = VK_MENU;
+ } else if (keySymCodeOrButtonNr == @symbol(Escape)) {
+ _keyCodeOrButtonNr = VK_ESCAPE;
+ } else if (keySymCodeOrButtonNr == @symbol(Space)) {
+ _keyCodeOrButtonNr = VK_SPACE;
+ } else if (keySymCodeOrButtonNr == @symbol(Prior)) {
+ _keyCodeOrButtonNr = VK_PRIOR;
+ } else if (keySymCodeOrButtonNr == @symbol(Next)) {
+ _keyCodeOrButtonNr = VK_NEXT;
+ } else if (keySymCodeOrButtonNr == @symbol(End)) {
+ _keyCodeOrButtonNr = VK_END;
+ } else if (keySymCodeOrButtonNr == @symbol(Home)) {
+ _keyCodeOrButtonNr = VK_HOME;
+ } else if (keySymCodeOrButtonNr == @symbol(Left)) {
+ _keyCodeOrButtonNr = VK_LEFT;
+ } else if (keySymCodeOrButtonNr == @symbol(Right)) {
+ _keyCodeOrButtonNr = VK_RIGHT;
+ } else if (keySymCodeOrButtonNr == @symbol(Down)) {
+ _keyCodeOrButtonNr = VK_DOWN;
+ } else if (keySymCodeOrButtonNr == @symbol(Up)) {
+ _keyCodeOrButtonNr = VK_UP;
+ } else if (keySymCodeOrButtonNr == @symbol(Insert)) {
+ _keyCodeOrButtonNr = VK_INSERT;
+ } else if (keySymCodeOrButtonNr == @symbol(Delete)) {
+ _keyCodeOrButtonNr = VK_DELETE;
+ } else if (keySymCodeOrButtonNr == @symbol(Help)) {
+ _keyCodeOrButtonNr = VK_HELP;
+ } else if (keySymCodeOrButtonNr == @symbol(F1)) {
+ _keyCodeOrButtonNr = VK_F1;
+ } else if (keySymCodeOrButtonNr == @symbol(F2)) {
+ _keyCodeOrButtonNr = VK_F2;
+ } else if (keySymCodeOrButtonNr == @symbol(F3)) {
+ _keyCodeOrButtonNr = VK_F3;
+ } else if (keySymCodeOrButtonNr == @symbol(F4)) {
+ _keyCodeOrButtonNr = VK_F4;
+ } else if (keySymCodeOrButtonNr == @symbol(F5)) {
+ _keyCodeOrButtonNr = VK_F5;
+ } else if (keySymCodeOrButtonNr == @symbol(F6)) {
+ _keyCodeOrButtonNr = VK_F6;
+ } else if (keySymCodeOrButtonNr == @symbol(F7)) {
+ _keyCodeOrButtonNr = VK_F7;
+ } else if (keySymCodeOrButtonNr == @symbol(F8)) {
+ _keyCodeOrButtonNr = VK_F8;
+ } else if (keySymCodeOrButtonNr == @symbol(F9)) {
+ _keyCodeOrButtonNr = VK_F9;
+ } else if (keySymCodeOrButtonNr == @symbol(F10)) {
+ _keyCodeOrButtonNr = VK_F10;
+ } else if (keySymCodeOrButtonNr == @symbol(F11)) {
+ _keyCodeOrButtonNr = VK_F11;
+ } else if (keySymCodeOrButtonNr == @symbol(F12)) {
+ _keyCodeOrButtonNr = VK_F12;
+ } else {
+ console_printf("bad key\n");
+ goto getOutOfHere;
+ }
}
if (__isSmallInteger(xLog)) {
- _x = __intVal(xLog);
+ _xP = __intVal(xLog);
}
if (__isSmallInteger(yLog)) {
- _y = __intVal(yLog);
- }
- lParam = _x | (_y << 16);
+ _yP = __intVal(yLog);
+ }
+ lParam = _xP | (_yP << 16);
if (typeSymbol == @symbol(buttonPress)) {
- _isMouseEvent = 1;
- switch (_keyCodeOrButtonNr) {
- case 1:
- msg = WM_LBUTTONDOWN;
- wParam = MK_LBUTTON;
- dwFlags = MOUSEEVENTF_LEFTDOWN;
- break;
- case 2:
- msg = WM_MBUTTONDOWN;
- wParam = MK_MBUTTON;
- dwFlags = MOUSEEVENTF_MIDDLEDOWN;
- break;
- case 3:
- msg = WM_RBUTTONDOWN;
- wParam = MK_RBUTTON;
- dwFlags = MOUSEEVENTF_RIGHTDOWN;
- break;
- default:
- console_printf("bad button\n");
- goto getOutOfHere;
- }
+ _isMouseEvent = 1;
+ switch (_keyCodeOrButtonNr) {
+ case 1:
+ msg = WM_LBUTTONDOWN;
+ wParam = MK_LBUTTON;
+ dwFlags = MOUSEEVENTF_LEFTDOWN;
+ break;
+ case 2:
+ msg = WM_MBUTTONDOWN;
+ wParam = MK_MBUTTON;
+ dwFlags = MOUSEEVENTF_MIDDLEDOWN;
+ break;
+ case 3:
+ msg = WM_RBUTTONDOWN;
+ wParam = MK_RBUTTON;
+ dwFlags = MOUSEEVENTF_RIGHTDOWN;
+ break;
+ default:
+ console_printf("bad button\n");
+ goto getOutOfHere;
+ }
} else if (typeSymbol == @symbol(buttonRelease)) {
- _isMouseEvent = 1;
- switch (_keyCodeOrButtonNr) {
- case 1:
- msg = WM_LBUTTONUP;
- dwFlags = MOUSEEVENTF_LEFTUP;
- break;
- case 2:
- msg = WM_MBUTTONUP;
- dwFlags = MOUSEEVENTF_MIDDLEUP;
- break;
- case 3:
- msg = WM_RBUTTONUP;
- dwFlags = MOUSEEVENTF_RIGHTUP;
- break;
- default:
- console_printf("bad button\n");
- goto getOutOfHere;
- }
+ _isMouseEvent = 1;
+ switch (_keyCodeOrButtonNr) {
+ case 1:
+ msg = WM_LBUTTONUP;
+ dwFlags = MOUSEEVENTF_LEFTUP;
+ break;
+ case 2:
+ msg = WM_MBUTTONUP;
+ dwFlags = MOUSEEVENTF_MIDDLEUP;
+ break;
+ case 3:
+ msg = WM_RBUTTONUP;
+ dwFlags = MOUSEEVENTF_RIGHTUP;
+ break;
+ default:
+ console_printf("bad button\n");
+ goto getOutOfHere;
+ }
} else if ((typeSymbol == @symbol(keyPress)) || (typeSymbol == @symbol(keyRelease))) {
- dwFlags = 0;
- if (typeSymbol == @symbol(keyRelease)) dwFlags = KEYEVENTF_KEYUP;
+ dwFlags = 0;
+ if (typeSymbol == @symbol(keyRelease)) dwFlags = KEYEVENTF_KEYUP;
} else {
- console_printf("bad typeSymbol\n");
- goto getOutOfHere;
+ console_printf("bad typeSymbol\n");
+ goto getOutOfHere;
}
if (_isMouseEvent) {
- if ((xPos == nil) || (yPos == nil)) {
- console_printf("bad x/y\n");
- goto getOutOfHere;
- }
+ if ((xPos == nil) || (yPos == nil)) {
+ console_printf("bad x/y\n");
+ goto getOutOfHere;
+ }
}
if (hWnd == 0) {
- // send to screen
- if ((xPos != nil) && (yPos != nil)) {
- mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, _x, _y, 0, NULL);
- }
-
- if (_isMouseEvent) {
-console_printf("mouse %08x %d/%d\n", dwFlags | MOUSEEVENTF_ABSOLUTE, _x, _y);
- mouse_event(dwFlags | MOUSEEVENTF_ABSOLUTE, _x, _y, 0, NULL);
- } else {
- if (_shifted) {
+ // send to screen
+ if ((xPos != nil) && (yPos != nil)) {
+ mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, _xP, _yP, 0, NULL);
+ }
+
+ if (_isMouseEvent) {
+console_printf("mouse %08x %d/%d\n", dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP);
+ mouse_event(dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP, 0, NULL);
+ } else {
+ if (_shifted) {
console_printf("shifted keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr);
- keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, 0, 0);
- keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
- keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, KEYEVENTF_KEYUP, 0);
- } else {
+ keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, 0, 0);
+ keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
+ keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, KEYEVENTF_KEYUP, 0);
+ } else {
console_printf("keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr);
- keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
- }
- }
+ keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
+ }
+ }
} else {
- rslt = PostMessage(hWnd, msg, wParam, lParam);
+ rslt = PostMessage(hWnd, msg, wParam, lParam);
}
ok = true;
getOutOfHere: ;
%}.
ok ifFalse:[
- 'WinWorkstation [warning]: sendKeyOrButtonEvent unimplemented' infoPrintCR.
- self primitiveFailed.
+ 'WinWorkstation [warning]: sendKeyOrButtonEvent unimplemented' infoPrintCR.
+ self primitiveFailed.
].
^ ok
! !
@@ -16656,7 +16657,7 @@
|error bytesPerLine bitmapPad bitsPerPixel|
((w <= 0) or:[h <= 0]) ifTrue:[
- ^ self primitiveFailed:'zero width or height'.
+ ^ self primitiveFailed:'zero width or height'.
].
%{
@@ -16668,213 +16669,213 @@
HGDIOBJ hPrevious = 0;
HDC bDC = 0;
struct {
- BITMAPINFOHEADER bmiHeader;
- DWORD r;
- DWORD g;
- DWORD b;
+ BITMAPINFOHEADER bmiHeader;
+ DWORD r;
+ DWORD g;
+ DWORD b;
} bitmap;
if (! __isExternalAddress(aDrawableId)) {
- error = __MKSTRING("externalAddress arg");
- goto out;
+ error = __MKSTRING("externalAddress arg");
+ goto out;
}
if (! __bothSmallInteger(srcX, srcY)) {
- error = __MKSTRING("x,y args");
- goto out;
+ error = __MKSTRING("x,y args");
+ goto out;
}
if (! __bothSmallInteger(w, h)) {
- error = __MKSTRING("w,h args");
- goto out;
+ error = __MKSTRING("w,h args");
+ goto out;
}
if (! __isByteArray(imageBits)) {
- error = __MKSTRING("imageBits arg");
- goto out;
+ error = __MKSTRING("imageBits arg");
+ goto out;
}
{
- hWnd = _HWNDVal( aDrawableId );
- BMDPRINTF(("primGetBits %x\n",hWnd));
- if ( hWnd != 0 ) {
- HDC wDC;
- HANDLE prevBitmap;
- int widthRoundedUpToNextMultipleOf4 = ((width + 3 ) / 4) * 4;
- int widthUsed;
-
- bDC = CreateCompatibleDC(__rootDC);
-
- BMDPRINTF(("primGetBits srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
- height = __intVal(h);
- width = __intVal(w);
-
- widthUsed = widthRoundedUpToNextMultipleOf4;
- widthUsed = width;
-
- BMDPRINTF(("width %d height %d\n",width,height));
- hBitmap = CreateCompatibleBitmap(__rootDC, widthUsed, height);
- if (!hBitmap) {
- error = __MKSTRING("CreateCompatibleBitmap failed");
- goto out;
- }
- bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmap.bmiHeader.biPlanes = 1;
+ hWnd = _HWNDVal( aDrawableId );
+ BMDPRINTF(("primGetBits %x\n",hWnd));
+ if ( hWnd != 0 ) {
+ HDC wDC;
+ HANDLE prevBitmap;
+ int widthRoundedUpToNextMultipleOf4 = ((width + 3 ) / 4) * 4;
+ int widthUsed;
+
+ bDC = CreateCompatibleDC(__rootDC);
+
+ BMDPRINTF(("primGetBits srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
+ height = __intVal(h);
+ width = __intVal(w);
+
+ widthUsed = widthRoundedUpToNextMultipleOf4;
+ widthUsed = width;
+
+ BMDPRINTF(("width %d height %d\n",width,height));
+ hBitmap = CreateCompatibleBitmap(__rootDC, widthUsed, height);
+ if (!hBitmap) {
+ error = __MKSTRING("CreateCompatibleBitmap failed");
+ goto out;
+ }
+ bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bitmap.bmiHeader.biPlanes = 1;
#ifdef ALWAYSTRUECOLOR
- bitmap.bmiHeader.biCompression = BI_RGB;
- bytesPerRow = (((width*3) + 3 ) / 4) * 4;
-#else
- if (__depth == 24) {
- bitmap.bmiHeader.biCompression = BI_RGB;
- bytesPerRow = (((width*3) + 3 ) / 4) * 4;
- } else if (__depth == 16) {
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ bytesPerRow = (((width*3) + 3 ) / 4) * 4;
+#else
+ if (__depth == 24) {
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ bytesPerRow = (((width*3) + 3 ) / 4) * 4;
+ } else if (__depth == 16) {
# if 0
- bitmap.bmiHeader.biCompression = BI_BITFIELDS;
- bitmap.b = 0x001f;
- bitmap.g = 0x07e0;
- bitmap.r = 0xf800;
- bytesPerRow = (((width*2) + 1 ) / 4) * 4;
+ bitmap.bmiHeader.biCompression = BI_BITFIELDS;
+ bitmap.b = 0x001f;
+ bitmap.g = 0x07e0;
+ bitmap.r = 0xf800;
+ bytesPerRow = (((width*2) + 1 ) / 4) * 4;
# else
- bitmap.b = 0;
- bitmap.g = 0;
- bitmap.r = 0;
- bitmap.bmiHeader.biCompression = BI_RGB;
- bytesPerRow = (((width*3) + 3 ) / 4) * 4;
-# endif
- }
+ bitmap.b = 0;
+ bitmap.g = 0;
+ bitmap.r = 0;
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ bytesPerRow = (((width*3) + 3 ) / 4) * 4;
+# endif
+ }
#endif /* ALWAYSTRUECOLOR */
- bitmap.bmiHeader.biSizeImage = 0;
- bitmap.bmiHeader.biXPelsPerMeter = 0;
- bitmap.bmiHeader.biYPelsPerMeter = 0;
- bitmap.bmiHeader.biClrUsed = 0;
- bitmap.bmiHeader.biClrImportant = 0;
- bitmap.bmiHeader.biBitCount = __depth;
-
- bitmap.bmiHeader.biWidth = widthUsed;
- bitmap.bmiHeader.biHeight = -height;
-
- wDC = GetDC(hWnd);
-
- hPrevious = SelectObject(bDC, hBitmap);
- if (BitBlt(bDC,
- 0,0,
- width,height,
- wDC,
- __intVal(srcX), __intVal(srcY),
- SRCCOPY|CAPTUREBLT)
- == 0
- )
- {
- INFOFPRINTF((stderr, "WinWorkstation [warning]: in primGetBitsFrom: BitBlt\n"));
- }
+ bitmap.bmiHeader.biSizeImage = 0;
+ bitmap.bmiHeader.biXPelsPerMeter = 0;
+ bitmap.bmiHeader.biYPelsPerMeter = 0;
+ bitmap.bmiHeader.biClrUsed = 0;
+ bitmap.bmiHeader.biClrImportant = 0;
+ bitmap.bmiHeader.biBitCount = __depth;
+
+ bitmap.bmiHeader.biWidth = widthUsed;
+ bitmap.bmiHeader.biHeight = -height;
+
+ wDC = GetDC(hWnd);
+
+ hPrevious = SelectObject(bDC, hBitmap);
+ if (BitBlt(bDC,
+ 0,0,
+ width,height,
+ wDC,
+ __intVal(srcX), __intVal(srcY),
+ SRCCOPY|CAPTUREBLT)
+ == 0
+ )
+ {
+ INFOFPRINTF((stderr, "WinWorkstation [warning]: in primGetBitsFrom: BitBlt\n"));
+ }
#ifdef CACHE_LAST_DC
- if (lastGcData && (lastGcData->_hDC == wDC)) {
+ if (lastGcData && (lastGcData->_hDC == wDC)) {
# ifdef DEBUG_DC_REUSE
- console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - cachedDC reuse\n", __LINE__);
-# endif
- } else
-#endif
- {
+ console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - cachedDC reuse\n", __LINE__);
+# endif
+ } else
+#endif
+ {
#ifdef CACHE_LAST_WM_PAINT_DC
- if (last_wm_paint_dc && (last_wm_paint_dc == wDC)) {
+ if (last_wm_paint_dc && (last_wm_paint_dc == wDC)) {
# ifdef DEBUG_DC_REUSE
- console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - last_wm_paint_dc reuse\n", __LINE__);
-# endif
- } else
-#endif
- {
- ReleaseDC(hWnd, wDC);
- }
- }
-
- if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
- {
- error = __MKSTRING("noinfo returned in primGetBits");
- goto out;
- }
- BMDPRINTF(("bitmap info:%d %d %d %d\n",
- bitmap.bmiHeader.biWidth, bitmap.bmiHeader.biHeight,
- bitmap.bmiHeader.biBitCount, bitmap.bmiHeader.biSizeImage));
- numBytes = bitmap.bmiHeader.biSizeImage;
- if ( numBytes != 0 ) {
- if (numBytes > __byteArraySize(imageBits)) {
- /* imageBits too small */
- INFOFPRINTF((stderr, "WinWorkstation [warning]: primGetBits - byteArray too small (is:%d need:%d; w:%d h:%d)\n",
- __byteArraySize(imageBits), numBytes,
- bitmap.bmiHeader.biWidth, -bitmap.bmiHeader.biHeight
- ));
- error = __MKSTRING("byteArray too small");
- goto out;
- }
- BMDPRINTF(("numBytes %d\n",numBytes));
-
- bitmap.bmiHeader.biHeight = -height;
- if (GetDIBits(bDC,hBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
- {
- error = __MKSTRING("zero bits returned in primGetBits");
- goto out;
- }
-
- /* swap red and blue (windows delivers BGR) */
- {
- char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
- int _h;
- char *rowp = cp;
-
- for (_h=height; _h>0; _h--) {
- int _w;
- char *pixel = rowp;
-
- for (_w=width; _w>0; _w--) {
- char b;
-
- b = pixel[0];
- pixel[0] = pixel[2];
- pixel[2] = b;
- pixel += 3;
- };
- rowp += bytesPerRow;
- };
- }
- } else {
- error = __MKSTRING("unacceptable bitmap in primGetBits");
- goto out;
- }
- } else {
- error = __MKSTRING("unacceptable HWND in primGetBits");
- goto out;
- }
-
- bytesPerLine = __MKSMALLINT(bytesPerRow);
- bitmapPad = __MKSMALLINT(WIN32PADDING);
- bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
+ console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - last_wm_paint_dc reuse\n", __LINE__);
+# endif
+ } else
+#endif
+ {
+ ReleaseDC(hWnd, wDC);
+ }
+ }
+
+ if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
+ {
+ error = __MKSTRING("noinfo returned in primGetBits");
+ goto out;
+ }
+ BMDPRINTF(("bitmap info:%d %d %d %d\n",
+ bitmap.bmiHeader.biWidth, bitmap.bmiHeader.biHeight,
+ bitmap.bmiHeader.biBitCount, bitmap.bmiHeader.biSizeImage));
+ numBytes = bitmap.bmiHeader.biSizeImage;
+ if ( numBytes != 0 ) {
+ if (numBytes > __byteArraySize(imageBits)) {
+ /* imageBits too small */
+ INFOFPRINTF((stderr, "WinWorkstation [warning]: primGetBits - byteArray too small (is:%d need:%d; w:%d h:%d)\n",
+ __byteArraySize(imageBits), numBytes,
+ bitmap.bmiHeader.biWidth, -bitmap.bmiHeader.biHeight
+ ));
+ error = __MKSTRING("byteArray too small");
+ goto out;
+ }
+ BMDPRINTF(("numBytes %d\n",numBytes));
+
+ bitmap.bmiHeader.biHeight = -height;
+ if (GetDIBits(bDC,hBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
+ {
+ error = __MKSTRING("zero bits returned in primGetBits");
+ goto out;
+ }
+
+ /* swap red and blue (windows delivers BGR) */
+ {
+ char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
+ int _h;
+ char *rowp = cp;
+
+ for (_h=height; _h>0; _h--) {
+ int _w;
+ char *pixel = rowp;
+
+ for (_w=width; _w>0; _w--) {
+ char b;
+
+ b = pixel[0];
+ pixel[0] = pixel[2];
+ pixel[2] = b;
+ pixel += 3;
+ };
+ rowp += bytesPerRow;
+ };
+ }
+ } else {
+ error = __MKSTRING("unacceptable bitmap in primGetBits");
+ goto out;
+ }
+ } else {
+ error = __MKSTRING("unacceptable HWND in primGetBits");
+ goto out;
+ }
+
+ bytesPerLine = __MKSMALLINT(bytesPerRow);
+ bitmapPad = __MKSMALLINT(WIN32PADDING);
+ bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
}
out:
if ((hPrevious != NULL) && (bDC != NULL))
- SelectObject(bDC, hPrevious);
+ SelectObject(bDC, hPrevious);
if (bDC)
- DeleteDC(bDC);
+ DeleteDC(bDC);
if (hBitmap)
- _DeleteObject(hBitmap, __LINE__);
+ _DeleteObject(hBitmap, __LINE__);
%}.
error notNil ifTrue:[
- ^ self primitiveFailed:error.
+ ^ self primitiveFailed:error.
].
^ IdentityDictionary new
- at:#bitOrder put:#msbFirst;
- at:#depth put:1;
- at:#bytesPerLine put:bytesPerLine;
- at:#byteOrder put:#lsbFirst;
- at:#format put:#XYPixmap;
- at:#bitmapUnit put:0;
- at:#bitmapPad put:bitmapPad;
- at:#bitsPerPixel put:bitsPerPixel;
- at:#redMask put:16rFF0000;
- at:#greenMask put:16r00FF00;
- at:#blueMask put:16r0000FF;
- yourself.
+ at:#bitOrder put:#msbFirst;
+ at:#depth put:1;
+ at:#bytesPerLine put:bytesPerLine;
+ at:#byteOrder put:#lsbFirst;
+ at:#format put:#XYPixmap;
+ at:#bitmapUnit put:0;
+ at:#bitmapPad put:bitmapPad;
+ at:#bitsPerPixel put:bitsPerPixel;
+ at:#redMask put:16rFF0000;
+ at:#greenMask put:16r00FF00;
+ at:#blueMask put:16r0000FF;
+ yourself.
"Modified (comment): / 28-03-2017 / 14:28:39 / stefan"
!
@@ -16889,8 +16890,8 @@
|rawInfo error bytesPerLine format bitmapPad bitsPerPixel|
((w <= 0) or:[h <= 0]) ifTrue:[
- self primitiveFailed:'zero width or height'.
- ^ nil
+ self primitiveFailed:'zero width or height'.
+ ^ nil
].
rawInfo := Array new:11.
@@ -16905,8 +16906,8 @@
HDC xDC = 0;
struct
{
- BITMAPINFOHEADER bmiHeader;
- DWORD rgb[2];
+ BITMAPINFOHEADER bmiHeader;
+ DWORD rgb[2];
} bitmap;
BITMAP bitmapInfo;
@@ -16916,147 +16917,147 @@
&& __isArray(rawInfo) && __arraySize(rawInfo) >= 11
&& __isByteArray(imageBits))
{
- xBitmap = _HBITMAPVAL( aDrawableId );
- BMDPRINTF(("primGetBitsFromPixmap %x\n",xBitmap));
- if (xBitmap != 0) {
- xDC = GetDC(0);
- SelectObject(xDC, xBitmap);
- GetObject(xBitmap,sizeof(bitmapInfo),&bitmapInfo);
-
- bDC = CreateCompatibleDC(__rootDC);
- BMDPRINTF(("srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
- height = __intVal(h);
- width = __intVal(w);
- BMDPRINTF(("width %d height %d\n",width,height));
-
- hBitmap = CreateCompatibleBitmap(xDC, width, height);
- if (!hBitmap) {
- error = __MKSTRING("create bitmap failed");
- goto out;
- }
-
- SelectObject(bDC,hBitmap);
- if (BitBlt(bDC,
- 0,0,
- width,height,
- xDC,
- __intVal(srcX), __intVal(srcY),
- SRCCOPY)
- == 0
- )
- {
- error = __MKSTRING("BitBlt failed");
- goto out;
- }
- bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmap.bmiHeader.biPlanes = 1;
+ xBitmap = _HBITMAPVAL( aDrawableId );
+ BMDPRINTF(("primGetBitsFromPixmap %x\n",xBitmap));
+ if (xBitmap != 0) {
+ xDC = GetDC(0);
+ SelectObject(xDC, xBitmap);
+ GetObject(xBitmap,sizeof(bitmapInfo),&bitmapInfo);
+
+ bDC = CreateCompatibleDC(__rootDC);
+ BMDPRINTF(("srcX %d srcY %d w %d h %d\n",__intVal(srcX),__intVal(srcY),__intVal(w),__intVal(h)));
+ height = __intVal(h);
+ width = __intVal(w);
+ BMDPRINTF(("width %d height %d\n",width,height));
+
+ hBitmap = CreateCompatibleBitmap(xDC, width, height);
+ if (!hBitmap) {
+ error = __MKSTRING("create bitmap failed");
+ goto out;
+ }
+
+ SelectObject(bDC,hBitmap);
+ if (BitBlt(bDC,
+ 0,0,
+ width,height,
+ xDC,
+ __intVal(srcX), __intVal(srcY),
+ SRCCOPY)
+ == 0
+ )
+ {
+ error = __MKSTRING("BitBlt failed");
+ goto out;
+ }
+ bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bitmap.bmiHeader.biPlanes = 1;
#ifdef ALWAYSTRUECOLOR
- bitmap.bmiHeader.biCompression = BI_RGB;
-#else
- if (__depth == 24) {
- /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
- bitmap.r = 0xff0000;
- bitmap.g = 0x00ff00;
- bitmap.b = 0x0000ff;*/
- bitmap.bmiHeader.biCompression = BI_RGB;
- } else if (__depth == 16) {
- bitmap.b = 0x001f;
- bitmap.g = 0x07e0;
- bitmap.r = 0xf800;*/
- bitmap.bmiHeader.biCompression = BI_RGB;
- } else {
- error = __MKSTRING("primGetBitsFromPixmap: unsupported depth");
- got fail;
- }
+ bitmap.bmiHeader.biCompression = BI_RGB;
+#else
+ if (__depth == 24) {
+ /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
+ bitmap.r = 0xff0000;
+ bitmap.g = 0x00ff00;
+ bitmap.b = 0x0000ff;*/
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ } else if (__depth == 16) {
+ bitmap.b = 0x001f;
+ bitmap.g = 0x07e0;
+ bitmap.r = 0xf800;*/
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ } else {
+ error = __MKSTRING("primGetBitsFromPixmap: unsupported depth");
+ got fail;
+ }
#endif /* ALWAYSTRUECOLOR */
- bitmap.bmiHeader.biSizeImage = 0;
- bitmap.bmiHeader.biXPelsPerMeter = 0;
- bitmap.bmiHeader.biYPelsPerMeter = 0;
- bitmap.bmiHeader.biClrUsed = 0;
- bitmap.bmiHeader.biClrImportant = 0;
-
- bitmap.bmiHeader.biWidth = width;
- bitmap.bmiHeader.biHeight = -height;
- bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel;
-
- if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
- {
- error = __MKSTRING("GetDIBits failed");
- goto out;
- }
- BMDPRINTF(("bitmap info:%d %d %d %d\n",bitmap.bmiHeader.biWidth,bitmap.bmiHeader.biHeight,bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biSizeImage));
- numBytes = bitmap.bmiHeader.biSizeImage;
- if ( numBytes != 0 ) {
- if (numBytes > __byteArraySize(imageBits)) {
- /* imageBits too small */
- error = __MKSTRING("provided byteArray too small");
- goto out;
- }
- BMDPRINTF(("numBytes %d\n",numBytes));
-
- bitmap.bmiHeader.biHeight = -height;
- bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel; /*__depth;*/
- bitmap.rgb[0] = 0;
- bitmap.rgb[1] = 0xffffff;
- if (GetDIBits(xDC,xBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
- {
- BMDPRINTF(("zero bits returned\n"));
- error = __MKSTRING("zero bits returned");
- goto out;
- }
-
-#if 0
- {
- /* swap red and blue (windows delivers BGR) */
- char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
- int n = numBytes;
-
- for ( ;n > 0; n -= 3, cp += 3) {
- char b = cp[0];
- cp[0] = cp[2];
- cp[2] = b;
- }
- }
-#endif
- } else {
- error = __MKSTRING("unacceptable bitmap (size is 0 bytes)");
- goto out;
- }
- } else {
- error = __MKSTRING("unacceptable bitmap (null xBitmap)");
- goto out;
- }
- bytesPerLine = __MKSMALLINT(numBytes/height);
- format = (bitmap.bmiHeader.biBitCount == 1) ? @symbol(ZPixmap) : @symbol(XYPixmap);
- bitmapPad = __MKSMALLINT(WIN32PADDING);
- bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
+ bitmap.bmiHeader.biSizeImage = 0;
+ bitmap.bmiHeader.biXPelsPerMeter = 0;
+ bitmap.bmiHeader.biYPelsPerMeter = 0;
+ bitmap.bmiHeader.biClrUsed = 0;
+ bitmap.bmiHeader.biClrImportant = 0;
+
+ bitmap.bmiHeader.biWidth = width;
+ bitmap.bmiHeader.biHeight = -height;
+ bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel;
+
+ if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
+ {
+ error = __MKSTRING("GetDIBits failed");
+ goto out;
+ }
+ BMDPRINTF(("bitmap info:%d %d %d %d\n",bitmap.bmiHeader.biWidth,bitmap.bmiHeader.biHeight,bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biSizeImage));
+ numBytes = bitmap.bmiHeader.biSizeImage;
+ if ( numBytes != 0 ) {
+ if (numBytes > __byteArraySize(imageBits)) {
+ /* imageBits too small */
+ error = __MKSTRING("provided byteArray too small");
+ goto out;
+ }
+ BMDPRINTF(("numBytes %d\n",numBytes));
+
+ bitmap.bmiHeader.biHeight = -height;
+ bitmap.bmiHeader.biBitCount = bitmapInfo.bmBitsPixel; /*__depth;*/
+ bitmap.rgb[0] = 0;
+ bitmap.rgb[1] = 0xffffff;
+ if (GetDIBits(xDC,xBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
+ {
+ BMDPRINTF(("zero bits returned\n"));
+ error = __MKSTRING("zero bits returned");
+ goto out;
+ }
+
+#if 0
+ {
+ /* swap red and blue (windows delivers BGR) */
+ char *cp = __ByteArrayInstPtr(imageBits)->ba_element;
+ int n = numBytes;
+
+ for ( ;n > 0; n -= 3, cp += 3) {
+ char b = cp[0];
+ cp[0] = cp[2];
+ cp[2] = b;
+ }
+ }
+#endif
+ } else {
+ error = __MKSTRING("unacceptable bitmap (size is 0 bytes)");
+ goto out;
+ }
+ } else {
+ error = __MKSTRING("unacceptable bitmap (null xBitmap)");
+ goto out;
+ }
+ bytesPerLine = __MKSMALLINT(numBytes/height);
+ format = (bitmap.bmiHeader.biBitCount == 1) ? @symbol(ZPixmap) : @symbol(XYPixmap);
+ bitmapPad = __MKSMALLINT(WIN32PADDING);
+ bitsPerPixel = __MKSMALLINT(bitmap.bmiHeader.biBitCount);
}
out:
if (bDC)
- DeleteDC(bDC);
+ DeleteDC(bDC);
if (xDC)
- ReleaseDC(0, xDC); //DeleteDC(xDC);
+ ReleaseDC(0, xDC); //DeleteDC(xDC);
if (hBitmap)
- DeleteObject(hBitmap);
+ DeleteObject(hBitmap);
%}.
error notNil ifTrue:[
- self primitiveFailed:error.
+ self primitiveFailed:error.
].
^ IdentityDictionary new
- at:#bitOrder put:#msbFirst;
- at:#depth put:1;
- at:#bytesPerLine put:bytesPerLine;
- at:#byteOrder put:#lsbFirst;
- at:#format put:format;
- at:#bitmapUnit put:0;
- at:#bitmapPad put:bitmapPad;
- at:#bitsPerPixel put:bitsPerPixel;
- at:#redMask put:16rFF0000;
- at:#greenMask put:16r00FF00;
- at:#blueMask put:16r0000FF;
- yourself.
+ at:#bitOrder put:#msbFirst;
+ at:#depth put:1;
+ at:#bytesPerLine put:bytesPerLine;
+ at:#byteOrder put:#lsbFirst;
+ at:#format put:format;
+ at:#bitmapUnit put:0;
+ at:#bitmapPad put:bitmapPad;
+ at:#bitsPerPixel put:bitsPerPixel;
+ at:#redMask put:16rFF0000;
+ at:#greenMask put:16r00FF00;
+ at:#blueMask put:16r0000FF;
+ yourself.
"Modified (comment): / 28-03-2017 / 14:28:46 / stefan"
!