1 | /* $Id: oslibgdi.h,v 1.8 2000-11-19 11:52:39 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Window GDI wrapper functions for OS/2
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #ifndef __OSLIBGDI_H__
|
---|
13 | #define __OSLIBGDI_H__
|
---|
14 |
|
---|
15 | #ifdef OS2_INCLUDED
|
---|
16 | #include "win32type.h"
|
---|
17 | #endif
|
---|
18 | #include <win32wbase.h>
|
---|
19 |
|
---|
20 | typedef struct
|
---|
21 | {
|
---|
22 | LONG xLeft;
|
---|
23 | LONG yBottom;
|
---|
24 | LONG xRight;
|
---|
25 | LONG yTop;
|
---|
26 | } RECTLOS2, *PRECTLOS2;
|
---|
27 |
|
---|
28 | typedef struct
|
---|
29 | {
|
---|
30 | LONG x;
|
---|
31 | LONG y;
|
---|
32 | } OSLIBPOINT;
|
---|
33 |
|
---|
34 | //Mapping functions
|
---|
35 |
|
---|
36 | INT mapScreenY(INT screenPosY);
|
---|
37 | INT mapScreenY(INT screenH,INT screenPosY);
|
---|
38 | INT inline mapY(INT height, int y)
|
---|
39 | {
|
---|
40 | return height - 1 - y;
|
---|
41 | }
|
---|
42 |
|
---|
43 | INT inline mapY(Win32BaseWindow *win32wnd,INT y)
|
---|
44 | {
|
---|
45 | return win32wnd->getWindowHeight() - 1 - y;
|
---|
46 | }
|
---|
47 |
|
---|
48 | INT inline mapOS2ToWin32Y(Win32BaseWindow *win32wnd,INT y)
|
---|
49 | {
|
---|
50 | return win32wnd->getWindowHeight() - 1 - (y + win32wnd->getClientRectPtr()->top);
|
---|
51 | }
|
---|
52 |
|
---|
53 | INT inline mapOS2ToWin32X(Win32BaseWindow *win32wnd,INT x)
|
---|
54 | {
|
---|
55 | return x - win32wnd->getClientRectPtr()->left;
|
---|
56 | }
|
---|
57 |
|
---|
58 | INT inline mapWin32ToOS2Y(Win32BaseWindow *win32wnd,INT y)
|
---|
59 | {
|
---|
60 | if(win32wnd->getParent()) {
|
---|
61 | return win32wnd->getWindowHeight() - 1 - (y - win32wnd->getParent()->getClientRectPtr()->top);
|
---|
62 | }
|
---|
63 | else return y;
|
---|
64 | }
|
---|
65 |
|
---|
66 | INT inline mapWin32ToOS2X(Win32BaseWindow *win32wnd,INT x)
|
---|
67 | {
|
---|
68 | if(win32wnd->getParent()) {
|
---|
69 | return x + win32wnd->getParent()->getClientRectPtr()->left;
|
---|
70 | }
|
---|
71 | else return x;
|
---|
72 | }
|
---|
73 |
|
---|
74 | INT mapOS2ToWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY);
|
---|
75 | INT mapWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY);
|
---|
76 | BOOL mapScreenPoint(OSLIBPOINT *screenPt);
|
---|
77 | BOOL mapScreenPoint(INT screenH,OSLIBPOINT *screenPt);
|
---|
78 |
|
---|
79 | BOOL mapOS2ToWin32Rect(int height, PRECTLOS2 rectOS2, PRECT rectWin32);
|
---|
80 | BOOL mapWin32ToOS2Rect(int height, PRECT rectWin32,PRECTLOS2 rectOS2);
|
---|
81 |
|
---|
82 | BOOL mapWin32ToOS2RectClientToFrame(Win32BaseWindow *window, PRECT rectWin32,PRECTLOS2 rectOS2);
|
---|
83 | BOOL mapOS2ToWin32RectFrameToClient(Win32BaseWindow *window, PRECTLOS2 rectOS2, PRECT rectWin32);
|
---|
84 |
|
---|
85 | #define mapWin32ToOS2RectFrame(window, rectWin32, rectOS2) \
|
---|
86 | if(window->getParent()) { \
|
---|
87 | mapWin32ToOS2Rect(window->getParent()->getWindowHeight(), rectWin32, rectOS2); \
|
---|
88 | } \
|
---|
89 | else mapWin32ToOS2Rect(OSLibQueryScreenHeight(), rectWin32, rectOS2);
|
---|
90 |
|
---|
91 | #define mapWin32ToOS2RectClient(window, rectWin32, rectOS2) \
|
---|
92 | mapWin32ToOS2Rect(window->getClientHeight(), rectWin32, rectOS2)
|
---|
93 |
|
---|
94 | #define mapWin32ToOS2ScreenRect(rectOS2, rectWin32) \
|
---|
95 | mapWin32ToOS2Rect(OSLibQueryScreenHeight(), rectOS2, rectWin32)
|
---|
96 |
|
---|
97 | #define mapOS2ToWin32RectFrame(window, rectOS2, rectWin32) \
|
---|
98 | if(window->getParent()) { \
|
---|
99 | mapOS2ToWin32Rect(window->getParent()->getWindowHeight(), rectOS2, rectWin32); \
|
---|
100 | } \
|
---|
101 | else mapOS2ToWin32Rect(OSLibQueryScreenHeight(), rectOS2, rectWin32);
|
---|
102 |
|
---|
103 |
|
---|
104 | #define mapOS2ToWin32RectClient(window, rectOS2, rectWin32) \
|
---|
105 | mapOS2ToWin32Rect(window->getClientHeight(), rectOS2, rectWin32)
|
---|
106 |
|
---|
107 | #define mapOS2ToWin32ScreenRect(rectOS2, rectWin32) \
|
---|
108 | mapOS2ToWin32Rect(OSLibQueryScreenHeight(), rectOS2, rectWin32)
|
---|
109 |
|
---|
110 | BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32);
|
---|
111 | BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2);
|
---|
112 | INT mapOS2ToWin32ChildOrigin(INT parentH,INT parentPosY,INT childH);
|
---|
113 |
|
---|
114 | #define RECT_WIDTH(a) ((a).right - (a).left)
|
---|
115 | #define RECT_HEIGHT(a) ((a).bottom - (a).top)
|
---|
116 |
|
---|
117 | #endif //__OSLIBGDI_H__
|
---|