2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: salgdi.cxx,v $
|
|
|
|
*
|
2001-01-03 21:05:32 +00:00
|
|
|
* $Revision: 1.38 $
|
|
|
|
* last change: $Author: bmahbod $ $Date: 2001-01-03 22:05:32 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#define _SV_SALGDI_CXX
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
#ifndef _SV_SALBMP_HXX
|
|
|
|
#include <salbmp.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _SV_SALDATA_HXX
|
|
|
|
#include <saldata.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_SALGDI_HXX
|
|
|
|
#include <salgdi.hxx>
|
|
|
|
#endif
|
2000-11-19 01:37:03 +00:00
|
|
|
#ifndef _SV_OUTFONT_HXX
|
|
|
|
#include <outfont.hxx>
|
|
|
|
#endif
|
2000-11-02 05:43:26 +00:00
|
|
|
#ifndef _SV_VCLGRAPHICS_H
|
|
|
|
#include <VCLGraphics.h>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-24 02:38:20 +00:00
|
|
|
static inline unsigned long AbsoluteValue ( const long nValue )
|
|
|
|
{
|
|
|
|
unsigned long nAbsValue = 0;
|
|
|
|
|
|
|
|
if ( nValue < 0 )
|
|
|
|
{
|
|
|
|
nAbsValue = -nValue;
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nAbsValue = nValue;
|
|
|
|
} // else
|
|
|
|
|
|
|
|
return nAbsValue;
|
|
|
|
} // AbsoluteValue
|
|
|
|
|
2000-12-18 23:49:20 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
static void SetWhiteBackColor()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-06 00:20:05 +00:00
|
|
|
RGBColor aWhiteBackColor;
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
// White color
|
2000-12-01 02:20:53 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
aWhiteBackColor.red = 0xffff;
|
|
|
|
aWhiteBackColor.green = 0xffff;
|
|
|
|
aWhiteBackColor.blue = 0xffff;
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
// Set background color to white
|
2000-12-05 00:57:55 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
RGBBackColor( &aWhiteBackColor );
|
|
|
|
} // SetWhiteBackColor
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-12-05 00:57:55 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
static void SetBlackForeColor()
|
|
|
|
{
|
|
|
|
RGBColor aBlackForeColor;
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
// Black color
|
2000-12-05 00:57:55 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
aBlackForeColor.red = 0x0000;
|
|
|
|
aBlackForeColor.green = 0x0000;
|
|
|
|
aBlackForeColor.blue = 0x0000;
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
// Set foreground color to black
|
2000-12-05 00:57:55 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
RGBForeColor( &aBlackForeColor );
|
|
|
|
} // SetBlackForeColor
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
// =======================================================================
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-12-18 23:49:20 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-07 18:33:34 +00:00
|
|
|
static void CheckRectBounds ( Rect *rSrcRect,
|
|
|
|
Rect *rDstRect,
|
|
|
|
const Rect *rPortBoundsRect
|
|
|
|
)
|
2000-12-05 00:57:55 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
if ( rSrcRect->top < rPortBoundsRect->top )
|
|
|
|
{
|
|
|
|
rDstRect->top += (rPortBoundsRect->top - rSrcRect->top);
|
|
|
|
rSrcRect->top = rPortBoundsRect->top;
|
|
|
|
} // if
|
|
|
|
|
|
|
|
if ( rSrcRect->left < rPortBoundsRect->left )
|
|
|
|
{
|
|
|
|
rDstRect->left += (rPortBoundsRect->left - rSrcRect->left);
|
|
|
|
rSrcRect->left = rPortBoundsRect->left;
|
|
|
|
} // if
|
|
|
|
|
|
|
|
if ( rSrcRect->bottom > rPortBoundsRect->bottom )
|
|
|
|
{
|
|
|
|
|
|
|
|
rDstRect->bottom += (rPortBoundsRect->bottom - rSrcRect->bottom);
|
|
|
|
rSrcRect->bottom = rPortBoundsRect->bottom;
|
|
|
|
} // if
|
|
|
|
|
|
|
|
if ( rSrcRect->right > rPortBoundsRect->right )
|
|
|
|
{
|
|
|
|
rDstRect->right += (rPortBoundsRect->right - rSrcRect->right);
|
|
|
|
rSrcRect->right = rPortBoundsRect->right;
|
|
|
|
} // if
|
2000-12-05 19:59:26 +00:00
|
|
|
} // CheckRectBounds
|
2000-12-05 00:57:55 +00:00
|
|
|
|
2000-12-18 23:49:20 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
static inline void GetQDRect ( const long nX,
|
|
|
|
const long nY,
|
|
|
|
const long nWidth,
|
|
|
|
const long nHeight,
|
|
|
|
Rect *rRect
|
|
|
|
)
|
|
|
|
{
|
|
|
|
SetRect( rRect, nX, nY, nX + nWidth, nY + nHeight );
|
|
|
|
} // GetQDRect
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static inline void SalTwoRect2SQDDstRect ( const SalTwoRect *pPosAry,
|
|
|
|
Rect *rDstRect
|
|
|
|
)
|
2000-12-18 23:49:20 +00:00
|
|
|
{
|
|
|
|
SetRect( rDstRect,
|
|
|
|
pPosAry->mnDestX,
|
|
|
|
pPosAry->mnDestY,
|
|
|
|
pPosAry->mnDestX + pPosAry->mnDestWidth,
|
|
|
|
pPosAry->mnDestY + pPosAry->mnDestHeight
|
|
|
|
);
|
|
|
|
} // GetSalSourceRect
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
static inline void SalTwoRect2SQDSrcRect ( const SalTwoRect *pPosAry,
|
|
|
|
Rect *rSrcRect
|
|
|
|
)
|
2000-12-18 23:49:20 +00:00
|
|
|
{
|
|
|
|
SetRect( rSrcRect,
|
|
|
|
pPosAry->mnSrcX,
|
|
|
|
pPosAry->mnSrcY,
|
|
|
|
pPosAry->mnSrcX + pPosAry->mnSrcWidth,
|
|
|
|
pPosAry->mnSrcY + pPosAry->mnSrcHeight
|
|
|
|
);
|
2000-12-21 18:37:41 +00:00
|
|
|
} // SalTwoRect2SQDSrcRect
|
2000-12-18 23:49:20 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static inline short SelectCopyMode ( const SalGraphicsDataPtr pSalGraphicsData )
|
|
|
|
{
|
|
|
|
short nCopyMode = 0;
|
|
|
|
|
|
|
|
if ( pSalGraphicsData->mnPenMode == patCopy )
|
|
|
|
{
|
|
|
|
nCopyMode = srcCopy;
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nCopyMode = srcXor;
|
|
|
|
} // else
|
|
|
|
|
|
|
|
return nCopyMode;
|
|
|
|
} // SelectCopyMode
|
|
|
|
|
2000-12-05 19:59:26 +00:00
|
|
|
// =======================================================================
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-05 19:59:26 +00:00
|
|
|
// =======================================================================
|
2000-12-11 19:39:31 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
static RgnHandle GetPolygonRgn ( const unsigned long nPolyCount,
|
|
|
|
const unsigned long *pPoints,
|
|
|
|
PCONSTSALPOINT *ppPtAry,
|
|
|
|
OSStatus *rQDStatus
|
|
|
|
)
|
|
|
|
{
|
|
|
|
RgnHandle hSrcRgnA = NULL;
|
|
|
|
|
|
|
|
hSrcRgnA = NewRgn();
|
|
|
|
|
|
|
|
if ( hSrcRgnA != NULL )
|
|
|
|
{
|
|
|
|
RgnHandle hSrcRgnB = NULL;
|
|
|
|
|
|
|
|
hSrcRgnB = NewRgn();
|
|
|
|
|
|
|
|
if ( hSrcRgnB != NULL )
|
|
|
|
{
|
|
|
|
unsigned short nPolyEdgeIndex = 0;
|
|
|
|
unsigned short nPolyIndex = 0;
|
|
|
|
unsigned short nPolyEdges = 0;
|
|
|
|
|
|
|
|
for ( nPolyIndex = 0;
|
|
|
|
nPolyIndex < nPolyCount;
|
|
|
|
nPolyIndex++
|
|
|
|
)
|
|
|
|
{
|
|
|
|
const SalPoint *pPtAry = ppPtAry[nPolyIndex];
|
|
|
|
|
|
|
|
nPolyEdges = pPoints[nPolyIndex];
|
|
|
|
|
|
|
|
// Begin region construction
|
|
|
|
|
|
|
|
OpenRgn();
|
|
|
|
|
|
|
|
// Begin polygon construction
|
|
|
|
|
|
|
|
MoveTo ( pPtAry[0].mnX, pPtAry[0].mnY );
|
|
|
|
|
|
|
|
for ( nPolyEdgeIndex = 1;
|
|
|
|
nPolyEdgeIndex < nPolyEdges;
|
|
|
|
nPolyEdgeIndex++
|
|
|
|
)
|
|
|
|
{
|
|
|
|
MacLineTo( pPtAry[nPolyEdgeIndex].mnX,
|
|
|
|
pPtAry[nPolyEdgeIndex].mnY
|
|
|
|
);
|
|
|
|
} // for
|
|
|
|
|
|
|
|
MacLineTo( pPtAry[0].mnX, pPtAry[0].mnY );
|
|
|
|
|
|
|
|
// End polygon construction
|
|
|
|
|
|
|
|
CloseRgn( hSrcRgnB );
|
|
|
|
|
|
|
|
// End region construction
|
|
|
|
|
|
|
|
*rQDStatus = QDErr();
|
|
|
|
|
|
|
|
if ( *rQDStatus == noErr )
|
|
|
|
{
|
|
|
|
if ( nPolyIndex == 0 )
|
|
|
|
{
|
|
|
|
MacCopyRgn( hSrcRgnB, hSrcRgnA );
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MacXorRgn( hSrcRgnA, hSrcRgnB, hSrcRgnA );
|
|
|
|
} // else
|
|
|
|
} // if
|
|
|
|
} // for
|
|
|
|
|
|
|
|
DisposeRgn( hSrcRgnB );
|
|
|
|
|
|
|
|
*rQDStatus = QDErr();
|
|
|
|
|
|
|
|
if ( *rQDStatus != noErr )
|
|
|
|
{
|
|
|
|
DisposeRgn( hSrcRgnA );
|
|
|
|
|
|
|
|
hSrcRgnA = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hSrcRgnB = NULL;
|
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
|
|
|
|
return hSrcRgnA;
|
|
|
|
} // GetPolygonRgn
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-24 02:38:20 +00:00
|
|
|
static unsigned long Compress32BitRGBColor ( const RGBColor *pRGBColor )
|
|
|
|
{
|
|
|
|
unsigned long nCTableIndex = 0;
|
|
|
|
|
|
|
|
nCTableIndex = ( pRGBColor->red >> kOneByte ) << kTwoBytes;
|
|
|
|
nCTableIndex |= ( pRGBColor->green >> kOneByte ) << kOneByte;
|
|
|
|
nCTableIndex |= pRGBColor->blue >> kOneByte;
|
|
|
|
|
|
|
|
return nCTableIndex;
|
|
|
|
} // Compress32BitRGBColor
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static unsigned long Compress16BitRGBColor ( const RGBColor *pRGBColor )
|
|
|
|
{
|
|
|
|
unsigned long nCTableIndex = 0;
|
|
|
|
|
|
|
|
nCTableIndex = ( pRGBColor->red >> kElevenBits ) << kTenBits;
|
|
|
|
nCTableIndex |= ( pRGBColor->green >> kElevenBits ) << kFiveBits;
|
|
|
|
nCTableIndex |= pRGBColor->blue >> kElevenBits;
|
|
|
|
|
|
|
|
return nCTableIndex;
|
|
|
|
} // Compress16BitRGBColor
|
2000-12-11 23:55:18 +00:00
|
|
|
|
2000-12-24 02:38:20 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-12-11 23:55:18 +00:00
|
|
|
|
|
|
|
static void CompressRGBColor ( const PixMapPtr pPixMap,
|
2000-12-24 02:38:20 +00:00
|
|
|
const RGBColor *pRGBColor,
|
|
|
|
SalColor *rSalColor
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if ( pPixMap->pixelSize == k32BitScreenDepth )
|
|
|
|
{
|
|
|
|
*rSalColor = Compress32BitRGBColor( pRGBColor );
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*rSalColor = Compress16BitRGBColor( pRGBColor );
|
|
|
|
} // else
|
|
|
|
} // CompressRGBColor
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static unsigned long RGBDistance ( const RGBColor *pRGBColor1,
|
|
|
|
const RGBColor *pRGBColor2
|
|
|
|
)
|
|
|
|
{
|
|
|
|
unsigned long nRGBDist = 0;
|
|
|
|
long nDeltaRed = 0;
|
|
|
|
long nDeltaGreen = 0;
|
|
|
|
long nDeltaBlue = 0;
|
|
|
|
|
|
|
|
nDeltaRed = (long)pRGBColor2->red - (long)pRGBColor1->red;
|
|
|
|
nDeltaGreen = (long)pRGBColor2->green - (long)pRGBColor1->green;
|
|
|
|
nDeltaBlue = (long)pRGBColor2->blue - (long)pRGBColor1->blue;
|
|
|
|
|
|
|
|
nRGBDist = AbsoluteValue(nDeltaRed)
|
|
|
|
+ AbsoluteValue(nDeltaGreen)
|
|
|
|
+ AbsoluteValue(nDeltaBlue);
|
2000-12-11 23:55:18 +00:00
|
|
|
|
2000-12-24 02:38:20 +00:00
|
|
|
return nRGBDist;
|
|
|
|
} // RGBDistance
|
2000-12-11 23:55:18 +00:00
|
|
|
|
2000-12-24 02:38:20 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static BOOL QDColorsMatch ( const RGBColor *pRGBColor1,
|
|
|
|
const RGBColor *pRGBColor2
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if ( ( pRGBColor2->red == pRGBColor1->red )
|
|
|
|
&& ( pRGBColor2->green == pRGBColor1->green )
|
|
|
|
&& ( pRGBColor2->blue == pRGBColor1->blue )
|
2000-12-11 23:55:18 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
return TRUE;
|
2000-12-12 00:23:12 +00:00
|
|
|
} // if
|
2000-12-11 23:55:18 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
2000-12-24 02:38:20 +00:00
|
|
|
} // else
|
|
|
|
} // QDColorsMatch
|
2000-12-11 23:55:18 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void GetBestSalColor ( const CTabPtr pCTable,
|
2000-12-24 02:38:20 +00:00
|
|
|
const RGBColor *pRGBColor,
|
|
|
|
unsigned long *pBestSalColor
|
|
|
|
)
|
|
|
|
{
|
|
|
|
unsigned short nCTableSize = 0;
|
|
|
|
unsigned long nCTableIndex = 0;
|
|
|
|
unsigned long nRGBNewDistance = 0;
|
|
|
|
unsigned long nRGBMinDistance = UID_MAX;
|
|
|
|
RGBColor *pRGBNextColor = NULL;
|
|
|
|
BOOL bRGBColorsMatch = FALSE;
|
|
|
|
|
|
|
|
*pBestSalColor = 0;
|
|
|
|
|
|
|
|
nCTableSize = pCTable->ctSize;
|
|
|
|
|
|
|
|
while ( ( nCTableIndex < nCTableSize ) && ( bRGBColorsMatch == FALSE ) )
|
|
|
|
{
|
|
|
|
pRGBNextColor = &pCTable->ctTable[nCTableIndex].rgb;
|
|
|
|
|
2000-12-11 23:55:18 +00:00
|
|
|
bRGBColorsMatch = QDColorsMatch( pRGBColor, pRGBNextColor );
|
2000-12-24 02:38:20 +00:00
|
|
|
|
|
|
|
if ( bRGBColorsMatch == TRUE )
|
|
|
|
{
|
|
|
|
*pBestSalColor= nCTableIndex;
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nRGBNewDistance = RGBDistance( pRGBColor, pRGBNextColor );
|
|
|
|
|
|
|
|
if ( nRGBNewDistance < nRGBMinDistance )
|
|
|
|
{
|
|
|
|
nRGBMinDistance = nRGBNewDistance;
|
|
|
|
*pBestSalColor = nCTableIndex;
|
|
|
|
} // if
|
|
|
|
|
|
|
|
nCTableIndex++;
|
|
|
|
} //else
|
|
|
|
} // while
|
|
|
|
} // GetBestSalColor
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2000-12-11 23:55:18 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
static void GetCTableIndex ( const PixMapPtr pPixMap,
|
2000-12-24 02:38:20 +00:00
|
|
|
const RGBColor *pRGBColor,
|
|
|
|
SalColor *rSalColor
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CTabPtr pCTable = NULL;
|
|
|
|
|
|
|
|
pCTable = *(*pPixMap).pmTable;
|
|
|
|
|
2000-12-11 23:55:18 +00:00
|
|
|
if ( pCTable != NULL )
|
2000-12-24 02:38:20 +00:00
|
|
|
{
|
|
|
|
GetBestSalColor( pCTable, pRGBColor, rSalColor );
|
|
|
|
|
|
|
|
if ( *rSalColor > pCTable->ctSize )
|
|
|
|
{
|
|
|
|
*rSalColor = 255;
|
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
} // GetCTableIndex
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2000-12-12 00:23:12 +00:00
|
|
|
//
|
|
|
|
// Convert RGB color to Sal color.
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------
|
2000-12-11 23:55:18 +00:00
|
|
|
|
2000-12-24 02:38:20 +00:00
|
|
|
static SalColor RGBColor2SALColor ( const RGBColor *pRGBColor )
|
|
|
|
{
|
|
|
|
GDPtr pGDevice = NULL;
|
|
|
|
SalColor nSalColor = 0;
|
|
|
|
|
|
|
|
pGDevice = *GetGDevice ( );
|
|
|
|
|
2000-12-11 23:55:18 +00:00
|
|
|
if ( pGDevice != NULL )
|
|
|
|
{
|
|
|
|
PixMapPtr pPixMap = NULL;
|
|
|
|
|
|
|
|
pPixMap = *(*pGDevice).gdPMap;
|
|
|
|
|
|
|
|
if ( pPixMap != NULL )
|
2000-12-24 02:38:20 +00:00
|
|
|
{
|
|
|
|
if ( pGDevice->gdType == directType )
|
|
|
|
{
|
|
|
|
CompressRGBColor( pPixMap, pRGBColor, &nSalColor );
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetCTableIndex( pPixMap, pRGBColor, &nSalColor );
|
|
|
|
} // else
|
2000-12-11 23:55:18 +00:00
|
|
|
} // if
|
2000-12-24 02:38:20 +00:00
|
|
|
} // if
|
|
|
|
|
|
|
|
return nSalColor;
|
|
|
|
} // RGBColor2SALColor
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
static unsigned short SalColorTo32BitDeviceColor ( SalColor *rSalColor )
|
|
|
|
{
|
|
|
|
unsigned short nDirectColor = 0;
|
|
|
|
unsigned short nUpperByte = 0;
|
|
|
|
unsigned short nLowerByte = 0;
|
|
|
|
|
|
|
|
nLowerByte = *rSalColor & kByteMask;
|
|
|
|
nUpperByte = nLowerByte << kOneByte;
|
|
|
|
nDirectColor = nUpperByte | nLowerByte;
|
|
|
|
*rSalColor >>= kOneByte;
|
|
|
|
|
|
|
|
return nDirectColor;
|
|
|
|
} // SalColorTo32BitDeviceColor
|
2000-12-11 23:55:18 +00:00
|
|
|
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-05 19:59:26 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-24 02:38:20 +00:00
|
|
|
static void SalColor2DirectColor ( const SalColor nSalColor,
|
|
|
|
RGBColor *rRGBColor
|
|
|
|
)
|
|
|
|
{
|
2000-12-14 18:32:45 +00:00
|
|
|
SalColor nIndexedColor = nSalColor;
|
2000-12-24 02:38:20 +00:00
|
|
|
|
|
|
|
rRGBColor->blue = SalColorTo32BitDeviceColor( &nIndexedColor );
|
|
|
|
rRGBColor->green = SalColorTo32BitDeviceColor( &nIndexedColor );
|
|
|
|
rRGBColor->red = SalColorTo32BitDeviceColor( &nIndexedColor );
|
|
|
|
|
|
|
|
} // SalColor2DirectColor
|
|
|
|
|
|
|
|
|
2000-12-05 19:59:26 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
static void SalColor2EightBitColor ( const GDPtr pGDevice,
|
2000-12-24 02:38:20 +00:00
|
|
|
const SalColor nSalColor,
|
|
|
|
RGBColor *rRGBColor
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CTabPtr pCTable = NULL;
|
|
|
|
PixMapPtr pPixMap = NULL;
|
|
|
|
|
|
|
|
pPixMap = *(*pGDevice).gdPMap;
|
2000-12-11 23:55:18 +00:00
|
|
|
|
|
|
|
if ( pPixMap != NULL )
|
2000-12-24 02:38:20 +00:00
|
|
|
{
|
|
|
|
pCTable = *(*pPixMap).pmTable;
|
2000-12-11 23:55:18 +00:00
|
|
|
|
|
|
|
if ( pCTable != NULL )
|
2000-12-24 02:38:20 +00:00
|
|
|
{
|
|
|
|
if ( nSalColor <= pCTable->ctSize )
|
|
|
|
{
|
|
|
|
RGBColor aRGBColor;
|
|
|
|
|
|
|
|
aRGBColor = pCTable->ctTable[nSalColor].rgb;
|
|
|
|
rRGBColor->red = aRGBColor.red;
|
|
|
|
rRGBColor->green = aRGBColor.green;
|
|
|
|
rRGBColor->blue = aRGBColor.blue;
|
|
|
|
} // if
|
2000-12-11 23:55:18 +00:00
|
|
|
} // if
|
2000-12-24 02:38:20 +00:00
|
|
|
} // if
|
|
|
|
} // SalColor2EightBitColor
|
|
|
|
|
|
|
|
|
2000-12-05 19:59:26 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
//
|
2000-12-12 00:23:12 +00:00
|
|
|
// Here we will convert SAL color to either 8-bit or 32-bit color.
|
2000-12-07 18:33:34 +00:00
|
|
|
// For 16-bit color we shall let Mac OS compute the nearest color
|
|
|
|
// from that of 32-bit color using the Euclidean 2-norm in RGB color
|
|
|
|
// space.
|
2000-12-05 19:59:26 +00:00
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------
|
2000-12-04 22:00:52 +00:00
|
|
|
|
2000-12-11 23:55:18 +00:00
|
|
|
static RGBColor SALColor2RGBColor ( const SalColor nSalColor )
|
2000-12-05 19:59:26 +00:00
|
|
|
{
|
2000-12-24 02:38:20 +00:00
|
|
|
GDPtr pGDevice = NULL;
|
|
|
|
RGBColor aRGBColor;
|
|
|
|
|
|
|
|
memset( &aRGBColor, 0, sizeof(RGBColor) );
|
|
|
|
|
|
|
|
pGDevice = *GetGDevice();
|
|
|
|
|
2000-12-11 23:55:18 +00:00
|
|
|
if ( pGDevice != NULL )
|
2000-12-24 02:38:20 +00:00
|
|
|
{
|
|
|
|
if ( pGDevice->gdType == directType )
|
|
|
|
{
|
|
|
|
SalColor2DirectColor( nSalColor, &aRGBColor );
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SalColor2EightBitColor( pGDevice, nSalColor, &aRGBColor );
|
|
|
|
} // else
|
2000-12-14 18:32:45 +00:00
|
|
|
} // if
|
2000-12-24 02:38:20 +00:00
|
|
|
|
|
|
|
|
2000-12-04 22:00:52 +00:00
|
|
|
return aRGBColor;
|
2000-12-05 19:59:26 +00:00
|
|
|
} // SALColor2RGBColor
|
2000-12-04 22:00:52 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// =======================================================================
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
static SalColor GetROPSalColor( SalROPColor nROPColor )
|
|
|
|
{
|
|
|
|
SalColor nSalColor = 0;
|
|
|
|
|
|
|
|
if ( nROPColor == SAL_ROP_0 )
|
|
|
|
{
|
|
|
|
RGBColor aBlackColor;
|
|
|
|
|
|
|
|
aBlackColor.red = 0x0000;
|
|
|
|
aBlackColor.green = 0x0000;
|
|
|
|
aBlackColor.blue = 0x0000;
|
|
|
|
|
|
|
|
nSalColor = RGBColor2SALColor ( &aBlackColor );
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RGBColor aWhiteColor;
|
|
|
|
|
|
|
|
aWhiteColor.red = 0xffff;
|
|
|
|
aWhiteColor.green = 0xffff;
|
|
|
|
aWhiteColor.blue = 0xffff;
|
|
|
|
|
|
|
|
nSalColor = RGBColor2SALColor ( &aWhiteColor );
|
|
|
|
} // else
|
|
|
|
|
|
|
|
return nSalColor;
|
|
|
|
} // GetROPSalColor
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
static OSStatus GetGDeviceBitDepth ( unsigned short *rGDeviceBitDepth )
|
2000-12-18 20:15:25 +00:00
|
|
|
{
|
2000-12-24 02:38:20 +00:00
|
|
|
GDPtr pGDevice = NULL;
|
|
|
|
OSStatus nQDStatus = noErr;
|
|
|
|
|
|
|
|
pGDevice = *GetGDevice ( );
|
|
|
|
|
|
|
|
nQDStatus = QDErr();
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( ( pGDevice != NULL ) && ( nQDStatus == noErr ) )
|
2000-12-18 20:15:25 +00:00
|
|
|
{
|
2000-12-18 23:49:20 +00:00
|
|
|
PixMapPtr pPixMap = NULL;
|
2000-12-18 20:15:25 +00:00
|
|
|
|
|
|
|
pPixMap = *pGDevice->gdPMap;
|
|
|
|
|
|
|
|
if ( pPixMap != NULL )
|
|
|
|
{
|
|
|
|
// From the PixMap data get the current bits-per-pixel
|
|
|
|
// as associated with the current GDevice
|
|
|
|
|
2000-12-18 23:49:20 +00:00
|
|
|
*rGDeviceBitDepth = (unsigned short)pPixMap->pixelSize;
|
2000-12-18 20:15:25 +00:00
|
|
|
} // if
|
2000-12-18 23:49:20 +00:00
|
|
|
} // if
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
return nQDStatus;
|
2000-12-18 23:49:20 +00:00
|
|
|
} // GetGDeviceBitDepth
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
static OSStatus GetGDeviceResolution ( long *rGDeviceHRes,
|
|
|
|
long *rGDeviceVRes
|
|
|
|
)
|
2000-12-18 23:49:20 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
GDPtr pGDevice = NULL;
|
2000-12-24 02:38:20 +00:00
|
|
|
OSStatus nQDStatus = noErr;
|
|
|
|
|
|
|
|
pGDevice = *GetGDevice ( );
|
|
|
|
|
|
|
|
nQDStatus = QDErr();
|
2000-12-18 23:49:20 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( ( pGDevice != NULL ) && ( nQDStatus == noErr ) )
|
2000-12-18 23:49:20 +00:00
|
|
|
{
|
|
|
|
long nGDeviceTop = pGDevice->gdRect.top;
|
|
|
|
long nGDeviceLeft = pGDevice->gdRect.left;
|
|
|
|
long nGDeviceBottom = pGDevice->gdRect.bottom;
|
|
|
|
long nGDeviceRight = pGDevice->gdRect.right;
|
2000-12-18 20:15:25 +00:00
|
|
|
|
|
|
|
// From the current GDevice get its horizontal resolution
|
|
|
|
|
2000-12-18 23:49:20 +00:00
|
|
|
*rGDeviceHRes = AbsoluteValue( nGDeviceRight - nGDeviceLeft );
|
2000-12-18 20:15:25 +00:00
|
|
|
|
|
|
|
// From the current GDevice get its vertical resolution
|
|
|
|
|
2000-12-18 23:49:20 +00:00
|
|
|
*rGDeviceVRes = AbsoluteValue( nGDeviceBottom - nGDeviceTop );
|
2000-12-18 20:15:25 +00:00
|
|
|
} // if
|
2000-12-18 23:49:20 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
return nQDStatus;
|
2000-12-18 20:15:25 +00:00
|
|
|
} // GetGDeviceResolution
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
static OSStatus BeginClip ( SalGraphicsDataPtr rSalGraphicsData )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
if ( ( rSalGraphicsData->mbClipRegionChanged == TRUE )
|
|
|
|
&& ( rSalGraphicsData->mhClipRgn != NULL )
|
|
|
|
)
|
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
// Set the clip region
|
2000-12-14 18:32:45 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
SetClip( rSalGraphicsData->mhClipRgn );
|
2000-12-14 21:06:45 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
// Was there an error after setting the clipping region?
|
2000-12-14 21:06:45 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
rSalGraphicsData->mnMacOSStatus = QDErr();
|
2000-12-14 18:32:45 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
// Set the new status flag for our port
|
2000-12-14 18:32:45 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
rSalGraphicsData->mbClipRegionChanged = FALSE;
|
2000-12-14 18:32:45 +00:00
|
|
|
} // if
|
2000-12-21 18:37:41 +00:00
|
|
|
return rSalGraphicsData->mnMacOSStatus;
|
2000-12-14 21:06:45 +00:00
|
|
|
} // BeginClip
|
2000-12-14 18:32:45 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
static OSStatus EndClip ( SalGraphicsDataPtr rSalGraphicsData )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
// Set the new status flag for our port
|
2000-12-14 18:32:45 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
rSalGraphicsData->mbClipRegionChanged = FALSE;
|
2000-12-14 18:32:45 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
return rSalGraphicsData->mnMacOSStatus;
|
2000-12-14 21:06:45 +00:00
|
|
|
} // EndClip
|
2000-12-14 18:32:45 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
static OSStatus BeginGraphics ( SalGraphicsDataPtr rSalGraphicsData )
|
2000-12-06 00:20:05 +00:00
|
|
|
{
|
2000-12-08 01:29:05 +00:00
|
|
|
// Previous to entering this function, was there a QD error?
|
2000-12-06 00:20:05 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( rSalGraphicsData->mnMacOSStatus == noErr )
|
2000-12-07 21:20:07 +00:00
|
|
|
{
|
|
|
|
// Get the graph port and lock focus on it
|
|
|
|
|
2000-12-24 18:39:13 +00:00
|
|
|
if ( rSalGraphicsData->mbWindow )
|
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
rSalGraphicsData->mpCGrafPort
|
|
|
|
= VCLGraphics_LockFocusCGrafPort( rSalGraphicsData->mhDC );
|
|
|
|
} // if
|
2000-12-07 21:20:07 +00:00
|
|
|
|
|
|
|
if ( rSalGraphicsData->mpCGrafPort != NULL )
|
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
// Set to the current offscreen world for Mac OS X
|
|
|
|
// only as everything is written to GWorld here
|
2000-12-07 21:20:07 +00:00
|
|
|
|
2000-12-24 18:39:13 +00:00
|
|
|
SetGWorld( rSalGraphicsData->mpCGrafPort, NULL );
|
2000-12-07 21:20:07 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
// Was there a QD error when we set the GWorld?
|
2000-12-07 21:20:07 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
rSalGraphicsData->mnMacOSStatus = QDErr();
|
2000-12-24 18:39:13 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
// Set background and foreground colors on this GWorld port
|
2000-12-24 18:39:13 +00:00
|
|
|
|
|
|
|
SetWhiteBackColor();
|
|
|
|
SetBlackForeColor();
|
2000-12-07 21:20:07 +00:00
|
|
|
} // if
|
|
|
|
} // if
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
return rSalGraphicsData->mnMacOSStatus;
|
2001-01-03 20:28:40 +00:00
|
|
|
} // BeginGraphics
|
2000-12-07 21:20:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
static OSStatus EndGraphics ( SalGraphicsDataPtr rSalGraphicsData )
|
2000-12-07 21:20:07 +00:00
|
|
|
{
|
2000-12-08 01:29:05 +00:00
|
|
|
// Previous to entering this function, was there a QD error?
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( rSalGraphicsData->mnMacOSStatus == noErr )
|
2000-12-07 21:20:07 +00:00
|
|
|
{
|
2000-12-08 01:29:05 +00:00
|
|
|
// Flush the QuickDraw buffer
|
2000-12-06 00:20:05 +00:00
|
|
|
|
2000-12-08 01:29:05 +00:00
|
|
|
QDFlushPortBuffer( rSalGraphicsData->mpCGrafPort, NULL );
|
2000-12-07 21:20:07 +00:00
|
|
|
|
2000-12-08 01:29:05 +00:00
|
|
|
// Unlock focus on the current NSView
|
2000-12-07 21:20:07 +00:00
|
|
|
|
2000-12-24 18:39:13 +00:00
|
|
|
if ( rSalGraphicsData->mbWindow )
|
|
|
|
{
|
|
|
|
VCLGraphics_UnLockFocusCGrafPort( rSalGraphicsData->mhDC );
|
2001-01-03 20:28:40 +00:00
|
|
|
} // if
|
2000-12-07 21:20:07 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// When we get here then the QD port must have changed(?)
|
2000-12-11 19:28:28 +00:00
|
|
|
|
|
|
|
PortChanged( rSalGraphicsData->mpCGrafPort );
|
|
|
|
|
2000-12-08 01:29:05 +00:00
|
|
|
// Was there a QD error?
|
2000-12-07 21:20:07 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
rSalGraphicsData->mnMacOSStatus = QDErr();
|
2000-12-07 21:20:07 +00:00
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
return rSalGraphicsData->mnMacOSStatus;
|
2001-01-03 20:28:40 +00:00
|
|
|
} // EndGraphics
|
2000-12-07 21:20:07 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
static void InitBrush ( SalGraphicsDataPtr rSalGraphicsData )
|
|
|
|
{
|
2000-12-08 01:29:05 +00:00
|
|
|
RGBColor aBlackColor;
|
|
|
|
|
|
|
|
aBlackColor.red = 0x0000;
|
|
|
|
aBlackColor.green = 0x0000;
|
|
|
|
aBlackColor.blue = 0x0000;
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
rSalGraphicsData->mbBrushTransparent = FALSE;
|
2000-12-08 01:29:05 +00:00
|
|
|
rSalGraphicsData->maBrushColor = aBlackColor;
|
2000-12-07 21:20:07 +00:00
|
|
|
} // InitBrush
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-08 01:29:05 +00:00
|
|
|
static void InitFont ( SalGraphicsDataPtr rSalGraphicsData )
|
2000-12-07 21:20:07 +00:00
|
|
|
{
|
|
|
|
RGBColor aBlackColor;
|
2000-12-07 18:33:34 +00:00
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
aBlackColor.red = 0x0000;
|
|
|
|
aBlackColor.green = 0x0000;
|
|
|
|
aBlackColor.blue = 0x0000;
|
|
|
|
|
2000-12-08 01:29:05 +00:00
|
|
|
rSalGraphicsData->maFontColor = aBlackColor;
|
2000-12-07 21:20:07 +00:00
|
|
|
rSalGraphicsData->mnFontID = kFontIDGeneva;
|
|
|
|
rSalGraphicsData->mnFontSize = 10;
|
|
|
|
rSalGraphicsData->mnFontStyle = normal;
|
|
|
|
} // InitFont
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void InitPen ( SalGraphicsDataPtr rSalGraphicsData )
|
|
|
|
{
|
2000-12-08 01:29:05 +00:00
|
|
|
RGBColor aBlackColor;
|
|
|
|
|
|
|
|
aBlackColor.red = 0x0000;
|
|
|
|
aBlackColor.green = 0x0000;
|
|
|
|
aBlackColor.blue = 0x0000;
|
|
|
|
|
|
|
|
rSalGraphicsData->maPenColor = aBlackColor;
|
2000-12-07 21:20:07 +00:00
|
|
|
rSalGraphicsData->mnPenMode = patCopy;
|
2001-01-03 20:28:40 +00:00
|
|
|
rSalGraphicsData->mbPenTransparent = FALSE;
|
2000-12-07 21:20:07 +00:00
|
|
|
} // InitPen
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-11 19:28:28 +00:00
|
|
|
static void InitQD ( SalGraphicsDataPtr rSalGraphicsData )
|
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
rSalGraphicsData->mhDC = NULL;
|
|
|
|
rSalGraphicsData->mpCGrafPort = NULL;
|
|
|
|
rSalGraphicsData->mpGWorld = NULL;
|
2000-12-11 19:28:28 +00:00
|
|
|
} // InitQD
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-07 21:20:07 +00:00
|
|
|
static void InitRegions ( SalGraphicsDataPtr rSalGraphicsData )
|
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
rSalGraphicsData->mhClipRgn = NULL;
|
2000-12-24 02:38:20 +00:00
|
|
|
rSalGraphicsData->mbClipRegionChanged = FALSE;
|
2000-12-07 21:20:07 +00:00
|
|
|
} // InitRegions
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static void InitStatusFlags ( SalGraphicsDataPtr rSalGraphicsData )
|
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
rSalGraphicsData->mbPrinter = FALSE;
|
|
|
|
rSalGraphicsData->mbVirDev = FALSE;
|
|
|
|
rSalGraphicsData->mbWindow = FALSE;
|
|
|
|
rSalGraphicsData->mbScreen = FALSE;
|
2000-12-21 18:37:41 +00:00
|
|
|
rSalGraphicsData->mnMacOSStatus = noErr;
|
2000-12-07 21:20:07 +00:00
|
|
|
} // InitStatusFlags
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-07 21:20:07 +00:00
|
|
|
SalGraphics::SalGraphics()
|
|
|
|
{
|
2000-12-11 19:28:28 +00:00
|
|
|
// QuickDraw graph port, offscreen graphic world, and graphic device handle
|
|
|
|
|
|
|
|
InitQD( &maGraphicsData );
|
|
|
|
|
2000-12-07 21:20:07 +00:00
|
|
|
// Regions within a current port
|
|
|
|
|
|
|
|
InitRegions( &maGraphicsData );
|
|
|
|
|
2000-12-07 18:33:34 +00:00
|
|
|
// Font attributes
|
|
|
|
|
2000-12-07 21:20:07 +00:00
|
|
|
InitFont( &maGraphicsData );
|
2000-12-07 18:33:34 +00:00
|
|
|
|
|
|
|
// Pen attributes and status
|
|
|
|
|
2000-12-07 21:20:07 +00:00
|
|
|
InitPen( &maGraphicsData );
|
2000-12-07 18:33:34 +00:00
|
|
|
|
|
|
|
// Brush attributes and status
|
|
|
|
|
2000-12-07 21:20:07 +00:00
|
|
|
InitBrush( &maGraphicsData );
|
2000-12-07 18:33:34 +00:00
|
|
|
|
|
|
|
// Miscellaneous status flags
|
|
|
|
|
2000-12-07 21:20:07 +00:00
|
|
|
InitStatusFlags( &maGraphicsData );
|
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
} // SalGraphics Class Constructor
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
SalGraphics::~SalGraphics()
|
|
|
|
{
|
2000-12-07 21:20:07 +00:00
|
|
|
if ( maGraphicsData.mpCGrafPort != NULL )
|
|
|
|
{
|
|
|
|
DisposePort( maGraphicsData.mpCGrafPort );
|
|
|
|
} // if
|
|
|
|
|
2000-12-06 00:20:05 +00:00
|
|
|
if ( maGraphicsData.mhClipRgn != NULL )
|
|
|
|
{
|
|
|
|
DisposeRgn( maGraphicsData.mhClipRgn );
|
|
|
|
} // if
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
if ( maGraphicsData.mpGWorld != NULL )
|
2000-12-24 02:38:20 +00:00
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
DisposeGWorld( maGraphicsData.mpGWorld );
|
2000-12-24 02:38:20 +00:00
|
|
|
} // if
|
2000-12-06 00:20:05 +00:00
|
|
|
} // SalGraphics Class Destructor
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
void SalGraphics::GetResolution( long& rDPIX,
|
|
|
|
long& rDPIY
|
|
|
|
)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-18 23:49:20 +00:00
|
|
|
long nHRes = 0;
|
|
|
|
long nVRes = 0;
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
maGraphicsData.mnMacOSStatus = GetGDeviceResolution( &nHRes, &nVRes );
|
2000-12-18 23:49:20 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( maGraphicsData.mnMacOSStatus == noErr )
|
2000-12-18 23:49:20 +00:00
|
|
|
{
|
|
|
|
rDPIX = nHRes;
|
|
|
|
rDPIY = nVRes;
|
|
|
|
} // if
|
2000-12-18 20:15:25 +00:00
|
|
|
} // SalGraphics::GetResolution
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
void SalGraphics::GetScreenFontResolution( long& rDPIX,
|
|
|
|
long& rDPIY
|
|
|
|
)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-18 23:49:20 +00:00
|
|
|
long nHRes = 0;
|
|
|
|
long nVRes = 0;
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
maGraphicsData.mnMacOSStatus = GetGDeviceResolution( &nHRes, &nVRes );
|
2000-12-18 23:49:20 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( maGraphicsData.mnMacOSStatus == noErr )
|
2000-12-04 22:00:52 +00:00
|
|
|
{
|
2000-12-18 23:49:20 +00:00
|
|
|
rDPIX = nHRes;
|
|
|
|
rDPIY = nVRes;
|
|
|
|
} // if
|
|
|
|
} // SalGraphics::GetScreenFontResolution
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
USHORT SalGraphics::GetBitCount()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-18 23:49:20 +00:00
|
|
|
unsigned short nBitDepth = 0;
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
maGraphicsData.mnMacOSStatus = GetGDeviceBitDepth( &nBitDepth );
|
2000-12-18 23:49:20 +00:00
|
|
|
|
|
|
|
return nBitDepth;
|
|
|
|
} // SalGraphics::GetBitCount
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::ResetClipRegion()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-14 18:32:45 +00:00
|
|
|
if ( !maGraphicsData.mbWindow )
|
|
|
|
{
|
|
|
|
if ( maGraphicsData.mhClipRgn != NULL )
|
|
|
|
{
|
|
|
|
DisposeRgn( maGraphicsData.mhClipRgn );
|
|
|
|
|
|
|
|
maGraphicsData.mhClipRgn = NULL;
|
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Rect aClipRect;
|
|
|
|
short nLeft = 0;
|
|
|
|
short nTop = 0;
|
|
|
|
short nRight = 0;
|
|
|
|
short nBottom = 0;
|
|
|
|
|
|
|
|
if ( maGraphicsData.mhClipRgn == NULL )
|
|
|
|
{
|
|
|
|
maGraphicsData.mhClipRgn = NewRgn();
|
|
|
|
} // if
|
|
|
|
|
|
|
|
GetPortBounds( maGraphicsData.mpCGrafPort, &aClipRect);
|
|
|
|
|
|
|
|
nRight = aClipRect.right - aClipRect.left;
|
|
|
|
nBottom = aClipRect.bottom - aClipRect.top;
|
|
|
|
|
|
|
|
MacSetRectRgn ( maGraphicsData.mhClipRgn,
|
|
|
|
nLeft,
|
|
|
|
nTop,
|
|
|
|
nRight,
|
|
|
|
nBottom
|
|
|
|
);
|
|
|
|
} // else
|
|
|
|
|
|
|
|
maGraphicsData.mbClipRegionChanged = TRUE;
|
|
|
|
} // SalGraphics::ResetClipRegion
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::BeginSetClipRegion( ULONG nRectCount )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-14 18:32:45 +00:00
|
|
|
#pragma unused(nRectCount)
|
|
|
|
|
|
|
|
if ( maGraphicsData.mhClipRgn != NULL )
|
|
|
|
{
|
|
|
|
DisposeRgn( maGraphicsData.mhClipRgn );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
maGraphicsData.mhClipRgn = NULL;
|
|
|
|
} // if
|
|
|
|
} // SalGraphics::BeginSetClipRegion
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
BOOL SalGraphics::UnionClipRegion( long nX,
|
|
|
|
long nY,
|
|
|
|
long nWidth,
|
|
|
|
long nHeight
|
|
|
|
)
|
2000-11-01 21:12:34 +00:00
|
|
|
{
|
2000-12-14 18:32:45 +00:00
|
|
|
RgnHandle hClipRegion = NULL;
|
|
|
|
BOOL bClipRegionsJoined = FALSE;
|
|
|
|
|
|
|
|
hClipRegion = NewRgn();
|
|
|
|
|
|
|
|
if ( hClipRegion != NULL )
|
|
|
|
{
|
|
|
|
short nLeft = nX;
|
|
|
|
short nTop = nY;
|
|
|
|
short nRight = nX+nWidth;
|
|
|
|
short nBottom = nY+nHeight;
|
|
|
|
|
|
|
|
MacSetRectRgn ( hClipRegion,
|
|
|
|
nLeft,
|
|
|
|
nTop,
|
|
|
|
nRight,
|
|
|
|
nBottom
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( maGraphicsData.mhClipRgn != NULL )
|
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
MacUnionRgn ( maGraphicsData.mhClipRgn,
|
|
|
|
hClipRegion,
|
|
|
|
maGraphicsData.mhClipRgn
|
|
|
|
);
|
2000-12-14 18:32:45 +00:00
|
|
|
|
|
|
|
// Was there a QD error when joining clip regions?
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
maGraphicsData.mnMacOSStatus = QDErr();
|
2000-12-14 18:32:45 +00:00
|
|
|
|
|
|
|
DisposeRgn( hClipRegion );
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maGraphicsData.mhClipRgn = hClipRegion;
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
maGraphicsData.mnMacOSStatus = noErr;
|
2000-12-14 18:32:45 +00:00
|
|
|
} // else
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( maGraphicsData.mnMacOSStatus == noErr )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
bClipRegionsJoined = TRUE;
|
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
|
|
|
|
return bClipRegionsJoined;
|
|
|
|
} // SalGraphics::UnionClipRegion
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::EndSetClipRegion()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
maGraphicsData.mbClipRegionChanged = TRUE;
|
|
|
|
|
|
|
|
if ( maGraphicsData.mhClipRgn == NULL )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
ResetClipRegion();
|
2001-01-03 20:28:40 +00:00
|
|
|
}
|
2000-12-14 18:32:45 +00:00
|
|
|
} // SalGraphics::EndSetClipRegion
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::SetLineColor()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
maGraphicsData.mbPenTransparent = TRUE;
|
2000-12-06 00:20:05 +00:00
|
|
|
} // SalGraphics::SetLineColor
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::SetLineColor( SalColor nSalColor )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
maGraphicsData.mbPenTransparent = FALSE;
|
2000-12-04 22:00:52 +00:00
|
|
|
maGraphicsData.maPenColor = SALColor2RGBColor( nSalColor );
|
2000-12-06 00:20:05 +00:00
|
|
|
} // SalGraphics::SetLineColor
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::SetFillColor()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
maGraphicsData.mbBrushTransparent = TRUE;
|
2000-12-06 00:20:05 +00:00
|
|
|
} // SalGraphics::SetFillColor
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::SetFillColor( SalColor nSalColor )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-04 22:00:52 +00:00
|
|
|
RGBColor aRGBColor;
|
2000-11-29 22:11:27 +00:00
|
|
|
|
2000-12-04 22:00:52 +00:00
|
|
|
aRGBColor = SALColor2RGBColor( nSalColor );
|
2000-11-29 22:11:27 +00:00
|
|
|
|
|
|
|
maGraphicsData.maBrushColor = aRGBColor;
|
2001-01-03 20:28:40 +00:00
|
|
|
maGraphicsData.mbBrushTransparent = FALSE;
|
2000-12-06 00:20:05 +00:00
|
|
|
} // SalGraphics::SetFillColor
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::SetXORMode( BOOL bSet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-01 02:20:53 +00:00
|
|
|
if ( bSet == TRUE )
|
|
|
|
{
|
|
|
|
maGraphicsData.mnPenMode = patXor;
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maGraphicsData.mnPenMode = patCopy;
|
|
|
|
} // else
|
2000-12-06 00:20:05 +00:00
|
|
|
} // SalGraphics::SetXORMode
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::SetROPLineColor( SalROPColor nROPColor )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-21 19:19:31 +00:00
|
|
|
SalColor nSalColor = GetROPSalColor( nROPColor );
|
|
|
|
|
|
|
|
SetLineColor( nSalColor );
|
|
|
|
} // SalGraphics::SetROPLineColor
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::SetROPFillColor( SalROPColor nROPColor )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-21 19:19:31 +00:00
|
|
|
SalColor nSalColor = GetROPSalColor( nROPColor );
|
|
|
|
|
|
|
|
SetFillColor( nSalColor );
|
|
|
|
} // SalGraphics::SetROPFillColor
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
void SalGraphics::DrawPixel( long nX,
|
|
|
|
long nY
|
|
|
|
)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
OSStatus aQDStatus = noErr;
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
2000-12-14 18:32:45 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
RGBColor aPixelRGBColor = maGraphicsData.maPenColor;
|
|
|
|
|
|
|
|
SetCPixel( nX, nY, &aPixelRGBColor );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 21:06:45 +00:00
|
|
|
EndClip( &maGraphicsData );
|
2000-12-14 18:32:45 +00:00
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
EndGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
} // if
|
|
|
|
} // SalGraphics::DrawPixel
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
void SalGraphics::DrawPixel( long nX,
|
|
|
|
long nY,
|
|
|
|
SalColor nSalColor
|
|
|
|
)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
OSStatus aQDStatus = noErr;
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
RGBColor aPixelRGBColor;
|
|
|
|
|
|
|
|
aPixelRGBColor = SALColor2RGBColor( nSalColor );
|
2000-11-20 22:32:57 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
SetCPixel( nX, nY, &aPixelRGBColor );
|
|
|
|
|
2000-12-14 21:06:45 +00:00
|
|
|
EndClip( &maGraphicsData );
|
2000-12-14 18:32:45 +00:00
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
EndGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
} // SalGraphics::DrawPixel
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
void SalGraphics::DrawLine( long nX1,
|
|
|
|
long nY1,
|
|
|
|
long nX2,
|
|
|
|
long nY2
|
|
|
|
)
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
OSStatus aQDStatus = noErr;
|
2000-11-16 18:53:30 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
2000-12-14 18:32:45 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
short nPortPenMode = 0;
|
|
|
|
short nPenMode = maGraphicsData.mnPenMode;
|
|
|
|
CGrafPtr pCGraf = maGraphicsData.mpCGrafPort;
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// What is the current pen mode associated with this graph port?
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
nPortPenMode = GetPortPenMode( pCGraf );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
SetPortPenMode( pCGraf, nPenMode );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
MoveTo( nX1, nY1 );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
if ( maGraphicsData.mbPenTransparent == TRUE )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
SetBlackForeColor();
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RGBColor aPenColor = maGraphicsData.maPenColor;
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
RGBForeColor( &aPenColor );
|
|
|
|
} // else
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
MacLineTo( nX2, nY2 );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// Reset the port to its original pen mode
|
|
|
|
|
|
|
|
SetPortPenMode( pCGraf, nPortPenMode );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 21:06:45 +00:00
|
|
|
EndClip( &maGraphicsData );
|
2000-12-14 18:32:45 +00:00
|
|
|
} // if
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
EndGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
} // if
|
|
|
|
} // SalGraphics::DrawLine
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
void SalGraphics::DrawRect( long nX,
|
|
|
|
long nY,
|
|
|
|
long nWidth,
|
|
|
|
long nHeight
|
|
|
|
)
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
OSStatus aQDStatus = noErr;
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-11-16 18:53:30 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
long nEndX = 0;
|
|
|
|
long nEndY = 0;
|
|
|
|
RGBColor aBrushColor = maGraphicsData.maBrushColor;
|
|
|
|
Rect aRect;
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// Compute the second set of (nX,nY) coordinates
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
nEndX = nX + nWidth;
|
|
|
|
nEndY = nY + nHeight;
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
RGBForeColor( &aBrushColor );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
MoveTo( nX, nY );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
MacSetRect( &aRect, nX, nY, nEndX, nEndY );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
if ( maGraphicsData.mbBrushTransparent == TRUE )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
short nPortPenMode = 0;
|
|
|
|
short nPenMode = maGraphicsData.mnPenMode;
|
|
|
|
CGrafPtr pCGraf = maGraphicsData.mpCGrafPort;
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// What is the current pen mode associated with this graph port?
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
nPortPenMode = GetPortPenMode( pCGraf );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
SetPortPenMode( pCGraf, nPenMode );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
MacFrameRect( &aRect );
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// Reset the port to its original pen mode
|
|
|
|
|
|
|
|
SetPortPenMode( pCGraf, nPortPenMode );
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PaintRect( &aRect );
|
|
|
|
} // else
|
|
|
|
|
2000-12-14 21:06:45 +00:00
|
|
|
EndClip( &maGraphicsData );
|
2000-11-30 00:48:03 +00:00
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
EndGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
} // if
|
|
|
|
} // SalGraphics::DrawRect
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
void SalGraphics::DrawPolyLine( ULONG nPoints,
|
|
|
|
const SalPoint *pPtAry
|
|
|
|
)
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
|
|
|
if ( ( nPoints > 1 ) && ( pPtAry != NULL ) )
|
2000-11-16 18:53:30 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
OSStatus aQDStatus = noErr;
|
2000-11-20 22:32:57 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
long nPolyEdges = 0;
|
|
|
|
short nPortPenMode = 0;
|
|
|
|
short nPenMode = maGraphicsData.mnPenMode;
|
|
|
|
CGrafPtr pCGraf = maGraphicsData.mpCGrafPort;
|
|
|
|
PolyHandle hPolygon = NULL;
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// What is the current pen mode associated with this graph port?
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
nPortPenMode = GetPortPenMode( pCGraf );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
SetBlackForeColor();
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
SetPortPenMode( pCGraf, nPenMode );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// Construct a polygon
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
hPolygon = OpenPoly();
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
if ( hPolygon != NULL )
|
2000-12-08 01:29:05 +00:00
|
|
|
{
|
2000-12-14 18:32:45 +00:00
|
|
|
MoveTo ( pPtAry[0].mnX, pPtAry[0].mnY );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
for ( nPolyEdges = 1;
|
|
|
|
nPolyEdges < nPoints;
|
|
|
|
nPolyEdges++
|
|
|
|
)
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
MacLineTo( pPtAry[nPolyEdges].mnX,
|
|
|
|
pPtAry[nPolyEdges].mnY
|
|
|
|
);
|
2000-12-14 18:32:45 +00:00
|
|
|
} // for
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
MacLineTo( pPtAry[0].mnX, pPtAry[0].mnY );
|
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
ClosePoly();
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// Did a QD error occur whilst constructing a polygon?
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
maGraphicsData.mnMacOSStatus = QDErr();
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
if ( ( maGraphicsData.mnMacOSStatus == noErr )
|
|
|
|
&& ( hPolygon != NULL )
|
|
|
|
)
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
FramePoly( hPolygon );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
KillPoly( hPolygon );
|
|
|
|
} // if
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// Reset the port to its original pen mode
|
|
|
|
|
|
|
|
SetPortPenMode( pCGraf, nPortPenMode );
|
|
|
|
|
2000-12-14 21:06:45 +00:00
|
|
|
EndClip( &maGraphicsData );
|
2000-12-14 18:32:45 +00:00
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
EndGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
} // SalGraphics::DrawPolyLine
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
void SalGraphics::DrawPolygon( ULONG nPoints,
|
|
|
|
const SalPoint *pPtAry
|
|
|
|
)
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
|
|
|
if ( ( nPoints > 1 ) && ( pPtAry != NULL ) )
|
2000-11-16 18:53:30 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
OSStatus aQDStatus = noErr;
|
2000-11-29 22:11:27 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-11-20 22:32:57 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
long nPolyEdges = 0;
|
|
|
|
short nPortPenMode = 0;
|
|
|
|
short nPenMode = maGraphicsData.mnPenMode;
|
|
|
|
CGrafPtr pCGraf = maGraphicsData.mpCGrafPort;
|
|
|
|
PolyHandle hPolygon = NULL;
|
|
|
|
RGBColor aPolyColor = maGraphicsData.maBrushColor;
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// What is the current pen mode associated with this graph port?
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
nPortPenMode = GetPortPenMode( pCGraf );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
RGBForeColor( &aPolyColor );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
SetPortPenMode( pCGraf, nPenMode );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// Construct a polygon
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
hPolygon = OpenPoly();
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
if ( hPolygon != NULL )
|
2000-12-08 01:29:05 +00:00
|
|
|
{
|
2000-12-14 18:32:45 +00:00
|
|
|
MoveTo ( pPtAry[0].mnX, pPtAry[0].mnY );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
for ( nPolyEdges = 1; nPolyEdges < nPoints; nPolyEdges ++ )
|
|
|
|
{
|
|
|
|
MacLineTo( pPtAry[nPolyEdges].mnX, pPtAry[nPolyEdges].mnY );
|
|
|
|
} // for
|
|
|
|
|
|
|
|
MacLineTo( pPtAry[0].mnX, pPtAry[0].mnY );
|
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
ClosePoly();
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// Did a QD error occur whilst constructing a polygon?
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
maGraphicsData.mnMacOSStatus = QDErr();
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
if ( ( maGraphicsData.mnMacOSStatus == noErr )
|
|
|
|
&& ( hPolygon != NULL )
|
|
|
|
)
|
2000-12-14 18:32:45 +00:00
|
|
|
{
|
|
|
|
PaintPoly( hPolygon );
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
KillPoly( hPolygon );
|
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
// Reset the port to its original pen mode
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
SetPortPenMode( pCGraf, nPortPenMode );
|
|
|
|
|
2000-12-14 21:06:45 +00:00
|
|
|
EndClip( &maGraphicsData );
|
2000-12-14 18:32:45 +00:00
|
|
|
} // if
|
2000-12-08 01:29:05 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
EndGraphics( &maGraphicsData );
|
2000-11-20 22:32:57 +00:00
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
} // SalGraphics::DrawPolygon
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
void SalGraphics::DrawPolyPolygon( ULONG nPoly,
|
|
|
|
const ULONG *pPoints,
|
|
|
|
PCONSTSALPOINT *ppPtAry
|
|
|
|
)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( ( nPoly > 1 ) && ( ppPtAry != NULL ) && ( ppPtAry != NULL ) )
|
|
|
|
{
|
|
|
|
OSStatus aQDStatus = noErr;
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-12-21 18:37:41 +00:00
|
|
|
|
|
|
|
if ( aQDStatus == noErr )
|
|
|
|
{
|
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
|
|
|
|
|
|
|
if ( aQDStatus == noErr )
|
|
|
|
{
|
|
|
|
short nPortPenMode = 0;
|
|
|
|
short nPenMode = maGraphicsData.mnPenMode;
|
|
|
|
CGrafPtr pCGraf = maGraphicsData.mpCGrafPort;
|
|
|
|
RgnHandle hPolyRgn = NULL;
|
|
|
|
RGBColor aPolyColor = maGraphicsData.maBrushColor;
|
|
|
|
OSStatus aQDStatus = noErr;
|
|
|
|
|
|
|
|
// What is the current pen mode associated with this graph port?
|
|
|
|
|
|
|
|
nPortPenMode = GetPortPenMode( pCGraf );
|
|
|
|
|
|
|
|
RGBForeColor( &aPolyColor );
|
|
|
|
|
|
|
|
SetPortPenMode( pCGraf, nPenMode );
|
|
|
|
|
|
|
|
// Construct a polygon region
|
|
|
|
|
|
|
|
hPolyRgn = GetPolygonRgn( nPoly,
|
|
|
|
pPoints,
|
|
|
|
ppPtAry,
|
|
|
|
&aQDStatus
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( ( hPolyRgn != NULL ) && ( aQDStatus == noErr ) )
|
|
|
|
{
|
|
|
|
MacPaintRgn( hPolyRgn );
|
|
|
|
|
|
|
|
DisposeRgn( hPolyRgn );
|
|
|
|
|
|
|
|
aQDStatus = QDErr();
|
|
|
|
|
|
|
|
hPolyRgn = NULL;
|
|
|
|
} // if
|
|
|
|
|
|
|
|
// Reset the port to its original pen mode
|
|
|
|
|
|
|
|
SetPortPenMode( pCGraf, nPortPenMode );
|
|
|
|
|
|
|
|
maGraphicsData.mnMacOSStatus = aQDStatus;
|
|
|
|
|
|
|
|
EndClip( &maGraphicsData );
|
|
|
|
} // if
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
EndGraphics( &maGraphicsData );
|
2000-12-21 18:37:41 +00:00
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
} // SalGraphics::DrawPolyPolygon
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
void SalGraphics::CopyBits( const SalTwoRect *pPosAry,
|
|
|
|
SalGraphics *pSrcGraphics
|
|
|
|
)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( ( maGraphicsData.mpCGrafPort != NULL )
|
|
|
|
&& ( pPosAry != NULL )
|
|
|
|
&& ( pSrcGraphics != NULL )
|
|
|
|
)
|
2000-12-01 02:20:53 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
OSStatus aQDStatus = noErr;
|
2000-12-01 02:20:53 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-12-01 02:20:53 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
2000-12-01 02:20:53 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( aQDStatus == noErr )
|
2000-12-01 02:20:53 +00:00
|
|
|
{
|
2000-12-14 18:32:45 +00:00
|
|
|
const BitMap *pDstBitMap = GetPortBitMapForCopyBits( maGraphicsData.mpCGrafPort );
|
2000-12-01 02:20:53 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
if ( pDstBitMap != NULL )
|
2000-12-01 02:20:53 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
maGraphicsData.mnMacOSStatus = LockPortBits( maGraphicsData.mpCGrafPort );
|
2000-12-01 02:20:53 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
if ( maGraphicsData.mnMacOSStatus == noErr )
|
2000-12-01 02:20:53 +00:00
|
|
|
{
|
2000-12-14 18:32:45 +00:00
|
|
|
Rect aSrcRect;
|
|
|
|
Rect aDstRect;
|
|
|
|
Rect aPortBoundsRect;
|
|
|
|
RgnHandle hMaskRgn = NULL; // Mask Region for QD CopyBits
|
|
|
|
short nCopyMode = 0;
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
SalTwoRect2SQDSrcRect( pPosAry, &aSrcRect );
|
2000-12-14 18:32:45 +00:00
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
SalTwoRect2SQDDstRect( pPosAry, &aDstRect );
|
2000-12-14 18:32:45 +00:00
|
|
|
|
|
|
|
GetPortBounds( pSrcGraphics->maGraphicsData.mpCGrafPort, &aPortBoundsRect );
|
|
|
|
|
|
|
|
CheckRectBounds( &aSrcRect, &aDstRect, &aPortBoundsRect );
|
|
|
|
|
2000-12-14 21:06:45 +00:00
|
|
|
nCopyMode = SelectCopyMode( &maGraphicsData );
|
2000-12-14 18:32:45 +00:00
|
|
|
|
|
|
|
// Now we can call QD CopyBits to copy the bits from source rectangle
|
|
|
|
// to the destination rectangle
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2000-12-14 18:32:45 +00:00
|
|
|
if ( ( pSrcGraphics != NULL )
|
|
|
|
&& ( pSrcGraphics->maGraphicsData.mpCGrafPort != NULL )
|
|
|
|
)
|
2000-12-11 19:28:28 +00:00
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
const BitMap *pSrcBitMap = GetPortBitMapForCopyBits( pSrcGraphics->maGraphicsData.mpCGrafPort );
|
2000-12-14 18:32:45 +00:00
|
|
|
|
|
|
|
if ( pSrcBitMap != NULL )
|
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
maGraphicsData.mnMacOSStatus
|
|
|
|
= LockPortBits( pSrcGraphics->maGraphicsData.mpCGrafPort );
|
|
|
|
|
|
|
|
if ( maGraphicsData.mnMacOSStatus == noErr )
|
|
|
|
{
|
|
|
|
::CopyBits ( pSrcBitMap,
|
|
|
|
pDstBitMap,
|
|
|
|
&aSrcRect,
|
|
|
|
&aDstRect,
|
|
|
|
nCopyMode,
|
|
|
|
hMaskRgn
|
|
|
|
);
|
|
|
|
|
|
|
|
UnlockPortBits( pSrcGraphics->maGraphicsData.mpCGrafPort );
|
|
|
|
} // if
|
2000-12-14 18:32:45 +00:00
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
::CopyBits ( pDstBitMap,
|
2000-12-11 19:28:28 +00:00
|
|
|
pDstBitMap,
|
|
|
|
&aSrcRect,
|
|
|
|
&aDstRect,
|
|
|
|
nCopyMode,
|
|
|
|
hMaskRgn
|
|
|
|
);
|
2000-12-14 18:32:45 +00:00
|
|
|
} // else
|
|
|
|
|
|
|
|
UnlockPortBits( maGraphicsData.mpCGrafPort );
|
2000-12-01 02:20:53 +00:00
|
|
|
} // if
|
|
|
|
} // if
|
2000-12-14 18:32:45 +00:00
|
|
|
|
2000-12-14 21:06:45 +00:00
|
|
|
EndClip( &maGraphicsData );
|
2000-12-01 02:20:53 +00:00
|
|
|
} // if
|
2000-12-11 19:28:28 +00:00
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
EndGraphics( &maGraphicsData );
|
2000-12-01 02:20:53 +00:00
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
} // SalGraphics::CopyBits
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 18:37:41 +00:00
|
|
|
void SalGraphics::CopyArea( long nDstX,
|
|
|
|
long nDstY,
|
|
|
|
long nSrcX,
|
|
|
|
long nSrcY,
|
|
|
|
long nSrcWidth,
|
|
|
|
long nSrcHeight,
|
|
|
|
USHORT nFlags
|
|
|
|
)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-21 18:37:41 +00:00
|
|
|
#pragma unused(nFlags)
|
|
|
|
|
|
|
|
if ( maGraphicsData.mpCGrafPort != NULL )
|
|
|
|
{
|
|
|
|
OSStatus aQDStatus = noErr;
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-12-21 18:37:41 +00:00
|
|
|
|
|
|
|
if ( aQDStatus == noErr )
|
|
|
|
{
|
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
|
|
|
|
|
|
|
if ( aQDStatus == noErr )
|
|
|
|
{
|
|
|
|
const BitMap *pSrcBitMap = GetPortBitMapForCopyBits( maGraphicsData.mpCGrafPort );
|
|
|
|
const BitMap *pDstBitMap = pSrcBitMap;
|
|
|
|
|
|
|
|
if ( pSrcBitMap != NULL )
|
|
|
|
{
|
|
|
|
maGraphicsData.mnMacOSStatus = LockPortBits( maGraphicsData.mpCGrafPort );
|
|
|
|
|
|
|
|
if ( maGraphicsData.mnMacOSStatus == noErr )
|
|
|
|
{
|
|
|
|
short nCopyMode = 0;
|
|
|
|
long nDstWidth = nSrcWidth;
|
|
|
|
long nDstHeight = nSrcHeight;
|
|
|
|
RgnHandle hMaskRgn = NULL; // Mask Region for QD CopyBits
|
|
|
|
Rect aSrcRect;
|
|
|
|
Rect aDstRect;
|
|
|
|
Rect aPortBoundsRect;
|
|
|
|
|
|
|
|
GetQDRect ( nSrcX, nSrcY, nSrcWidth, nSrcHeight, &aSrcRect );
|
|
|
|
|
|
|
|
GetQDRect ( nDstX, nDstY, nDstWidth, nDstHeight, &aDstRect );
|
|
|
|
|
|
|
|
GetPortBounds( maGraphicsData.mpCGrafPort, &aPortBoundsRect );
|
|
|
|
|
|
|
|
CheckRectBounds( &aSrcRect, &aDstRect, &aPortBoundsRect );
|
|
|
|
|
|
|
|
nCopyMode = SelectCopyMode( &maGraphicsData );
|
|
|
|
|
|
|
|
// Now we can call QD CopyBits to copy the bits from source rectangle
|
|
|
|
// to the destination rectangle
|
|
|
|
|
|
|
|
::CopyBits ( pSrcBitMap,
|
|
|
|
pDstBitMap,
|
|
|
|
&aSrcRect,
|
|
|
|
&aDstRect,
|
|
|
|
nCopyMode,
|
|
|
|
hMaskRgn
|
|
|
|
);
|
|
|
|
|
|
|
|
UnlockPortBits( maGraphicsData.mpCGrafPort );
|
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
|
|
|
|
EndClip( &maGraphicsData );
|
|
|
|
} // if
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
EndGraphics( &maGraphicsData );
|
2000-12-21 18:37:41 +00:00
|
|
|
} // if
|
|
|
|
} // if
|
|
|
|
} // SalGraphics::CopyArea
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
|
|
|
|
const SalBitmap& rSalBitmap )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
|
|
|
|
const SalBitmap& rSalBitmap,
|
|
|
|
SalColor nTransparentColor )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
|
|
|
|
const SalBitmap& rSalBitmap,
|
|
|
|
const SalBitmap& rTransparentBitmap )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::DrawMask( const SalTwoRect* pPosAry,
|
|
|
|
const SalBitmap& rSalBitmap,
|
|
|
|
SalColor nMaskColor )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-05 00:57:55 +00:00
|
|
|
} // SalGraphics::DrawMask
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
SalBitmap* SalGraphics::GetBitmap( long nX, long nY, long nDX, long nDY )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-01 21:12:34 +00:00
|
|
|
return NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-21 19:19:31 +00:00
|
|
|
SalColor SalGraphics::GetPixel( long nX,
|
|
|
|
long nY
|
|
|
|
)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-11 23:55:18 +00:00
|
|
|
RGBColor aRGBColor;
|
|
|
|
SalColor nSalColor = 0;
|
|
|
|
short aHorizontalCoor = (short)nX;
|
|
|
|
short aVerticalCoor = (short)nY;
|
|
|
|
|
|
|
|
GetCPixel( aHorizontalCoor, aVerticalCoor, &aRGBColor );
|
|
|
|
|
|
|
|
nSalColor = RGBColor2SALColor ( &aRGBColor );
|
|
|
|
|
2000-12-24 02:38:20 +00:00
|
|
|
return nSalColor;
|
|
|
|
|
2000-12-11 23:55:18 +00:00
|
|
|
} // SalGraphics::GetPixel
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::Invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::Invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nSalFlags )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
BOOL SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight,
|
|
|
|
void* pPtr, ULONG nSize )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-01 21:12:34 +00:00
|
|
|
return FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::SetTextColor( SalColor nSalColor )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-08 01:29:05 +00:00
|
|
|
maGraphicsData.maFontColor = SALColor2RGBColor( nSalColor );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
USHORT SalGraphics::SetFont( ImplFontSelectData* pFont )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-01 21:12:34 +00:00
|
|
|
return 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
long SalGraphics::GetCharWidth( sal_Unicode nChar1, sal_Unicode nChar2, long* pWidthAry )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-29 23:01:54 +00:00
|
|
|
// Stub code: we have not yet written any interfaces to native fonts.
|
|
|
|
// However, we need to get some font info in order to continue porting.
|
|
|
|
return 10;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::GetFontMetric( ImplFontMetricData* pMetric )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-18 23:49:20 +00:00
|
|
|
// Stub Code
|
|
|
|
|
|
|
|
FMetricRec aFMetric;
|
|
|
|
|
|
|
|
FontMetrics( &aFMetric );
|
|
|
|
|
2000-11-29 23:01:54 +00:00
|
|
|
pMetric->mnAscent = 10;
|
|
|
|
pMetric->mnDescent = 10;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
ULONG SalGraphics::GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-01 21:12:34 +00:00
|
|
|
return 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
void SalGraphics::GetDevFontList( ImplDevFontList* pList )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-19 01:37:03 +00:00
|
|
|
// Stub code: we have not yet written any interfaces to native fonts.
|
|
|
|
// However, we need to create at least one fake font to continue our
|
|
|
|
// porting.
|
|
|
|
ImplFontData *pFontData = new ImplFontData;
|
|
|
|
pFontData->mnWidth = 10;
|
|
|
|
pFontData->mnHeight = 10;
|
|
|
|
pList->Add( pFontData );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-12-11 23:55:18 +00:00
|
|
|
void SalGraphics::DrawText( long nX,
|
|
|
|
long nY,
|
|
|
|
const xub_Unicode *pStr,
|
|
|
|
xub_StrLen nLen
|
|
|
|
)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-12 00:23:12 +00:00
|
|
|
// The implementation is not yet complete
|
|
|
|
|
2000-12-24 18:39:13 +00:00
|
|
|
OSStatus aQDStatus = noErr;
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
aQDStatus = BeginGraphics( &maGraphicsData );
|
2000-12-24 18:39:13 +00:00
|
|
|
|
|
|
|
if ( aQDStatus == noErr )
|
2000-12-11 23:55:18 +00:00
|
|
|
{
|
2000-12-24 18:39:13 +00:00
|
|
|
if ( ( pStr != NULL ) && ( nLen > 0 ) )
|
|
|
|
{
|
2001-01-03 20:28:40 +00:00
|
|
|
ByteString aByteString( pStr, nLen, gsl_getSystemTextEncoding() );
|
2000-12-11 23:55:18 +00:00
|
|
|
|
2000-12-24 18:39:13 +00:00
|
|
|
aQDStatus = BeginClip( &maGraphicsData );
|
|
|
|
|
|
|
|
if ( aQDStatus == noErr )
|
|
|
|
{
|
2001-01-03 21:05:32 +00:00
|
|
|
short nFirstByte = 0;
|
|
|
|
short nByteCount = nLen;
|
|
|
|
const char *pTextBuffer = aByteString.GetBuffer();
|
|
|
|
const RGBColor aFontForeColor = maGraphicsData.maFontColor;
|
2001-01-03 20:28:40 +00:00
|
|
|
|
|
|
|
if ( pTextBuffer != NULL )
|
|
|
|
{
|
2001-01-03 21:05:32 +00:00
|
|
|
RGBForeColor( &aFontForeColor );
|
|
|
|
|
2001-01-03 20:28:40 +00:00
|
|
|
MoveTo( nX, nY );
|
|
|
|
|
|
|
|
::MacDrawText( pTextBuffer, nFirstByte, nByteCount );
|
|
|
|
} // if
|
2000-12-11 23:55:18 +00:00
|
|
|
|
2000-12-24 18:39:13 +00:00
|
|
|
EndClip( &maGraphicsData );
|
|
|
|
} // if
|
|
|
|
} // if
|
2001-01-03 20:28:40 +00:00
|
|
|
|
|
|
|
EndGraphics( &maGraphicsData );
|
2000-12-11 23:55:18 +00:00
|
|
|
} // if
|
2000-12-12 00:23:12 +00:00
|
|
|
} // SalGraphics::DrawText
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SalGraphics::DrawTextArray( long nX, long nY,
|
|
|
|
const xub_Unicode* pStr, xub_StrLen nLen,
|
|
|
|
const long* pDXAry )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL SalGraphics::GetGlyphBoundRect( xub_Unicode cChar, long* pX, long* pY,
|
|
|
|
long* pWidth, long* pHeight )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-01 21:12:34 +00:00
|
|
|
return FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-01 21:12:34 +00:00
|
|
|
ULONG SalGraphics::GetGlyphOutline( xub_Unicode cChar, USHORT** ppPolySizes,
|
|
|
|
SalPoint** ppPoints, BYTE** ppFlags )
|
|
|
|
{
|
|
|
|
return 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2000-12-04 22:00:52 +00:00
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|