home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 13.2 KB | 466 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: PRShAttr.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPINK_H
- #define FWPINK_H
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #ifndef SLGCONST_K
- #include "SLGConst.k"
- #endif
-
- #ifndef SLSHATTR_H
- #include "SLShAttr.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifndef PRGRREF_H
- #include "PRGrRef.h"
- #endif
-
- #ifndef FWSTRING_H
- #include "FWString.h" // [KVV] SL using FWString
- #endif
-
- //========================================================================================
- // Forward class declartions
- //========================================================================================
-
- class FW_CReadableStream;
- class FW_CWritableStream;
-
- //========================================================================================
- // CLASS FW_CPrivPatternRep
- //========================================================================================
-
- class FW_CPrivPatternRep : public FW_CPrivGrRefObj
- {
- public:
- FW_DECLARE_CLASS
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- protected:
- FW_CPrivPatternRep();
-
- public:
- ~FW_CPrivPatternRep();
-
- //----------------------------------------------------------------------------------------
- // Memory management
- //
- #ifdef FW_NATIVE_EXCEPTIONS
- void* operator new(size_t size);
- void operator delete(void* p);
- #endif
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- virtual FW_CPrivPatternRep* Copy() const = 0;
-
- virtual FW_Boolean IsBlack() const = 0;
- virtual FW_Boolean IsEqual(const FW_CPrivPatternRep* rep) const = 0;
-
- virtual void Invert() = 0;
-
- virtual void FlipHorizontally() = 0;
- virtual void FlipVertically() = 0;
-
- virtual void ShiftUp() = 0;
- virtual void ShiftDown() = 0;
- virtual void ShiftLeft() = 0;
- virtual void ShiftRight() = 0;
-
- virtual void Flatten(FW_CWritableStream& stream) const = 0;
- static void Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object);
-
- //----------------------------------------------------------------------------------------
- // Platform Specific
- //
- public:
- #ifdef FW_BUILD_MAC
- virtual void MacSetInCurPort() const = 0;
- #endif
- #ifdef FW_BUILD_WIN
- virtual HBRUSH WinCreatePatternBrush() const = 0;
- #endif
- };
-
- typedef FW_CPrivGrRefPtr<FW_CPrivPatternRep> FW_PPrivPattern;
-
- //========================================================================================
- // CLASS FW_CPrivBWPatternRep
- //========================================================================================
-
- class FW_CPrivBWPatternRep : public FW_CPrivPatternRep
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CPrivBWPatternRep)
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CPrivBWPatternRep();
- FW_CPrivBWPatternRep(FW_CReadableStream& stream);
- FW_CPrivBWPatternRep(const FW_BitPattern& bits);
- ~FW_CPrivBWPatternRep();
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- virtual FW_CPrivPatternRep* Copy() const;
-
- virtual FW_Boolean IsBlack() const;
- virtual FW_Boolean IsEqual(const FW_CPrivPatternRep* rep) const;
-
- virtual void Invert();
-
- virtual void FlipHorizontally();
- virtual void FlipVertically();
-
- virtual void ShiftUp();
- virtual void ShiftDown();
- virtual void ShiftLeft();
- virtual void ShiftRight();
-
- virtual void Flatten(FW_CWritableStream& stream) const;
- static void* Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
-
- private:
- void MoveBitPattern(const void* source, void* destination)
- {FW_PrimitiveCopyMemory(source, destination, 8);}
-
- //----------------------------------------------------------------------------------------
- // Platform Specific
- //
- public:
- #ifdef FW_BUILD_WIN
- virtual HBRUSH WinCreatePatternBrush() const;
- #endif
- #ifdef FW_BUILD_MAC
- virtual void MacSetInCurPort() const;
- #endif
-
- //----------------------------------------------------------------------------------------
- // Data Member
- //
- private:
- FW_BitPattern fBitPattern; // ODF convention 1:foreground 0:background
- };
-
- //========================================================================================
- // CLASS FW_CPrivColorPatternRep
- //========================================================================================
-
- class FW_CPrivColorPatternRep : public FW_CPrivPatternRep
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CPrivColorPatternRep)
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CPrivColorPatternRep(const FW_PixelPattern& pixels, short nbColors, const FW_SColor* colorTable);
- FW_CPrivColorPatternRep(FW_PlatformColorPattern platformColorPattern);
- FW_CPrivColorPatternRep(FW_CReadableStream& stream);
- ~FW_CPrivColorPatternRep();
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- virtual FW_CPrivPatternRep* Copy() const;
-
- virtual FW_Boolean IsBlack() const;
- virtual FW_Boolean IsEqual(const FW_CPrivPatternRep* rep) const;
-
- virtual void Invert();
-
- virtual void FlipHorizontally();
- virtual void FlipVertically();
-
- virtual void ShiftUp();
- virtual void ShiftDown();
- virtual void ShiftLeft();
- virtual void ShiftRight();
-
- virtual void Flatten(FW_CWritableStream& stream) const;
- static void* Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
-
- private:
- void MakePixelPattern(const FW_PixelPattern& pixels, short nbColors, const FW_SColor* colorTable);
-
- void GetPixelData(FW_PixelPattern& pixData) const;
- void SetPixelData(const FW_PixelPattern& pixData);
-
- unsigned short GetColorTable(FW_SColor*& colors) const;
-
- //----------------------------------------------------------------------------------------
- // Platform Specific
- //
- public:
- #ifdef FW_BUILD_WIN
- virtual HBRUSH WinCreatePatternBrush() const;
-
- static void WinFlipPixelCopy(const void* source, void* dest);
- #endif
-
- #ifdef FW_BUILD_MAC
- virtual void MacSetInCurPort() const;
- static PixPatHandle MacNewPixPat(const void* pixels, short rowbytes, short pixelSize,
- short withPower, short heightPower,
- short nbColors, const FW_SColor* colorTable);
- #endif
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_PlatformColorPattern fPlatformColorPattern;
-
- #ifdef FW_BUILD_WIN
- HBITMAP fWinCachedBitmap;
- void WinForgetCachedBitmap();
- #endif
- };
-
- //========================================================================================
- // class FW_CPrivInkRep
- //========================================================================================
-
- class FW_CPrivInkRep : public FW_CPrivGrRefObj
- {
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CPrivInkRep(FW_SColor fore, FW_SColor back, FW_TransferModes mode);
- FW_CPrivInkRep(FW_EStandardInks std);
- FW_CPrivInkRep(const FW_CPrivInkRep& other);
- FW_CPrivInkRep(FW_CReadableStream& stream);
- ~FW_CPrivInkRep();
-
- //----------------------------------------------------------------------------------------
- // Memory management
- //
- #ifdef FW_NATIVE_EXCEPTIONS
- void* operator new(size_t size);
- void operator delete(void* p);
- #endif
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- void Write(FW_CWritableStream& stream) const;
- FW_Boolean IsEqual(const FW_CPrivInkRep* other) const;
-
- // ----- Accessors -----
- void SetForeColor(const FW_SColor& foreColor)
- {fForeColor = foreColor;}
- void GetForeColor(FW_SColor& foreColor) const
- {foreColor = fForeColor;}
- FW_CColor GetForeColor() const
- {return fForeColor;}
-
- void SetBackColor(const FW_SColor& backColor)
- {fBackColor = backColor;}
- void GetBackColor(FW_SColor& backColor) const
- {backColor = fBackColor;}
- FW_CColor GetBackColor() const
- {return fBackColor;}
-
- void SetTransferMode(FW_TransferModes transferMode)
- {fTransferMode = transferMode;}
- FW_TransferModes GetTransferMode() const
- {return fTransferMode;}
-
- //----------------------------------------------------------------------------------------
- // Public but for internal use only
- //
- public:
- FW_Boolean PrivSpecialTransferMode() const
- {return fTransferMode == FW_kInvert || fTransferMode == FW_kErase;}
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_CColor fForeColor;
- FW_CColor fBackColor;
- FW_TransferModes fTransferMode;
- };
-
- typedef FW_CPrivGrRefPtr<FW_CPrivInkRep> FW_PPrivInk;
-
- //========================================================================================
- // class FW_CPrivStyleRep
- //========================================================================================
-
- class FW_CPrivStyleRep : public FW_CPrivGrRefObj
- {
- public:
- FW_DECLARE_AUTO(FW_CPrivStyleRep)
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CPrivStyleRep(FW_Fixed penSize, FW_HPattern pattern);
- FW_CPrivStyleRep(FW_Fixed penSize, FW_EStyleDash dash);
- FW_CPrivStyleRep(const FW_CPrivStyleRep& other);
- FW_CPrivStyleRep(FW_CReadableStream& stream);
- FW_CPrivStyleRep(FW_EStandardStyles std);
-
- ~FW_CPrivStyleRep();
-
- //----------------------------------------------------------------------------------------
- // Memory management
- //
- public:
- #ifdef FW_NATIVE_EXCEPTIONS
- void* operator new(size_t size);
- void operator delete(void* p);
- #endif
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- void Write(FW_CWritableStream& stream) const;
- FW_Boolean IsEqual(const FW_CPrivStyleRep* other) const;
-
- // ----- Accessors -----
- void SetPenSize(FW_Fixed penSize)
- { fPenSize = penSize; }
- FW_Fixed GetPenSize() const
- { return fPenSize; }
-
- void SetPattern(FW_HPattern pattern)
- { fPattern = pattern; }
- FW_HPattern GetPattern()
- { return fPattern; }
- FW_HPattern GetUnSharedPattern();
-
- void SetDashStyle(FW_EStyleDash dash)
- { fDash = dash; }
- FW_EStyleDash GetDashStyle() const
- { return fDash; }
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_Fixed fPenSize;
- FW_EStyleDash fDash;
- FW_PPrivPattern fPattern;
- };
-
- typedef FW_CPrivGrRefPtr<FW_CPrivStyleRep> FW_PPrivStyle;
-
- //========================================================================================
- // class FW_CPrivFontRep
- //========================================================================================
-
- class FW_CPrivFontRep : public FW_CPrivGrRefObj
- {
- public:
- FW_DECLARE_AUTO(FW_CPrivFontRep)
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CPrivFontRep();
- FW_CPrivFontRep(const FW_CString& fontName, FW_FontStyle fontStyle, FW_Fixed fontSize);
- FW_CPrivFontRep(const FW_CPrivFontRep& otherRep);
- FW_CPrivFontRep(FW_EStandardFonts std);
- FW_CPrivFontRep(FW_CReadableStream& stream);
-
- ~FW_CPrivFontRep();
-
- //----------------------------------------------------------------------------------------
- // Memory management
- //
- public:
- #ifdef FW_NATIVE_EXCEPTIONS
- // [JEL] When using exception emulation a different technique must be used for
- // class-scoped allocation. See FWRepMem.cpp
- void* operator new(size_t size);
- void operator delete(void* p);
- #endif
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- void Write(FW_CWritableStream& stream) const;
- FW_Boolean IsEqual(const FW_CPrivFontRep* other) const;
-
- // ----- Accessors -----
- void SetFontSize(FW_Fixed fontSize)
- {fFontSize = fontSize;}
- FW_Fixed GetFontSize() const
- {return fFontSize;}
-
- void SetFontStyle(FW_FontStyle fontStyle);
- FW_FontStyle GetFontStyle() const
- {return fFontStyle;}
-
- void SetFontName(const FW_CString& fontName);
- void GetFontName(FW_CString& fontName) const
- {fontName = fFontName;}
-
- //----------------------------------------------------------------------------------------
- // Internal use Only
- //
- public:
- #ifdef FW_BUILD_MAC
- short MacGetFontID() const;
- Style MacGetFontStyle() const;
-
- void MacSetFontID(short macFontID);
-
- protected:
- void MacCheckFontCache();
- #endif
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_CString fFontName;
- FW_FontStyle fFontStyle;
- FW_Fixed fFontSize; // Font size always in point (1/72")
-
- #ifdef FW_BUILD_MAC
- FW_Boolean fMacValidCache;
- short fMacFontID;
- Style fMacFontStyle;
- FW_Boolean fMacFontNotFound;
- #endif
- };
-
- typedef FW_CPrivGrRefPtr<FW_CPrivFontRep> FW_PPrivFont;
-
- #endif // FWSHATTR_H
-