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 / FWTxtShp.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  4.4 KB  |  154 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWTxtShp.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWTXTSHP_H
  11. #define FWTXTSHP_H
  12.  
  13. #ifndef FWBTXTSH_H
  14. #include "FWBTxtSh.h"
  15. #endif
  16.  
  17. #ifndef FWGCONST_H
  18. #include "FWGConst.h"
  19. #endif
  20.  
  21. //========================================================================================
  22. //    class FW_CTextShape
  23. //========================================================================================
  24.  
  25. class FW_CTextShape : public FW_CBaseTextShape
  26. {
  27. public:
  28.     FW_DECLARE_CLASS
  29.     FW_DECLARE_AUTO(FW_CTextShape)
  30.  
  31. //----------------------------------------------------------------------------------------
  32. //    Constructors/Destructors
  33. //
  34. public:
  35.  
  36.     enum
  37.     {
  38.         kDefaultAlignment = 
  39.             FW_kTextAlignLeft |
  40.             FW_kTextAlignTop |
  41.             FW_kTextAlignUseSpecifiedPos
  42.     };
  43.  
  44.     FW_CTextShape();
  45.     FW_CTextShape(const FW_CString& string,
  46.                   FW_Fixed xPos,
  47.                   FW_Fixed yPos,
  48.                   const FW_CFont& font = FW_kNormalFont,
  49.                   FW_TextAlignment textAlignment = kDefaultAlignment,
  50.                   const FW_CInk& ink = FW_kNormalTextInk);
  51.                   
  52.     FW_CTextShape(FW_CTextReader& textReader,
  53.                   FW_Fixed xPos,
  54.                   FW_Fixed yPos,
  55.                   const FW_CFont& font = FW_kNormalFont,
  56.                   FW_TextAlignment textAlignment = kDefaultAlignment,
  57.                   const FW_CInk& ink = FW_kNormalTextInk);
  58.                     
  59.     FW_CTextShape(const FW_CTextShape& other);
  60.     FW_CTextShape(FW_CReadableStream& stream);
  61.     
  62.     virtual ~ FW_CTextShape();
  63.     
  64. //----------------------------------------------------------------------------------------
  65. //    Operators
  66. //
  67. public:
  68.     FW_CTextShape& operator=(const FW_CTextShape& other);
  69.     
  70. //----------------------------------------------------------------------------------------
  71. //    Inherited API
  72. //
  73. public:
  74.     // ----- Rendering -----
  75.     virtual void                 Render(FW_CGraphicContext& gc) const;
  76.                             
  77.     // ----- Transform -----
  78.     virtual void                Transform(Environment* ev, ODTransform* odTransform);
  79.     virtual void                InverseTransform(Environment* ev, ODTransform* odTransform);
  80.  
  81.     virtual void                MoveShape(FW_Fixed deltaX, FW_Fixed deltaY);
  82.     virtual void                MoveShapeTo(FW_Fixed x, FW_Fixed y);
  83.  
  84.     virtual void                Inset(FW_Fixed x, FW_Fixed y);
  85.     
  86.     // ----- Copying -----
  87.     virtual FW_CShape*            Copy() const;
  88.     
  89.     // ----- Geometry -----
  90.     virtual void                 GetBounds(FW_CGraphicContext& gc, FW_CRect& rect) const;
  91.     
  92.     // ----- Anchor Point -----
  93.     virtual FW_CPoint            GetAnchorPoint() const;
  94.     
  95.     // ----- Flatten -----
  96.     virtual void                Flatten(FW_CWritableStream& stream) const;
  97.  
  98. //----------------------------------------------------------------------------------------
  99. //    New API
  100. //
  101. public:
  102.     // ----- Rendering -----
  103.     static void                 RenderText(FW_CGraphicContext& gc,
  104.                                               FW_CTextReader& textReader,
  105.                                               const FW_CPoint& position,
  106.                                               const FW_CFont& font,
  107.                                               FW_TextAlignment textAlignment = kDefaultAlignment,
  108.                                               const FW_CInk& ink = FW_kNormalTextInk);
  109.  
  110.     static void                 RenderText(FW_CGraphicContext& gc,
  111.                                               const FW_CString& string,
  112.                                               const FW_CPoint& position,
  113.                                               const FW_CFont& font,
  114.                                               FW_TextAlignment textAlignment = kDefaultAlignment,
  115.                                               const FW_CInk& ink = FW_kNormalTextInk);
  116.  
  117.     // ----- Measurement -----
  118.     FW_CPoint                    CalcExtent(FW_CGraphicContext& gc) const;
  119.     
  120.     static FW_CPoint            CalcTextExtent(FW_CGraphicContext& gc,
  121.                                               FW_CTextReader& textReader,
  122.                                               const FW_CFont& font);
  123.     static FW_CPoint            CalcTextExtent(FW_CGraphicContext& gc,
  124.                                               const FW_CString& string,
  125.                                               const FW_CFont& font);
  126.     
  127.     // ----- Archiving -----
  128.     static void*                 Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
  129.  
  130.     // ----- Geometry -----
  131.     FW_CPoint                    GetPosition() const
  132.                                     {return fPosition;}
  133.  
  134.     void                        SetPosition(FW_Fixed xPos, FW_Fixed yPos)
  135.                                     {fPosition.x = xPos, fPosition.y = yPos;}
  136.  
  137.     FW_TextAlignment            GetTextAlignment() const
  138.                                     {return fTextAlignment;}                                
  139.     void                        SetTextAlignment(FW_TextAlignment textAlignment)
  140.                                     {fTextAlignment = textAlignment;}
  141.     
  142.     void                        GetBaseLine(FW_CGraphicContext& gc,
  143.                                             FW_CPoint& start, FW_CPoint& end) const;
  144.     
  145. //----------------------------------------------------------------------------------------
  146. //    Data Members
  147. //
  148. protected:
  149.     FW_CPoint                    fPosition;
  150.     FW_TextAlignment            fTextAlignment;
  151. };
  152.  
  153. #endif
  154.