1 | /* $Id: oslibgpi.cpp,v 1.1 1999-12-09 16:49:45 cbratschi Exp $ */
|
---|
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
|
---|
13 | #define INCL_WIN
|
---|
14 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
15 | #include <stdlib.h>
|
---|
16 | #include <string.h>
|
---|
17 | #include "win32type.h"
|
---|
18 | #include "oslibgpi.h"
|
---|
19 | #include "dcdata.h"
|
---|
20 |
|
---|
21 | #define GetDCData(a) ((pDCData)a)
|
---|
22 |
|
---|
23 | void inline swap(LONG &a,LONG &b)
|
---|
24 | {
|
---|
25 | LONG temp = a;
|
---|
26 |
|
---|
27 | a = b;
|
---|
28 | b = temp;
|
---|
29 | }
|
---|
30 |
|
---|
31 | void inline swap(int &a,int &b)
|
---|
32 | {
|
---|
33 | int temp = a;
|
---|
34 |
|
---|
35 | a = b;
|
---|
36 | b = temp;
|
---|
37 | }
|
---|
38 |
|
---|
39 | void inline sortAscending(LONG &a,LONG &b)
|
---|
40 | {
|
---|
41 | if (a > b) swap(a,b);
|
---|
42 | }
|
---|
43 |
|
---|
44 | void inline sortAscending(int &a,int &b)
|
---|
45 | {
|
---|
46 | if (a > b) swap(a,b);
|
---|
47 | }
|
---|
48 |
|
---|
49 | void inline sortAscending(POINTLOS2 &a,POINTLOS2 &b)
|
---|
50 | {
|
---|
51 | sortAscending(a.x,b.x);
|
---|
52 | sortAscending(a.y,b.y);
|
---|
53 | }
|
---|
54 |
|
---|
55 | BOOL excludeBottomRightPoint(PVOID pHps,PPOINTLOS2 pptl)
|
---|
56 | {
|
---|
57 | sortAscending(pptl[0],pptl[1]);
|
---|
58 |
|
---|
59 | if (GetDCData(pHps)->graphicsMode != GM_COMPATIBLE_W)
|
---|
60 | {
|
---|
61 | return TRUE;
|
---|
62 | }
|
---|
63 |
|
---|
64 | if (pptl[0].x == pptl[1].x || pptl[0].y == pptl[1].y)
|
---|
65 | {
|
---|
66 | return FALSE;
|
---|
67 | }
|
---|
68 |
|
---|
69 | if (abs((int)GetDCData(pHps)->viewportXExt) <= abs((int)GetDCData(pHps)->windowExt.cx))
|
---|
70 | {
|
---|
71 | if (GetDCData(pHps)->isLeftLeft)
|
---|
72 | pptl[1].x -= abs(GetDCData(pHps)->worldXDeltaFor1Pixel);
|
---|
73 | else
|
---|
74 | pptl[0].x += abs(GetDCData(pHps)->worldXDeltaFor1Pixel);
|
---|
75 | }
|
---|
76 |
|
---|
77 | if (abs((int)GetDCData(pHps)->viewportYExt) <= abs((int)GetDCData(pHps)->windowExt.cy))
|
---|
78 | {
|
---|
79 | if (GetDCData(pHps)->isTopTop)
|
---|
80 | pptl[1].y -= abs(GetDCData(pHps)->worldYDeltaFor1Pixel);
|
---|
81 | else
|
---|
82 | pptl[0].y += abs(GetDCData(pHps)->worldYDeltaFor1Pixel);
|
---|
83 | }
|
---|
84 |
|
---|
85 | sortAscending(pptl[0], pptl[1]);
|
---|
86 |
|
---|
87 | return TRUE;
|
---|
88 | }
|
---|
89 |
|
---|
90 | BOOL getAlignUpdateCP(PVOID pHps)
|
---|
91 | {
|
---|
92 | return GetDCData(pHps)->alignUpdateCP;
|
---|
93 | }
|
---|
94 |
|
---|
95 | INT getWorldYDeltaFor1Pixel(PVOID pHps)
|
---|
96 | {
|
---|
97 | return GetDCData(pHps)->worldYDeltaFor1Pixel;
|
---|
98 | }
|
---|
99 |
|
---|
100 | INT getWorldXDeltaFor1Pixel(PVOID pHps)
|
---|
101 | {
|
---|
102 | return GetDCData(pHps)->worldXDeltaFor1Pixel;
|
---|
103 | }
|
---|
104 |
|
---|
105 | BOOL OSLibGpiQueryCurrentPosition(PVOID pHps,PPOINTLOS2 ptl)
|
---|
106 | {
|
---|
107 | return GpiQueryCurrentPosition(GetDCData(pHps)->hps,(PPOINTL)ptl);
|
---|
108 | }
|
---|
109 |
|
---|
110 | BOOL OSLibGpiSetCurrentPosition(PVOID pHps,PPOINTLOS2 ptl)
|
---|
111 | {
|
---|
112 | return GpiSetCurrentPosition(GetDCData(pHps)->hps,(PPOINTL)ptl);
|
---|
113 | }
|
---|
114 |
|
---|
115 | BOOL OSLibGpiCharStringPosAt(PVOID pHps,PPOINTLOS2 ptl,PRECTLOS2 rct,ULONG flOptions,LONG lCount,LPCSTR pchString,CONST INT *alAdx)
|
---|
116 | {
|
---|
117 | return GpiCharStringPosAt(GetDCData(pHps)->hps,(PPOINTL)ptl,(PRECTL)rct,flOptions,lCount,(PCH)pchString,(PLONG)alAdx);
|
---|
118 | }
|
---|
119 |
|
---|
120 | BOOL OSLibGpiQueryCharStringPosAt(PVOID pHps,PPOINTLOS2 ptl,ULONG flOptions,LONG lCount,LPCSTR pchString,CONST INT *alAdx,PPOINTLOS2 aptlPos)
|
---|
121 | {
|
---|
122 | return GpiQueryCharStringPosAt(GetDCData(pHps)->hps,(PPOINTL)ptl,flOptions,lCount,(PCH)pchString,(PLONG)alAdx,(PPOINTL)aptlPos);
|
---|
123 | }
|
---|
124 |
|
---|
125 | BOOL OSLibGpiSetTextAlignment(PVOID pHps,LONG lHoriz,LONG lVert)
|
---|
126 | {
|
---|
127 | return GpiSetTextAlignment(GetDCData(pHps)->hps,lHoriz,lVert);
|
---|
128 | }
|
---|
129 |
|
---|
130 | BOOL OSLibGpiQueryTextAlignment(PVOID pHps,PLONG plHoriz,PLONG plVert)
|
---|
131 | {
|
---|
132 | return GpiQueryTextAlignment(GetDCData(pHps)->hps,plHoriz,plVert);
|
---|
133 | }
|
---|