[5685] | 1 | /* $Id: oslibgdi.cpp,v 1.14 2001-05-11 08:39:42 sandervl Exp $ */
|
---|
[2469] | 2 | /*
|
---|
| 3 | * Window GDI wrapper functions for OS/2
|
---|
| 4 | *
|
---|
| 5 | *
|
---|
| 6 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
| 7 | * Copyright 1999 Christoph Bratschi (cbratschi@datacomm.ch)
|
---|
| 8 | *
|
---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 10 | *
|
---|
| 11 | */
|
---|
| 12 | #define INCL_WIN
|
---|
| 13 | #define INCL_PM
|
---|
| 14 | #include <os2wrap.h>
|
---|
| 15 | #include <stdlib.h>
|
---|
| 16 | #include <string.h>
|
---|
| 17 | #include <misc.h>
|
---|
[3101] | 18 | #include <winconst.h>
|
---|
[21916] | 19 | #include "oslibgdi.h"
|
---|
| 20 | #include "oslibwin.h"
|
---|
[2469] | 21 | #include "win32wbase.h"
|
---|
| 22 |
|
---|
[2804] | 23 | #define DBG_LOCALLOG DBG_oslibgdi
|
---|
| 24 | #include "dbglocal.h"
|
---|
| 25 |
|
---|
[2469] | 26 | /*
|
---|
| 27 | First letter is lower case to avoid conflicts with Win32 API names
|
---|
| 28 | All transformations are for screen or client windows, for frame windows use OS/2 API's
|
---|
| 29 |
|
---|
| 30 | Single y mapping:
|
---|
| 31 | mapScreenY()
|
---|
[3662] | 32 | mapY() //only reverses y
|
---|
| 33 | mapOS2ToWin32Y() //reverse y + subtract parent client offset
|
---|
| 34 | mapOS2ToWin32X() //subtract parent client offset
|
---|
[2469] | 35 |
|
---|
[3662] | 36 | mapWin32ToOS2Y() //reverse y + add parent client offset
|
---|
| 37 | mapWin32ToOS2Y() //add parent client offset
|
---|
| 38 |
|
---|
[2469] | 39 | Single point mapping:
|
---|
| 40 | mapScreenPoint()
|
---|
| 41 | mapOS2ToWin32Point()
|
---|
| 42 | mapWin32ToOS2Point()
|
---|
| 43 | mapWin32Point()
|
---|
| 44 |
|
---|
| 45 | Single rect mapping:
|
---|
| 46 | mapOS2ToWin32ScreenRect()
|
---|
| 47 | mapWin32ToOS2ScreenRect()
|
---|
| 48 | mapOS2ToWin32Rect()
|
---|
| 49 | mapWin32ToOS2Rect()
|
---|
| 50 | mapWin32Rect()
|
---|
| 51 |
|
---|
| 52 | Rect transformation:
|
---|
| 53 | copyOS2ToWin32Rect()
|
---|
| 54 | copyWin32ToOS2Rect()
|
---|
| 55 | */
|
---|
| 56 |
|
---|
| 57 | //******************************************************************************
|
---|
| 58 | // To translation between OS/2 <-> Win32
|
---|
| 59 | //******************************************************************************
|
---|
| 60 | INT mapScreenY(INT screenPosY)
|
---|
| 61 | {
|
---|
| 62 | return ScreenHeight-1-screenPosY;
|
---|
| 63 | }
|
---|
| 64 | //******************************************************************************
|
---|
| 65 | // To translation between OS/2 <-> Win32
|
---|
| 66 | //******************************************************************************
|
---|
| 67 | INT mapScreenY(INT screenH,INT screenPosY)
|
---|
| 68 | {
|
---|
| 69 | return screenH-1-screenPosY;
|
---|
| 70 | }
|
---|
| 71 | //******************************************************************************
|
---|
| 72 | // To translation between OS/2 <-> Win32
|
---|
| 73 | //******************************************************************************
|
---|
| 74 | BOOL mapScreenPoint(OSLIBPOINT *screenPt)
|
---|
| 75 | {
|
---|
| 76 | if(!screenPt) return FALSE;
|
---|
| 77 | screenPt->y = ScreenHeight-1-screenPt->y;
|
---|
| 78 |
|
---|
| 79 | return TRUE;
|
---|
| 80 | }
|
---|
| 81 | //******************************************************************************
|
---|
| 82 | // To translation between OS/2 <-> Win32
|
---|
| 83 | //******************************************************************************
|
---|
| 84 | BOOL mapScreenPoint(INT screenH,OSLIBPOINT *screenPt)
|
---|
| 85 | {
|
---|
| 86 | if (!screenPt) return FALSE;
|
---|
| 87 | screenPt->y = screenH-1-screenPt->y;
|
---|
| 88 |
|
---|
| 89 | return TRUE;
|
---|
| 90 | }
|
---|
| 91 | //******************************************************************************
|
---|
| 92 | // To translation between OS/2 <-> Win32
|
---|
| 93 | //******************************************************************************
|
---|
[3662] | 94 | BOOL mapOS2ToWin32Rect(int height, PRECTLOS2 rectOS2, PRECT rectWin32)
|
---|
[2469] | 95 | {
|
---|
[3662] | 96 | if(!rectOS2 || !rectWin32) {
|
---|
| 97 | DebugInt3();
|
---|
| 98 | return FALSE;
|
---|
[2469] | 99 | }
|
---|
[3662] | 100 | rectWin32->bottom = height-rectOS2->yBottom;
|
---|
| 101 | rectWin32->top = height-rectOS2->yTop;
|
---|
[2469] | 102 | rectWin32->left = rectOS2->xLeft;
|
---|
| 103 | rectWin32->right = rectOS2->xRight;
|
---|
| 104 |
|
---|
| 105 | return TRUE;
|
---|
| 106 | }
|
---|
| 107 | //******************************************************************************
|
---|
| 108 | //******************************************************************************
|
---|
[3662] | 109 | BOOL mapWin32ToOS2Rect(int height, PRECT rectWin32, PRECTLOS2 rectOS2)
|
---|
[2469] | 110 | {
|
---|
[3662] | 111 | if(!rectOS2 || !rectWin32) {
|
---|
| 112 | DebugInt3();
|
---|
| 113 | return FALSE;
|
---|
[2469] | 114 | }
|
---|
[3662] | 115 | rectOS2->yBottom = height-rectWin32->bottom;
|
---|
| 116 | rectOS2->yTop = height-rectWin32->top;
|
---|
[2469] | 117 | rectOS2->xLeft = rectWin32->left;
|
---|
| 118 | rectOS2->xRight = rectWin32->right;
|
---|
| 119 |
|
---|
| 120 | return TRUE;
|
---|
| 121 | }
|
---|
[5685] | 122 | #ifndef CLIENTFRAME
|
---|
[2469] | 123 | //******************************************************************************
|
---|
[3679] | 124 | //Win32 rectangle in client coordinates (relative to upper left corner of client window)
|
---|
| 125 | //Convert to frame coordinates (relative to lower left corner of window)
|
---|
[2469] | 126 | //******************************************************************************
|
---|
[3662] | 127 | BOOL mapWin32ToOS2RectClientToFrame(Win32BaseWindow *window, PRECT rectWin32,PRECTLOS2 rectOS2)
|
---|
[2469] | 128 | {
|
---|
[3662] | 129 | int height;
|
---|
| 130 | int xclientorg;
|
---|
| 131 | int yclientorg;
|
---|
[2469] | 132 |
|
---|
[3662] | 133 | if(!window || !rectOS2 || !rectWin32) {
|
---|
| 134 | DebugInt3();
|
---|
| 135 | return FALSE;
|
---|
[2469] | 136 | }
|
---|
[3662] | 137 | height = window->getWindowHeight();
|
---|
| 138 | xclientorg = window->getClientRectPtr()->left;
|
---|
| 139 | yclientorg = window->getClientRectPtr()->top;
|
---|
[2469] | 140 |
|
---|
[3662] | 141 | rectOS2->yBottom = height - (rectWin32->bottom + yclientorg);
|
---|
| 142 | rectOS2->yTop = height - (rectWin32->top + yclientorg);
|
---|
[3679] | 143 | rectOS2->xLeft = rectWin32->left + xclientorg;
|
---|
| 144 | rectOS2->xRight = rectWin32->right + xclientorg;
|
---|
[2469] | 145 |
|
---|
| 146 | return TRUE;
|
---|
| 147 | }
|
---|
| 148 | //******************************************************************************
|
---|
[3679] | 149 | //OS/2 rectangle in frame coordinates (relative to lower left corner of window)
|
---|
| 150 | //Convert to client coordinates (relative to upper left corner of client window)
|
---|
| 151 | //Note: win32 rectangle can be bigger than client area!
|
---|
[2469] | 152 | //******************************************************************************
|
---|
[3679] | 153 | BOOL mapOS2ToWin32RectFrameToClient(Win32BaseWindow *window, PRECTLOS2 rectOS2,
|
---|
| 154 | PRECT rectWin32)
|
---|
| 155 | {
|
---|
| 156 | int height;
|
---|
| 157 | int xclientorg;
|
---|
| 158 | int yclientorg;
|
---|
| 159 |
|
---|
| 160 | if(!window || !rectOS2 || !rectWin32) {
|
---|
| 161 | DebugInt3();
|
---|
| 162 | return FALSE;
|
---|
| 163 | }
|
---|
| 164 | height = window->getWindowHeight();
|
---|
| 165 | xclientorg = window->getClientRectPtr()->left;
|
---|
| 166 | yclientorg = window->getClientRectPtr()->top;
|
---|
| 167 |
|
---|
| 168 | rectWin32->bottom = height - (rectOS2->yBottom + yclientorg);
|
---|
| 169 | rectWin32->top = height - (rectOS2->yTop + yclientorg);
|
---|
| 170 | rectWin32->left = rectOS2->xLeft - xclientorg;
|
---|
| 171 | rectWin32->right = rectOS2->xRight - xclientorg;
|
---|
| 172 |
|
---|
| 173 | return TRUE;
|
---|
| 174 | }
|
---|
[5685] | 175 | #endif //CLIENTFRAME
|
---|
[3679] | 176 | //******************************************************************************
|
---|
| 177 | //******************************************************************************
|
---|
[2469] | 178 | BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32)
|
---|
| 179 | {
|
---|
| 180 | rectWin32->bottom = rectOS2->yBottom;
|
---|
| 181 | rectWin32->top = rectOS2->yTop;
|
---|
| 182 | rectWin32->left = rectOS2->xLeft;
|
---|
| 183 | rectWin32->right = rectOS2->xRight;
|
---|
| 184 |
|
---|
| 185 | return TRUE;
|
---|
| 186 | }
|
---|
| 187 | //******************************************************************************
|
---|
| 188 | //******************************************************************************
|
---|
| 189 | BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2)
|
---|
| 190 | {
|
---|
| 191 | rectOS2->yBottom = rectWin32->bottom;
|
---|
| 192 | rectOS2->yTop = rectWin32->top;
|
---|
| 193 | rectOS2->xLeft = rectWin32->left;
|
---|
| 194 | rectOS2->xRight = rectWin32->right;
|
---|
| 195 |
|
---|
| 196 | return TRUE;
|
---|
| 197 | }
|
---|
| 198 | //******************************************************************************
|
---|
| 199 | //******************************************************************************
|
---|