home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Border.cpp
-
- Contains: Implementation of active border display routines
-
- Owned by: Joshua Susser
-
- Copyright: © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <3> 10/4/96 JBS 1263682 don't smash active GrafPort, use
- correct colors
- <4> 6/20/95 JBS 1257315 change Facet::AcquireWindow to
- GetWindow
- <3> 5/26/95 RR #1251403: Multithreading naming support
- <2> 5/17/95 JBS 1242496 remove SOM_CATCH
- <1> 2/28/95 JBS first checked in
- <0> 2/28/95 JBS 1198509 created
- */
-
- /*
- These functions are private utilities for use by ODFacet to display and
- invalidate the active border. The functions are platform-dependent, in
- that they make direct calls to the platform graphics system.
- */
-
- #ifndef _BORDER_
- #include "Border.h"
- #endif
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
- #pragma segment ODFacet
-
- //==============================================================================
- // Constants
- //==============================================================================
-
- static const RGBColor rgbWhite = { 0xFFFF, 0xFFFF, 0xFFFF };
- static const RGBColor rgbBlack = { 0x0000, 0x0000, 0x0000 };
-
- //==============================================================================
- // Global variables
- //==============================================================================
-
- extern Pattern borderPattern;
-
- //==============================================================================
- // Functions
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // ODDrawBorder
- //------------------------------------------------------------------------------
-
- void
- ODDrawBorder(Environment *ev, ODShape* borderShape, ODFacet* facet)
- {
- GrafPtr savePort;
- GrafPtr usePort;
- RgnHandle saveClip;
- ODSShort saveH;
- ODSShort saveV;
- RGBColor saveBack;
- RGBColor saveFore;
-
- ODWindow* window = facet->GetWindow(ev);
- if ( window != kODNULL )
- {
- GetPort(&savePort);
-
- usePort = (GrafPtr)(window->GetRootFacet(ev)->
- GetCanvas(ev)->GetPlatformCanvas(ev, kODQuickDraw));
- SetPort(usePort);
-
- // save old GrafPort state so it can be restored later
- saveClip = ODNewRgn();
- GetClip(saveClip);
- saveH = usePort->portRect.left;
- saveV = usePort->portRect.top;
- GetBackColor(&saveBack);
- GetForeColor(&saveFore);
-
- // set the state we need
- SetOrigin(0,0);
- ClipRect(&(ODQDGlobals.thePort->portRect));
- RGBBackColor(&rgbWhite);
- RGBForeColor(&rgbBlack);
-
- // draw the border
- RgnHandle borderRgn = borderShape->GetQDRegion(ev);
- FillRgn(borderRgn, &borderPattern);
-
- // restore GrafPort state
- RGBBackColor(&saveBack);
- RGBForeColor(&saveFore);
- SetOrigin(saveH, saveV);
- SetClip(saveClip);
- ODDisposeHandle((Handle)saveClip);
-
- SetPort(savePort);
- }
- }
-
- //------------------------------------------------------------------------------
- // ODInvalidateBorder
- //------------------------------------------------------------------------------
-
- void
- ODInvalidateBorder(Environment *ev, ODShape* borderShape, ODFacet* facet)
- {
- GrafPtr savePort;
- GrafPtr usePort;
- RgnHandle saveClip;
- ODSShort saveH;
- ODSShort saveV;
-
- ODWindow* window = facet->GetWindow(ev);
- if ( window != kODNULL )
- {
- GetPort(&savePort);
-
- usePort = (GrafPtr)(window->GetRootFacet(ev)->
- GetCanvas(ev)->GetPlatformCanvas(ev, kODQuickDraw));
- SetPort(usePort);
-
- // save old GrafPort state so it can be restored later
- saveClip = ODNewRgn();
- GetClip(saveClip);
- saveH = usePort->portRect.left;
- saveV = usePort->portRect.top;
-
- // set the state we need
- SetOrigin(0,0);
- ClipRect(&(ODQDGlobals.thePort->portRect));
-
- // invalidate the border
- RgnHandle borderRgn = borderShape->GetQDRegion(ev);
- InvalRgn(borderRgn);
-
- // restore GrafPort state
- SetOrigin(saveH, saveV);
- SetClip(saveClip);
- ODDisposeHandle((Handle)saveClip);
-
- SetPort(savePort);
- }
- }
-
-