home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.1 KB | 217 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: PRGrUtil.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef PRGRUTIL_H
- #include "PRGrUtil.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphx_PrivateGrUtil
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PrivMacGetPortTextStyle
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMacGetPortTextStyle(TextStyle& theTextStyle)
- {
- GrafPtr curPort = FW_QDGlobals.thePort;
- theTextStyle.tsFont = curPort->txFont;
- theTextStyle.tsFace = curPort->txFace;
- theTextStyle.tsSize = curPort->txSize;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PrivMacSetPortTextStyle
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMacSetPortTextStyle(const TextStyle& theTextStyle)
- {
- ::TextFont(theTextStyle.tsFont);
- ::TextFace(theTextStyle.tsFace);
- ::TextSize(theTextStyle.tsSize);
- }
- #endif
-
- #ifdef FW_BUILD_WIN
-
- //----------------------------------------------------------------------------------------
- // FW_WinPrivGetDisplayColorInfo
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivWinGetDisplayColorInfo(short& planeCount, short& bitsPixel)
- {
- static short gPlaneCount = -1;
- static short gBitsPixel = -1;
-
- if(gPlaneCount == -1)
- {
- HDC hDC = ::GetDC(NULL);
- gPlaneCount = (short) ::GetDeviceCaps(hDC, PLANES);
- gBitsPixel = (short) ::GetDeviceCaps(hDC, BITSPIXEL);
- ::ReleaseDC(NULL, hDC);
- }
-
- planeCount = gPlaneCount;
- bitsPixel = gBitsPixel;
- }
-
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PrivMacGetMacTransferMode
- //----------------------------------------------------------------------------------------
-
- static const short FW_gTransferModes[] =
- {
- patCopy, // FW_kCopy
- notPatCopy, // FW_kNotCopy
- patOr, // FW_kOr
- notPatOr, // FW_kNotOr
- patXor, // FW_kXOr
- notPatXor, // FW_kNotXOr
- patBic, // FW_kClear
- notPatBic, // FW_kNotClear
- hilitetransfermode, // FW_kHilite
- patCopy, // FW_kErase
- patCopy, // FW_kInvert
- hilitetransfermode, // FW_kSystemHilite
- };
-
- short FW_PrivMacGetMacTransferMode(FW_TransferModes transferMode)
- {
- if ((transferMode & 0xFFFF0000) == 0)
- return (short)transferMode; // Native transfer mode
- else
- {
- FW_ASSERT(transferMode <= FW_kPrivLastTransferMode);
- return FW_gTransferModes[transferMode & 0x0000FFFF];
- }
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_PrivWinConvertRasterOp
- //----------------------------------------------------------------------------------------
- static const DWORD FW_gWinRasterOps[] =
- {
- SRCCOPY, // FW_kCopy
- NOTSRCCOPY, // FW_kNotCopy
- SRCPAINT, // FW_kOr
- MERGEPAINT, // FW_kNotOr
- SRCINVERT, // FW_kXOr
- 0x00990066UL, // FW_kNotXOr
- SRCAND, // FW_kClear
- 0x00440328UL, // FW_kNotClear
- SRCINVERT, // FW_kHilite
- SRCCOPY, // FW_kErase
- SRCINVERT // FW_kInvert
- SRCINVERT, // FW_kSystemHilite
- };
-
- DWORD FW_PrivWinConvertRasterOp(FW_TransferModes transferMode)
- {
- if ((transferMode & 0xFFFF0000L) == 0)
- return (DWORD)transferMode; // Native Raster ops
- else
- {
- FW_ASSERT(transferMode <= FW_kLastTransferMode);
- return FW_gWinRasterOps[transferMode & 0x0000FFFFL];
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivWinROP2
- //----------------------------------------------------------------------------------------
-
- // Don't forget than on windows black and white are inverted.
- // That's why it seems that the xxNOTxx is at the wrong place
- static const int FW_gTransferModes[] =
- {
- R2_COPYPEN, // FW_kCopy
- R2_NOTCOPYPEN, // FW_kNotCopy
- R2_NOTMERGEPEN, // FW_kOr
- R2_MERGEPEN, // FW_kNotOr
- R2_NOTXORPEN, // FW_kXOr
- R2_XORPEN, // FW_kNotXOr
- R2_NOTMASKPEN, // FW_kClear
- R2_MASKPEN, // FW_kNotClear
- R2_NOTXORPEN, // FW_kHilite
- R2_COPYPEN, // FW_kErase
- R2_NOTXORPEN // FW_kInvert
- R2_NOTXORPEN, // FW_kSystemHilite
- };
-
- int FW_PrivWinROP2(FW_TransferModes transferMode)
- {
- if ((transferMode & 0xFFFF0000L) == 0)
- return (int)transferMode; // Native transfer mode
- else
- {
- FW_ASSERT(transferMode <= FW_kLastTransferMode);
- return FW_gTransferModes[transferMode & 0x0000FFFFL];
- }
- }
-
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_PrivCalcArcPoints
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivCalcArcPoints(const FW_CPlatformRect& rect,
- short angle,
- FW_CPlatformPoint& arcPoint)
- {
- FW_Fixed fxRad = (FW_IntToFixed(angle) * FW_kFixedPI) / FW_IntToFixed(180);
-
- FW_PlatformCoordinate middleX = ((long) rect.right + rect.left) / 2;
- FW_PlatformCoordinate middleY = ((long) rect.bottom + rect.top) / 2;
-
- FW_Fixed halfX = FW_IntToFixed(((long) rect.right - rect.left) / 2);
- FW_Fixed halfY = FW_IntToFixed(((long) rect.bottom - rect.top) / 2);
-
- short shortX = FW_FixedToInt(halfX * FW_Sin(fxRad));
- short shortY = -FW_FixedToInt(halfY * FW_Cos(fxRad));
-
- arcPoint.Set(shortX + middleX, shortY + middleY);
- }
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PrivMacSetStdColors
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PrivMacSetStdColors()
- {
- RGBColor macBlackColor = { 0x0000, 0x0000, 0x0000 };
- ::RGBForeColor(&macBlackColor);
- RGBColor macWhiteColor = { 0xFFFF, 0xFFFF, 0xFFFF };
- ::RGBBackColor(&macWhiteColor);
- }
- #endif