| 1 | /* $Id: oslibgdi.cpp,v 1.12 2000-06-07 14:51:26 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 | //******************************************************************************
|
|---|
| 124 | BOOL mapWin32ToOS2RectClientToFrame(Win32BaseWindow *window, PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 125 | {
|
|---|
| 126 | int height;
|
|---|
| 127 | int xclientorg;
|
|---|
| 128 | int yclientorg;
|
|---|
| 129 |
|
|---|
| 130 | if(!window || !rectOS2 || !rectWin32) {
|
|---|
| 131 | DebugInt3();
|
|---|
| 132 | return FALSE;
|
|---|
| 133 | }
|
|---|
| 134 | height = window->getWindowHeight();
|
|---|
| 135 | xclientorg = window->getClientRectPtr()->left;
|
|---|
| 136 | yclientorg = window->getClientRectPtr()->top;
|
|---|
| 137 |
|
|---|
| 138 | rectOS2->yBottom = height - (rectWin32->bottom + yclientorg);
|
|---|
| 139 | rectOS2->yTop = height - (rectWin32->top + yclientorg);
|
|---|
| 140 | rectOS2->xLeft = rectWin32->left - xclientorg;
|
|---|
| 141 | rectOS2->xRight = rectWin32->right - xclientorg;
|
|---|
| 142 |
|
|---|
| 143 | return TRUE;
|
|---|
| 144 | }
|
|---|
| 145 | //******************************************************************************
|
|---|
| 146 | //******************************************************************************
|
|---|
| 147 | BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32)
|
|---|
| 148 | {
|
|---|
| 149 | rectWin32->bottom = rectOS2->yBottom;
|
|---|
| 150 | rectWin32->top = rectOS2->yTop;
|
|---|
| 151 | rectWin32->left = rectOS2->xLeft;
|
|---|
| 152 | rectWin32->right = rectOS2->xRight;
|
|---|
| 153 |
|
|---|
| 154 | return TRUE;
|
|---|
| 155 | }
|
|---|
| 156 | //******************************************************************************
|
|---|
| 157 | //******************************************************************************
|
|---|
| 158 | BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2)
|
|---|
| 159 | {
|
|---|
| 160 | rectOS2->yBottom = rectWin32->bottom;
|
|---|
| 161 | rectOS2->yTop = rectWin32->top;
|
|---|
| 162 | rectOS2->xLeft = rectWin32->left;
|
|---|
| 163 | rectOS2->xRight = rectWin32->right;
|
|---|
| 164 |
|
|---|
| 165 | return TRUE;
|
|---|
| 166 | }
|
|---|
| 167 | //******************************************************************************
|
|---|
| 168 | //******************************************************************************
|
|---|