WinWorkstation.st
changeset 8144 abf53adf9239
parent 8055 99ee0d7766eb
child 8173 24ca1712f183
equal deleted inserted replaced
8143:cdd9fdf39d88 8144:abf53adf9239
  7047 	    if (hUser) {
  7047 	    if (hUser) {
  7048 		P_GetMonitorInfo = (BOOL (__stdcall *)(HMONITOR, MONITORINFOEX * ))
  7048 		P_GetMonitorInfo = (BOOL (__stdcall *)(HMONITOR, MONITORINFOEX * ))
  7049 				    GetProcAddress(hUser, "GetMonitorInfo");
  7049 				    GetProcAddress(hUser, "GetMonitorInfo");
  7050 	    }
  7050 	    }
  7051 	}
  7051 	}
  7052 	console_printf("P_GetMonitorInfo: %x\n", P_GetMonitorInfo);
  7052 	DPRINTF(("P_GetMonitorInfo: %x\n", P_GetMonitorInfo));
  7053 	if ((*P_GetMonitorInfo)(hMonitor, &info))
  7053 	if ((*P_GetMonitorInfo)(hMonitor, &info))
  7054 #else
  7054 #else
  7055 	if (GetMonitorInfo(hMonitor, (MONITORINFO *)(&info)))
  7055 	if (GetMonitorInfo(hMonitor, (MONITORINFO *)(&info)))
  7056 #endif
  7056 #endif
  7057 	{
  7057 	{
 11015     destinationOrigin:dstOrigin
 11015     destinationOrigin:dstOrigin
 11016     extent:imageExtent2
 11016     extent:imageExtent2
 11017     with:aGCId
 11017     with:aGCId
 11018 
 11018 
 11019     (self
 11019     (self
 11020         primDrawBits:imageBits
 11020 	primDrawBits:imageBits
 11021         bitsPerPixel:bitsPerPixel
 11021 	bitsPerPixel:bitsPerPixel
 11022         depth:imageDepth
 11022 	depth:imageDepth
 11023         width:imageExtent x height:imageExtent y
 11023 	width:imageExtent x height:imageExtent y
 11024         x:srcOrigin x y:srcOrigin y
 11024 	x:srcOrigin x y:srcOrigin y
 11025         into:ignoredDrawableId
 11025 	into:ignoredDrawableId
 11026         x:dstOrigin x y:dstOrigin y
 11026 	x:dstOrigin x y:dstOrigin y
 11027         width:imageExtent x height:imageExtent y
 11027 	width:imageExtent x height:imageExtent y
 11028         with:aGCId
 11028 	with:aGCId
 11029         parameters:(Array with:nil with:padd with:(maskVector at:1) with:(maskVector at:2) with:(maskVector at:3))
 11029 	parameters:(Array with:nil with:padd with:(maskVector at:1) with:(maskVector at:2) with:(maskVector at:3))
 11030         "/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
 11030 	"/ the params array is ONLY used, because there is a 15-argument limit in st/x !!
 11031         "/   sourceAlphaOrNil := params at:1.
 11031 	"/   sourceAlphaOrNil := params at:1.
 11032         "/   padd := params at:2.
 11032 	"/   padd := params at:2.
 11033         "/   redMask := params at:3.
 11033 	"/   redMask := params at:3.
 11034         "/   greenMask := params at:4.
 11034 	"/   greenMask := params at:4.
 11035         "/   blueMask := params at:5.
 11035 	"/   blueMask := params at:5.
 11036     ) ifFalse:[
 11036     ) ifFalse:[
 11037         "
 11037 	"
 11038          also happens, if a segmentation violation occurs in primitive code...
 11038 	 also happens, if a segmentation violation occurs in primitive code...
 11039         "
 11039 	"
 11040         self primitiveFailed
 11040 	self primitiveFailed
 11041     ].
 11041     ].
 11042 !
 11042 !
 11043 
 11043 
 11044 primDrawBits:imageBits
 11044 primDrawBits:imageBits
 11045 	bitsPerPixel:bitsPerPixel depth:imageDepth
 11045 	bitsPerPixel:bitsPerPixel depth:imageDepth
 11141 
 11141 
 11142 	bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 11142 	bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 11143 	bitmap.bmiHeader.biPlanes = 1;
 11143 	bitmap.bmiHeader.biPlanes = 1;
 11144 	switch (__intVal(imageDepth)) {
 11144 	switch (__intVal(imageDepth)) {
 11145 	    case 16:
 11145 	    case 16:
 11146 		/* notice the default r/g/b (STX order here) */
 11146 		// BI_BITFIELDS is only possible with 16 and 32 bit images
 11147 #if 1
 11147 		// (see msdn.microoft.com/library/cc250415.aspx)
       
 11148 
       
 11149 		// notice the default r/g/b (STX order here)
 11148 		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 11150 		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 11149 		bitmap.r = redMask == nil ? 0xf800 : __intVal(redMask);
 11151 		bitmap.r = redMask == nil ? 0xf800 : __intVal(redMask);
 11150 		bitmap.g = greenMask == nil ? 0x07e0 : __intVal(greenMask);
 11152 		bitmap.g = greenMask == nil ? 0x07e0 : __intVal(greenMask);
 11151 		bitmap.b = blueMask == nil ? 0x001f : __intVal(blueMask);
 11153 		bitmap.b = blueMask == nil ? 0x001f : __intVal(blueMask);
 11152 #endif
       
 11153 		break;
 11154 		break;
 11154 
 11155 
 11155 	    case 24:
 11156 	    case 24:
 11156 		/* notice the default b/g/r (WIN32 order here) */
 11157 		// BI_BITFIELDS is only possible with 16 and 32 bit images
 11157 #if 0
 11158 		// (see msdn.microoft.com/library/cc250415.aspx)
 11158 		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 11159 
 11159 		bitmap.r = redMask == nil ? 0xff0000 : __intVal(redMask);
 11160 		// notice the default b/g/r (WIN32 order here)
 11160 		bitmap.g = greenMask == nil ? 0x00ff00 : __intVal(greenMask);
       
 11161 		bitmap.b = blueMask == nil ? 0x0000ff : __intVal(blueMask);
       
 11162 #endif
       
 11163 		bitmap.bmiHeader.biCompression = BI_RGB;
 11161 		bitmap.bmiHeader.biCompression = BI_RGB;
 11164 		break;
 11162 		break;
 11165 
 11163 
 11166 	    case 32:
 11164 	    case 32:
 11167 		/* notice the default r/g/b (STX order here) */
 11165 		// BI_BITFIELDS is only possible with 16 and 32 bit images
 11168 		bitmap.bmiHeader.biCompression = BI_RGB;
 11166 		// (see msdn.microoft.com/library/cc250415.aspx)
 11169 #if 1
 11167 
       
 11168 		// notice the default r/g/b (STX order here)
 11170 		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 11169 		bitmap.bmiHeader.biCompression = BI_BITFIELDS;
 11171 		bitmap.r = redMask == nil ? 0x0000ff : __intVal(redMask);
 11170 		bitmap.r = redMask == nil ? 0x0000ff : __intVal(redMask);
 11172 		bitmap.g = greenMask == nil ? 0x00ff00 : __intVal(greenMask);
 11171 		bitmap.g = greenMask == nil ? 0x00ff00 : __intVal(greenMask);
 11173 		bitmap.b = blueMask == nil ? 0xff0000 : __intVal(blueMask);
 11172 		bitmap.b = blueMask == nil ? 0xff0000 : __intVal(blueMask);
 11174 		bitmap.a = 0xff000000;
 11173 		bitmap.a = 0xff000000;
 11175 #endif
       
 11176 		break;
 11174 		break;
 11177 	}
 11175 	}
 11178 
 11176 
 11179 	if (sourceAlphaOrNil != nil) {
 11177 	if (sourceAlphaOrNil != nil) {
 11180 console_printf("sourceAlphaOrNil = %x\n", sourceAlphaOrNil);
 11178 	    DPRINTF(("sourceAlphaOrNil = %x\n", sourceAlphaOrNil));
 11181 	    _sourceAlpha = __intVal(sourceAlphaOrNil);
 11179 	    _sourceAlpha = __intVal(sourceAlphaOrNil);
 11182 	    _doAlphaBlend = 1;
 11180 	    _doAlphaBlend = 1;
 11183 	}
 11181 	}
 11184 
 11182 
 11185 	bitmap.bmiHeader.biSizeImage = 0;
 11183 	bitmap.bmiHeader.biSizeImage = 0;
 11188 	bitmap.bmiHeader.biClrUsed = 0;
 11186 	bitmap.bmiHeader.biClrUsed = 0;
 11189 	bitmap.bmiHeader.biClrImportant = 0;
 11187 	bitmap.bmiHeader.biClrImportant = 0;
 11190 	bitmap.bmiHeader.biWidth = __intVal(imageWidth);
 11188 	bitmap.bmiHeader.biWidth = __intVal(imageWidth);
 11191 	bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
 11189 	bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
 11192 	bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
 11190 	bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
 11193 	/*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);*/
 11191 	DPRINTF(("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));
 11194 
 11192 
 11195 	if (! _doAlphaBlend) {
 11193 	if (! _doAlphaBlend) {
       
 11194 	    // normal draw (no alpha)
       
 11195 
 11196 	    SetDIBitsToDevice(hDC,
 11196 	    SetDIBitsToDevice(hDC,
 11197 				__intVal(dstx), __intVal(dsty),
 11197 				__intVal(dstx), __intVal(dsty),
 11198 				__intVal(w), __intVal(h),
 11198 				__intVal(w), __intVal(h),
 11199 				__intVal(srcx), __intVal(srcy),
 11199 				__intVal(srcx), __intVal(srcy),
 11200 				0, __intVal(h),
 11200 				0, __intVal(h),
 11201 				(void *)b_bits,
 11201 				(void *)b_bits,
 11202 				(BITMAPINFO*)&bitmap,
 11202 				(BITMAPINFO*)&bitmap,
 11203 				DIB_RGB_COLORS);
 11203 				DIB_RGB_COLORS);
 11204 	} else {
 11204 	} else {
       
 11205 	    // alpha blending
       
 11206 
 11205 	    HDC ahdc;
 11207 	    HDC ahdc;
 11206 	    HBITMAP ahbitmap;
 11208 	    HBITMAP ahbitmap;
 11207 	    void *pvBits;
 11209 	    void *pvBits;
 11208 	    BLENDFUNCTION bf;
 11210 	    BLENDFUNCTION bf;
 11209 	    static BOOL (__stdcall *P_AlphaBlend)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION );
 11211 	    static BOOL (__stdcall *P_AlphaBlend)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION );
 11217 		    P_AlphaBlend = (BOOL (__stdcall *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION ))
 11219 		    P_AlphaBlend = (BOOL (__stdcall *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION ))
 11218 					GetProcAddress(hWinGDI, "AlphaBlend");
 11220 					GetProcAddress(hWinGDI, "AlphaBlend");
 11219 		}
 11221 		}
 11220 	    }
 11222 	    }
 11221 	    if (P_AlphaBlend != 0) {
 11223 	    if (P_AlphaBlend != 0) {
 11222 console_printf("***********************************\n");
 11224 		DPRINTF(("***********************************\n"));
 11223 console_printf("_sourceAlpha = %d\n", _sourceAlpha);
 11225 		DPRINTF(("_sourceAlpha = %d\n", _sourceAlpha));
       
 11226 
 11224 		ahdc = CreateCompatibleDC(hDC);
 11227 		ahdc = CreateCompatibleDC(hDC);
 11225 
 11228 
 11226 		ahbitmap = CreateCompatibleBitmap(hDC, __intVal(imageWidth), __intVal(imageHeight));
 11229 		ahbitmap = CreateCompatibleBitmap(hDC, __intVal(imageWidth), __intVal(imageHeight));
 11227 		SelectObject(ahdc, ahbitmap);
 11230 		SelectObject(ahdc, ahbitmap);
 11228 		SetDIBitsToDevice(ahdc,
 11231 		SetDIBitsToDevice(ahdc,
 11371 activate:aBoolean view:aView
 11374 activate:aBoolean view:aView
 11372     "some view was activated/deactivated.
 11375     "some view was activated/deactivated.
 11373      For compatibility we send a focus-event to that topView"
 11376      For compatibility we send a focus-event to that topView"
 11374 
 11377 
 11375     aBoolean ifFalse:[
 11378     aBoolean ifFalse:[
 11376         activeView == aView ifTrue:[
 11379 	activeView == aView ifTrue:[
 11377             activeView := nil.
 11380 	    activeView := nil.
 11378         ].
 11381 	].
 11379         self focusOutView:aView.
 11382 	self focusOutView:aView.
 11380     ] ifTrue:[
 11383     ] ifTrue:[
 11381         activeView := aView.
 11384 	activeView := aView.
 11382         self focusInView:aView.
 11385 	self focusInView:aView.
 11383     ].
 11386     ].
 11384 
 11387 
 11385     "Created: / 28.4.1999 / 14:51:51 / cg"
 11388     "Created: / 28.4.1999 / 14:51:51 / cg"
 11386     "Modified: / 28.4.1999 / 15:07:09 / cg"
 11389     "Modified: / 28.4.1999 / 15:07:09 / cg"
 11387 !
 11390 !
 13068 	_keyCodeOrButtonNr = __intVal(keySymCodeOrButtonNr);
 13071 	_keyCodeOrButtonNr = __intVal(keySymCodeOrButtonNr);
 13069     } else {
 13072     } else {
 13070 	if (__isCharacter(keySymCodeOrButtonNr)) {
 13073 	if (__isCharacter(keySymCodeOrButtonNr)) {
 13071 
 13074 
 13072 	    _keyCodeOrButtonNr = __intVal(__characterVal(keySymCodeOrButtonNr));
 13075 	    _keyCodeOrButtonNr = __intVal(__characterVal(keySymCodeOrButtonNr));
 13073 console_printf("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr);
 13076 	    DPRINTF(("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13074 	    if ((_keyCodeOrButtonNr >= 'a') && (_keyCodeOrButtonNr <= 'z')) {
 13077 	    if ((_keyCodeOrButtonNr >= 'a') && (_keyCodeOrButtonNr <= 'z')) {
 13075 		_keyCodeOrButtonNr -= 0x20;
 13078 		_keyCodeOrButtonNr -= 0x20;
 13076 console_printf("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr);
 13079 		DPRINTF(("code: %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13077 	    } else {
 13080 	    } else {
 13078 		if ((_keyCodeOrButtonNr >= 'A') && (_keyCodeOrButtonNr <= 'Z')) {
 13081 		if ((_keyCodeOrButtonNr >= 'A') && (_keyCodeOrButtonNr <= 'Z')) {
 13079 console_printf("code: shifted %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr);
 13082 		    DPRINTF(("code: shifted %d (#%02x)\n", _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13080 		    _shifted = 1;
 13083 		    _shifted = 1;
 13081 		}
 13084 		}
 13082 	    }
 13085 	    }
 13083 	} else if (keySymCodeOrButtonNr == @symbol(Return)) {
 13086 	} else if (keySymCodeOrButtonNr == @symbol(Return)) {
 13084 	    _keyCodeOrButtonNr = VK_RETURN;
 13087 	    _keyCodeOrButtonNr = VK_RETURN;
 13217 	if ((xPos != nil) && (yPos != nil)) {
 13220 	if ((xPos != nil) && (yPos != nil)) {
 13218 	    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, _xP, _yP, 0, NULL);
 13221 	    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, _xP, _yP, 0, NULL);
 13219 	}
 13222 	}
 13220 
 13223 
 13221 	if (_isMouseEvent) {
 13224 	if (_isMouseEvent) {
 13222 console_printf("mouse %08x %d/%d\n", dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP);
 13225 	    DPRINTF(("mouse %08x %d/%d\n", dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP));
 13223 	    mouse_event(dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP, 0, NULL);
 13226 	    mouse_event(dwFlags | MOUSEEVENTF_ABSOLUTE, _xP, _yP, 0, NULL);
 13224 	} else {
 13227 	} else {
 13225 	    if (_shifted) {
 13228 	    if (_shifted) {
 13226 console_printf("shifted keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr);
 13229 		DPRINTF(("shifted keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13227 		keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, 0, 0);
 13230 		keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, 0, 0);
 13228 		keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
 13231 		keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
 13229 		keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, KEYEVENTF_KEYUP, 0);
 13232 		keybd_event( VK_SHIFT, 0 /* _keyCodeOrButtonNr */, KEYEVENTF_KEYUP, 0);
 13230 	    } else {
 13233 	    } else {
 13231 console_printf("keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr);
 13234 		DPRINTF(("keybd #%08x %d (#%02x)\n", dwFlags, _keyCodeOrButtonNr, _keyCodeOrButtonNr));
 13232 		keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
 13235 		keybd_event( _keyCodeOrButtonNr, 0 /* _keyCodeOrButtonNr */, dwFlags, 0);
 13233 	    }
 13236 	    }
 13234 	}
 13237 	}
 13235     } else {
 13238     } else {
 13236 	rslt = PostMessage(hWnd, msg, wParam, lParam);
 13239 	rslt = PostMessage(hWnd, msg, wParam, lParam);
 15917 	char *dst = filterBuffer;
 15920 	char *dst = filterBuffer;
 15918 	unsigned int idx;
 15921 	unsigned int idx;
 15919 
 15922 
 15920 	for (idx=0; idx<__arraySize(filterArrayOrNil); idx++) {
 15923 	for (idx=0; idx<__arraySize(filterArrayOrNil); idx++) {
 15921 	    OBJ el = __ArrayInstPtr(filterArrayOrNil)->a_element[idx];
 15924 	    OBJ el = __ArrayInstPtr(filterArrayOrNil)->a_element[idx];
 15922 // console_printf("idx = %d\n", idx);
 15925 	    // console_printf("idx = %d\n", idx);
 15923 	    if (__isArrayLike(el) && (__arraySize(el) == 2)) {
 15926 	    if (__isArrayLike(el) && (__arraySize(el) == 2)) {
 15924 		OBJ descr, filter;
 15927 		OBJ descr, filter;
 15925 
 15928 
 15926 		descr = __ArrayInstPtr(el)->a_element[0];
 15929 		descr = __ArrayInstPtr(el)->a_element[0];
 15927 		filter = __ArrayInstPtr(el)->a_element[1];
 15930 		filter = __ArrayInstPtr(el)->a_element[1];
 15928 		if (__isStringLike(descr) && __isStringLike(filter)) {
 15931 		if (__isStringLike(descr) && __isStringLike(filter)) {
 15929 		    char *src = __stringVal(descr);
 15932 		    char *src = __stringVal(descr);
 15930 
 15933 
 15931 // console_printf("descr: %s filter: %s\n", __stringVal(descr), __stringVal(filter));
 15934 		    // console_printf("descr: %s filter: %s\n", __stringVal(descr), __stringVal(filter));
 15932 
 15935 
 15933 		    // append (incl 0-byte)
 15936 		    // append (incl 0-byte)
 15934 		    while (*src) {
 15937 		    while (*src) {
 15935 			*dst++ = *src++;
 15938 			*dst++ = *src++;
 15936 		    }
 15939 		    }