home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / PRShAttr.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  13.2 KB  |  466 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                PRShAttr.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWPINK_H
  11. #define FWPINK_H
  12.  
  13. #ifndef FWCOLOR_H
  14. #include "FWColor.h"
  15. #endif
  16.  
  17. #ifndef SLGCONST_K
  18. #include "SLGConst.k"
  19. #endif
  20.  
  21. #ifndef SLSHATTR_H
  22. #include "SLShAttr.h"
  23. #endif
  24.  
  25. #ifndef FWFXMATH_H
  26. #include "FWFxMath.h"
  27. #endif
  28.  
  29. #ifndef PRGRREF_H
  30. #include "PRGrRef.h"
  31. #endif
  32.  
  33. #ifndef FWSTRING_H
  34. #include "FWString.h"    // [KVV] SL using FWString
  35. #endif
  36.  
  37. //========================================================================================
  38. //    Forward class declartions
  39. //========================================================================================
  40.  
  41. class FW_CReadableStream;
  42. class FW_CWritableStream;
  43.  
  44. //========================================================================================
  45. //    CLASS FW_CPrivPatternRep
  46. //========================================================================================
  47.  
  48. class    FW_CPrivPatternRep : public FW_CPrivGrRefObj
  49. {
  50. public:
  51.     FW_DECLARE_CLASS
  52. //----------------------------------------------------------------------------------------
  53. //    Constructors/Destructors
  54. //
  55. protected:
  56.     FW_CPrivPatternRep();
  57.  
  58. public:
  59.     ~FW_CPrivPatternRep();
  60.  
  61. //----------------------------------------------------------------------------------------
  62. //    Memory management
  63. //
  64. #ifdef FW_NATIVE_EXCEPTIONS
  65.     void*                operator new(size_t size);
  66.     void                operator delete(void* p);
  67. #endif
  68.  
  69. //----------------------------------------------------------------------------------------
  70. //    New API
  71. //
  72. public:
  73.     virtual FW_CPrivPatternRep*    Copy() const = 0;
  74.  
  75.     virtual FW_Boolean            IsBlack() const = 0;
  76.     virtual FW_Boolean            IsEqual(const FW_CPrivPatternRep* rep) const = 0;
  77.     
  78.     virtual void                Invert() = 0;
  79.  
  80.     virtual void                FlipHorizontally() = 0;
  81.     virtual void                FlipVertically() = 0;
  82.     
  83.     virtual void                ShiftUp() = 0;
  84.     virtual void                ShiftDown() = 0;
  85.     virtual void                ShiftLeft() = 0;
  86.     virtual void                ShiftRight() = 0;
  87.  
  88.     virtual void                Flatten(FW_CWritableStream& stream) const = 0;
  89.     static void                 Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object);
  90.  
  91. //----------------------------------------------------------------------------------------
  92. //    Platform Specific
  93. //
  94. public:
  95. #ifdef FW_BUILD_MAC
  96.     virtual void                MacSetInCurPort() const = 0;    
  97. #endif
  98. #ifdef FW_BUILD_WIN
  99.     virtual HBRUSH                WinCreatePatternBrush() const = 0;    
  100. #endif
  101. };
  102.  
  103. typedef FW_CPrivGrRefPtr<FW_CPrivPatternRep> FW_PPrivPattern;
  104.  
  105. //========================================================================================
  106. //    CLASS FW_CPrivBWPatternRep
  107. //========================================================================================
  108.  
  109. class    FW_CPrivBWPatternRep : public FW_CPrivPatternRep
  110. {
  111. public:
  112.     FW_DECLARE_CLASS
  113.     FW_DECLARE_AUTO(FW_CPrivBWPatternRep)
  114.  
  115. //----------------------------------------------------------------------------------------
  116. //    Constructors/Destructors
  117. //
  118. public:
  119.     FW_CPrivBWPatternRep();
  120.     FW_CPrivBWPatternRep(FW_CReadableStream& stream);
  121.     FW_CPrivBWPatternRep(const FW_BitPattern& bits);
  122.     ~FW_CPrivBWPatternRep();
  123.  
  124. //----------------------------------------------------------------------------------------
  125. //    Inherited API
  126. //
  127. public:    
  128.     virtual FW_CPrivPatternRep*    Copy() const;
  129.  
  130.     virtual FW_Boolean        IsBlack() const;
  131.     virtual FW_Boolean        IsEqual(const FW_CPrivPatternRep* rep) const;
  132.     
  133.     virtual void             Invert();
  134.     
  135.     virtual void            FlipHorizontally();
  136.     virtual void            FlipVertically();
  137.     
  138.     virtual void            ShiftUp();
  139.     virtual void            ShiftDown();
  140.     virtual void            ShiftLeft();
  141.     virtual void            ShiftRight();    
  142.  
  143.     virtual void            Flatten(FW_CWritableStream& stream) const;
  144.     static void*            Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
  145.  
  146. private:
  147.     void                    MoveBitPattern(const void* source, void* destination)
  148.                                 {FW_PrimitiveCopyMemory(source, destination, 8);}
  149.  
  150. //----------------------------------------------------------------------------------------
  151. //    Platform Specific
  152. //
  153. public:
  154. #ifdef FW_BUILD_WIN
  155.     virtual HBRUSH            WinCreatePatternBrush() const;    
  156. #endif
  157. #ifdef FW_BUILD_MAC
  158.     virtual void            MacSetInCurPort() const;    
  159. #endif
  160.  
  161. //----------------------------------------------------------------------------------------
  162. //    Data Member
  163. //
  164. private:    
  165.     FW_BitPattern        fBitPattern;        // ODF convention 1:foreground     0:background
  166. };
  167.  
  168. //========================================================================================
  169. //    CLASS FW_CPrivColorPatternRep
  170. //========================================================================================
  171.  
  172. class    FW_CPrivColorPatternRep : public FW_CPrivPatternRep
  173. {    
  174. public:
  175.     FW_DECLARE_CLASS
  176.     FW_DECLARE_AUTO(FW_CPrivColorPatternRep)
  177.  
  178. //----------------------------------------------------------------------------------------
  179. //    Constructors/Destructors
  180. //
  181. public:
  182.     FW_CPrivColorPatternRep(const FW_PixelPattern& pixels, short nbColors, const FW_SColor* colorTable);
  183.     FW_CPrivColorPatternRep(FW_PlatformColorPattern platformColorPattern);
  184.     FW_CPrivColorPatternRep(FW_CReadableStream& stream);
  185.     ~FW_CPrivColorPatternRep();
  186.  
  187. //----------------------------------------------------------------------------------------
  188. //    Inherited API
  189. //
  190. public:    
  191.     virtual FW_CPrivPatternRep*    Copy() const;
  192.  
  193.     virtual FW_Boolean        IsBlack() const;
  194.     virtual FW_Boolean        IsEqual(const FW_CPrivPatternRep* rep) const;
  195.     
  196.     virtual void             Invert();
  197.     
  198.     virtual void            FlipHorizontally();
  199.     virtual void            FlipVertically();
  200.     
  201.     virtual void            ShiftUp();
  202.     virtual void            ShiftDown();
  203.     virtual void            ShiftLeft();
  204.     virtual void            ShiftRight();    
  205.     
  206.     virtual void            Flatten(FW_CWritableStream& stream) const;
  207.     static void*            Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
  208.  
  209. private:
  210.     void                        MakePixelPattern(const FW_PixelPattern& pixels, short nbColors, const FW_SColor* colorTable);
  211.  
  212.     void                        GetPixelData(FW_PixelPattern& pixData) const;
  213.     void                        SetPixelData(const FW_PixelPattern& pixData);
  214.     
  215.     unsigned short                GetColorTable(FW_SColor*& colors) const;
  216.  
  217. //----------------------------------------------------------------------------------------
  218. //    Platform Specific
  219. //
  220. public:
  221. #ifdef FW_BUILD_WIN
  222.     virtual HBRUSH                WinCreatePatternBrush() const;
  223.  
  224.     static void                    WinFlipPixelCopy(const void* source, void* dest);
  225. #endif
  226.  
  227. #ifdef FW_BUILD_MAC
  228.     virtual void                MacSetInCurPort() const;    
  229.     static PixPatHandle            MacNewPixPat(const void* pixels, short rowbytes, short pixelSize, 
  230.                                             short withPower, short heightPower,
  231.                                             short nbColors, const FW_SColor* colorTable);
  232. #endif
  233.  
  234. //----------------------------------------------------------------------------------------
  235. //    Data Members
  236. //
  237. private:
  238.     FW_PlatformColorPattern        fPlatformColorPattern;
  239.     
  240. #ifdef FW_BUILD_WIN
  241.     HBITMAP                        fWinCachedBitmap;
  242.     void                        WinForgetCachedBitmap();
  243. #endif
  244. };
  245.  
  246. //========================================================================================
  247. //    class FW_CPrivInkRep
  248. //========================================================================================
  249.  
  250. class FW_CPrivInkRep : public FW_CPrivGrRefObj
  251. {
  252. //----------------------------------------------------------------------------------------
  253. //    Constructors/Destructors
  254. //
  255. public:
  256.     FW_CPrivInkRep(FW_SColor fore, FW_SColor back, FW_TransferModes mode);
  257.     FW_CPrivInkRep(FW_EStandardInks std);
  258.     FW_CPrivInkRep(const FW_CPrivInkRep& other);
  259.     FW_CPrivInkRep(FW_CReadableStream& stream);
  260.     ~FW_CPrivInkRep();
  261.  
  262. //----------------------------------------------------------------------------------------
  263. //    Memory management
  264. //
  265. #ifdef FW_NATIVE_EXCEPTIONS
  266.     void*                operator new(size_t size);
  267.     void                operator delete(void* p);
  268. #endif
  269.  
  270. //----------------------------------------------------------------------------------------
  271. //    New API
  272. //
  273. public:
  274.     void                Write(FW_CWritableStream& stream) const;
  275.     FW_Boolean             IsEqual(const FW_CPrivInkRep* other) const;
  276.  
  277.     // ----- Accessors -----
  278.     void                SetForeColor(const FW_SColor& foreColor)
  279.                             {fForeColor = foreColor;}
  280.     void                GetForeColor(FW_SColor& foreColor) const
  281.                             {foreColor = fForeColor;}
  282.     FW_CColor            GetForeColor() const
  283.                             {return fForeColor;}
  284.  
  285.     void                SetBackColor(const FW_SColor& backColor)
  286.                             {fBackColor = backColor;}
  287.     void                GetBackColor(FW_SColor& backColor) const
  288.                             {backColor = fBackColor;}
  289.     FW_CColor            GetBackColor() const
  290.                             {return fBackColor;}
  291.     
  292.     void                SetTransferMode(FW_TransferModes transferMode)
  293.                             {fTransferMode = transferMode;}
  294.     FW_TransferModes    GetTransferMode() const
  295.                             {return fTransferMode;}
  296.     
  297. //----------------------------------------------------------------------------------------
  298. //    Public but for internal use only
  299. //
  300. public:
  301.     FW_Boolean    PrivSpecialTransferMode() const
  302.                     {return fTransferMode == FW_kInvert || fTransferMode == FW_kErase;}
  303.     
  304. //----------------------------------------------------------------------------------------
  305. //    Data Members
  306. //
  307. private:
  308.     FW_CColor            fForeColor;
  309.     FW_CColor            fBackColor;
  310.     FW_TransferModes     fTransferMode;
  311. };
  312.  
  313. typedef FW_CPrivGrRefPtr<FW_CPrivInkRep> FW_PPrivInk;
  314.  
  315. //========================================================================================
  316. //    class FW_CPrivStyleRep
  317. //========================================================================================
  318.  
  319. class FW_CPrivStyleRep : public FW_CPrivGrRefObj
  320. {
  321. public:
  322.     FW_DECLARE_AUTO(FW_CPrivStyleRep)
  323.  
  324. //----------------------------------------------------------------------------------------
  325. //    Constructors/Destructors
  326. //
  327. public:
  328.     FW_CPrivStyleRep(FW_Fixed penSize, FW_HPattern pattern);
  329.     FW_CPrivStyleRep(FW_Fixed penSize, FW_EStyleDash dash);
  330.     FW_CPrivStyleRep(const FW_CPrivStyleRep& other);
  331.     FW_CPrivStyleRep(FW_CReadableStream& stream);
  332.     FW_CPrivStyleRep(FW_EStandardStyles std);
  333.  
  334.     ~FW_CPrivStyleRep();
  335.  
  336. //----------------------------------------------------------------------------------------
  337. //    Memory management
  338. //
  339. public:
  340. #ifdef FW_NATIVE_EXCEPTIONS
  341.     void*                operator new(size_t size);
  342.     void                operator delete(void* p);
  343. #endif
  344.  
  345. //----------------------------------------------------------------------------------------
  346. //    New API
  347. //
  348. public:
  349.     void                Write(FW_CWritableStream& stream) const;
  350.     FW_Boolean             IsEqual(const FW_CPrivStyleRep* other) const;
  351.  
  352.     // ----- Accessors -----
  353.     void                SetPenSize(FW_Fixed penSize)
  354.                             { fPenSize = penSize; }
  355.     FW_Fixed             GetPenSize() const
  356.                             { return fPenSize; }
  357.  
  358.     void                SetPattern(FW_HPattern pattern)
  359.                             { fPattern = pattern; }
  360.     FW_HPattern            GetPattern()
  361.                             { return fPattern; }
  362.     FW_HPattern            GetUnSharedPattern();
  363.  
  364.     void                SetDashStyle(FW_EStyleDash dash)
  365.                             { fDash = dash; }
  366.     FW_EStyleDash        GetDashStyle() const
  367.                             { return fDash; }
  368.  
  369. //----------------------------------------------------------------------------------------
  370. //    Data Members
  371. //
  372. private:
  373.     FW_Fixed            fPenSize;
  374.     FW_EStyleDash        fDash;
  375.     FW_PPrivPattern        fPattern;
  376. };
  377.  
  378. typedef FW_CPrivGrRefPtr<FW_CPrivStyleRep> FW_PPrivStyle;
  379.  
  380. //========================================================================================
  381. //    class FW_CPrivFontRep
  382. //========================================================================================
  383.  
  384. class    FW_CPrivFontRep : public FW_CPrivGrRefObj
  385. {
  386. public:
  387.     FW_DECLARE_AUTO(FW_CPrivFontRep)
  388.  
  389. //----------------------------------------------------------------------------------------
  390. //    Constructors/Destructors
  391. //
  392. public:
  393.     FW_CPrivFontRep();    
  394.     FW_CPrivFontRep(const FW_CString& fontName, FW_FontStyle fontStyle, FW_Fixed fontSize);
  395.     FW_CPrivFontRep(const FW_CPrivFontRep& otherRep);
  396.     FW_CPrivFontRep(FW_EStandardFonts std);
  397.     FW_CPrivFontRep(FW_CReadableStream& stream);
  398.  
  399.     ~FW_CPrivFontRep();
  400.  
  401. //----------------------------------------------------------------------------------------
  402. //    Memory management
  403. //
  404. public:
  405. #ifdef FW_NATIVE_EXCEPTIONS
  406. // [JEL] When using exception emulation a different technique must be used for
  407. // class-scoped allocation.  See FWRepMem.cpp
  408.     void*                operator new(size_t size);
  409.     void                operator delete(void* p);
  410. #endif
  411.  
  412. //----------------------------------------------------------------------------------------
  413. //    New API
  414. //
  415. public:
  416.     void                Write(FW_CWritableStream& stream) const;
  417.     FW_Boolean             IsEqual(const FW_CPrivFontRep* other) const;
  418.  
  419.     // ----- Accessors -----
  420.     void                SetFontSize(FW_Fixed fontSize)
  421.                             {fFontSize = fontSize;}
  422.     FW_Fixed            GetFontSize() const
  423.                             {return fFontSize;}
  424.  
  425.     void                SetFontStyle(FW_FontStyle fontStyle);
  426.     FW_FontStyle         GetFontStyle() const
  427.                             {return fFontStyle;}
  428.  
  429.     void                SetFontName(const FW_CString& fontName);
  430.     void                GetFontName(FW_CString& fontName) const
  431.                             {fontName = fFontName;}
  432.  
  433. //----------------------------------------------------------------------------------------
  434. //    Internal use Only
  435. //
  436. public:    
  437. #ifdef FW_BUILD_MAC
  438.     short                MacGetFontID() const;
  439.     Style                MacGetFontStyle() const;
  440.     
  441.     void                MacSetFontID(short macFontID);
  442.  
  443. protected:
  444.     void                MacCheckFontCache();
  445. #endif
  446.                 
  447. //----------------------------------------------------------------------------------------
  448. //    Data Members
  449. //
  450. private:
  451.     FW_CString            fFontName;
  452.     FW_FontStyle        fFontStyle;
  453.     FW_Fixed            fFontSize;        // Font size always in point (1/72")
  454.  
  455. #ifdef FW_BUILD_MAC
  456.     FW_Boolean            fMacValidCache;
  457.     short                fMacFontID;
  458.     Style                fMacFontStyle;
  459.     FW_Boolean            fMacFontNotFound;
  460. #endif
  461. };
  462.  
  463. typedef FW_CPrivGrRefPtr<FW_CPrivFontRep> FW_PPrivFont;
  464.  
  465. #endif // FWSHATTR_H
  466.