WinWorkstation.st
changeset 5570 33913e2520ac
parent 5554 17dce8b18c2e
child 5574 c5a18b1d05fa
equal deleted inserted replaced
5569:25b945e9c1f5 5570:33913e2520ac
  6979     |screenL screenT screenR screenB screenW screenH
  6979     |screenL screenT screenR screenB screenW screenH
  6980      workL workT workR workB workW workH
  6980      workL workT workR workB workW workH
  6981      isPrimary mName|
  6981      isPrimary mName|
  6982 %{
  6982 %{
  6983     if (__isExternalAddress(aMonitorId)) {
  6983     if (__isExternalAddress(aMonitorId)) {
  6984         HMONITOR hMonitor = _HWNDVal(aMonitorId);
  6984 	HMONITOR hMonitor = _HWNDVal(aMonitorId);
  6985         MONITORINFOEX info;
  6985 	MONITORINFOEX info;
  6986 
  6986 
  6987         info.cbSize = sizeof(MONITORINFOEX);
  6987 	info.cbSize = sizeof(MONITORINFOEX);
  6988 #if 0
  6988 #if 0
  6989         static BOOL (__stdcall *P_GetMonitorInfo)(HMONITOR , MONITORINFOEX *);
  6989 	static BOOL (__stdcall *P_GetMonitorInfo)(HMONITOR , MONITORINFOEX *);
  6990 
  6990 
  6991         if (P_GetMonitorInfo == 0) {
  6991 	if (P_GetMonitorInfo == 0) {
  6992             HINSTANCE hUser = LoadLibrary("user32.dll");
  6992 	    HINSTANCE hUser = LoadLibrary("user32.dll");
  6993             // console_printf("hUser: %x\n", hUser);
  6993 	    // console_printf("hUser: %x\n", hUser);
  6994             if (hUser) {
  6994 	    if (hUser) {
  6995                 P_GetMonitorInfo = (BOOL (__stdcall *)(HMONITOR, MONITORINFOEX * ))
  6995 		P_GetMonitorInfo = (BOOL (__stdcall *)(HMONITOR, MONITORINFOEX * ))
  6996                                     GetProcAddress(hUser, "GetMonitorInfo");
  6996 				    GetProcAddress(hUser, "GetMonitorInfo");
  6997             }
  6997 	    }
  6998         }
  6998 	}
  6999         console_printf("P_GetMonitorInfo: %x\n", P_GetMonitorInfo);
  6999 	console_printf("P_GetMonitorInfo: %x\n", P_GetMonitorInfo);
  7000         if ((*P_GetMonitorInfo)(hMonitor, &info))
  7000 	if ((*P_GetMonitorInfo)(hMonitor, &info))
  7001 #else
  7001 #else
  7002         if (GetMonitorInfo(hMonitor, &info))
  7002 	if (GetMonitorInfo(hMonitor, &info))
  7003 #endif
  7003 #endif
  7004         {
  7004 	{
  7005             // console_printf("l %d\n", info.rcMonitor.left);
  7005 	    // console_printf("l %d\n", info.rcMonitor.left);
  7006             screenL = __MKSMALLINT(info.rcMonitor.left);
  7006 	    screenL = __MKSMALLINT(info.rcMonitor.left);
  7007             screenT = __MKSMALLINT(info.rcMonitor.top);
  7007 	    screenT = __MKSMALLINT(info.rcMonitor.top);
  7008             screenR = __MKSMALLINT(info.rcMonitor.right);
  7008 	    screenR = __MKSMALLINT(info.rcMonitor.right);
  7009             screenB = __MKSMALLINT(info.rcMonitor.bottom);
  7009 	    screenB = __MKSMALLINT(info.rcMonitor.bottom);
  7010             workL = __MKSMALLINT(info.rcWork.left);
  7010 	    workL = __MKSMALLINT(info.rcWork.left);
  7011             workT = __MKSMALLINT(info.rcWork.top);
  7011 	    workT = __MKSMALLINT(info.rcWork.top);
  7012             workR = __MKSMALLINT(info.rcWork.right);
  7012 	    workR = __MKSMALLINT(info.rcWork.right);
  7013             workB = __MKSMALLINT(info.rcWork.bottom);
  7013 	    workB = __MKSMALLINT(info.rcWork.bottom);
  7014             isPrimary = (info.dwFlags & MONITORINFOF_PRIMARY) ? true : false;
  7014 	    isPrimary = (info.dwFlags & MONITORINFOF_PRIMARY) ? true : false;
  7015             info.szDevice[31] = '\0';
  7015 	    info.szDevice[31] = '\0';
  7016             mName = __MKSTRING(info.szDevice);
  7016 	    mName = __MKSTRING(info.szDevice);
  7017         }
  7017 	}
  7018     }
  7018     }
  7019 %}.
  7019 %}.
  7020     screenL isNil ifTrue:[ ^ nil ].
  7020     screenL isNil ifTrue:[ ^ nil ].
  7021 
  7021 
  7022     ^ MonitorInfo new
  7022     ^ MonitorInfo new
  7023         screenX:screenL screenY:screenT
  7023 	screenX:screenL screenY:screenT
  7024         screenWidth:(screenR-screenL) screenHeight:(screenB-screenT)
  7024 	screenWidth:(screenR-screenL) screenHeight:(screenB-screenT)
  7025         workX:workL workY:workT
  7025 	workX:workL workY:workT
  7026         workWidth:(workR-workL) workHeight:(workB-workT)
  7026 	workWidth:(workR-workL) workHeight:(workB-workT)
  7027         isPrimary:isPrimary
  7027 	isPrimary:isPrimary
  7028         name:mName
  7028 	name:mName
  7029 
  7029 
  7030     "
  7030     "
  7031      Screen current monitorInfoFor:(Screen current monitorHandleForView:(Transcript topView id))
  7031      Screen current monitorInfoFor:(Screen current monitorHandleForView:(Transcript topView id))
  7032      Screen current monitorInfoFor:(Screen current monitorHandleForPoint:(0@0))
  7032      Screen current monitorInfoFor:(Screen current monitorHandleForPoint:(0@0))
  7033      Screen current monitorInfoFor:(Screen current monitorHandleForPoint:(Display pointFromUser))
  7033      Screen current monitorInfoFor:(Screen current monitorHandleForPoint:(Display pointFromUser))
  7440 
  7440 
  7441     w := wSingle := self getSystemMetrics:#SM_CXFULLSCREEN.
  7441     w := wSingle := self getSystemMetrics:#SM_CXFULLSCREEN.
  7442     h := hSingle := self getSystemMetrics:#SM_CYFULLSCREEN.
  7442     h := hSingle := self getSystemMetrics:#SM_CYFULLSCREEN.
  7443 
  7443 
  7444     (self numberOfMonitors) > 1 ifTrue:[
  7444     (self numberOfMonitors) > 1 ifTrue:[
  7445         w := self getSystemMetrics:#SM_CXVIRTUALSCREEN.
  7445 	w := self getSystemMetrics:#SM_CXVIRTUALSCREEN.
  7446         h := self getSystemMetrics:#SM_CYVIRTUALSCREEN.
  7446 	h := self getSystemMetrics:#SM_CYVIRTUALSCREEN.
  7447         (w isNil or:[h isNil]) ifTrue:[
  7447 	(w isNil or:[h isNil]) ifTrue:[
  7448             "/ not supported under win95 and win-nt4 - fallback to real extent
  7448 	    "/ not supported under win95 and win-nt4 - fallback to real extent
  7449             w := wSingle.
  7449 	    w := wSingle.
  7450             h := hSingle.
  7450 	    h := hSingle.
  7451         ] ifFalse:[
  7451 	] ifFalse:[
  7452             dx := (self getSystemMetrics:#SM_CXSCREEN) - wSingle.
  7452 	    dx := (self getSystemMetrics:#SM_CXSCREEN) - wSingle.
  7453             dy := (self getSystemMetrics:#SM_CYSCREEN) - hSingle.
  7453 	    dy := (self getSystemMetrics:#SM_CYSCREEN) - hSingle.
  7454             w := w - dx.
  7454 	    w := w - dx.
  7455             h := h - dy - 8.
  7455 	    h := h - dy - 8.
  7456         ].
  7456 	].
  7457     ].
  7457     ].
  7458     ^ w @ h.
  7458     ^ w @ h.
  7459 
  7459 
  7460     "
  7460     "
  7461      Display usableExtent
  7461      Display usableExtent
  7470 
  7470 
  7471 usableHeightAt:aPoint
  7471 usableHeightAt:aPoint
  7472     "returns the usable height of the display (in pixels) at a given point
  7472     "returns the usable height of the display (in pixels) at a given point
  7473      Normally, the same as height, but may be smaller, in
  7473      Normally, the same as height, but may be smaller, in
  7474      case some menu space is taken up by the window manager (windows).
  7474      case some menu space is taken up by the window manager (windows).
  7475      On multi-display systems with different sized screens, this should care for 
  7475      On multi-display systems with different sized screens, this should care for
  7476      which display is at the given x-position"
  7476      which display is at the given x-position"
  7477 
  7477 
  7478     |info|
  7478     |info|
  7479 
  7479 
  7480     (self numberOfMonitors) > 1 ifTrue:[
  7480     (self numberOfMonitors) > 1 ifTrue:[
  7481         info := self monitorInfoFor:(self monitorHandleForPoint:(aPoint max:(0@0))).
  7481 	info := self monitorInfoFor:(self monitorHandleForPoint:(aPoint max:(0@0))).
  7482         info notNil ifTrue:[ ^ info workHeight ].
  7482 	info notNil ifTrue:[ ^ info workHeight ].
  7483     ].
  7483     ].
  7484     ^ self usableHeight
  7484     ^ self usableHeight
  7485 
  7485 
  7486     "
  7486     "
  7487      Display usableHeightAt:100@100
  7487      Display usableHeightAt:100@100
  7883     OBJ num;
  7883     OBJ num;
  7884     unsigned char *allocatedBits = 0;
  7884     unsigned char *allocatedBits = 0;
  7885     unsigned char fastBits[10000];
  7885     unsigned char fastBits[10000];
  7886 
  7886 
  7887     if (__bothSmallInteger(w, h) && __isNonNilObject(anArray)) {
  7887     if (__bothSmallInteger(w, h) && __isNonNilObject(anArray)) {
  7888         b_width = __intVal(w);
  7888 	b_width = __intVal(w);
  7889         b_height = __intVal(h);
  7889 	b_height = __intVal(h);
  7890         bytesPerRowST = (b_width + 7) / 8;
  7890 	bytesPerRowST = (b_width + 7) / 8;
  7891         bytesPerRowWN = ((b_width + 15) / 16) * 2;
  7891 	bytesPerRowWN = ((b_width + 15) / 16) * 2;
  7892         padding = bytesPerRowWN - bytesPerRowST;
  7892 	padding = bytesPerRowWN - bytesPerRowST;
  7893 
  7893 
  7894         if ((padding == 0) && (__isByteArrayLike(anArray))) {
  7894 	if ((padding == 0) && (__isByteArrayLike(anArray))) {
  7895             b_bits = __ByteArrayInstPtr(anArray)->ba_element;
  7895 	    b_bits = __ByteArrayInstPtr(anArray)->ba_element;
  7896             cp = 0;
  7896 	    cp = 0;
  7897         } else {
  7897 	} else {
  7898             int nBytes = b_height * bytesPerRowWN;
  7898 	    int nBytes = b_height * bytesPerRowWN;
  7899 
  7899 
  7900             if (nBytes < sizeof(fastBits)) {
  7900 	    if (nBytes < sizeof(fastBits)) {
  7901                 cp = b_bits = fastBits;
  7901 		cp = b_bits = fastBits;
  7902             } else {
  7902 	    } else {
  7903                 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
  7903 		cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
  7904                 if (! cp) goto fail;
  7904 		if (! cp) goto fail;
  7905             }
  7905 	    }
  7906         }
  7906 	}
  7907         if (cp) {
  7907 	if (cp) {
  7908             if (__qIsArrayLike(anArray)) {
  7908 	    if (__qIsArrayLike(anArray)) {
  7909                 OBJ *op;
  7909 		OBJ *op;
  7910 
  7910 
  7911                 index = 1;
  7911 		index = 1;
  7912                 op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
  7912 		op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
  7913                 for (row = b_height; row; row--) {
  7913 		for (row = b_height; row; row--) {
  7914                     for (col = bytesPerRowST; col; col--) {
  7914 		    for (col = bytesPerRowST; col; col--) {
  7915                         num = *op++;
  7915 			num = *op++;
  7916                         if (! __isSmallInteger(num))
  7916 			if (! __isSmallInteger(num))
  7917                             goto fail;
  7917 			    goto fail;
  7918                         *cp++ = __intVal(num);
  7918 			*cp++ = __intVal(num);
  7919                     }
  7919 		    }
  7920                     cp += padding;
  7920 		    cp += padding;
  7921                 }
  7921 		}
  7922             } else if (__qIsByteArrayLike(anArray)) {
  7922 	    } else if (__qIsByteArrayLike(anArray)) {
  7923                 unsigned char *pBits;
  7923 		unsigned char *pBits;
  7924 
  7924 
  7925                 pBits = __ByteArrayInstPtr(anArray)->ba_element;
  7925 		pBits = __ByteArrayInstPtr(anArray)->ba_element;
  7926                 for (row = b_height; row; row--) {
  7926 		for (row = b_height; row; row--) {
  7927                     for (col = bytesPerRowST; col; col--) {
  7927 		    for (col = bytesPerRowST; col; col--) {
  7928                         *cp++ = ( *pBits++ /*^ 0xFF*/ );
  7928 			*cp++ = ( *pBits++ /*^ 0xFF*/ );
  7929                     }
  7929 		    }
  7930                     cp += padding;
  7930 		    cp += padding;
  7931                 }
  7931 		}
  7932             } else {
  7932 	    } else {
  7933                 goto fail;
  7933 		goto fail;
  7934             }
  7934 	    }
  7935         }
  7935 	}
  7936         CPRINTF(("create bitmap ...\n"));
  7936 	CPRINTF(("create bitmap ...\n"));
  7937 
  7937 
  7938         newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
  7938 	newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
  7939 
  7939 
  7940         if (newBitmapHandle ) {
  7940 	if (newBitmapHandle ) {
  7941 #ifdef COUNT_BMP_RESOURCES
  7941 #ifdef COUNT_BMP_RESOURCES
  7942             __cnt_bitmap++;
  7942 	    __cnt_bitmap++;
  7943             RES_BMP_PRINTF(("CreateBitmap %x %d\n",newBitmapHandle,__cnt_bitmap));
  7943 	    RES_BMP_PRINTF(("CreateBitmap %x %d\n",newBitmapHandle,__cnt_bitmap));
  7944 #endif
  7944 #endif
  7945             DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
  7945 	    DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
  7946             if (allocatedBits) {
  7946 	    if (allocatedBits) {
  7947                 free(allocatedBits);
  7947 		free(allocatedBits);
  7948             }
  7948 	    }
  7949             RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
  7949 	    RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
  7950         }
  7950 	}
  7951     }
  7951     }
  7952 fail: ;
  7952 fail: ;
  7953     DDPRINTF(("create bitmap FAILED!!!\n"));
  7953     DDPRINTF(("create bitmap FAILED!!!\n"));
  7954     if (allocatedBits) {
  7954     if (allocatedBits) {
  7955         CPRINTF(("freeing up bitmap bits ...\n"));
  7955 	CPRINTF(("freeing up bitmap bits ...\n"));
  7956         free(allocatedBits);
  7956 	free(allocatedBits);
  7957     }
  7957     }
  7958     CPRINTF(("returning nil ...\n"));
  7958     CPRINTF(("returning nil ...\n"));
  7959     RETURN ( nil );
  7959     RETURN ( nil );
  7960 %}
  7960 %}
  7961 !
  7961 !
  9619 
  9619 
  9620 dragFinish:dropHandle
  9620 dragFinish:dropHandle
  9621     "free Win32 data (and remove the drop-file)"
  9621     "free Win32 data (and remove the drop-file)"
  9622 %{
  9622 %{
  9623     if (__isExternalAddress(dropHandle)) {
  9623     if (__isExternalAddress(dropHandle)) {
  9624         HDROP hDrop = (HDROP)__externalAddressVal(dropHandle);
  9624 	HDROP hDrop = (HDROP)__externalAddressVal(dropHandle);
  9625 
  9625 
  9626         __externalAddressVal(dropHandle) = 0;
  9626 	__externalAddressVal(dropHandle) = 0;
  9627         if (hDrop) {
  9627 	if (hDrop) {
  9628             DragFinish(hDrop);
  9628 	    DragFinish(hDrop);
  9629         }
  9629 	}
  9630     }
  9630     }
  9631 %}
  9631 %}
  9632 ! !
  9632 ! !
  9633 
  9633 
  9634 !WinWorkstation methodsFor:'drawing'!
  9634 !WinWorkstation methodsFor:'drawing'!
 13277 	__ArrayInstPtr(rawData)->a_element[5] = __MKSMALLINT(tmet.tmMaxCharWidth);  /* maxWidth   -> (data at:6) */
 13277 	__ArrayInstPtr(rawData)->a_element[5] = __MKSMALLINT(tmet.tmMaxCharWidth);  /* maxWidth   -> (data at:6) */
 13278 	__ArrayInstPtr(rawData)->a_element[6] = __MKSMALLINT(avgWidth);             /* avgWidth   -> (data at:7) */
 13278 	__ArrayInstPtr(rawData)->a_element[6] = __MKSMALLINT(avgWidth);             /* avgWidth   -> (data at:7) */
 13279 	__ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar);     /* min        -> (data at:8) */
 13279 	__ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar);     /* min        -> (data at:8) */
 13280 	__ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar);      /* max        -> (data at:9) */
 13280 	__ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar);      /* max        -> (data at:9) */
 13281 	__ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar);   /* default    -> (data at:10) */
 13281 	__ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar);   /* default    -> (data at:10) */
       
 13282 	__PROTECT__(rawData);
 13282 	t = __charSetSymbolFor(tmet.tmCharSet);
 13283 	t = __charSetSymbolFor(tmet.tmCharSet);
       
 13284 	__UNPROTECT__(rawData);
 13283 	__ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t);             /* charSet    -> (data at:11) */
 13285 	__ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t);             /* charSet    -> (data at:11) */
 13284 
 13286 
 13285 	DPRINTF(("textMetrics h=%x  avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n",
 13287 	DPRINTF(("textMetrics h=%x  avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n",
 13286 		    hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth,
 13288 		    hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth,
 13287 		    tmet.tmAveCharWidth));
 13289 		    tmet.tmAveCharWidth));
 14942 
 14944 
 14943     pX := aPoint x.
 14945     pX := aPoint x.
 14944     pY := aPoint y.
 14946     pY := aPoint y.
 14945 %{
 14947 %{
 14946     if (__bothSmallInteger(pX, pY)) {
 14948     if (__bothSmallInteger(pX, pY)) {
 14947         POINT p;
 14949 	POINT p;
 14948         HMONITOR hMonitor;
 14950 	HMONITOR hMonitor;
 14949         p.x = __intVal(pX);
 14951 	p.x = __intVal(pX);
 14950         p.y = __intVal(pY);
 14952 	p.y = __intVal(pY);
 14951 #if 0
 14953 #if 0
 14952         static HMONITOR (__stdcall *P_MonitorFromPoint)(POINT, int);
 14954 	static HMONITOR (__stdcall *P_MonitorFromPoint)(POINT, int);
 14953 
 14955 
 14954         if (P_MonitorFromPoint == 0) {
 14956 	if (P_MonitorFromPoint == 0) {
 14955             HINSTANCE hUser = LoadLibrary("user32.dll");
 14957 	    HINSTANCE hUser = LoadLibrary("user32.dll");
 14956             // console_printf("hUser: %x\n", hUser);
 14958 	    // console_printf("hUser: %x\n", hUser);
 14957             if (hUser) {
 14959 	    if (hUser) {
 14958                 P_MonitorFromPoint = (HMONITOR (__stdcall *)(POINT, int ))
 14960 		P_MonitorFromPoint = (HMONITOR (__stdcall *)(POINT, int ))
 14959                                     GetProcAddress(hUser, "MonitorFromPoint");
 14961 				    GetProcAddress(hUser, "MonitorFromPoint");
 14960             }
 14962 	    }
 14961         }
 14963 	}
 14962         // console_printf("P_MonitorFromPoint: %x\n", P_MonitorFromPoint);
 14964 	// console_printf("P_MonitorFromPoint: %x\n", P_MonitorFromPoint);
 14963 
 14965 
 14964         hMonitor = (*P_MonitorFromPoint)(p, MONITOR_DEFAULTTONULL);
 14966 	hMonitor = (*P_MonitorFromPoint)(p, MONITOR_DEFAULTTONULL);
 14965 #else
 14967 #else
 14966         hMonitor = MonitorFromPoint(p, MONITOR_DEFAULTTONULL);
 14968 	hMonitor = MonitorFromPoint(p, MONITOR_DEFAULTTONULL);
 14967 #endif
 14969 #endif
 14968         if (hMonitor == 0) {
 14970 	if (hMonitor == 0) {
 14969             RETURN(nil);
 14971 	    RETURN(nil);
 14970         }
 14972 	}
 14971         RETURN ( __MKEXTERNALADDRESS(hMonitor) );
 14973 	RETURN ( __MKEXTERNALADDRESS(hMonitor) );
 14972     }
 14974     }
 14973 %}
 14975 %}
 14974     "
 14976     "
 14975      Screen current monitorHandleForPoint:(0@0)
 14977      Screen current monitorHandleForPoint:(0@0)
 14976      Screen current monitorHandleForPoint:(1500@0)
 14978      Screen current monitorHandleForPoint:(1500@0)
 18874 ! !
 18876 ! !
 18875 
 18877 
 18876 !WinWorkstation class methodsFor:'documentation'!
 18878 !WinWorkstation class methodsFor:'documentation'!
 18877 
 18879 
 18878 version
 18880 version
 18879     ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.422 2010-02-03 18:14:54 cg Exp $'
 18881     ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.423 2010-07-06 12:11:33 cg Exp $'
 18880 !
 18882 !
 18881 
 18883 
 18882 version_CVS
 18884 version_CVS
 18883     ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.422 2010-02-03 18:14:54 cg Exp $'
 18885     ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.423 2010-07-06 12:11:33 cg Exp $'
 18884 ! !
 18886 ! !
 18885 
 18887 
 18886 WinWorkstation initialize!
 18888 WinWorkstation initialize!