home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 7.8 KB | 284 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWGDev.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWGDEV_H
- #define FWGDEV_H
-
- #ifndef FWGRDEF_H
- #include "FWGrDef.h"
- #endif
-
- #ifndef FWGCONST_H
- #include "FWGConst.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(FWGDIOBJ_H)
- #include "FWGDIObj.h"
- #endif
-
- #ifdef SelectFont
- #undef SelectFont // Macro in Windowsx.h
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWREFCNT_H
- #include "FWRefCnt.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class FW_CLASS_ATTR ODShape;
- class FW_CLASS_ATTR FW_PInk;
- class FW_CLASS_ATTR FW_PStyle;
- class FW_CLASS_ATTR FW_PFont;
- class FW_CLASS_ATTR FW_CPoint;
- class FW_CLASS_ATTR FW_CRect;
- class FW_CLASS_ATTR FW_CGraphicContext;
-
- struct FW_CLASS_ATTR FW_SPlatformRect;
- struct FW_CLASS_ATTR FW_SPlatformPoint;
-
- //========================================================================================
- // class FW_CGraphicDevice
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CGraphicDevice : public FW_MRefCount
- {
- //---------------------------------------------------------------------------------------
- // Constructor/Destructor
- //
- public:
- FW_CGraphicDevice(Environment *ev, ODCanvas* odCanvas);
- FW_CGraphicDevice(Environment *ev, ODPlatformCanvas platformCanvas);
-
- virtual ~FW_CGraphicDevice();
-
- //---------------------------------------------------------------------------------------
- // API
- //
- public:
- ODPlatformCanvas GetPlatformCanvas() const;
- operator ODPlatformCanvas() const;
-
- ODCanvas* GetODCanvas() const;
-
- FW_SDeviceState* OpenDevice(Environment *ev, FW_CGraphicContext* context);
- void CloseDevice(Environment *ev, FW_SDeviceState* deviceState);
-
- ODRgnHandle GetClip() const; // return a copy
- void GetClipRect(FW_SPlatformRect& clipRect) const;
-
- void SetClip(ODRgnHandle clipRegion); // Use a copy
- void SetClipRect(const FW_SPlatformRect& clipRect);
- void IntersectClipRect(const FW_SPlatformRect& clipRect);
-
- void SetOrigin(FW_SPlatformPoint origin);
-
- FW_SDeviceState* GetState();
-
- FW_SSuspendResumeState* Suspend();
- void Resume(FW_SSuspendResumeState *suspendResumeState);
-
- void CanvasChanged(Environment *ev, ODCanvas* odCanvas);
- void MappingChanged();
-
- // ----- Return the resolution in dpi -----
- FW_CPoint GetResolution(Environment *ev) const;
- void SetResolution(const FW_CPoint& resolution);
-
- private:
- void UpdateOriginForContext();
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
- ODCanvas* fODCanvas; // Might be NULL
- ODPlatformCanvas fPlatformCanvas;
-
- short fOpenDeviceCount;
-
- FW_CPoint fResolution;
-
- FW_Boolean fSuspended;
-
- FW_CGraphicContext* fContext;
-
- Environment* fEV;
-
- //----------------------------------------------------------------------------------------
- // Platform Specific API
- //
- #ifdef FW_BUILD_WIN
- public:
- void SelectFont(const FW_PFont& font, FW_Boolean scale);
-
- FW_Boolean IsMetaFileCanvas() const;
-
- // ----- Settings -----
- void SelectInkAndFont(const FW_PInk& ink,
- const FW_PFont& font);
- FW_Boolean SelectInkAndStyle(const FW_PInk& ink,
- const FW_PStyle& style,
- FW_EShapeCategories shapeType,
- FW_ERenderVerbs renderVerb);
-
- void SetTextColor(COLORREF textColor);
- void SetBkColor(COLORREF bkColor);
-
- protected:
- // ----- We don't bother doing any caching for those, they should be pretty fast -----
- void SetDrawingMode(int drawingMode)
- {::SetROP2(fPlatformCanvas, drawingMode);}
- void SetBkMode(int bkMode)
- {::SetBkMode(fPlatformCanvas, bkMode);}
- #endif
- #ifdef FW_BUILD_MAC
- public:
- // ----- Settings -----
- void SelectInk(const FW_PInk& ink,
- FW_EShapeCategories shapeCategory,
- FW_ERenderVerbs renderVerb);
- FW_Boolean SelectStyle(const FW_PStyle& style,
- FW_TransferModes transferMode);
- void SelectFont(const FW_PFont& font,
- FW_Boolean scale);
-
- void SetInGrafPort();
- void ResetSettings();
-
- // Values for fChangeFlag
- enum
- {
- FW_kForeColorChanged = 0x0001,
- FW_kBackColorChanged = 0x0002,
- FW_kHiliteColorChanged = 0x0004,
- FW_kPatternChanged = 0x0008
- };
-
- void SetForeColor(const FW_CColor& foreColor)
- {fForeColor = foreColor; fChangeFlag |= FW_kForeColorChanged;}
- void SetBackColor(const FW_CColor& backColor)
- {fBackColor = backColor; fChangeFlag |= FW_kBackColorChanged;}
- void SetHiliteColor(const FW_CColor& hiliteColor)
- {fHiliteColor = hiliteColor; fChangeFlag |= FW_kHiliteColorChanged;}
- void SetPattern(const FW_PPattern& pattern);
- void SetPenSize(short hPenSize, short vPenSize)
- {fHPenSize = hPenSize; fVPenSize = vPenSize;}
- void SetFontID(short fontID)
- {fFontID = fontID;}
- void SetFontSize(short fontSize)
- {fFontSize = fontSize;}
- void SetFontStyle(Style fontStyle)
- {fFontStyle = fontStyle;}
- void SetPenMode(short penMode)
- {fPenMode = penMode;}
- void SetTextMode(short textMode)
- {fTextMode = textMode;}
-
- static void SetHiliteMode();
-
- private:
- void MacBeginPostScriptClip(RgnHandle rgn);
- void MacEndPostScriptClip();
- #endif
-
- //----------------------------------------------------------------------------------------
- // Platform Specific Data Members
- //
- #ifdef FW_BUILD_WIN
- public:
- // ----- Settings -----
- COLORREF fTextColor;
- COLORREF fBkColor;
- FW_SPlatformPoint fPenSize; // Used for frame with brush
-
- // ----- Brush/Pen/Font -----
- FW_CPrivGDIPen fGDIPen;
- FW_CPrivGDIBrush fGDIBrush;
- FW_CPrivGDIFont fGDIFont;
- #endif
- #ifdef FW_BUILD_MAC
- public:
- // ----- Device Settings -----
- FW_CColor fForeColor;
- FW_CColor fBackColor;
- FW_CColor fHiliteColor;
- FW_PPattern fPattern;
- short fHPenSize;
- short fVPenSize;
- short fFontID;
- short fFontSize;
- Style fFontStyle;
- short fPenMode;
- short fTextMode;
-
- private:
- unsigned short fChangeFlag;
-
- // ----- PostScript clipping
- FW_Boolean fMacPostScriptClip;
- #endif
- };
-
- //---------------------------------------------------------------------------------------
- // FW_CGraphicDevice::GetODCanvas
- //---------------------------------------------------------------------------------------
- inline ODCanvas* FW_CGraphicDevice::GetODCanvas() const
- {
- return fODCanvas;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CGraphicDevice::GetPlatformCanvas
- //---------------------------------------------------------------------------------------
- inline ODPlatformCanvas FW_CGraphicDevice::GetPlatformCanvas() const
- {
- return fPlatformCanvas;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CGraphicDevice::operator ODPlatformCanvas
- //---------------------------------------------------------------------------------------
- inline FW_CGraphicDevice::operator ODPlatformCanvas() const
- {
- return fPlatformCanvas;
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-