WinWorkstation.st
branchjv
changeset 7994 42a7e4c6503d
parent 7743 fa3c8eb0bc1d
child 8016 653376a94c8f
equal deleted inserted replaced
7972:fa17f9363939 7994:42a7e4c6503d
  2798 		if (lI && (lI->minWidth) && (lI->maxWidth)) {
  2798 		if (lI && (lI->minWidth) && (lI->maxWidth)) {
  2799 		  lpmmi->ptMaxPosition.x = 0;
  2799 		  lpmmi->ptMaxPosition.x = 0;
  2800 		  lpmmi->ptMaxPosition.y = 0;
  2800 		  lpmmi->ptMaxPosition.y = 0;
  2801 		  lpmmi->ptMaxSize.x = lI->currentMonitorWidth;
  2801 		  lpmmi->ptMaxSize.x = lI->currentMonitorWidth;
  2802 		  lpmmi->ptMaxSize.y = lI->currentMonitorHeight;
  2802 		  lpmmi->ptMaxSize.y = lI->currentMonitorHeight;
  2803 #define MIN(a, b) (a < b ? a : b)
  2803 /* Added Extra parentheses to avoid operator precedence problem */
       
  2804 #define MIN(a,b) (((a)<(b))?(a):(b))
  2804 		  lpmmi->ptMaxSize.x = MIN(GetSystemMetrics(SM_CXMAXIMIZED), lI->maxWidth);
  2805 		  lpmmi->ptMaxSize.x = MIN(GetSystemMetrics(SM_CXMAXIMIZED), lI->maxWidth);
  2805 		  lpmmi->ptMaxSize.y = MIN(GetSystemMetrics(SM_CYMAXIMIZED), lI->maxHeight);
  2806 		  lpmmi->ptMaxSize.y = MIN(GetSystemMetrics(SM_CYMAXIMIZED), lI->maxHeight);
  2806 
  2807 
  2807 		  lpmmi->ptMaxTrackSize.x = lI->maxWidth == 0 ? GetSystemMetrics(SM_CXMAXTRACK) : lI->maxWidth;
  2808 		  lpmmi->ptMaxTrackSize.x = lI->maxWidth == 0 ? GetSystemMetrics(SM_CXMAXTRACK) : lI->maxWidth;
  2808 		  lpmmi->ptMaxTrackSize.y = lI->maxHeight == 0 ? GetSystemMetrics(SM_CYMAXTRACK) : lI->maxHeight;
  2809 		  lpmmi->ptMaxTrackSize.y = lI->maxHeight == 0 ? GetSystemMetrics(SM_CYMAXTRACK) : lI->maxHeight;
 10758 
 10759 
 10759 displayString:aString from:index1 to:index2 x:x y:y in:ignoredDrawableId with:aGCId opaque:opaque
 10760 displayString:aString from:index1 to:index2 x:x y:y in:ignoredDrawableId with:aGCId opaque:opaque
 10760     "draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both
 10761     "draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both
 10761      foreground and background characters.
 10762      foreground and background characters.
 10762      If the coordinates are not integers, an error is triggered."
 10763      If the coordinates are not integers, an error is triggered."
 10763 
       
 10764 %{  /* NOCONTEXT */
 10764 %{  /* NOCONTEXT */
       
 10765   /* NOTICE:
       
 10766    * A change here was forced by (an undocumented) limited internal display buffer. 
       
 10767    * A check is needed to draw against such internal limit; then draw it chunk-by-chunk.
       
 10768    */
       
 10769 
 10765     unsigned char *cp;
 10770     unsigned char *cp;
 10766     OBJ cls;
 10771     OBJ cls;
 10767     int i1, i2, l, n;
 10772     int i1, i2, n, l, toDisplay;
 10768     int nInstBytes;
 10773     int nInstBytes;
       
 10774 
 10769 
 10775 
 10770     if (__isExternalAddress(aGCId)
 10776     if (__isExternalAddress(aGCId)
 10771      && __isNonNilObject(aString)
 10777      && __isNonNilObject(aString)
 10772      && __bothSmallInteger(index1, index2)
 10778      && __bothSmallInteger(index1, index2)
 10773      && __bothSmallInteger(x, y))
 10779      && __bothSmallInteger(x, y))
 10775 	struct gcData *gcData;
 10781 	struct gcData *gcData;
 10776 	int pX, pY;
 10782 	int pX, pY;
 10777 	HDC hDC;
 10783 	HDC hDC;
 10778 	HFONT hOldFont;
 10784 	HFONT hOldFont;
 10779 
 10785 
       
 10786 	/* Windows (as in 7 or newer) limits the string size for TextOut* to 3275 */
       
 10787 	const int MAX_DISPLAY_BUFFER = 3275;
       
 10788 
 10780 	i1 = __intVal(index1) - 1;
 10789 	i1 = __intVal(index1) - 1;
 10781 	i2 = __intVal(index2) - 1;
 10790 	i2 = __intVal(index2) - 1;
 10782 	if ((i1 < 0) || (i2 < i1)) {
 10791 	if ((i1 < 0) || (i2 < i1)) {
 10783 	    RETURN (self);
 10792 	    RETURN (self);
 10784 	}
 10793 	}
 10811 #if 0
 10820 #if 0
 10812 	GcDataGetPen(hDC, gcData);
 10821 	GcDataGetPen(hDC, gcData);
 10813 #endif
 10822 #endif
 10814 
 10823 
 10815 	cls = __qClass(aString);
 10824 	cls = __qClass(aString);
 10816 
       
 10817 	cp = __stringVal(aString);
 10825 	cp = __stringVal(aString);
 10818 	l = i2 - i1 + 1;
 10826 	l = i2 - i1 + 1;
 10819 	if (l > 32758) {
 10827 	toDisplay = l;
 10820 	    /* Windows (as in XP) limits the string size for TextOut* to 32758 */
 10828 
 10821 	    l = 32758;
 10829 	/* Set the current point to the reference point. */
 10822 	}
 10830 	SetTextAlign(hDC, TA_UPDATECP);
       
 10831 	MoveToEx(hDC, pX, pY, NULL);
 10823 
 10832 
 10824 	if (__isStringLike(aString)) {
 10833 	if (__isStringLike(aString)) {
 10825 	    n = __stringSize(aString);
 10834 	    n = __stringSize(aString);
 10826 commonOutChars:
 10835 commonOutChars:
 10827 	    if (i2 < n) {
 10836 	    if (i2 < n) {
 10828 		cp += i1;
 10837 	        cp += i1;
 10829 		CPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC));
 10838 	        do {
 10830 		if (! TextOutA(hDC, pX, pY, (char *)cp, l)) {
 10839 	            /* TA_UPDATECP used => pX, pY ignored */
 10831 		    PRINTF(("WinWorkstation [warning]: TextOutA failed. [%d]\n", __LINE__));
 10840 	            if (! TextOutA(hDC, 0, 0, (char *)cp, MIN(toDisplay, MAX_DISPLAY_BUFFER))) { 
 10832 		    PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d\n", GetLastError(), pX, pY, l));
 10841 	                PRINTF(("WinWorkstation [warning]: TextOutA failed. [%d]\n", __LINE__));
 10833 		    goto error;
 10842 	                PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d leftToShow=%d\n", GetLastError(), pX, pY, l, toDisplay));
 10834 		}
 10843 	                goto error;
       
 10844 	            }
       
 10845 	            cp += MAX_DISPLAY_BUFFER;
       
 10846 	            toDisplay -= MAX_DISPLAY_BUFFER;
       
 10847 	        } while(toDisplay > 0);
 10835 	    }
 10848 	    }
 10836 	    goto ret;
 10849 	    goto ret;
 10837 	}
 10850 	}
 10838 
 10851 
 10839 	nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
 10852 	nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
 10845 	}
 10858 	}
 10846 
 10859 
 10847 	/* Unicode */
 10860 	/* Unicode */
 10848 	if (__isWords(aString)) {
 10861 	if (__isWords(aString)) {
 10849 	    n = n / 2;
 10862 	    n = n / 2;
 10850 	    if (i2 < n) {
 10863 	    WIDECHAR *w_cp = (WIDECHAR *)cp;
 10851 		WIDECHAR *w_cp = (WIDECHAR *)cp;
 10864 	    if (i2 < n){
 10852 		w_cp += i1;
 10865 	        w_cp += i1;
 10853 		if (! TextOutW(hDC, pX, pY, w_cp, l)) {
 10866 	        do {
 10854 		    PRINTF(("WinWorkstation [warning]: TextOutW failed. [%d]\n", __LINE__));
 10867 	            /* TA_UPDATECP used => pX, pY ignored */
 10855 		    PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d\n", GetLastError(), pX, pY, l));
 10868 	            if (! TextOutW(hDC, 0, 0, w_cp, MIN(toDisplay, MAX_DISPLAY_BUFFER))) { 
 10856 		}
 10869 	                PRINTF(("WinWorkstation [warning]: TextOutW failed. [%d]\n", __LINE__));
 10857 		goto ret;
 10870 	                PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d leftToShow=%d\n", GetLastError(), pX, pY, l, toDisplay));
 10858 	    }
 10871 	                goto error;
       
 10872 	            }
       
 10873 	            w_cp += MAX_DISPLAY_BUFFER;
       
 10874 	            toDisplay -= MAX_DISPLAY_BUFFER;
       
 10875 	        } while (toDisplay > 0);
       
 10876 	    }
       
 10877 	    goto ret;
 10859 	}
 10878 	}
 10860 ret:;
 10879 ret:;
 10861 #if 0
 10880 #if 0
 10862 	GcDataReleasePen(hDC, gcData);
 10881 	GcDataReleasePen(hDC, gcData);
 10863 #endif
 10882 #endif