home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 4.9 KB | 185 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWGrUtil.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifndef FWGCONST_H
- #include "FWGConst.h"
- #endif
-
- #ifndef SLREGION_H
- #include "SLRegion.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- // ----- C Includes -----
-
- #if defined(FW_BUILD_MAC) & !defined(__FP__)
- #include <FP.h>
- #endif
-
- #if defined(FW_BUILD_WIN) & !defined(__MATH_H)
- #include <Math.h>
- #endif
-
- #ifdef FW_DEBUG
- #include <stdio.h> // for sprintf()
- #endif
-
- // ------ Platform includes ------
-
- #if defined(FW_BUILD_MAC) & !defined(__QDOFFSCREEN__)
- #include <QDOffscreen.h>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphx_GrUtil
- #endif
-
- //========================================================================================
- // Global Methods
- //========================================================================================
-
- //-------------------------------------------------------------------------
- // FW_CreateLineODShape
- //-------------------------------------------------------------------------
-
- ODShape* FW_CreateLineODShape(Environment *ev, const FW_CPoint& from, const FW_CPoint& to, FW_Fixed penSize)
- {
- FW_CPoint lineThickness(penSize, penSize);
-
- ODShape* shape = ::FW_NewODShape(ev);
- ::FW_SetShapeRegion(ev, shape, ::FW_CreateLineRegion( from, to, lineThickness));
- return shape;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CreateOvalODShape
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CreateOvalODShape(Environment *ev, const FW_CRect& rect)
- {
- ODShape* shape = ::FW_NewODShape(ev);
- ::FW_SetShapeRegion(ev, shape, ::FW_CreateOvalRegion(rect));
- return shape;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CreateArcODShape
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CreateArcODShape(Environment *ev, const FW_CRect& rect, short startAngle, short arcAngle)
- {
- ODShape* shape = ::FW_NewODShape(ev);
- ::FW_SetShapeRegion(ev, shape, ::FW_CreateArcRegion(rect, startAngle, arcAngle));
- return shape;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CreateRoundRectODShape
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CreateRoundRectODShape(Environment *ev, const FW_CRect& rect, const FW_CPoint& ovalSize)
- {
- ODShape* shape = ::FW_NewODShape(ev);
- ::FW_SetShapeRegion(ev, shape, ::FW_CreateRoundRectRegion(rect, ovalSize));
- return shape;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_OutlineODShape
- //----------------------------------------------------------------------------------------
-
- void FW_OutlineODShape(Environment *ev, ODShape* odShapeToOutline, FW_Fixed outlineSize)
- {
- ODShape* odTempShape = ::FW_NewODShape(ev, odShapeToOutline);
-
- if (outlineSize <= FW_kFixed0)
- outlineSize = FW_kFixedPos1;
-
- odTempShape->Outset(ev, - FW_FixedToODFixed(outlineSize));
-
- odShapeToOutline->Subtract(ev, odTempShape);
- odTempShape->Release(ev);
- }
-
- #ifdef FW_BUILD_MAC
- //========================================================================================
- // class FW_CMacTempPort
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CMacTempPort)
-
- //----------------------------------------------------------------------------------------
- // FW_CMacTempPort::FW_CMacTempPort
- //----------------------------------------------------------------------------------------
-
- FW_CMacTempPort::FW_CMacTempPort(GrafPtr tempPort /* = NULL */)
- {
- ::GetPort(&fMacPort);
-
- if (tempPort != NULL)
- SetPort(tempPort);
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMacTempPort::~FW_CMacTempPort
- //----------------------------------------------------------------------------------------
-
- FW_CMacTempPort::~FW_CMacTempPort()
- {
- FW_START_DESTRUCTOR
-
- ::SetPort(fMacPort);
- }
-
- #endif
-
-