home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 3.7 KB | 149 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWScrCon.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWSCRCON_H
- #include "FWScrCon.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef SLREGION_H
- #include "SLRegion.h"
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__WINDOWS__)
- #include "Windows.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__QUICKDRAW__)
- #include "QuickDraw.h"
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphx_ScreenContext
- #endif
-
- FW_DEFINE_AUTO(FW_CScreenContext)
-
- //========================================================================================
- // class FW_CScreenContext
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CScreenContext::FW_CScreenContext
- //----------------------------------------------------------------------------------------
-
- FW_CScreenContext::FW_CScreenContext(Environment* ev,
- ODShape* clipShape,
- ODTransform* transform) :
- FW_CGraphicContext(ev),
- fGraphicDevice(NULL)
- {
- ODShape* odClipShape = NULL;
-
- FW_TRY
- {
- #ifdef FW_BUILD_WIN
- fDC = ::GetDC(NULL);
- fGraphicDevice = FW_PrivGDev_CreateFromPlatformCanvas(ev, fDC);
- FW_FailOnEvError(ev);
-
- int xScreen = ::GetSystemMetrics(SM_CXSCREEN);
- int yScreen = ::GetSystemMetrics(SM_CYSCREEN);
-
- FW_CRect rect(FW_IntToFixed(0), FW_IntToFixed(0), FW_IntToFixed(xScreen), FW_IntToFixed(yScreen));
- odClipShape = ::FW_NewODShape(ev, rect);
- #endif
- #ifdef FW_BUILD_MAC
- GrafPtr savePort;
- ::GetPort(&savePort);
- ::OpenCPort(&fCGrafPort);
- ::SetPort(savePort);
-
- fGraphicDevice = FW_PrivGDev_CreateFromPlatformCanvas(ev, (ODPlatformCanvas) &fCGrafPort);
- FW_FailOnEvError(ev);
-
- ODRgnHandle grayRgnCopy = ::FW_CopyRegion(GetGrayRgn());
- odClipShape = ::FW_NewODShape(ev, grayRgnCopy);
- #endif
-
- if(clipShape != NULL)
- odClipShape->Intersect(ev, clipShape);
-
- InitGraphicContext(fGraphicDevice,
- transform,
- odClipShape);
-
- odClipShape->Release(ev); // we don't need it
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- if(odClipShape != NULL)
- odClipShape->Release(ev);
-
- FW_PrivGDev_Release(fGraphicDevice);
-
- #ifdef FW_BUILD_WIN
- ::ReleaseDC(NULL, fDC);
- #endif
- #ifdef FW_BUILD_MAC
- ::CloseCPort(&fCGrafPort);
- #endif
-
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CScreenContext::~FW_CScreenContext
- //----------------------------------------------------------------------------------------
-
- FW_CScreenContext::~FW_CScreenContext()
- {
- FW_START_DESTRUCTOR
-
- // ----- Terminate the superclass
- TerminateGraphicContext();
-
- // ----- Delete the device
- FW_PrivGDev_Release(fGraphicDevice);
-
- // ----- It is now safe to clean up the platform device
- #ifdef FW_BUILD_WIN
- ::ReleaseDC(NULL, fDC);
- #endif
- #ifdef FW_BUILD_MAC
- ::CloseCPort(&fCGrafPort);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CScreenContext::Reset
- //----------------------------------------------------------------------------------------
-
- void FW_CScreenContext::Reset()
- {
- // Nothing to do [HLX] Am i sure ?
- }