[10594] | 1 | /* $Id: oslibgpi.cpp,v 1.19 2004-04-30 13:27:18 sandervl Exp $ */
|
---|
[2049] | 2 |
|
---|
| 3 | /*
|
---|
| 4 | * GPI interface code
|
---|
| 5 | *
|
---|
| 6 | * Copyright 1999 Christoph Bratschi (cbratschi@datacomm.ch)
|
---|
| 7 | *
|
---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 9 | *
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | #define INCL_GPI
|
---|
[10374] | 13 | #define INCL_GPIERRORS
|
---|
[2049] | 14 | #define INCL_WIN
|
---|
| 15 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
| 16 | #include <stdlib.h>
|
---|
| 17 | #include <string.h>
|
---|
[2092] | 18 | #include <math.h>
|
---|
[2049] | 19 | #include "win32type.h"
|
---|
[3705] | 20 | #include <winconst.h>
|
---|
[2049] | 21 | #include "oslibgpi.h"
|
---|
[4596] | 22 | #include <dcdata.h>
|
---|
| 23 | #include <misc.h>
|
---|
[2049] | 24 |
|
---|
[4012] | 25 | #define DBG_LOCALLOG DBG_oslibgpi
|
---|
[2802] | 26 | #include "dbglocal.h"
|
---|
| 27 |
|
---|
[2049] | 28 | #define GetDCData(a) ((pDCData)a)
|
---|
| 29 |
|
---|
[2092] | 30 | LONG APIENTRY _GpiQueryTabbedTextExtent(HPS hps,LONG lCount,PCH pchString,LONG lTabCount,PULONG puTabStops);
|
---|
| 31 |
|
---|
| 32 | inline LONG GpiQueryTabbedTextExtent(HPS hps,LONG lCount,PCH pchString,LONG lTabCount,PULONG puTabStops)
|
---|
| 33 | {
|
---|
| 34 | LONG yyrc;
|
---|
| 35 | USHORT sel = RestoreOS2FS();
|
---|
| 36 |
|
---|
| 37 | yyrc = _GpiQueryTabbedTextExtent(hps,lCount,pchString,lTabCount,puTabStops);
|
---|
| 38 | SetFS(sel);
|
---|
| 39 |
|
---|
| 40 | return yyrc;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | LONG APIENTRY _GpiTabbedCharStringAt(HPS hps,PPOINTL pPtStart,PRECTL prclRect,ULONG flOptions,LONG lCount,PCH pchString,LONG lTabCount,PULONG puTabStops,LONG lTabOrigin);
|
---|
| 44 |
|
---|
| 45 | inline LONG GpiTabbedCharStringAt(HPS hps,PPOINTL pPtStart,PRECTL prclRect,ULONG flOptions,LONG lCount,PCH pchString,LONG lTabCount,PULONG puTabStops,LONG lTabOrigin)
|
---|
| 46 | {
|
---|
| 47 | LONG yyrc;
|
---|
| 48 | USHORT sel = RestoreOS2FS();
|
---|
| 49 |
|
---|
| 50 | yyrc = _GpiTabbedCharStringAt(hps,pPtStart,prclRect,flOptions,lCount,pchString,lTabCount,puTabStops,lTabOrigin);
|
---|
| 51 | SetFS(sel);
|
---|
| 52 |
|
---|
| 53 | return yyrc;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
[4170] | 56 | LONG APIENTRY WinDrawTabbedText(HPS hps,LONG cchText,LONG lTabWidth,PCH lpchText,PRECTL prcl,LONG clrFore,LONG clrBack,ULONG flCmd);
|
---|
| 57 |
|
---|
| 58 | inline LONG _WinDrawTabbedText(HPS hps,LONG cchText,LONG lTabWidth,PCH lpchText,PRECTL prcl,LONG clrFore,LONG clrBack,ULONG flCmd)
|
---|
| 59 | {
|
---|
| 60 | LONG yyrc;
|
---|
| 61 | USHORT sel = RestoreOS2FS();
|
---|
| 62 |
|
---|
| 63 | yyrc = WinDrawTabbedText(hps,cchText,lTabWidth,lpchText,prcl,clrFore,clrBack,flCmd);
|
---|
| 64 | SetFS(sel);
|
---|
| 65 |
|
---|
| 66 | return yyrc;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | #undef WinDrawTabbedText
|
---|
| 70 | #define WinDrawTabbedText _WinDrawTabbedText
|
---|
| 71 |
|
---|
[2049] | 72 | void inline swap(LONG &a,LONG &b)
|
---|
| 73 | {
|
---|
| 74 | LONG temp = a;
|
---|
| 75 |
|
---|
| 76 | a = b;
|
---|
| 77 | b = temp;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | void inline swap(int &a,int &b)
|
---|
| 81 | {
|
---|
| 82 | int temp = a;
|
---|
| 83 |
|
---|
| 84 | a = b;
|
---|
| 85 | b = temp;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | void inline sortAscending(LONG &a,LONG &b)
|
---|
| 89 | {
|
---|
| 90 | if (a > b) swap(a,b);
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | void inline sortAscending(int &a,int &b)
|
---|
| 94 | {
|
---|
| 95 | if (a > b) swap(a,b);
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | void inline sortAscending(POINTLOS2 &a,POINTLOS2 &b)
|
---|
| 99 | {
|
---|
| 100 | sortAscending(a.x,b.x);
|
---|
| 101 | sortAscending(a.y,b.y);
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | BOOL excludeBottomRightPoint(PVOID pHps,PPOINTLOS2 pptl)
|
---|
| 105 | {
|
---|
| 106 | sortAscending(pptl[0],pptl[1]);
|
---|
| 107 |
|
---|
| 108 | if (GetDCData(pHps)->graphicsMode != GM_COMPATIBLE_W)
|
---|
| 109 | {
|
---|
| 110 | return TRUE;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | if (pptl[0].x == pptl[1].x || pptl[0].y == pptl[1].y)
|
---|
| 114 | {
|
---|
| 115 | return FALSE;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | if (abs((int)GetDCData(pHps)->viewportXExt) <= abs((int)GetDCData(pHps)->windowExt.cx))
|
---|
| 119 | {
|
---|
| 120 | if (GetDCData(pHps)->isLeftLeft)
|
---|
| 121 | pptl[1].x -= abs(GetDCData(pHps)->worldXDeltaFor1Pixel);
|
---|
| 122 | else
|
---|
| 123 | pptl[0].x += abs(GetDCData(pHps)->worldXDeltaFor1Pixel);
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | if (abs((int)GetDCData(pHps)->viewportYExt) <= abs((int)GetDCData(pHps)->windowExt.cy))
|
---|
| 127 | {
|
---|
| 128 | if (GetDCData(pHps)->isTopTop)
|
---|
| 129 | pptl[1].y -= abs(GetDCData(pHps)->worldYDeltaFor1Pixel);
|
---|
| 130 | else
|
---|
| 131 | pptl[0].y += abs(GetDCData(pHps)->worldYDeltaFor1Pixel);
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | sortAscending(pptl[0], pptl[1]);
|
---|
| 135 |
|
---|
| 136 | return TRUE;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
[3705] | 139 | BOOL includeBottomRightPoint(PVOID pHps,PPOINTLOS2 pptl)
|
---|
| 140 | {
|
---|
| 141 | if(GetDCData(pHps)->graphicsMode != GM_COMPATIBLE_W)
|
---|
| 142 | {
|
---|
| 143 | return TRUE; // already inclusive/inclusive
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | if(GetDCData(pHps)->isLeftLeft)
|
---|
| 147 | {
|
---|
| 148 | pptl[1].x += abs(GetDCData(pHps)->worldXDeltaFor1Pixel);
|
---|
| 149 | sortAscending(pptl[0].x, pptl[1].x);
|
---|
| 150 | }
|
---|
| 151 | else
|
---|
| 152 | {
|
---|
| 153 | pptl[0].x -= abs(GetDCData(pHps)->worldXDeltaFor1Pixel);
|
---|
| 154 | sortAscending(pptl[1].x, pptl[0].x);
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | if(GetDCData(pHps)->isTopTop)
|
---|
| 158 | {
|
---|
| 159 | pptl[1].y += abs(GetDCData(pHps)->worldYDeltaFor1Pixel);
|
---|
| 160 | sortAscending(pptl[1].y, pptl[0].y);
|
---|
| 161 | }
|
---|
| 162 | else
|
---|
| 163 | {
|
---|
| 164 | pptl[0].y -= abs(GetDCData(pHps)->worldYDeltaFor1Pixel);
|
---|
| 165 | sortAscending(pptl[0].y, pptl[1].y);
|
---|
| 166 | }
|
---|
| 167 | return TRUE;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
[2049] | 170 | BOOL getAlignUpdateCP(PVOID pHps)
|
---|
| 171 | {
|
---|
| 172 | return GetDCData(pHps)->alignUpdateCP;
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | INT getWorldYDeltaFor1Pixel(PVOID pHps)
|
---|
| 176 | {
|
---|
| 177 | return GetDCData(pHps)->worldYDeltaFor1Pixel;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | INT getWorldXDeltaFor1Pixel(PVOID pHps)
|
---|
| 181 | {
|
---|
| 182 | return GetDCData(pHps)->worldXDeltaFor1Pixel;
|
---|
| 183 | }
|
---|
| 184 |
|
---|
[2092] | 185 | BOOL getInPath(PVOID pHps)
|
---|
| 186 | {
|
---|
| 187 | return GetDCData(pHps)->inPath;
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | VOID setInPath(PVOID pHps,BOOL inPath)
|
---|
| 191 | {
|
---|
| 192 | GetDCData(pHps)->inPath = inPath;
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | BOOL getIsWideLine(PVOID pHps)
|
---|
| 196 | {
|
---|
| 197 | return GetDCData(pHps)->isWideLine;
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | BOOL getIsTopTop(PVOID pHps)
|
---|
| 201 | {
|
---|
| 202 | return GetDCData(pHps)->isTopTop;
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | ULONG getMapMode(PVOID pHps)
|
---|
| 206 | {
|
---|
| 207 | return GetDCData(pHps)->MapMode;
|
---|
| 208 | }
|
---|
| 209 |
|
---|
[2049] | 210 | BOOL OSLibGpiQueryCurrentPosition(PVOID pHps,PPOINTLOS2 ptl)
|
---|
| 211 | {
|
---|
| 212 | return GpiQueryCurrentPosition(GetDCData(pHps)->hps,(PPOINTL)ptl);
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | BOOL OSLibGpiSetCurrentPosition(PVOID pHps,PPOINTLOS2 ptl)
|
---|
| 216 | {
|
---|
| 217 | return GpiSetCurrentPosition(GetDCData(pHps)->hps,(PPOINTL)ptl);
|
---|
| 218 | }
|
---|
| 219 |
|
---|
| 220 | BOOL OSLibGpiCharStringPosAt(PVOID pHps,PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCSTR pchString,CONST INT *alAdx)
|
---|
| 221 | {
|
---|
| 222 | return GpiCharStringPosAt(GetDCData(pHps)->hps,(PPOINTL)ptl,(PRECTL)rct,flOptions,lCount,(PCH)pchString,(PLONG)alAdx);
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | BOOL OSLibGpiQueryCharStringPosAt(PVOID pHps,PPOINTLOS2 ptl,ULONG flOptions,LONG lCount,LPCSTR pchString,CONST INT *alAdx,PPOINTLOS2 aptlPos)
|
---|
| 226 | {
|
---|
| 227 | return GpiQueryCharStringPosAt(GetDCData(pHps)->hps,(PPOINTL)ptl,flOptions,lCount,(PCH)pchString,(PLONG)alAdx,(PPOINTL)aptlPos);
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | BOOL OSLibGpiSetTextAlignment(PVOID pHps,LONG lHoriz,LONG lVert)
|
---|
| 231 | {
|
---|
| 232 | return GpiSetTextAlignment(GetDCData(pHps)->hps,lHoriz,lVert);
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | BOOL OSLibGpiQueryTextAlignment(PVOID pHps,PLONG plHoriz,PLONG plVert)
|
---|
| 236 | {
|
---|
| 237 | return GpiQueryTextAlignment(GetDCData(pHps)->hps,plHoriz,plVert);
|
---|
| 238 | }
|
---|
[2092] | 239 |
|
---|
[4602] | 240 | LONG OSLibGpiQueryTabbedTextExtent(pDCData pHps,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops)
|
---|
[2092] | 241 | {
|
---|
[4602] | 242 | return GpiQueryTabbedTextExtent(pHps->hps,lCount,(PCH)pchString,lTabCount,(PULONG)puTabStops);
|
---|
[2092] | 243 | }
|
---|
| 244 |
|
---|
| 245 | LONG OSLibGpiTabbedCharStringAt(PVOID pHps,PPOINTLOS2 pPtStart,PRECTLOS2 prclRect,ULONG flOptions,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops,INT lTabOrigin)
|
---|
| 246 | {
|
---|
| 247 | return GpiTabbedCharStringAt(GetDCData(pHps)->hps,(PPOINTL)pPtStart,(PRECTL)prclRect,flOptions,lCount,(PCH)pchString,lTabCount,(PULONG)puTabStops,lTabOrigin);
|
---|
| 248 | }
|
---|
| 249 |
|
---|
[4602] | 250 | BOOL OSLibGpiQueryTextBox(pDCData pHps,LONG lCount1,LPCSTR pchString,LONG lCount2,PPOINTLOS2 aptlPoints)
|
---|
[2092] | 251 | {
|
---|
[4602] | 252 | return GpiQueryTextBox(pHps->hps,lCount1,(PCH)pchString,lCount2,(PPOINTL)aptlPoints);
|
---|
[2092] | 253 | }
|
---|
| 254 |
|
---|
| 255 | VOID calcDimensions(POINTLOS2 box[],PPOINTLOS2 point)
|
---|
| 256 | {
|
---|
| 257 | ULONG cx;
|
---|
| 258 | ULONG cy;
|
---|
[10374] | 259 |
|
---|
[10349] | 260 | //ignore underhang (just like GetTextExtentPoint does in Windows)
|
---|
| 261 | if (box[TXTBOX_BOTTOMLEFT].x < 0) {
|
---|
| 262 | dprintf(("WARNING: Ignoring underhang!!"));
|
---|
| 263 | box[TXTBOX_BOTTOMLEFT].x = 0;
|
---|
| 264 | }
|
---|
| 265 |
|
---|
[2092] | 266 | if (box[TXTBOX_BOTTOMLEFT].y == box[TXTBOX_BOTTOMRIGHT].y)
|
---|
| 267 | {
|
---|
[10372] | 268 | point->y = labs (box[TXTBOX_BOTTOMLEFT].y-box[TXTBOX_TOPLEFT].y);
|
---|
[10349] | 269 | point->x = labs (box[TXTBOX_CONCAT].x - box[TXTBOX_BOTTOMLEFT].x);
|
---|
| 270 |
|
---|
[2092] | 271 | if (box[TXTBOX_BOTTOMLEFT].x != box[TXTBOX_TOPLEFT].x)
|
---|
| 272 | {
|
---|
| 273 | if (point->y < 25)
|
---|
| 274 | cx = 2;
|
---|
| 275 | else
|
---|
| 276 | cx = ((point->y*10)+50)/100;
|
---|
| 277 | point->x += cx;
|
---|
| 278 | }
|
---|
| 279 | } else
|
---|
| 280 | {
|
---|
[10372] | 281 | cx = labs (box[TXTBOX_BOTTOMLEFT].x-box[TXTBOX_TOPLEFT].x);
|
---|
| 282 | cy = labs (box[TXTBOX_BOTTOMLEFT].y-box[TXTBOX_TOPLEFT].y);
|
---|
[2092] | 283 | point->y = (ULONG)hypot(cx,cy);
|
---|
| 284 |
|
---|
[10372] | 285 | cx = labs (box[TXTBOX_TOPRIGHT].x-box[TXTBOX_TOPLEFT].x);
|
---|
| 286 | cy = labs (box[TXTBOX_TOPRIGHT].y-box[TXTBOX_TOPLEFT].y);
|
---|
[2092] | 287 | point->x = (ULONG)hypot(cx,cy);
|
---|
| 288 | }
|
---|
| 289 | }
|
---|
| 290 |
|
---|
| 291 | LONG OSLibGpiQueryBackMix(PVOID pHps)
|
---|
| 292 | {
|
---|
| 293 | return GpiQueryBackMix(GetDCData(pHps)->hps);
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 | BOOL doesYAxisGrowNorth(PVOID pHps)
|
---|
| 297 | {
|
---|
| 298 | if ((GetDCData(pHps)->windowExt.cy < 0 && GetDCData(pHps)->viewportYExt > 0.0) ||
|
---|
| 299 | (GetDCData(pHps)->windowExt.cy > 0 && GetDCData(pHps)->viewportYExt < 0.0))
|
---|
| 300 | {
|
---|
| 301 | if (GetDCData(pHps)->graphicsMode == GM_COMPATIBLE_W ||
|
---|
| 302 | (GetDCData(pHps)->graphicsMode == GM_ADVANCED_W && GetDCData(pHps)->xform.eM22 >= 0.0))
|
---|
| 303 | return TRUE;
|
---|
| 304 | } else
|
---|
| 305 | {
|
---|
| 306 | if (GetDCData(pHps)->graphicsMode == GM_ADVANCED_W && GetDCData(pHps)->xform.eM22 < 0.0)
|
---|
| 307 | return TRUE;
|
---|
| 308 | }
|
---|
| 309 |
|
---|
| 310 | return FALSE;
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 | LONG OSLibWinDrawTabbedText(PVOID pHps,LONG cchText,LONG lTabs,LPCSTR lpchText,PVOID prcl,LONG clrFore,LONG clrBack,ULONG flCmd)
|
---|
| 314 | {
|
---|
[4012] | 315 | return WinDrawTabbedText(GetDCData(pHps)->hps,cchText,lTabs,(PCH)lpchText,(PRECTL)prcl,clrFore,clrBack,flCmd);
|
---|
[2092] | 316 | }
|
---|
| 317 |
|
---|
| 318 | BOOL OSLibGpiMove(PVOID pHps,PPOINTLOS2 pptlPoint)
|
---|
| 319 | {
|
---|
| 320 | return GpiMove(GetDCData(pHps)->hps,(PPOINTL)pptlPoint);
|
---|
| 321 | }
|
---|
| 322 |
|
---|
[10374] | 323 | BOOL OSLibGpiLine(PVOID pHps,PPOINTLOS2 pptlEndPoint)
|
---|
| 324 | {
|
---|
| 325 | LONG ret = GpiLine(GetDCData(pHps)->hps,(PPOINTL)pptlEndPoint);
|
---|
| 326 | if(ret != GPI_OK) {
|
---|
| 327 | dprintf(("GpiLine failed with error %x", WinGetLastError(0)));
|
---|
| 328 | }
|
---|
| 329 | return (ret == GPI_OK);
|
---|
[2092] | 330 | }
|
---|
| 331 |
|
---|
| 332 | #define FSP_ENDPATH 0x00000010
|
---|
| 333 | #define FSP_FILL 0x00000020
|
---|
| 334 | #define FSP_CLOSEPATH 0x00000040
|
---|
| 335 |
|
---|
| 336 | BOOL APIENTRY _PaxStrokeAndFillPath(HPS hPS,ULONG ulAction,ULONG ulStrokeAttrs,PAREABUNDLE pPenStroke);
|
---|
| 337 |
|
---|
| 338 | inline BOOL PaxStrokeAndFillPath(HPS hPS,ULONG ulAction,ULONG ulStrokeAttrs,PAREABUNDLE pPenStroke)
|
---|
| 339 | {
|
---|
| 340 | BOOL yyrc;
|
---|
| 341 | USHORT sel = RestoreOS2FS();
|
---|
| 342 |
|
---|
| 343 | yyrc = _PaxStrokeAndFillPath(hPS,ulAction,ulStrokeAttrs,pPenStroke);
|
---|
| 344 | SetFS(sel);
|
---|
| 345 |
|
---|
| 346 | return yyrc;
|
---|
| 347 | }
|
---|
| 348 |
|
---|
[4170] | 349 |
|
---|
[2092] | 350 | BOOL OSLibGpiEndPath(PVOID pHps)
|
---|
| 351 | {
|
---|
| 352 | return GpiEndPath(GetDCData(pHps)->hps);
|
---|
| 353 | }
|
---|
| 354 |
|
---|
| 355 | BOOL drawLinePointCircle(PVOID pHps,INT width,INT height,LONG color)
|
---|
| 356 | {
|
---|
| 357 | ARCPARAMS arcp;
|
---|
| 358 | BOOL rc = TRUE;
|
---|
| 359 |
|
---|
| 360 | arcp.lP = 1;
|
---|
| 361 | arcp.lQ = 1;
|
---|
| 362 | arcp.lR = 0;
|
---|
| 363 | arcp.lS = 0;
|
---|
| 364 | if (!GpiSetArcParams(GetDCData(pHps)->hps,&arcp))
|
---|
[10594] | 365 | {
|
---|
| 366 | dprintf(("drawLinePointCircle: GpiSetArcParams failed with %x!!", WinGetLastError(0)));
|
---|
| 367 | return FALSE;
|
---|
| 368 | }
|
---|
[2092] | 369 |
|
---|
| 370 | AREABUNDLE newAreaBundle, oldAreaBundle;
|
---|
| 371 | LINEBUNDLE lineBundle;
|
---|
| 372 |
|
---|
| 373 | GpiQueryAttrs(GetDCData(pHps)->hps,PRIM_AREA,ABB_COLOR | ABB_MIX_MODE | ABB_SET | ABB_SYMBOL,(PBUNDLE)&oldAreaBundle);
|
---|
| 374 | GpiQueryAttrs(GetDCData(pHps)->hps,PRIM_LINE,LBB_MIX_MODE, (PBUNDLE)&lineBundle);
|
---|
| 375 |
|
---|
[21304] | 376 | ULONG penAttrs = ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL;
|
---|
| 377 |
|
---|
[2092] | 378 | newAreaBundle = oldAreaBundle;
|
---|
| 379 | newAreaBundle.lColor = color;
|
---|
| 380 | newAreaBundle.usMixMode = lineBundle.usMixMode;
|
---|
[21304] | 381 | if(!GetDCData(pHps)->isMetaPS && !GetDCData(pHps)->isPrinter)
|
---|
| 382 | {
|
---|
[2092] | 383 | newAreaBundle.usSet = LCID_DEFAULT;
|
---|
[21304] | 384 | penAttrs |= ABB_SET;
|
---|
| 385 | }
|
---|
[2092] | 386 | newAreaBundle.usSymbol = PATSYM_SOLID;
|
---|
| 387 |
|
---|
[21304] | 388 | if (!GpiSetAttrs(GetDCData(pHps)->hps,PRIM_AREA, penAttrs,0,(PBUNDLE)&newAreaBundle))
|
---|
[10594] | 389 | {
|
---|
| 390 | dprintf(("drawLinePointCircle: GpiSetAttrs failed with %x!!", WinGetLastError(0)));
|
---|
| 391 | return FALSE;
|
---|
| 392 | }
|
---|
[2092] | 393 |
|
---|
[21304] | 394 | if (GpiFullArc(GetDCData(pHps)->hps, GetDCData(pHps)->inPath ? DRO_OUTLINE : DRO_FILL, MAKEFIXED((width-1)>>1,0)) == GPI_ERROR)
|
---|
[10594] | 395 | {
|
---|
| 396 | dprintf(("drawLinePointCircle: GpiFullArc failed with %x!!", WinGetLastError(0)));
|
---|
| 397 | rc = FALSE;
|
---|
| 398 | }
|
---|
[21304] | 399 | GpiSetAttrs(GetDCData(pHps)->hps,PRIM_AREA,penAttrs,0,(PBUNDLE)&oldAreaBundle);
|
---|
[2092] | 400 |
|
---|
| 401 | return rc;
|
---|
| 402 | }
|
---|
| 403 |
|
---|
| 404 | BOOL drawLinePoint(PVOID pHps,PPOINTLOS2 pt,LONG color)
|
---|
| 405 | {
|
---|
| 406 | LINEBUNDLE lbOld, lbNew;
|
---|
| 407 | LONG defaults = GpiQueryAttrs(GetDCData(pHps)->hps, PRIM_LINE, LBB_COLOR, &lbOld);
|
---|
| 408 |
|
---|
| 409 | lbNew.lColor = color;
|
---|
[10374] | 410 | BOOL rc = GpiSetAttrs(GetDCData(pHps)->hps,PRIM_LINE,LBB_COLOR,0,&lbNew);
|
---|
| 411 | if(rc == FALSE) {
|
---|
[10583] | 412 | dprintf(("GpiSetAttrs failed with %x", WinGetLastError(0)));
|
---|
[10374] | 413 | }
|
---|
| 414 | else {
|
---|
| 415 | rc = GpiSetPel(GetDCData(pHps)->hps,(PPOINTL)pt) != GPI_ERROR;
|
---|
[10583] | 416 | if(rc == FALSE) {
|
---|
| 417 | dprintf(("WARNING: GpiSetPel failed %x (invalid in path?); retrying with GpiLine", WinGetLastError(0)));
|
---|
[10374] | 418 | rc = GpiLine(GetDCData(pHps)->hps,(PPOINTL)pt) != GPI_ERROR;
|
---|
| 419 | }
|
---|
| 420 | }
|
---|
| 421 | if(rc == FALSE) {
|
---|
| 422 | dprintf(("GpiSetPel/GpiLine failed with %x", WinGetLastError(0)));
|
---|
| 423 | }
|
---|
[2092] | 424 |
|
---|
| 425 | GpiSetAttrs(GetDCData(pHps)->hps,PRIM_LINE,LBB_COLOR,defaults,&lbOld);
|
---|
| 426 |
|
---|
| 427 | return rc;
|
---|
| 428 | }
|
---|
[2484] | 429 |
|
---|
[21916] | 430 | ULONG SYSTEM OSLibGpiQueryCp(HDC hdc)
|
---|
[2484] | 431 | {
|
---|
| 432 | return GpiQueryCp(hdc);
|
---|
| 433 | }
|
---|
| 434 |
|
---|
[21916] | 435 | BOOL SYSTEM OSLibGpiSetCp(HDC hdc, ULONG codepage)
|
---|
[2484] | 436 | {
|
---|
| 437 | return GpiSetCp(hdc, codepage);
|
---|
| 438 | }
|
---|
| 439 |
|
---|
[3705] | 440 |
|
---|
[10174] | 441 | int OSLibGpiQueryFontMaxHeight(HDC hdc)
|
---|
[4596] | 442 | {
|
---|
| 443 | FONTMETRICS metrics;
|
---|
| 444 | BOOL rc;
|
---|
| 445 |
|
---|
| 446 | rc = GpiQueryFontMetrics(hdc, sizeof(metrics), &metrics);
|
---|
| 447 | if(rc) {
|
---|
[10174] | 448 | return max(metrics.lMaxBaselineExt,
|
---|
| 449 | max(metrics.lMaxAscender+metrics.lMaxDescender,
|
---|
[9737] | 450 | metrics.lInternalLeading+metrics.lEmHeight));
|
---|
[4596] | 451 | }
|
---|
| 452 | else {
|
---|
[10174] | 453 | dprintf(("GpiQueryFontMetrics returned FALSE!!"));
|
---|
| 454 | return 0;
|
---|
[4596] | 455 | }
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | #ifdef DEBUG
|
---|
| 459 | void dprintfOrigin(HDC hdc)
|
---|
| 460 | {
|
---|
| 461 | POINTL point;
|
---|
| 462 |
|
---|
| 463 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
---|
| 464 | if(!pHps)
|
---|
| 465 | {
|
---|
[10174] | 466 | return;
|
---|
[4596] | 467 | }
|
---|
| 468 |
|
---|
| 469 | GreGetDCOrigin(pHps->hps, &point);
|
---|
[5165] | 470 | dprintf2(("HDC %x origin (%d,%d) org (%d,%d)", hdc, point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y));
|
---|
[4596] | 471 | }
|
---|
| 472 | #endif
|
---|
[9443] | 473 | //******************************************************************************
|
---|
| 474 | //******************************************************************************
|
---|
[4602] | 475 | BOOL OSLibDevQueryCaps(pDCData pHps, LONG lStart, LONG lCount, LONG *alArray)
|
---|
| 476 | {
|
---|
| 477 | return DevQueryCaps(pHps->hdc, lStart, lCount, alArray);
|
---|
| 478 | }
|
---|
[9443] | 479 | //******************************************************************************
|
---|
| 480 | //******************************************************************************
|
---|
| 481 | BOOL OSLibGpiLoadFonts(LPSTR lpszFontFile)
|
---|
| 482 | {
|
---|
[10374] | 483 | BOOL ret;
|
---|
| 484 |
|
---|
| 485 | //We must use GpiLoadPublicFonts here. GpiLoadFonts cannot be used for
|
---|
| 486 | //queued printer device contexts
|
---|
| 487 | //-> NOTE: this is no longer the case as we spool printer specific data now (not metafiles)
|
---|
| 488 | ret = GpiLoadFonts(0, lpszFontFile);
|
---|
| 489 | if(ret == FALSE) {
|
---|
| 490 | dprintf(("GpiLoadPublicFonts %s failed with %x", lpszFontFile, WinGetLastError(0)));
|
---|
| 491 | }
|
---|
| 492 | return ret;
|
---|
[9443] | 493 | }
|
---|
| 494 | //******************************************************************************
|
---|
| 495 | //******************************************************************************
|
---|
[10374] | 496 | BOOL OSLibGpiUnloadFonts(LPSTR lpszFontFile)
|
---|
| 497 | {
|
---|
| 498 | return GpiUnloadFonts(0, lpszFontFile);
|
---|
| 499 | }
|
---|
| 500 | //******************************************************************************
|
---|
| 501 | //******************************************************************************
|
---|
| 502 | BOOL OSLibGpiQueryFontName(LPSTR lpszFileName, LPSTR lpszFamily, LPSTR lpszFace, int cbString)
|
---|
| 503 | {
|
---|
| 504 | LONG cFonts = 0, cRemFonts;
|
---|
| 505 | PFFDESCS pffd = NULL;
|
---|
| 506 | ULONG cb;
|
---|
| 507 |
|
---|
| 508 | cRemFonts = GpiQueryFontFileDescriptions(0, lpszFileName, &cFonts, NULL);
|
---|
| 509 | if(cRemFonts == GPI_ALTERROR) {
|
---|
| 510 | DebugInt3();
|
---|
| 511 | return FALSE;
|
---|
| 512 | }
|
---|
| 513 |
|
---|
| 514 | cFonts = max(cFonts, cRemFonts);
|
---|
| 515 | cb = cFonts * sizeof(FFDESCS) + 100; // must allocate extra
|
---|
| 516 | pffd = (PFFDESCS)malloc(cb);
|
---|
| 517 | if(pffd == NULL) {
|
---|
| 518 | DebugInt3();
|
---|
| 519 | return FALSE;
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 | memset(pffd, 0, cb);
|
---|
| 523 |
|
---|
| 524 | //assuming one font for now
|
---|
| 525 | cFonts = 1;
|
---|
| 526 | if(GpiQueryFontFileDescriptions(0, lpszFileName, &cFonts, pffd) == 0)
|
---|
| 527 | {
|
---|
| 528 | strncpy(lpszFamily, (char *)pffd, cbString);
|
---|
| 529 | strncpy(lpszFace, (char *)pffd + FACESIZE, cbString);
|
---|
| 530 | }
|
---|
| 531 | free(pffd);
|
---|
| 532 | return TRUE;
|
---|
| 533 | }
|
---|
| 534 | //******************************************************************************
|
---|
| 535 | //******************************************************************************
|
---|
| 536 | BOOL ReallySetCharAttrs(PVOID lpHps)
|
---|
| 537 | {
|
---|
| 538 | BOOL bRet = FALSE;
|
---|
| 539 | pDCData pHps = (pDCData)lpHps;
|
---|
| 540 |
|
---|
| 541 | if(pHps)
|
---|
| 542 | {
|
---|
| 543 | if(!pHps->bAttrSet)
|
---|
| 544 | {
|
---|
| 545 | if (!pHps->bFirstSet) {
|
---|
| 546 | pHps->bFirstSet = TRUE;
|
---|
| 547 | }
|
---|
| 548 | if (pHps->ulCharMask) {
|
---|
| 549 | bRet = GpiSetAttrs(pHps->hps, PRIM_CHAR, pHps->ulCharMask, 0, &pHps->CBundle);
|
---|
| 550 | } else {
|
---|
| 551 | bRet = TRUE;
|
---|
| 552 | }
|
---|
| 553 | if(bRet == TRUE) {
|
---|
| 554 | pHps->CSetBundle = pHps->CBundle;
|
---|
| 555 | pHps->ulCharMask = 0;
|
---|
| 556 | pHps->bAttrSet = TRUE;
|
---|
| 557 | }
|
---|
| 558 | }
|
---|
| 559 | }
|
---|
| 560 | return(bRet);
|
---|
| 561 | }
|
---|
| 562 | //******************************************************************************
|
---|
| 563 | //******************************************************************************
|
---|