| 1 | /* $Id: oslibgdi.cpp,v 1.13 2000-06-08 18:10:10 sandervl Exp $ */
|
|---|
| 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>
|
|---|
| 18 | #include <winconst.h>
|
|---|
| 19 | #include <oslibgdi.h>
|
|---|
| 20 | #include <oslibwin.h>
|
|---|
| 21 | #include "win32wbase.h"
|
|---|
| 22 |
|
|---|
| 23 | #define DBG_LOCALLOG DBG_oslibgdi
|
|---|
| 24 | #include "dbglocal.h"
|
|---|
| 25 |
|
|---|
| 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()
|
|---|
| 32 | mapY() //only reverses y
|
|---|
| 33 | mapOS2ToWin32Y() //reverse y + subtract parent client offset
|
|---|
| 34 | mapOS2ToWin32X() //subtract parent client offset
|
|---|
| 35 |
|
|---|
| 36 | mapWin32ToOS2Y() //reverse y + add parent client offset
|
|---|
| 37 | mapWin32ToOS2Y() //add parent client offset
|
|---|
| 38 |
|
|---|
| 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 | //******************************************************************************
|
|---|
| 94 | BOOL mapOS2ToWin32Rect(int height, PRECTLOS2 rectOS2, PRECT rectWin32)
|
|---|
| 95 | {
|
|---|
| 96 | if(!rectOS2 || !rectWin32) {
|
|---|
| 97 | DebugInt3();
|
|---|
| 98 | return FALSE;
|
|---|
| 99 | }
|
|---|
| 100 | rectWin32->bottom = height-rectOS2->yBottom;
|
|---|
| 101 | rectWin32->top = height-rectOS2->yTop;
|
|---|
| 102 | rectWin32->left = rectOS2->xLeft;
|
|---|
| 103 | rectWin32->right = rectOS2->xRight;
|
|---|
| 104 |
|
|---|
| 105 | return TRUE;
|
|---|
| 106 | }
|
|---|
| 107 | //******************************************************************************
|
|---|
| 108 | //******************************************************************************
|
|---|
| 109 | BOOL mapWin32ToOS2Rect(int height, PRECT rectWin32, PRECTLOS2 rectOS2)
|
|---|
| 110 | {
|
|---|
| 111 | if(!rectOS2 || !rectWin32) {
|
|---|
| 112 | DebugInt3();
|
|---|
| 113 | return FALSE;
|
|---|
| 114 | }
|
|---|
| 115 | rectOS2->yBottom = height-rectWin32->bottom;
|
|---|
| 116 | rectOS2->yTop = height-rectWin32->top;
|
|---|
| 117 | rectOS2->xLeft = rectWin32->left;
|
|---|
| 118 | rectOS2->xRight = rectWin32->right;
|
|---|
| 119 |
|
|---|
| 120 | return TRUE;
|
|---|
| 121 | }
|
|---|
| 122 | //******************************************************************************
|
|---|
| 123 | //Win32 rectangle in client coordinates (relative to upper left corner of client window)
|
|---|
| 124 | //Convert to frame coordinates (relative to lower left corner of window)
|
|---|
| 125 | //******************************************************************************
|
|---|
| 126 | BOOL mapWin32ToOS2RectClientToFrame(Win32BaseWindow *window, PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 127 | {
|
|---|
| 128 | int height;
|
|---|
| 129 | int xclientorg;
|
|---|
| 130 | int yclientorg;
|
|---|
| 131 |
|
|---|
| 132 | if(!window || !rectOS2 || !rectWin32) {
|
|---|
| 133 | DebugInt3();
|
|---|
| 134 | return FALSE;
|
|---|
| 135 | }
|
|---|
| 136 | height = window->getWindowHeight();
|
|---|
| 137 | xclientorg = window->getClientRectPtr()->left;
|
|---|
| 138 | yclientorg = window->getClientRectPtr()->top;
|
|---|
| 139 |
|
|---|
| 140 | rectOS2->yBottom = height - (rectWin32->bottom + yclientorg);
|
|---|
| 141 | rectOS2->yTop = height - (rectWin32->top + yclientorg);
|
|---|
| 142 | rectOS2->xLeft = rectWin32->left + xclientorg;
|
|---|
| 143 | rectOS2->xRight = rectWin32->right + xclientorg;
|
|---|
| 144 |
|
|---|
| 145 | return TRUE;
|
|---|
| 146 | }
|
|---|
| 147 | //******************************************************************************
|
|---|
| 148 | //OS/2 rectangle in frame coordinates (relative to lower left corner of window)
|
|---|
| 149 | //Convert to client coordinates (relative to upper left corner of client window)
|
|---|
| 150 | //Note: win32 rectangle can be bigger than client area!
|
|---|
| 151 | //******************************************************************************
|
|---|
| 152 | BOOL mapOS2ToWin32RectFrameToClient(Win32BaseWindow *window, PRECTLOS2 rectOS2,
|
|---|
| 153 | PRECT rectWin32)
|
|---|
| 154 | {
|
|---|
| 155 | int height;
|
|---|
| 156 | int xclientorg;
|
|---|
| 157 | int yclientorg;
|
|---|
| 158 |
|
|---|
| 159 | if(!window || !rectOS2 || !rectWin32) {
|
|---|
| 160 | DebugInt3();
|
|---|
| 161 | return FALSE;
|
|---|
| 162 | }
|
|---|
| 163 | height = window->getWindowHeight();
|
|---|
| 164 | xclientorg = window->getClientRectPtr()->left;
|
|---|
| 165 | yclientorg = window->getClientRectPtr()->top;
|
|---|
| 166 |
|
|---|
| 167 | rectWin32->bottom = height - (rectOS2->yBottom + yclientorg);
|
|---|
| 168 | rectWin32->top = height - (rectOS2->yTop + yclientorg);
|
|---|
| 169 | rectWin32->left = rectOS2->xLeft - xclientorg;
|
|---|
| 170 | rectWin32->right = rectOS2->xRight - xclientorg;
|
|---|
| 171 |
|
|---|
| 172 | return TRUE;
|
|---|
| 173 | }
|
|---|
| 174 | //******************************************************************************
|
|---|
| 175 | //******************************************************************************
|
|---|
| 176 | BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32)
|
|---|
| 177 | {
|
|---|
| 178 | rectWin32->bottom = rectOS2->yBottom;
|
|---|
| 179 | rectWin32->top = rectOS2->yTop;
|
|---|
| 180 | rectWin32->left = rectOS2->xLeft;
|
|---|
| 181 | rectWin32->right = rectOS2->xRight;
|
|---|
| 182 |
|
|---|
| 183 | return TRUE;
|
|---|
| 184 | }
|
|---|
| 185 | //******************************************************************************
|
|---|
| 186 | //******************************************************************************
|
|---|
| 187 | BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 188 | {
|
|---|
| 189 | rectOS2->yBottom = rectWin32->bottom;
|
|---|
| 190 | rectOS2->yTop = rectWin32->top;
|
|---|
| 191 | rectOS2->xLeft = rectWin32->left;
|
|---|
| 192 | rectOS2->xRight = rectWin32->right;
|
|---|
| 193 |
|
|---|
| 194 | return TRUE;
|
|---|
| 195 | }
|
|---|
| 196 | //******************************************************************************
|
|---|
| 197 | //******************************************************************************
|
|---|