Changeset 12546
- Timestamp:
- Dec 3, 1999, 6:31:51 PM (25 years ago)
- Location:
- tags/trunk/src/gdi32
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tags/trunk/src/gdi32/gdi32.cpp ¶
r12539 r12546 1 /* $Id: gdi32.cpp,v 1.2 1 1999-12-03 11:55:45 sandervlExp $ */1 /* $Id: gdi32.cpp,v 1.22 1999-12-03 17:31:49 cbratschi Exp $ */ 2 2 3 3 /* … … 14 14 #include <stdarg.h> 15 15 #include <string.h> 16 #include <math.h>17 16 #include "misc.h" 18 17 #include "callback.h" 19 18 #include "unicode.h" 20 19 #include "dibsect.h" 21 22 #define ROUND_FLOAT(x) ((INT)((x < 0) ? x-0.5:x+0.5))23 #define sqr(x) (pow(x,2))24 20 25 21 typedef struct _POLYTEXTA … … 150 146 dprintf(("GDI32: SetTextColor from %X to %X\n", clr, crColor)); 151 147 return(clr); 152 }153 //******************************************************************************154 //******************************************************************************155 BOOL WIN32API TextOutA(HDC hdc, int nXStart, int nYStart,156 LPCSTR lpszString, int cbString)157 {158 BOOL rc;159 160 rc = O32_TextOut(hdc, nXStart, nYStart, lpszString, cbString);161 dprintf(("GDI32: TextOut %s returned %d\n", lpszString, rc));162 return(rc);163 148 } 164 149 //****************************************************************************** … … 284 269 //TEMPORARY HACK TO PREVENT CRASH IN OPEN32 (WSeB GA) 285 270 if(arg2->biHeight < 0) { 286 271 ((BITMAPINFOHEADER *)arg2)->biHeight = -arg2->biHeight; 287 272 } 288 273 return O32_CreateDIBitmap(arg1, arg2, arg3, arg4, arg5, arg6); … … 447 432 dprintf(("GDI32: SetBkMode\n")); 448 433 return O32_SetBkMode(arg1, arg2); 449 }450 //******************************************************************************451 //******************************************************************************452 BOOL WIN32API ExtTextOutA(HDC hdc, int X, int Y, UINT fuOptions, CONST RECT *lprc,453 LPCSTR lpszString, UINT cbCount, CONST INT *lpDx)454 {455 if(lpszString && strlen(lpszString) > cbCount)456 ((LPSTR)lpszString)[cbCount] = 0;457 dprintf(("GDI32: ExtTextOutA %s\n", lpszString));458 return(O32_ExtTextOut(hdc, X, Y, fuOptions, lprc, lpszString, cbCount, lpDx));459 434 } 460 435 //****************************************************************************** … … 963 938 //****************************************************************************** 964 939 //****************************************************************************** 965 POINT ToWin32LineEnd(POINT startPt,INT nXEnd,INT nYEnd)966 {967 POINT pt;968 969 if (startPt.x != nXEnd || startPt.y != nYEnd)970 {971 if (nXEnd == startPt.x)972 {973 pt.x = nXEnd;974 pt.y = (nYEnd > startPt.y) ? nYEnd-1:nYEnd+1;975 } else if (nYEnd == startPt.y)976 {977 pt.x = (nXEnd > startPt.x) ? nXEnd-1:nXEnd+1;978 pt.y = nYEnd;979 } else980 {981 DOUBLE len = sqrt(sqr(nXEnd-startPt.x)+sqr(nYEnd-startPt.y));982 DOUBLE lenDif = (len-1)/len;983 INT w = nXEnd-startPt.x,h = nYEnd-startPt.y;984 985 pt.x = startPt.x+ROUND_FLOAT(w*lenDif);986 pt.y = startPt.y+ROUND_FLOAT(h*lenDif);987 }988 } else989 {990 pt.x = nXEnd;991 pt.y = nYEnd;992 }993 994 return pt;995 }996 997 VOID DrawSingleLinePoint(HDC hdc,POINT pt)998 {999 LOGPEN penInfo;1000 1001 if (!GetObjectA(GetCurrentObject(hdc,OBJ_PEN),sizeof(penInfo),(LPVOID)&penInfo)) return;1002 if (penInfo.lopnWidth.x <= 1 && penInfo.lopnWidth.y <= 1) SetPixel(hdc,pt.x,pt.y,penInfo.lopnColor); else1003 {1004 INT x = pt.x-penInfo.lopnWidth.x/2;1005 INT y = pt.y-penInfo.lopnWidth.y/2;1006 Ellipse(hdc,x,y,x+penInfo.lopnWidth.x,y+penInfo.lopnWidth.y);1007 }1008 }1009 1010 BOOL WIN32API LineTo( HDC hdc, int nXEnd, int nYEnd)1011 {1012 POINT oldPt,pt;1013 1014 dprintf(("GDI32: LineTo"));1015 1016 //CB: Open32 draws a pixel too much!1017 GetCurrentPositionEx(hdc,&oldPt);1018 pt = ToWin32LineEnd(oldPt,nXEnd,nYEnd);1019 1020 BOOL rc;1021 1022 if (oldPt.x == pt.x && oldPt.y == pt.y)1023 {1024 DrawSingleLinePoint(hdc,pt);1025 1026 rc = TRUE;1027 } else rc = O32_LineTo(hdc,pt.x,pt.y);1028 MoveToEx(hdc,nXEnd,nYEnd,NULL);1029 1030 return rc;1031 }1032 //******************************************************************************1033 //******************************************************************************1034 940 BOOL WIN32API MoveToEx( HDC arg1, int arg2, int arg3, PPOINT arg4) 1035 941 { … … 1128 1034 dprintf(("GDI32: ExtSelectClipRgn")); 1129 1035 return O32_ExtSelectClipRgn(arg1, arg2, arg3); 1130 }1131 //******************************************************************************1132 //******************************************************************************1133 BOOL WIN32API ExtTextOutW(HDC hdc, int X, int Y, UINT fuOptions,1134 const RECT *lprc, LPCWSTR lpString, UINT cbCount,1135 const int *lpDx)1136 {1137 char *astring = UnicodeToAsciiString((LPWSTR)lpString);1138 BOOL rc;1139 1140 if(lprc)1141 dprintf(("GDI32: ExtTextOutW (%d,%d) %X, (%d,%d)(%d,%d)\n", X, Y, fuOptions, lprc->left, lprc->top, lprc->right, lprc->bottom));1142 else dprintf(("GDI32: ExtTextOutW (%d,%d) %X\n", X, Y, fuOptions));1143 rc = O32_ExtTextOut(hdc, X, Y, fuOptions, lprc, astring, cbCount, lpDx);1144 dprintf(("GDI32: ExtTextOutW %s (%X) length %d rc %d\n", astring, lpString, cbCount, rc));1145 FreeAsciiString(astring);1146 return(rc);1147 1036 } 1148 1037 //****************************************************************************** … … 1713 1602 //****************************************************************************** 1714 1603 //****************************************************************************** 1715 BOOL WIN32API LineDDA( int nXStart, int nYStart, int nXEnd, int nYEnd, LINEDDAPROC lpLineFunc, LPARAM lpData)1716 {1717 BOOL rc;1718 LineDDAProcCallback *callback = new LineDDAProcCallback(lpLineFunc, lpData);1719 POINT startPt,endPt;1720 1721 dprintf(("GDI32: LineDDA\n"));1722 1723 //CB: don't know if Open32 reports the last pixel, but all other line functions do1724 startPt.x = nXStart;1725 startPt.y = nYStart;1726 endPt = ToWin32LineEnd(startPt,nXEnd,nYEnd);1727 1728 rc = O32_LineDDA(startPt.x,startPt.y,endPt.x,endPt.y,callback->GetOS2Callback(),(LPARAM)callback);1729 if(callback)1730 delete callback;1731 return(rc);1732 }1733 //******************************************************************************1734 //******************************************************************************1735 1604 BOOL WIN32API MaskBlt( HDC arg1, int arg2, int arg3, int arg4, int arg5, HDC arg6, int arg7, int arg8, HBITMAP arg9, int arg10, int arg11, DWORD arg12) 1736 1605 { … … 1863 1732 dprintf(("GDI32: Polygon")); 1864 1733 return O32_Polygon(arg1, arg2, arg3); 1865 }1866 //******************************************************************************1867 //******************************************************************************1868 BOOL WIN32API Polyline( HDC hdc, const POINT *lppt, int cPoints)1869 {1870 dprintf(("GDI32: Polyline"));1871 1872 if (cPoints == 0) return TRUE;1873 if (cPoints < 0)1874 {1875 SetLastError(ERROR_INVALID_PARAMETER);1876 1877 return FALSE;1878 }1879 1880 if (cPoints == 1)1881 {1882 DrawSingleLinePoint(hdc,*lppt); //CB: check metafile recording1883 1884 return TRUE;1885 }1886 1887 //CB: Open32 draw a pixel too much!1888 POINT *points = (POINT*)lppt;1889 POINT lastPt = lppt[cPoints-1];1890 BOOL rc;1891 1892 points[cPoints-1] = ToWin32LineEnd(lppt[cPoints-2],lastPt.x,lastPt.y);1893 rc = O32_Polyline(hdc,lppt,cPoints);1894 points[cPoints-1] = lastPt;1895 1896 return rc;1897 }1898 //******************************************************************************1899 //******************************************************************************1900 BOOL WIN32API PolylineTo( HDC hdc, const POINT * lppt, DWORD cCount)1901 {1902 dprintf(("GDI32: PolylineTo"));1903 1904 if (cCount == 0) return TRUE;1905 1906 if (cCount == 1)1907 {1908 DrawSingleLinePoint(hdc,*lppt);1909 1910 return TRUE; //CB: check metafile recording1911 }1912 1913 //CB: Open32 draw a pixel too much!1914 POINT *points = (POINT*)lppt;1915 POINT lastPt = lppt[cCount-1];1916 BOOL rc;1917 1918 points[cCount-1] = ToWin32LineEnd(lppt[cCount-2],lastPt.x,lastPt.y);1919 rc = O32_PolylineTo(hdc,lppt,cCount);1920 points[cCount-1] = lastPt;1921 MoveToEx(hdc,lastPt.x,lastPt.y,NULL);1922 1923 return rc;1924 1734 } 1925 1735 //****************************************************************************** … … 2245 2055 dprintf(("GDI32: StartPage")); 2246 2056 return O32_StartPage(arg1); 2247 }2248 //******************************************************************************2249 //******************************************************************************2250 BOOL WIN32API TextOutW( HDC arg1, int arg2, int arg3, LPCWSTR arg4, int arg5)2251 {2252 char *astring = UnicodeToAsciiString((LPWSTR)arg4);2253 BOOL rc;2254 2255 dprintf(("GDI32: TextOutW"));2256 // NOTE: This will not work as is (needs UNICODE support)2257 rc = O32_TextOut(arg1, arg2, arg3, astring, arg5);2258 FreeAsciiString(astring);2259 return rc;2260 2057 } 2261 2058 //****************************************************************************** -
TabularUnified tags/trunk/src/gdi32/makefile ¶
r12517 r12546 1 # $Id: makefile,v 1.1 2 1999-12-01 23:30:09 sandervlExp $1 # $Id: makefile,v 1.13 1999-12-03 17:31:51 cbratschi Exp $ 2 2 3 3 # 4 4 # PD-Win32 API 5 5 # 6 # 6 # gdi32.dll makefile 7 7 # 8 8 … … 22 22 TARGET = gdi32 23 23 24 OBJS = gdi32.obj opengl.obj callback.obj dibsect.obj initterm.obj oslibgdi.obj font.obj text.obj palette.obj 24 OBJS = gdi32.obj opengl.obj callback.obj dibsect.obj initterm.obj oslibgdi.obj font.obj text.obj palette.obj line.obj 25 25 26 26 … … 29 29 30 30 $(TARGET).dll: $(OBJS) $(TARGET).def 31 31 $(LD) $(LDFLAGS) -Fm -Fe$@ $(OBJS) $(TARGET).def \ 32 32 $(PDWIN32_LIB)/pmwinx.lib $(PDWIN32_LIB)/kernel32.lib $(PDWIN32_LIB)/user32.lib \ 33 33 $(PDWIN32_LIB)/odincrt.lib OS2386.LIB $(RTLLIB_O) 34 34 $(CP) $@ $(PDWIN32_BIN) 35 35 36 36 37 37 $(TARGET).lib: $(TARGET)exp.def 38 39 38 $(IMPLIB) $(IMPLIBFLAGS) $@ $(TARGET)exp.def 39 $(CP) $@ $(PDWIN32_LIB) 40 40 41 41 $(TARGET)exp.def: $(TARGET).def … … 71 71 oslibgdi.obj: oslibgdi.cpp oslibgdi.h 72 72 73 line.obj: line.cpp \ 74 $(PDWIN32_INCLUDE)\misc.h \ 75 73 76 initterm.obj: initterm.cpp 74 77 75 78 76 79 clean: 77 78 79 80 $(RM) *.obj *.lib *.dll *.map *.pch 81 $(RM) $(PDWIN32_BIN)\$(TARGET).dll 82 $(RM) $(PDWIN32_LIB)\$(TARGET).lib 80 83 $(RM) $(TARGET)exp.def 81 84 -
TabularUnified tags/trunk/src/gdi32/text.cpp ¶
r12517 r12546 1 /* $Id: text.cpp,v 1. 1 1999-12-01 23:30:30 sandervlExp $ */1 /* $Id: text.cpp,v 1.2 1999-12-03 17:31:51 cbratschi Exp $ */ 2 2 3 3 /* … … 62 62 //****************************************************************************** 63 63 //****************************************************************************** 64 static BOOL InternalTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut) 65 { 66 if (cbCount < 0 || (lpszString == NULL && cbCount != 0)) 67 { 68 SetLastError(ERROR_INVALID_HANDLE); 69 return FALSE; 70 } 71 72 //CB: todo 73 74 if (IsExtTextOut) 75 return O32_ExtTextOut(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx); 76 else 77 return O32_TextOut(hdc,X,Y,lpszString,cbCount); 78 } 79 //****************************************************************************** 80 //****************************************************************************** 81 static BOOL InternalTextOutW(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCWSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut) 82 { 83 char *astring = UnicodeToAsciiString((LPWSTR)lpszString); 84 BOOL rc; 85 86 rc = InternalTextOutA(hdc,X,Y,fuOptions,lprc,(LPCSTR)astring,cbCount,lpDx,IsExtTextOut); 87 FreeAsciiString(astring); 88 89 return(rc); 90 } 91 //****************************************************************************** 92 //****************************************************************************** 93 BOOL WIN32API ExtTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,UINT cbCount,CONST INT *lpDx) 94 { 95 dprintf(("GDI32: ExtTextOutA\n")); 96 97 return InternalTextOutA(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE); 98 } 99 //****************************************************************************** 100 //****************************************************************************** 101 BOOL WIN32API ExtTextOutW(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCWSTR lpszString,UINT cbCount,CONST int *lpDx) 102 { 103 dprintf(("GDI32: ExtTextOutW\n")); 104 105 return InternalTextOutW(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE); 106 } 107 //****************************************************************************** 108 //****************************************************************************** 109 BOOL WIN32API TextOutA(HDC hdc,int nXStart,int nYStart,LPCSTR lpszString,int cbString) 110 { 111 dprintf(("GDI32: TextOutA")); 112 113 return InternalTextOutA(hdc,nXStart,nYStart,0,NULL,lpszString,cbString,NULL,FALSE); 114 } 115 //****************************************************************************** 116 //****************************************************************************** 117 BOOL WIN32API TextOutW(HDC hdc,int nXStart,int nYStart,LPCWSTR lpszString,int cbString) 118 { 119 dprintf(("GDI32: TextOutW")); 120 121 return InternalTextOutW(hdc,nXStart,nYStart,0,NULL,lpszString,cbString,NULL,FALSE); 122 } 123 //****************************************************************************** 124 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.