Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

oslibgdi.cpp

Go to the documentation of this file.
00001 /* $Id: oslibgdi.cpp,v 1.14 2001/05/11 08:39:42 sandervl Exp $ */
00002 /*
00003  * Window GDI wrapper functions for OS/2
00004  *
00005  *
00006  * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
00007  * Copyright 1999 Christoph Bratschi (cbratschi@datacomm.ch)
00008  *
00009  * Project Odin Software License can be found in LICENSE.TXT
00010  *
00011  */
00012 #define  INCL_WIN
00013 #define  INCL_PM
00014 #include <os2wrap.h>
00015 #include <stdlib.h>
00016 #include <string.h>
00017 #include <misc.h>
00018 #include <winconst.h>
00019 #include <oslibgdi.h>
00020 #include <oslibwin.h>
00021 #include "win32wbase.h"
00022 
00023 #define DBG_LOCALLOG    DBG_oslibgdi
00024 #include "dbglocal.h"
00025 
00026 /*
00027 First letter is lower case to avoid conflicts with Win32 API names
00028 All transformations are for screen or client windows, for frame windows use OS/2 API's
00029 
00030 Single y mapping:
00031  mapScreenY()
00032  mapY()                 //only reverses y
00033  mapOS2ToWin32Y()       //reverse y + subtract parent client offset
00034  mapOS2ToWin32X()       //subtract parent client offset
00035 
00036  mapWin32ToOS2Y()       //reverse y + add parent client offset
00037  mapWin32ToOS2Y()       //add parent client offset
00038 
00039 Single point mapping:
00040  mapScreenPoint()
00041  mapOS2ToWin32Point()
00042  mapWin32ToOS2Point()
00043  mapWin32Point()
00044 
00045 Single rect mapping:
00046  mapOS2ToWin32ScreenRect()
00047  mapWin32ToOS2ScreenRect()
00048  mapOS2ToWin32Rect()
00049  mapWin32ToOS2Rect()
00050  mapWin32Rect()
00051 
00052 Rect transformation:
00053  copyOS2ToWin32Rect()
00054  copyWin32ToOS2Rect()
00055 */
00056 
00057 //******************************************************************************
00058 // To translation between OS/2 <-> Win32
00059 //******************************************************************************
00060 INT mapScreenY(INT screenPosY)
00061 {
00062   return ScreenHeight-1-screenPosY;
00063 }
00064 //******************************************************************************
00065 // To translation between OS/2 <-> Win32
00066 //******************************************************************************
00067 INT mapScreenY(INT screenH,INT screenPosY)
00068 {
00069   return screenH-1-screenPosY;
00070 }
00071 //******************************************************************************
00072 // To translation between OS/2 <-> Win32
00073 //******************************************************************************
00074 BOOL mapScreenPoint(OSLIBPOINT *screenPt)
00075 {
00076   if(!screenPt) return FALSE;
00077   screenPt->y = ScreenHeight-1-screenPt->y;
00078 
00079   return TRUE;
00080 }
00081 //******************************************************************************
00082 // To translation between OS/2 <-> Win32
00083 //******************************************************************************
00084 BOOL mapScreenPoint(INT screenH,OSLIBPOINT *screenPt)
00085 {
00086   if (!screenPt) return FALSE;
00087   screenPt->y = screenH-1-screenPt->y;
00088 
00089   return TRUE;
00090 }
00091 //******************************************************************************
00092 // To translation between OS/2 <-> Win32
00093 //******************************************************************************
00094 BOOL mapOS2ToWin32Rect(int height, PRECTLOS2 rectOS2, PRECT rectWin32)
00095 {
00096   if(!rectOS2 || !rectWin32) {
00097         DebugInt3();
00098         return FALSE;
00099   }
00100   rectWin32->bottom = height-rectOS2->yBottom;
00101   rectWin32->top    = height-rectOS2->yTop;
00102   rectWin32->left   = rectOS2->xLeft;
00103   rectWin32->right  = rectOS2->xRight;
00104 
00105   return TRUE;
00106 }
00107 //******************************************************************************
00108 //******************************************************************************
00109 BOOL mapWin32ToOS2Rect(int height, PRECT rectWin32, PRECTLOS2 rectOS2)
00110 {
00111   if(!rectOS2 || !rectWin32) {
00112         DebugInt3();
00113         return FALSE;
00114   }
00115   rectOS2->yBottom = height-rectWin32->bottom;
00116   rectOS2->yTop    = height-rectWin32->top;
00117   rectOS2->xLeft   = rectWin32->left;
00118   rectOS2->xRight  = rectWin32->right;
00119 
00120   return TRUE;
00121 }
00122 #ifndef CLIENTFRAME
00123 //******************************************************************************
00124 //Win32 rectangle in client coordinates (relative to upper left corner of client window)
00125 //Convert to frame coordinates (relative to lower left corner of window)
00126 //******************************************************************************
00127 BOOL mapWin32ToOS2RectClientToFrame(Win32BaseWindow *window, PRECT rectWin32,PRECTLOS2 rectOS2)
00128 {
00129  int height;
00130  int xclientorg;
00131  int yclientorg;
00132 
00133   if(!window || !rectOS2 || !rectWin32) {
00134         DebugInt3();
00135         return FALSE;
00136   }
00137   height     = window->getWindowHeight();
00138   xclientorg = window->getClientRectPtr()->left;
00139   yclientorg = window->getClientRectPtr()->top;
00140 
00141   rectOS2->yBottom = height - (rectWin32->bottom + yclientorg);
00142   rectOS2->yTop    = height - (rectWin32->top + yclientorg);
00143   rectOS2->xLeft   = rectWin32->left  + xclientorg;
00144   rectOS2->xRight  = rectWin32->right + xclientorg;
00145 
00146   return TRUE;
00147 }
00148 //******************************************************************************
00149 //OS/2 rectangle in frame coordinates (relative to lower left corner of window)
00150 //Convert to client coordinates (relative to upper left corner of client window)
00151 //Note: win32 rectangle can be bigger than client area!
00152 //******************************************************************************
00153 BOOL mapOS2ToWin32RectFrameToClient(Win32BaseWindow *window, PRECTLOS2 rectOS2, 
00154                                     PRECT rectWin32)
00155 {
00156  int height;
00157  int xclientorg;
00158  int yclientorg;
00159 
00160   if(!window || !rectOS2 || !rectWin32) {
00161         DebugInt3();
00162         return FALSE;
00163   }
00164   height     = window->getWindowHeight();
00165   xclientorg = window->getClientRectPtr()->left;
00166   yclientorg = window->getClientRectPtr()->top;
00167 
00168   rectWin32->bottom = height - (rectOS2->yBottom + yclientorg);
00169   rectWin32->top    = height - (rectOS2->yTop + yclientorg);
00170   rectWin32->left   = rectOS2->xLeft  - xclientorg;
00171   rectWin32->right  = rectOS2->xRight - xclientorg;
00172 
00173   return TRUE;
00174 }
00175 #endif //CLIENTFRAME
00176 //******************************************************************************
00177 //******************************************************************************
00178 BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32)
00179 {
00180   rectWin32->bottom = rectOS2->yBottom;
00181   rectWin32->top    = rectOS2->yTop;
00182   rectWin32->left   = rectOS2->xLeft;
00183   rectWin32->right  = rectOS2->xRight;
00184 
00185   return TRUE;
00186 }
00187 //******************************************************************************
00188 //******************************************************************************
00189 BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2)
00190 {
00191   rectOS2->yBottom = rectWin32->bottom;
00192   rectOS2->yTop    = rectWin32->top;
00193   rectOS2->xLeft   = rectWin32->left;
00194   rectOS2->xRight  = rectWin32->right;
00195 
00196   return TRUE;
00197 }
00198 //******************************************************************************
00199 //******************************************************************************

Generated on Wed Jan 23 23:17:38 2002 for ODIN-user32 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001