- Timestamp:
- Dec 16, 1999, 5:52:33 PM (26 years ago)
- Location:
- trunk/src/gdi32
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/gdi32.DEF
r2049 r2092 1 ; $Id: gdi32.DEF,v 1. 4 1999-12-09 16:49:44cbratschi Exp $1 ; $Id: gdi32.DEF,v 1.5 1999-12-16 16:52:31 cbratschi Exp $ 2 2 3 3 ;Created by BLAST for IBM's compiler … … 6 6 7 7 IMPORTS 8 __GpiQueryDCData@4 = PMGPI.665 8 _GpiQueryTabbedTextExtent = PMGPI.658 9 _GpiTabbedCharStringAt = PMGPI.659 10 _GpiQueryDCData = PMGPI.665 11 _PaxStrokeAndFillPath = PMGPI.712 9 12 _GpiEnableYInversion = PMGPI.723 10 13 … … 342 345 343 346 ;USER32 functions 344 InternalDrawTextExA = _InternalDrawTextExA@24@1000345 InternalDrawTextExW = _InternalDrawTextExW@24@1001346 InternalTabbedTextOutA = _InternalTabbedTextOutA@32@1002347 InternalTabbedTextOutW = _InternalTabbedTextOutW@32@1003348 InternalGetTabbedTextExtentA = _InternalGetTabbedTextExtentA@20@1004349 InternalGetTabbedTextExtentW = _InternalGetTabbedTextExtentW@20@1005347 InternalDrawTextExA @1000 348 InternalDrawTextExW @1001 349 InternalTabbedTextOutA @1002 350 InternalTabbedTextOutW @1003 351 InternalGetTabbedTextExtentA @1004 352 InternalGetTabbedTextExtentW @1005 -
trunk/src/gdi32/gdi32.cpp
r2083 r2092 1 /* $Id: gdi32.cpp,v 1.2 5 1999-12-16 00:10:50 sandervlExp $ */1 /* $Id: gdi32.cpp,v 1.26 1999-12-16 16:52:31 cbratschi Exp $ */ 2 2 3 3 /* … … 18 18 #include "unicode.h" 19 19 #include "dibsect.h" 20 21 typedef struct _POLYTEXTA22 {23 int x;24 int y;25 UINT n;26 LPCSTR lpstr;27 UINT uiFlags;28 RECT rcl;29 int *pdx;30 } POLYTEXTA;31 32 33 typedef struct _POLYTEXTW34 {35 int x;36 int y;37 UINT n;38 LPCWSTR lpstr;39 UINT uiFlags;40 RECT rcl;41 int *pdx;42 } POLYTEXTW;43 44 20 45 21 static ULONG QueryPaletteSize(BITMAPINFOHEADER *pBHdr) … … 1000 976 //****************************************************************************** 1001 977 //****************************************************************************** 1002 BOOL WIN32API MoveToEx( HDC arg1, int arg2, int arg3, PPOINT arg4)1003 {1004 dprintf(("GDI32: MoveToEx\n"));1005 return O32_MoveToEx(arg1, arg2, arg3, arg4);1006 }1007 //******************************************************************************1008 //******************************************************************************1009 978 BOOL WIN32API PatBlt( HDC arg1, int arg2, int arg3, int arg4, int arg5, DWORD arg6) 1010 979 { … … 3173 3142 3174 3143 /***************************************************************************** 3175 * Name : BOOL PolyTextOutA3176 * Purpose : The PolyTextOutA function draws several strings using the font3177 * and text colors currently selected in the specified device context.3178 * Parameters: HDC hdc handle of device context3179 * CONST POLYTEXT *pptxt address of array of structures that identify strings3180 * int cStrings number of structures in array3181 * Variables :3182 * Result : TRUE / FALSE3183 * Remark :3184 * Status : UNTESTED STUB3185 *3186 * Author : Patrick Haller [Mon, 1998/06/15 08:00]3187 *****************************************************************************/3188 3189 BOOL WIN32API PolyTextOutA(HDC hdc,3190 POLYTEXTA *pptxt,3191 int cStrings)3192 {3193 dprintf(("GDI32: PolyTextOutA(%08xh, %08xh, %08xh) not implemented.\n",3194 hdc,3195 pptxt,3196 cStrings));3197 3198 return (FALSE);3199 }3200 3201 3202 #if 03203 3204 The POLYTEXT structure describes how the PolyTextOut function should draw a string of text.3205 3206 Members3207 3208 x3209 3210 Specifies the horizontal reference point for the string. The string is aligned to this point using the current text-alignment mode.3211 3212 y3213 3214 Specifies the vertical reference point for the string. The string is aligned to this point using the current text-alignment mode.3215 3216 n3217 3218 Specifies the number of characters in the string.3219 3220 uiFlags3221 3222 Specifies whether the string is to be opaque or clipped and whether the string is accompanied by an array of character-width values. This member can be one or more of the following values:3223 3224 Value Meaning3225 ETO_OPAQUE The rectangles given for each string is to be opaqued with the current background color.3226 ETO_CLIPPED Each string is to be clipped to its given rectangle.3227 lpstr3228 3229 Points to a string of text to be drawn by the PolyTextOut function.3230 3231 rcl3232 3233 Specifies a rectangle structure that contains the dimensions of the opaquing or clipping rectangle. This member is ignored if neither of the ETO_OPAQUE nor the ETO_CLIPPED value is specified for the uiFlags member.3234 3235 pdx3236 3237 Specifies in an array the width value for each character in the string.3238 3239 See Also3240 3241 PolyTextOut3242 #endif3243 3244 3245 /*****************************************************************************3246 * Name : BOOL PolyTextOutW3247 * Purpose : The PolyTextOutW function draws several strings using the font3248 * and text colors currently selected in the specified device context.3249 * Parameters: HDC hdc handle of device context3250 * CONST POLYTEXT *pptxt address of array of structures that identify strings3251 * int cStrings number of structures in array3252 * Variables :3253 * Result : TRUE / FALSE3254 * Remark :3255 * Status : UNTESTED STUB3256 *3257 * Author : Patrick Haller [Mon, 1998/06/15 08:00]3258 *****************************************************************************/3259 3260 BOOL WIN32API PolyTextOutW(HDC hdc,3261 POLYTEXTW *pptxt,3262 int cStrings)3263 {3264 dprintf(("GDI32: PolyTextOutW(%08xh, %08xh, %08xh) not implemented.\n",3265 hdc,3266 pptxt,3267 cStrings));3268 3269 return (FALSE);3270 }3271 3272 3273 /*****************************************************************************3274 3144 * Name : BOOL SetDeviceGammaRamp 3275 3145 * Purpose : The SetDeviceGammaRamp function sets the gamma ramp on direct -
trunk/src/gdi32/gdi32exp.def
r2049 r2092 319 319 _UpdateICMRegKeyW@16 @430 320 320 _WidenPath@4 @431 321 _InternalDrawTextExA@24@1000322 _InternalDrawTextExW@24@1001323 _InternalTabbedTextOutA@32@1002324 _InternalTabbedTextOutW@32@1003325 _InternalGetTabbedTextExtentA@20@1004326 _InternalGetTabbedTextExtentW@20@1005321 InternalDrawTextExA @1000 322 InternalDrawTextExW @1001 323 InternalTabbedTextOutA @1002 324 InternalTabbedTextOutW @1003 325 InternalGetTabbedTextExtentA @1004 326 InternalGetTabbedTextExtentW @1005 -
trunk/src/gdi32/line.cpp
r1961 r2092 1 /* $Id: line.cpp,v 1. 1 1999-12-03 17:31:51cbratschi Exp $ */1 /* $Id: line.cpp,v 1.2 1999-12-16 16:52:32 cbratschi Exp $ */ 2 2 /* 3 3 * Line API's … … 13 13 #include "misc.h" 14 14 #include "callback.h" 15 16 //CB: todo: rewrite them without using Open32 15 #include "oslibgpi.h" 17 16 18 17 #define ROUND_FLOAT(x) ((INT)((x < 0) ? x-0.5:x+0.5)) 19 #define sqr(x) (pow(x,2)) 20 21 POINT ToWin32LineEnd(POINT startPt,INT nXEnd,INT nYEnd) 22 { 23 POINT pt; 24 25 if (startPt.x != nXEnd || startPt.y != nYEnd) 26 { 27 if (nXEnd == startPt.x) 28 { 29 pt.x = nXEnd; 30 pt.y = (nYEnd > startPt.y) ? nYEnd-1:nYEnd+1; 31 } else if (nYEnd == startPt.y) 32 { 33 pt.x = (nXEnd > startPt.x) ? nXEnd-1:nXEnd+1; 34 pt.y = nYEnd; 18 19 VOID toWin32LineEnd(PPOINTLOS2 startPt,INT nXEnd,INT nYEnd,PPOINTLOS2 pt) 20 { 21 if (startPt->x != nXEnd || startPt->y != nYEnd) 22 { 23 if (nXEnd == startPt->x) 24 { 25 pt->x = nXEnd; 26 pt->y = (nYEnd > startPt->y) ? nYEnd-1:nYEnd+1; 27 } else if (nYEnd == startPt->y) 28 { 29 pt->x = (nXEnd > startPt->x) ? nXEnd-1:nXEnd+1; 30 pt->y = nYEnd; 35 31 } else 36 32 { 37 DOUBLE len = sqrt(sqr(nXEnd-startPt.x)+sqr(nYEnd-startPt.y));38 DOUBLE len Dif = (len-1)/len;39 INT w = nXEnd-startPt.x,h = nYEnd-startPt.y;40 41 pt .x = startPt.x+ROUND_FLOAT(w*lenDif);42 pt .y = startPt.y+ROUND_FLOAT(h*lenDif);33 INT w = nXEnd-startPt->x,h = nYEnd-startPt->y; 34 DOUBLE len = hypot(w,h); 35 DOUBLE lenQuot = (len-1)/len; 36 37 pt->x = startPt->x+ROUND_FLOAT(w*lenQuot); 38 pt->y = startPt->y+ROUND_FLOAT(h*lenQuot); 43 39 } 44 40 } else 45 41 { 46 pt.x = nXEnd; 47 pt.y = nYEnd; 48 } 49 50 return pt; 51 } 52 53 VOID DrawSingleLinePoint(HDC hdc,POINT pt) 42 pt->x = nXEnd; 43 pt->y = nYEnd; 44 } 45 } 46 47 BOOL drawSingleLinePoint(HDC hdc,PVOID pHps,PPOINTLOS2 pt) 54 48 { 55 49 LOGPEN penInfo; 56 50 57 if (!GetObjectA(GetCurrentObject(hdc,OBJ_PEN),sizeof(penInfo),(LPVOID)&penInfo)) return; 58 if (penInfo.lopnWidth.x <= 1 && penInfo.lopnWidth.y <= 1) SetPixel(hdc,pt.x,pt.y,penInfo.lopnColor); else 59 { 60 INT x = pt.x-penInfo.lopnWidth.x/2; 61 INT y = pt.y-penInfo.lopnWidth.y/2; 62 Ellipse(hdc,x,y,x+penInfo.lopnWidth.x,y+penInfo.lopnWidth.y); 63 } 64 } 65 51 if (!GetObjectA(GetCurrentObject(hdc,OBJ_PEN),sizeof(penInfo),(LPVOID)&penInfo)) return FALSE; 52 53 if (penInfo.lopnWidth.x > 1 || penInfo.lopnWidth.y > 1) 54 { 55 if (penInfo.lopnStyle != PS_INSIDEFRAME && penInfo.lopnStyle != PS_SOLID) 56 return FALSE; 57 58 LONG color = GetBValue(penInfo.lopnColor) | (GetGValue(penInfo.lopnColor)<<8) | (GetRValue(penInfo.lopnColor)<<16); 59 60 return drawLinePointCircle(pHps,penInfo.lopnWidth.x,penInfo.lopnWidth.y,color); 61 } else 62 { 63 LONG color = GetBValue(penInfo.lopnColor) | (GetGValue(penInfo.lopnColor)<<8) | (GetRValue(penInfo.lopnColor)<<16); 64 65 return drawLinePoint(pHps,pt,color); 66 } 67 } 68 69 BOOL WIN32API MoveToEx( HDC hdc, int X, int Y, LPPOINT lpPoint) 70 { 71 PVOID pHps = OSLibGpiQueryDCData(hdc); 72 73 dprintf(("GDI32: MoveToEx\n")); 74 75 if (pHps) 76 { 77 POINTLOS2 newPoint = {X,Y}; 78 79 if (lpPoint) 80 { 81 POINTLOS2 lastPoint; 82 83 OSLibGpiQueryCurrentPosition(pHps,&lastPoint); 84 lpPoint->x = lastPoint.x; 85 lpPoint->y = lastPoint.y; 86 } 87 88 if (OSLibGpiMove(pHps,&newPoint)) 89 { 90 //CB: add metafile info 91 return TRUE; 92 } 93 94 return FALSE; 95 } 96 97 SetLastError(ERROR_INVALID_HANDLE); 98 return FALSE; 99 } 100 //****************************************************************************** 101 //****************************************************************************** 66 102 BOOL WIN32API LineTo( HDC hdc, int nXEnd, int nYEnd) 67 103 { 68 POINT oldPt,pt; 104 PVOID pHps = OSLibGpiQueryDCData(hdc); 105 BOOL rc = TRUE; 69 106 70 107 dprintf(("GDI32: LineTo")); 71 108 72 //CB: Open32 draws a pixel too much! 73 GetCurrentPositionEx(hdc,&oldPt); 74 pt = ToWin32LineEnd(oldPt,nXEnd,nYEnd); 75 76 BOOL rc; 77 78 if (oldPt.x == pt.x && oldPt.y == pt.y) 79 { 80 DrawSingleLinePoint(hdc,pt); 81 82 rc = TRUE; 83 } else rc = O32_LineTo(hdc,pt.x,pt.y); 84 MoveToEx(hdc,nXEnd,nYEnd,NULL); 109 if (pHps) 110 { 111 POINTLOS2 oldPoint,newPoint; 112 BOOL bWideLine; 113 114 //CB: add metafile info 115 116 OSLibGpiQueryCurrentPosition(pHps,&oldPoint); 117 toWin32LineEnd(&oldPoint,nXEnd,nYEnd,&newPoint); 118 119 if (oldPoint.x == newPoint.x && oldPoint.y == newPoint.y) 120 { 121 rc = drawSingleLinePoint(hdc,pHps,&newPoint); 122 } else 123 { 124 if (getIsWideLine(pHps)) 125 { 126 rc = O32_LineTo(hdc,newPoint.x,newPoint.y); //CB: wide line not supported 127 } else 128 { 129 if (OSLibGpiLine(pHps,&newPoint) == 0) 130 rc = FALSE; 131 } 132 } 133 134 newPoint.x = nXEnd; 135 newPoint.y = nYEnd; 136 OSLibGpiMove(pHps,&newPoint); 137 } else 138 { 139 SetLastError(ERROR_INVALID_HANDLE); 140 rc = FALSE; 141 } 85 142 86 143 return rc; … … 90 147 BOOL WIN32API LineDDA( int nXStart, int nYStart, int nXEnd, int nYEnd, LINEDDAPROC lpLineFunc, LPARAM lpData) 91 148 { 92 BOOL rc;93 LineDDAProcCallback *callback = new LineDDAProcCallback(lpLineFunc, lpData);94 POINTstartPt,endPt;149 BOOL rc; 150 LineDDAProcCallback *callback = new LineDDAProcCallback(lpLineFunc, lpData); 151 POINTLOS2 startPt,endPt; 95 152 96 153 dprintf(("GDI32: LineDDA\n")); 97 154 98 //CB: don't know if Open32 reports the last pixel, but all other line functions do99 155 startPt.x = nXStart; 100 156 startPt.y = nYStart; 101 endPt = ToWin32LineEnd(startPt,nXEnd,nYEnd);157 toWin32LineEnd(&startPt,nXEnd,nYEnd,&endPt); 102 158 103 159 rc = O32_LineDDA(startPt.x,startPt.y,endPt.x,endPt.y,callback->GetOS2Callback(),(LPARAM)callback); … … 110 166 BOOL WIN32API Polyline( HDC hdc, const POINT *lppt, int cPoints) 111 167 { 112 dprintf(("GDI32: Polyline")); 113 114 if (cPoints == 0) return TRUE; 115 if (cPoints < 0) 116 { 117 SetLastError(ERROR_INVALID_PARAMETER); 118 119 return FALSE; 120 } 121 122 if (cPoints == 1) 123 { 124 DrawSingleLinePoint(hdc,*lppt); //CB: check metafile recording 125 126 return TRUE; 127 } 128 129 //CB: Open32 draw a pixel too much! 130 POINT *points = (POINT*)lppt; 131 POINT lastPt = lppt[cPoints-1]; 132 BOOL rc; 133 134 points[cPoints-1] = ToWin32LineEnd(lppt[cPoints-2],lastPt.x,lastPt.y); 135 rc = O32_Polyline(hdc,lppt,cPoints); 136 points[cPoints-1] = lastPt; 137 138 return rc; 168 PVOID pHps = OSLibGpiQueryDCData(hdc); 169 170 dprintf(("GDI32: Polyline")); 171 172 if (!pHps) 173 { 174 SetLastError(ERROR_INVALID_HANDLE); 175 return FALSE; 176 } 177 178 if (cPoints == 0) return TRUE; 179 if (cPoints < 0) 180 { 181 SetLastError(ERROR_INVALID_PARAMETER); 182 183 return FALSE; 184 } 185 186 if (cPoints == 1) 187 { 188 drawSingleLinePoint(hdc,pHps,(PPOINTLOS2)lppt); //CB: check metafile recording 189 190 return TRUE; 191 } 192 193 POINT *points = (POINT*)lppt; 194 POINT lastPt = lppt[cPoints-1]; 195 BOOL rc; 196 197 toWin32LineEnd((PPOINTLOS2)&lppt[cPoints-2],lastPt.x,lastPt.y,(PPOINTLOS2)&points[cPoints-1]); 198 rc = O32_Polyline(hdc,lppt,cPoints); 199 points[cPoints-1] = lastPt; 200 201 return rc; 139 202 } 140 203 //****************************************************************************** … … 142 205 BOOL WIN32API PolylineTo( HDC hdc, const POINT * lppt, DWORD cCount) 143 206 { 144 dprintf(("GDI32: PolylineTo")); 145 146 if (cCount == 0) return TRUE; 147 148 if (cCount == 1) 149 { 150 DrawSingleLinePoint(hdc,*lppt); 151 152 return TRUE; //CB: check metafile recording 153 } 154 155 //CB: Open32 draw a pixel too much! 156 POINT *points = (POINT*)lppt; 157 POINT lastPt = lppt[cCount-1]; 158 BOOL rc; 159 160 points[cCount-1] = ToWin32LineEnd(lppt[cCount-2],lastPt.x,lastPt.y); 161 rc = O32_PolylineTo(hdc,lppt,cCount); 162 points[cCount-1] = lastPt; 163 MoveToEx(hdc,lastPt.x,lastPt.y,NULL); 164 165 return rc; 166 } 167 //****************************************************************************** 168 //****************************************************************************** 169 207 PVOID pHps = OSLibGpiQueryDCData(hdc); 208 209 dprintf(("GDI32: PolylineTo")); 210 211 if (!pHps) 212 { 213 SetLastError(ERROR_INVALID_HANDLE); 214 return FALSE; 215 } 216 217 if (cCount == 0) return TRUE; 218 219 //CB: add metafile info 220 221 if (cCount == 1) 222 { 223 drawSingleLinePoint(hdc,pHps,(PPOINTLOS2)lppt); 224 225 return TRUE; 226 } 227 228 POINT *points = (POINT*)lppt; 229 POINT lastPt = lppt[cCount-1]; 230 BOOL rc; 231 232 toWin32LineEnd((PPOINTLOS2)&lppt[cCount-2],lastPt.x,lastPt.y,(PPOINTLOS2)&points[cCount-1]); 233 rc = O32_PolylineTo(hdc,lppt,cCount); 234 points[cCount-1] = lastPt; 235 OSLibGpiMove(pHps,(PPOINTLOS2)&lastPt); 236 237 return rc; 238 } 239 //****************************************************************************** 240 //****************************************************************************** 241 -
trunk/src/gdi32/oslibgpi.cpp
r2049 r2092 1 /* $Id: oslibgpi.cpp,v 1. 1 1999-12-09 16:49:45cbratschi Exp $ */1 /* $Id: oslibgpi.cpp,v 1.2 1999-12-16 16:52:32 cbratschi Exp $ */ 2 2 3 3 /* … … 15 15 #include <stdlib.h> 16 16 #include <string.h> 17 #include <math.h> 17 18 #include "win32type.h" 18 19 #include "oslibgpi.h" … … 20 21 21 22 #define GetDCData(a) ((pDCData)a) 23 24 LONG APIENTRY _GpiQueryTabbedTextExtent(HPS hps,LONG lCount,PCH pchString,LONG lTabCount,PULONG puTabStops); 25 26 inline LONG GpiQueryTabbedTextExtent(HPS hps,LONG lCount,PCH pchString,LONG lTabCount,PULONG puTabStops) 27 { 28 LONG yyrc; 29 USHORT sel = RestoreOS2FS(); 30 31 yyrc = _GpiQueryTabbedTextExtent(hps,lCount,pchString,lTabCount,puTabStops); 32 SetFS(sel); 33 34 return yyrc; 35 } 36 37 LONG APIENTRY _GpiTabbedCharStringAt(HPS hps,PPOINTL pPtStart,PRECTL prclRect,ULONG flOptions,LONG lCount,PCH pchString,LONG lTabCount,PULONG puTabStops,LONG lTabOrigin); 38 39 inline LONG GpiTabbedCharStringAt(HPS hps,PPOINTL pPtStart,PRECTL prclRect,ULONG flOptions,LONG lCount,PCH pchString,LONG lTabCount,PULONG puTabStops,LONG lTabOrigin) 40 { 41 LONG yyrc; 42 USHORT sel = RestoreOS2FS(); 43 44 yyrc = _GpiTabbedCharStringAt(hps,pPtStart,prclRect,flOptions,lCount,pchString,lTabCount,puTabStops,lTabOrigin); 45 SetFS(sel); 46 47 return yyrc; 48 } 22 49 23 50 void inline swap(LONG &a,LONG &b) … … 103 130 } 104 131 132 BOOL getInPath(PVOID pHps) 133 { 134 return GetDCData(pHps)->inPath; 135 } 136 137 VOID setInPath(PVOID pHps,BOOL inPath) 138 { 139 GetDCData(pHps)->inPath = inPath; 140 } 141 142 BOOL getIsWideLine(PVOID pHps) 143 { 144 return GetDCData(pHps)->isWideLine; 145 } 146 147 BOOL getIsTopTop(PVOID pHps) 148 { 149 return GetDCData(pHps)->isTopTop; 150 } 151 152 ULONG getMapMode(PVOID pHps) 153 { 154 return GetDCData(pHps)->MapMode; 155 } 156 105 157 BOOL OSLibGpiQueryCurrentPosition(PVOID pHps,PPOINTLOS2 ptl) 106 158 { … … 132 184 return GpiQueryTextAlignment(GetDCData(pHps)->hps,plHoriz,plVert); 133 185 } 186 187 LONG OSLibGpiQueryTabbedTextExtent(PVOID pHps,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops) 188 { 189 return GpiQueryTabbedTextExtent(GetDCData(pHps)->hps,lCount,(PCH)pchString,lTabCount,(PULONG)puTabStops); 190 } 191 192 LONG OSLibGpiTabbedCharStringAt(PVOID pHps,PPOINTLOS2 pPtStart,PRECTLOS2 prclRect,ULONG flOptions,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops,INT lTabOrigin) 193 { 194 return GpiTabbedCharStringAt(GetDCData(pHps)->hps,(PPOINTL)pPtStart,(PRECTL)prclRect,flOptions,lCount,(PCH)pchString,lTabCount,(PULONG)puTabStops,lTabOrigin); 195 } 196 197 BOOL OSLibGpiQueryTextBox(PVOID pHps,LONG lCount1,LPCSTR pchString,LONG lCount2,PPOINTLOS2 aptlPoints) 198 { 199 return GpiQueryTextBox(GetDCData(pHps)->hps,lCount1,(PCH)pchString,lCount2,(PPOINTL)aptlPoints); 200 } 201 202 VOID calcDimensions(POINTLOS2 box[],PPOINTLOS2 point) 203 { 204 ULONG cx; 205 ULONG cy; 206 207 if (box[TXTBOX_BOTTOMLEFT].y == box[TXTBOX_BOTTOMRIGHT].y) 208 { 209 point->y = labs (box[TXTBOX_BOTTOMLEFT].y-box[TXTBOX_TOPLEFT].y); 210 point->x = labs (box[TXTBOX_CONCAT].x-box[TXTBOX_BOTTOMLEFT].x); 211 212 if (box[TXTBOX_BOTTOMLEFT].x != box[TXTBOX_TOPLEFT].x) 213 { 214 if (point->y < 25) 215 cx = 2; 216 else 217 cx = ((point->y*10)+50)/100; 218 point->x += cx; 219 } 220 } else 221 { 222 cx = labs (box[TXTBOX_BOTTOMLEFT].x-box[TXTBOX_TOPLEFT].x); 223 cy = labs (box[TXTBOX_BOTTOMLEFT].y-box[TXTBOX_TOPLEFT].y); 224 point->y = (ULONG)hypot(cx,cy); 225 226 cx = labs (box[TXTBOX_TOPRIGHT].x-box[TXTBOX_TOPLEFT].x); 227 cy = labs (box[TXTBOX_TOPRIGHT].y-box[TXTBOX_TOPLEFT].y); 228 point->x = (ULONG)hypot(cx,cy); 229 } 230 } 231 232 LONG OSLibGpiQueryBackMix(PVOID pHps) 233 { 234 return GpiQueryBackMix(GetDCData(pHps)->hps); 235 } 236 237 BOOL doesYAxisGrowNorth(PVOID pHps) 238 { 239 if ((GetDCData(pHps)->windowExt.cy < 0 && GetDCData(pHps)->viewportYExt > 0.0) || 240 (GetDCData(pHps)->windowExt.cy > 0 && GetDCData(pHps)->viewportYExt < 0.0)) 241 { 242 if (GetDCData(pHps)->graphicsMode == GM_COMPATIBLE_W || 243 (GetDCData(pHps)->graphicsMode == GM_ADVANCED_W && GetDCData(pHps)->xform.eM22 >= 0.0)) 244 return TRUE; 245 } else 246 { 247 if (GetDCData(pHps)->graphicsMode == GM_ADVANCED_W && GetDCData(pHps)->xform.eM22 < 0.0) 248 return TRUE; 249 } 250 251 return FALSE; 252 } 253 254 LONG OSLibWinDrawTabbedText(PVOID pHps,LONG cchText,LONG lTabs,LPCSTR lpchText,PVOID prcl,LONG clrFore,LONG clrBack,ULONG flCmd) 255 { 256 //return WinDraw 257 //undocumented 258 return 0; 259 } 260 261 BOOL OSLibGpiMove(PVOID pHps,PPOINTLOS2 pptlPoint) 262 { 263 return GpiMove(GetDCData(pHps)->hps,(PPOINTL)pptlPoint); 264 } 265 266 LONG OSLibGpiLine(PVOID pHps,PPOINTLOS2 pptlEndPoint) 267 { 268 return GpiLine(GetDCData(pHps)->hps,(PPOINTL)pptlEndPoint); 269 } 270 271 #define FSP_ENDPATH 0x00000010 272 #define FSP_FILL 0x00000020 273 #define FSP_CLOSEPATH 0x00000040 274 275 BOOL APIENTRY _PaxStrokeAndFillPath(HPS hPS,ULONG ulAction,ULONG ulStrokeAttrs,PAREABUNDLE pPenStroke); 276 277 inline BOOL PaxStrokeAndFillPath(HPS hPS,ULONG ulAction,ULONG ulStrokeAttrs,PAREABUNDLE pPenStroke) 278 { 279 BOOL yyrc; 280 USHORT sel = RestoreOS2FS(); 281 282 yyrc = _PaxStrokeAndFillPath(hPS,ulAction,ulStrokeAttrs,pPenStroke); 283 SetFS(sel); 284 285 return yyrc; 286 } 287 288 BOOL OSLibGpiEndPath(PVOID pHps) 289 { 290 return GpiEndPath(GetDCData(pHps)->hps); 291 } 292 293 BOOL drawLinePointCircle(PVOID pHps,INT width,INT height,LONG color) 294 { 295 ARCPARAMS arcp; 296 BOOL rc = TRUE; 297 298 arcp.lP = 1; 299 arcp.lQ = 1; 300 arcp.lR = 0; 301 arcp.lS = 0; 302 if (!GpiSetArcParams(GetDCData(pHps)->hps,&arcp)) 303 return FALSE; 304 305 AREABUNDLE newAreaBundle, oldAreaBundle; 306 LINEBUNDLE lineBundle; 307 308 GpiQueryAttrs(GetDCData(pHps)->hps,PRIM_AREA,ABB_COLOR | ABB_MIX_MODE | ABB_SET | ABB_SYMBOL,(PBUNDLE)&oldAreaBundle); 309 GpiQueryAttrs(GetDCData(pHps)->hps,PRIM_LINE,LBB_MIX_MODE, (PBUNDLE)&lineBundle); 310 311 newAreaBundle = oldAreaBundle; 312 newAreaBundle.lColor = color; 313 newAreaBundle.usMixMode = lineBundle.usMixMode; 314 newAreaBundle.usSet = LCID_DEFAULT; 315 newAreaBundle.usSymbol = PATSYM_SOLID; 316 317 if (!GpiSetAttrs(GetDCData(pHps)->hps,PRIM_AREA,ABB_COLOR | ABB_MIX_MODE | ABB_SET | ABB_SYMBOL,0,(PBUNDLE)&newAreaBundle)) 318 return FALSE; 319 320 if (GpiFullArc(GetDCData(pHps)->hps,DRO_FILL,MAKEFIXED((width-1)>>1,0)) == GPI_ERROR) 321 rc = FALSE; 322 GpiSetAttrs(GetDCData(pHps)->hps,PRIM_AREA,ABB_COLOR | ABB_MIX_MODE | ABB_SET | ABB_SYMBOL,0,(PBUNDLE)&oldAreaBundle); 323 324 return rc; 325 } 326 327 BOOL drawLinePoint(PVOID pHps,PPOINTLOS2 pt,LONG color) 328 { 329 LINEBUNDLE lbOld, lbNew; 330 LONG defaults = GpiQueryAttrs(GetDCData(pHps)->hps, PRIM_LINE, LBB_COLOR, &lbOld); 331 332 lbNew.lColor = color; 333 BOOL rc = GpiSetAttrs(GetDCData(pHps)->hps,PRIM_LINE,LBB_COLOR,0,&lbNew) && GpiSetPel(GetDCData(pHps)->hps,(PPOINTL)pt) != GPI_ERROR; 334 335 GpiSetAttrs(GetDCData(pHps)->hps,PRIM_LINE,LBB_COLOR,defaults,&lbOld); 336 337 return rc; 338 } -
trunk/src/gdi32/oslibgpi.h
r2049 r2092 1 /* $Id: oslibgpi.h,v 1. 1 1999-12-09 16:49:45cbratschi Exp $ */1 /* $Id: oslibgpi.h,v 1.2 1999-12-16 16:52:33 cbratschi Exp $ */ 2 2 3 3 /* … … 16 16 #define GM_ADVANCED_W 2 17 17 18 PVOID APIENTRY _GpiQueryDCData(ULONG hps); 18 #define APIENTRYOS2 _System 19 20 PVOID APIENTRYOS2 _GpiQueryDCData(ULONG hps); 19 21 20 22 inline PVOID OSLibGpiQueryDCData(ULONG hps) 21 23 { 22 PVOID yyrc;23 USHORT sel = RestoreOS2FS();24 PVOID yyrc; 25 USHORT sel = RestoreOS2FS(); 24 26 25 26 27 yyrc = _GpiQueryDCData(hps); 28 SetFS(sel); 27 29 28 30 return yyrc; 29 31 } 30 32 … … 37 39 } RECTLOS2, *PRECTLOS2; 38 40 39 typedef struct 41 typedef struct //same as Win32 POINT 40 42 { 41 43 LONG x; … … 61 63 BOOL excludeBottomRightPoint(PVOID pHps,PPOINTLOS2 pptl); 62 64 BOOL getAlignUpdateCP(PVOID pHps); 63 INT getWorldYDeltaFor1Pixel(PVOID pHps); 64 INT getWorldXDeltaFor1Pixel(PVOID pHps); 65 INT getWorldYDeltaFor1Pixel(PVOID pHps); 66 INT getWorldXDeltaFor1Pixel(PVOID pHps); 67 BOOL getInPath(PVOID pHps); 68 VOID setInPath(PVOID pHps,BOOL inPath); 69 BOOL getIsWideLine(PVOID pHps); 70 BOOL getIsTopTop(PVOID pHps); 71 ULONG getMapMode(PVOID pHps); 65 72 66 73 BOOL OSLibGpiQueryCurrentPosition(PVOID pHps,PPOINTLOS2 ptl); … … 96 103 BOOL OSLibGpiQueryTextAlignment(PVOID pHps,PLONG plHoriz,PLONG plVert); 97 104 105 LONG OSLibGpiQueryTabbedTextExtent(PVOID pHps,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops); 106 LONG OSLibGpiTabbedCharStringAt(PVOID pHps,PPOINTLOS2 pPtStart,PRECTLOS2 prclRect,ULONG flOptions,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops,INT lTabOrigin); 107 108 #define TXTBOXOS_TOPLEFT 0L 109 #define TXTBOXOS_BOTTOMLEFT 1L 110 #define TXTBOXOS_TOPRIGHT 2L 111 #define TXTBOXOS_BOTTOMRIGHT 3L 112 #define TXTBOXOS_CONCAT 4L 113 #define TXTBOXOS_COUNT 5L 114 115 BOOL OSLibGpiQueryTextBox(PVOID pHps,LONG lCount1,LPCSTR pchString,LONG lCount2,PPOINTLOS2 aptlPoints); 116 117 VOID calcDimensions(POINTLOS2 box[],PPOINTLOS2 point); 118 119 #define DTOS_LEFT 0x00000000 120 #define DTOS_QUERYEXTENT 0x00000002 121 #define DTOS_UNDERSCORE 0x00000010 122 #define DTOS_STRIKEOUT 0x00000020 123 #define DTOS_TEXTATTRS 0x00000040 124 #define DTOS_EXTERNALLEADING 0x00000080 125 #define DTOS_CENTER 0x00000100 126 #define DTOS_RIGHT 0x00000200 127 #define DTOS_TOP 0x00000000 128 #define DTOS_VCENTER 0x00000400 129 #define DTOS_BOTTOM 0x00000800 130 #define DTOS_HALFTONE 0x00001000 131 #define DTOS_MNEMONIC 0x00002000 132 #define DTOS_WORDBREAK 0x00004000 133 #define DTOS_ERASERECT 0x00008000 134 135 #define BMOS_ERROR (-1L) 136 #define BMOS_DEFAULT 0L 137 #define BMOS_OR 1L 138 #define BMOS_OVERPAINT 2L 139 #define BMOS_LEAVEALONE 5L 140 141 LONG OSLibGpiQueryBackMix(PVOID pHps); 142 143 #define MMOS_TEXT 1 144 #define MMOS_LOMETRIC 2 145 #define MMOS_HIMETRIC 3 146 #define MMOS_LOENGLISH 4 147 #define MMOS_HIENGLISH 5 148 #define MMOS_TWIPS 6 149 #define MMOS_ISOTROPIC 7 150 #define MMOS_ANISOTROPIC 8 151 152 BOOL doesYAxisGrowNorth(PVOID pHps); 153 154 LONG OSLibWinDrawTabbedText(PVOID pHps,LONG cchText,LONG lTabs,LPCSTR lpchText,PVOID prcl,LONG clrFore,LONG clrBack,ULONG flCmd); 155 156 157 BOOL OSLibGpiMove(PVOID pHps,PPOINTLOS2 pptlPoint); 158 LONG OSLibGpiLine(PVOID pHps,PPOINTLOS2 pptlEndPoint); 159 160 BOOL OSLibGpiEndPath(PVOID pHps); 161 162 BOOL drawLinePointCircle(PVOID pHps,INT width,INT height,LONG color); 163 BOOL drawLinePoint(PVOID pHps,PPOINTLOS2 pt,LONG color); 164 98 165 #endif -
trunk/src/gdi32/text.cpp
r2052 r2092 1 /* $Id: text.cpp,v 1. 4 1999-12-10 08:34:06 achimhaExp $ */1 /* $Id: text.cpp,v 1.5 1999-12-16 16:52:33 cbratschi Exp $ */ 2 2 3 3 /* … … 7 7 * 8 8 * Copyright 1993, 1994 Alexandre Julliard 9 * 9 * Copyright 1999 Christoph Bratschi 10 10 * 11 11 * Project Odin Software License can be found in LICENSE.TXT … … 17 17 #include <string.h> 18 18 #include "oslibgpi.h" 19 20 #define ELLIPSIS "..." 21 #define ELLIPSISLEN 3 22 23 typedef struct _POLYTEXTA 24 { 25 int x; 26 int y; 27 UINT n; 28 LPCSTR lpstr; 29 UINT uiFlags; 30 RECT rcl; 31 int *pdx; 32 } POLYTEXTA; 33 34 typedef struct _POLYTEXTW 35 { 36 int x; 37 int y; 38 UINT n; 39 LPCWSTR lpstr; 40 UINT uiFlags; 41 RECT rcl; 42 int *pdx; 43 } POLYTEXTW; 19 44 20 45 //****************************************************************************** … … 64 89 // CB: USER32 function, but here is the better place 65 90 //****************************************************************************** 66 INT WIN32API InternalDrawTextExA(HDC hdc,LPCSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams) 67 { 68 //CB: todo 69 dprintf(("GDI32: InternalDrawTextExA, unimplemented stub!\n")); 91 INT SYSTEM EXPORT InternalDrawTextExA(HDC hdc,LPCSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams,BOOL isDrawTextEx) 92 { 93 /* 94 PVOID pHps = OSLibGpiQueryDCData(hdc); 95 INT rc; 96 ULONG flCmd; 97 RECT localRectangle; 98 PRECT rectPtr; 99 LONG lTabs,xLeft,yTop; 100 101 if (!lpchText || cchText == 0 || cchText < -1 || !lprc == NULL) 102 { 103 SetLastError(ERROR_INVALID_PARAMETER); 104 return 0; 105 } 106 107 if (!pHps) 108 { 109 SetLastError(ERROR_INVALID_HANDLE); 110 return 0; 111 } 112 113 if (cchText == -1) 114 { 115 cchText = strlen(lpchText); 116 if (cchText == 0) 117 return 0; //CB: does Win32 return textheight in this case? 118 } 119 120 if (lpDTParams) 121 { 122 // set margins 123 lprc->left += lpDTParams->iLeftMargin; 124 lprc->right -= lpDTParams->iRightMargin; 125 126 // just assume all the text has been drawn 127 lpDTParams->uiLengthDrawn = cchText; 128 } 129 130 if (!(dwDTFormat & DT_CALCRECT)) 131 { 132 BOOL bTopBottomIsOkay; 133 134 if ((getIsTopTop(pHps) && lprc->top > lprc->bottom) || 135 (!getIsTopTop(pHps) && lprc->top < lprc->bottom)) 136 bTopBottomIsOkay = FALSE; 137 else 138 bTopBottomIsOkay = TRUE; 139 140 if (lprc->left >= lprc->right || !bTopBottomIsOkay) 141 { 142 TEXTMETRICA txtMetrics; 143 BOOL result; 144 145 result = GetTextMetricsA(hdc,&txtMetrics); 146 if (result) 147 rc = (int)txtMetrics.tmHeight; 148 else 149 rc = 0; 150 151 if (lpDTParams) 152 { 153 lprc->left -= lpDTParams->iLeftMargin; 154 lprc->right += lpDTParams->iRightMargin; 155 } 156 157 return rc; 158 } 159 } 160 161 flCmd = DTOS_INVERT | DTOS_WORLDRECT | DTOS_TEXTATTRS | DTOS_AMPERSAND | DTOS_VERTICALEXTENT; 162 163 LONG lMixMode = OSLibGpiQueryBackMix(pHps); 164 if (lMixMode == BMOS_OVERPAINT) flCmd |= DTOS_OPAQUE; 165 166 if (dwDTFormat & DT_CALCRECT) 167 { 168 rectPtr = lprc; 169 flCmd |= DTOS_QUERYEXTENT; 170 171 xLeft = rectPtr->left; 172 yTop = rectPtr->top; 173 174 if (dwDTFormat & DT_RIGHT) 175 { 176 if (rectPtr->left >= rectPtr->right) 177 rectPtr->left = rectPtr->right-1; 178 } else 179 { 180 if (rectPtr->right <= rectPtr->left) 181 rectPtr->right = rectPtr->left+1; 182 } 183 184 if (dwDTFormat & DT_BOTTOM) 185 { 186 if (rectPtr->top >= rectPtr->bottom) 187 rectPtr->top = rectPtr->bottom-1; 188 } else 189 { 190 if (rectPtr->bottom <= rectPtr->top) 191 rectPtr->bottom = rectPtr->top+1; 192 } 193 } else 194 { 195 rectPtr = &localRectangle; 196 197 if (getMapMode(pHps) == MMOS_ANISOTROPIC || getMapMode(pHps) == MMOS_ISOTROPIC) 198 { 199 if (doesYAxisGrowNorth(pHps)) 200 { 201 flCmd &= ~DTOS_INVERT; 202 flCmd |= DTOS_INVERTCHAR; 203 } 204 } 205 206 if (lprc->left > lprc->right) 207 { 208 rectPtr->left = lprc->right; 209 rectPtr->right = lprc->left; 210 } else 211 { 212 rectPtr->left = lprc->left; 213 rectPtr->right = lprc->right; 214 } 215 if (lprc->top > lprc->bottom) 216 { 217 rectPtr->top = lprc->bottom; 218 rectPtr->bottom = lprc->top; 219 } else 220 { 221 rectPtr->top = lprc->top; 222 rectPtr->bottom = lprc->bottom; 223 } 224 } 225 226 if (dwDTFormat & DT_EXPANDTABS) 227 { 228 if (isDrawTextEx) 229 { 230 lTabs = (lpDTParams && dwDTFormat & DT_TABSTOP) ? lpDTParams->iTabLength:8; 231 } else 232 { 233 lTabs = 8; 234 235 if (dwDTFormat & DT_TABSTOP) 236 { 237 lTabs = (dwDTFormat >> 8) & 0x000000FF; 238 dwDTFormat &= 0xFFFF00FF; 239 } 240 } 241 } else lTabs = -1; 242 243 if (dwDTFormat & DT_RIGHT) 244 flCmd |= DTOS_RIGHT; 245 else 246 if (dwDTFormat & DT_CENTER) flCmd |= DTOS_CENTER; 247 if (dwDTFormat & DT_BOTTOM) flCmd |= DTOS_BOTTOM; 248 if (dwDTFormat & DT_VCENTER) flCmd |= DTOS_VCENTER; 249 if (dwDTFormat & DT_WORDBREAK) flCmd |= DTOS_WORDBREAK; 250 if (dwDTFormat & DT_EXTERNALLEADING) flCmd |= DTOS_EXTERNALLEADING; 251 if (!(dwDTFormat & DT_NOPREFIX)) flCmd |= DTOS_MNEMONIC; 252 if (dwDTFormat & DT_SINGLELINE) 253 flCmd |= DTOS_SINGLELINE; 254 else 255 flCmd |= DTOS_MULTILINE; 256 if (dwDTFormat & DT_NOCLIP) flCmd |= DTOS_NOCLIP; 257 258 //CB: DT_EDITCONTROL, DT_RTLREADING ignored 259 260 BOOL done = FALSE; 261 262 if (dwDTFormat & DT_END_ELLIPSIS && cchText > 1) 263 { 264 int textWidth,width; 265 RECT rect; 266 267 SetRectEmpty(&rect); 268 OSLibWinDrawTabbedText(pHps,cchText,lTabs,lpchText,&rect,0,0,flCmd | DTOS_QUERYEXTENT); 269 width = rectPtr->right-rectPtr->left; 270 textWidth = rect.right-rect.left; 271 if (textWidth > width && width > 0) 272 { 273 char* newText; 274 int newTextLen = cchText-1+ELLIPSISLEN; 275 int preLen = cchText-1; 276 277 newText = (char*)malloc(newTextLen+1); 278 strncpy(newText,lpchText,cchText-1); 279 do 280 { 281 strcpy(&newText[preLen],ELLIPSIS); 282 OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,&rect,0,0,flCmd | DTOS_QUERYEXTENT); 283 textWidth = rect.right-rect.left; 284 if (textWidth <= width || preLen == 1) break; 285 newTextLen--; 286 preLen--; 287 } while (TRUE); 288 rc = OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,rectPtr,0,0,flCmd); 289 if (dwDTFormat & DT_MODIFYSTRING) strcpy((LPSTR)lpchText,newText); //check length? 290 free(newText); 291 292 done = TRUE; 293 } 294 } else if (dwDTFormat & DT_PATH_ELLIPSIS && cchText > 1) 295 { 296 int textWidth,width; 297 RECT rect; 298 299 //CB: code not yet checked (-> testcase) 300 301 SetRectEmpty(&rect); 302 OSLibWinDrawTabbedText(pHps,cchText,lTabs,lpchText,&rect,0,0,flCmd | DTOS_QUERYEXTENT); 303 width = rectPtr->right-rectPtr->left; 304 textWidth = rect.right-rect.left; 305 if (textWidth > width && width > 0) 306 { 307 char *newText,*slashPos; 308 int newTextLen = cchText+ELLIPSISLEN; 309 310 newText = (char*)malloc(newTextLen+1); 311 strncpy(newText,lpchText,cchText); 312 slashPos = strrchr(newText,(int)"\\"); 313 if (slashPos != NULL) 314 { 315 int preLen = slashPos-newText; 316 char* endPtr = (char*)lpchText+preLen; 317 int endLen = cchText-preLen; 318 BOOL ok = FALSE; 319 320 //delete start 321 do 322 { 323 strcpy(&newText[preLen],ELLIPSIS); 324 strncpy(&newText[preLen+ELLIPSISLEN],endPtr,endLen); 325 OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,&rect,0,0,flCmd | DTOS_QUERYEXTENT); 326 textWidth = rect.right-rect.left; 327 if (textWidth <= width) 328 { 329 ok = TRUE; 330 break; 331 } 332 if (preLen == 0) break; 333 newTextLen--; 334 preLen--; 335 } while (TRUE); 336 337 if (!ok) 338 { 339 //delete end 340 do 341 { 342 endPtr++; 343 endLen--; 344 newTextLen--; 345 strncpy(&newText[ELLIPSISLEN],endPtr,endLen); 346 OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,&rect,0,0,flCmd | DTOS_QUERYEXTENT); 347 textWidth = rect.right-rect.left; 348 if (textWidth <= width || endLen == 0) break; 349 } while (TRUE); 350 } 351 } else 352 { 353 int preLen,endLen; 354 355 preLen = cchText/2; 356 endLen = cchText-preLen; //endLen >= preLen 357 char* endPtr = (char*)lpchText+preLen; 358 359 do 360 { 361 strcpy(&newText[preLen],ELLIPSIS); 362 strncpy(&newText[preLen+ELLIPSISLEN],endPtr,endLen); 363 OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,&rect,0,0,flCmd | DTOS_QUERYEXTENT); 364 textWidth = rect.right-rect.left; 365 if (textWidth <= width || preLen+endLen == 0) break; 366 if (endLen > preLen) 367 { 368 endLen--; 369 endPtr++; 370 } else preLen--; 371 newTextLen--; 372 } while (TRUE); 373 } 374 rc = OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,rectPtr,0,0,flCmd); 375 if (dwDTFormat & DT_MODIFYSTRING) strcpy((LPSTR)lpchText,newText); //check length? 376 free(newText); 377 378 done = TRUE; 379 } 380 } 381 382 if (!done) 383 rc = OSLibWinDrawTabbedText(pHps,cchText,lTabs,lpchText,rectPtr,0,0,flCmd); 384 385 if (dwDTFormat & DT_CALCRECT) 386 { 387 if (!(dwDTFormat & DT_RIGHT) && (rectPtr->left < xLeft)) 388 { 389 rectPtr->right = xLeft+(rectPtr->right-rectPtr->left); 390 rectPtr->left = xLeft; 391 } 392 if (!(dwDTFormat & DT_BOTTOM) && (rectPtr->top < yTop)) 393 { 394 rectPtr->bottom = yTop+(rectPtr->bottom-rectPtr->top); 395 rectPtr->top = yTop; 396 } 397 } 398 399 if (lpDTParams) 400 { 401 // don't forget to restore the margins 402 lprc->left -= lpDTParams->iLeftMargin; 403 lprc->right += lpDTParams->iRightMargin; 404 } 405 406 return rc; 407 */ 408 409 dwDTFormat &= ~(DT_END_ELLIPSIS | DT_PATH_ELLIPSIS); 410 return O32_DrawText(hdc,lpchText,cchText,lprc,dwDTFormat); 411 } 412 //****************************************************************************** 413 //****************************************************************************** 414 INT SYSTEM EXPORT InternalDrawTextExW(HDC hdc,LPCWSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams,BOOL isDrawTextEx) 415 { 416 char *astring = (cchText == -1) ? UnicodeToAsciiString((LPWSTR)lpchText):UnicodeToAsciiStringN((LPWSTR)lpchText,cchText); 417 INT rc; 418 419 rc = InternalDrawTextExA(hdc,astring,cchText,lprc,dwDTFormat,lpDTParams,isDrawTextEx); 420 if (dwDTFormat & DT_MODIFYSTRING && (dwDTFormat & (DT_END_ELLIPSIS | DT_PATH_ELLIPSIS))) AsciiToUnicode(astring,(LPWSTR)lpchText); 421 FreeAsciiString(astring); 422 423 return(rc); 424 } 425 //****************************************************************************** 426 // CB: USER32 function, but here is the better place 427 //****************************************************************************** 428 DWORD SYSTEM EXPORT InternalGetTabbedTextExtentA(HDC hDC,LPCSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions) 429 { 430 PVOID pHps = OSLibGpiQueryDCData(hDC); 431 BOOL result; 432 POINTLOS2 pts[TXTBOXOS_COUNT]; 433 POINTLOS2 widthHeight = {0,0}; 434 435 if (!pHps || nCount == 0 || nTabPositions < 0) 436 return 0; 437 438 if (nCount < 0) 439 { 440 SetLastError(ERROR_STACK_OVERFLOW); 441 return 0; 442 } 443 if (lpString == NULL || nCount > 512 || (nTabPositions > 0 && lpnTabStopPositions == NULL)) 444 { 445 SetLastError(ERROR_INVALID_PARAMETER); 446 return 0; 447 } 448 //CB: Win95 supports negative values for right aligned text 449 for (INT i = 0;i < nTabPositions;i++) 450 { 451 if (lpnTabStopPositions[i] < 0) 452 { 453 SetLastError(ERROR_INVALID_PARAMETER); 454 return 0; 455 } 456 } 457 458 result = OSLibGpiQueryTextBox(pHps,(nCount > 1) ? 1:nCount,lpString,TXTBOXOS_COUNT,pts); 459 if (result == FALSE) 460 return 0; 461 calcDimensions(pts,&widthHeight); 462 463 LONG rv1 = OSLibGpiQueryTabbedTextExtent(pHps,nCount,lpString,nTabPositions,lpnTabStopPositions); 464 if (rv1 == GPIOS_ERROR) 465 return 0; 466 467 return (widthHeight.y <<16)+labs(rv1); 468 } 469 //****************************************************************************** 470 //****************************************************************************** 471 DWORD SYSTEM EXPORT InternalGetTabbedTextExtentW(HDC hDC,LPCWSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions) 472 { 473 char *astring = (nCount == -1) ? UnicodeToAsciiString((LPWSTR)lpString):UnicodeToAsciiStringN((LPWSTR)lpString,nCount); 474 DWORD rc; 475 476 rc = InternalGetTabbedTextExtentA(hDC,astring,nCount,nTabPositions,lpnTabStopPositions); 477 FreeAsciiString(astring); 478 479 return(rc); 480 } 481 //****************************************************************************** 482 // CB: USER32 function, but here is the better place 483 //****************************************************************************** 484 LONG SYSTEM EXPORT InternalTabbedTextOutA(HDC hdc,INT x,INT y,LPCSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions,INT nTabOrigin) 485 { 486 PVOID pHps = OSLibGpiQueryDCData(hdc); 487 POINTLOS2 ptl; 488 DWORD dimensions; 489 490 if (pHps == NULL || lpString == NULL) 491 { 492 SetLastError(ERROR_INVALID_HANDLE); 493 return 0; 494 } 495 if (nCount == -1) 496 nCount = strlen(lpString); 497 if (nCount < 1) 498 { 499 SetLastError(ERROR_INVALID_HANDLE); 500 return 0; 501 } 502 if (lpnTabStopPositions == NULL) 503 nTabPositions = 0; 504 if (nTabPositions == 0) 505 lpnTabStopPositions = NULL; 506 if (nTabPositions < 0) 507 { 508 SetLastError(ERROR_INVALID_HANDLE); 509 return 0; 510 } 511 if (getAlignUpdateCP(pHps) == TRUE) 512 OSLibGpiQueryCurrentPosition(pHps,&ptl); 513 else 514 { 515 ptl.x = x; 516 ptl.y = y; 517 } 518 519 //CB: nTabOrigin is ignored! -> wrong size (width)! 520 // todo: change low word (width), height is ok 521 dimensions = InternalGetTabbedTextExtentA(hdc,lpString,nCount,nTabPositions,lpnTabStopPositions); 522 if (dimensions != 0) 523 { 524 LONG rcGPI; 525 526 ptl.y += getWorldYDeltaFor1Pixel(pHps); 527 528 rcGPI = OSLibGpiTabbedCharStringAt(pHps,&ptl,NULL,0,nCount,lpString,nTabPositions,lpnTabStopPositions,nTabOrigin); 529 if (rcGPI == GPIOS_ALTERROR) 530 return 0; 531 if (getAlignUpdateCP(pHps)) 532 { 533 OSLibGpiQueryCurrentPosition (pHps,&ptl); 534 ptl.y -= getWorldYDeltaFor1Pixel(pHps); 535 OSLibGpiSetCurrentPosition (pHps,&ptl); 536 } 537 538 return dimensions; 539 } 70 540 return 0; 71 541 } 72 542 //****************************************************************************** 73 543 //****************************************************************************** 74 INT WIN32API InternalDrawTextExW(HDC hdc,LPWSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams) 75 { 76 char *astring = UnicodeToAsciiStringN((LPWSTR)lpchText,cchText); 77 INT rc; 78 79 rc = InternalDrawTextExA(hdc,astring,cchText,lprc,dwDTFormat,lpDTParams); 80 FreeAsciiString(astring); 81 82 return(rc); 83 } 84 //****************************************************************************** 85 // CB: USER32 function, but here is the better place 86 //****************************************************************************** 87 LONG WIN32API InternalTabbedTextOutA( HDC hdc, int x, int y, LPCSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin) 88 { 89 //CB: todo 90 dprintf(("GDI32: InternalTabbedTextOutA, unimplemented stub!\n")); 91 return 0; 92 } 93 //****************************************************************************** 94 //****************************************************************************** 95 LONG WIN32API InternalTabbedTextOutW( HDC hdc, int x, int y, LPCWSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin) 96 { 97 char *astring = UnicodeToAsciiStringN((LPWSTR)lpString,nCount); 544 LONG SYSTEM EXPORT InternalTabbedTextOutW(HDC hdc,INT x,INT y,LPCWSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions,INT nTabOrigin) 545 { 546 char *astring = (nCount == -1) ? UnicodeToAsciiString((LPWSTR)lpString):UnicodeToAsciiStringN((LPWSTR)lpString,nCount); 98 547 LONG rc; 99 548 100 549 rc = InternalTabbedTextOutA(hdc,x,y,astring,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin); 101 FreeAsciiString(astring);102 103 return(rc);104 }105 //******************************************************************************106 // CB: USER32 function, but here is the better place107 //******************************************************************************108 DWORD WIN32API InternalGetTabbedTextExtentA( HDC hDC, LPCSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions)109 {110 //CB: todo111 dprintf(("GDI32: InternalGetTabbedTexExtentA, unimplemented stub!\n"));112 return 0;113 }114 //******************************************************************************115 //******************************************************************************116 DWORD WIN32API InternalGetTabbedTextExtentW( HDC hDC, LPCWSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions)117 {118 char *astring = UnicodeToAsciiStringN((LPWSTR)lpString,nCount);119 DWORD rc;120 121 rc = InternalGetTabbedTextExtentA(hDC,astring,nCount,nTabPositions,lpnTabStopPositions);122 550 FreeAsciiString(astring); 123 551 … … 188 616 flOptions |= CHSOS_VECTOR; 189 617 190 if ( getAlignUpdateCP(pHps) == FALSE)618 if (!getAlignUpdateCP(pHps)) 191 619 { 192 620 ptl.x = X; … … 199 627 LONG pmHAlign,pmVAlign; 200 628 201 //CB: TA_RIGHT not supported , only TA_CENTER and TA_LEFT629 //CB: TA_RIGHT not supported by PM, only TA_CENTER and TA_LEFT 202 630 if ((align & 0x6) == TA_RIGHT) 203 631 { … … 225 653 226 654 if (hits == GPIOS_ERROR) 227 {228 655 return FALSE; 229 } 656 230 657 if (getAlignUpdateCP(pHps)) 231 658 { … … 241 668 BOOL InternalTextOutW(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCWSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut) 242 669 { 243 char *astring = UnicodeToAsciiStringN((LPWSTR)lpszString,cbCount);670 char *astring = (cbCount == -1) ? UnicodeToAsciiString((LPWSTR)lpszString):UnicodeToAsciiStringN((LPWSTR)lpszString,cbCount); 244 671 BOOL rc; 245 672 … … 283 710 //****************************************************************************** 284 711 //****************************************************************************** 712 BOOL WIN32API PolyTextOutA(HDC hdc,POLYTEXTA *pptxt,int cStrings) 713 { 714 dprintf(("GDI32: PolyTextOutA")); 715 716 for (INT x = 0;x < cStrings;x++) 717 { 718 BOOL rc; 719 720 rc = InternalTextOutA(hdc,pptxt[x].x,pptxt[x].y,pptxt[x].uiFlags,&pptxt[x].rcl,pptxt[x].lpstr,pptxt[x].n,pptxt[x].pdx,TRUE); 721 if (!rc) return FALSE; 722 } 723 724 return TRUE; 725 } 726 //****************************************************************************** 727 //****************************************************************************** 728 BOOL WIN32API PolyTextOutW(HDC hdc,POLYTEXTW *pptxt,int cStrings) 729 { 730 dprintf(("GDI32: PolyTextOutW")); 731 732 for (INT x = 0;x < cStrings;x++) 733 { 734 BOOL rc; 735 736 rc = InternalTextOutW(hdc,pptxt[x].x,pptxt[x].y,pptxt[x].uiFlags,&pptxt[x].rcl,pptxt[x].lpstr,pptxt[x].n,pptxt[x].pdx,TRUE); 737 if (!rc) return FALSE; 738 } 739 740 return TRUE; 741 }
Note:
See TracChangeset
for help on using the changeset viewer.