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 / Framewrk / FWViews / FWStatic.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.4 KB  |  174 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWStatic.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10.  
  11. #ifndef FWSTATIC_H
  12. #define FWSTATIC_H
  13.  
  14. #ifndef FWVIEW_H
  15. #include "FWView.h"
  16. #endif
  17.  
  18. #ifndef FWSTRING_H
  19. #include "FWString.h"
  20. #endif
  21.  
  22. #ifndef FWTXTBOX_H
  23. #include "FWTxtBox.h"
  24. #endif
  25.  
  26. //========================================================================================
  27. //    Forward Declarations
  28. //========================================================================================
  29.  
  30. //========================================================================================
  31. //    class FW_CStaticText
  32. //========================================================================================
  33.  
  34. class FW_CStaticText: public FW_CView
  35. {
  36. public:
  37.     FW_DECLARE_CLASS
  38.     FW_DECLARE_AUTO(FW_CStaticText)
  39.  
  40. //----------------------------------------------------------------------------------------
  41. //    Initialization/Destruction
  42. //
  43.     FW_CStaticText(Environment* ev, 
  44.                     FW_CSuperView* container, 
  45.                     const FW_CRect& bounds,
  46.                     ODID viewID,
  47.                     const FW_CString& text,
  48.                     const FW_CFont& font = FW_kNormalFont,  
  49.                     FW_TextBoxOptions options = FW_kTextBoxClipToBox,
  50.                     const FW_CInk& ink = FW_kNormalTextInk);  
  51.     
  52.     FW_CStaticText(Environment* ev, 
  53.                     FW_CSuperView* container,
  54.                     ODID viewID,
  55.                     const FW_CTextBoxShape& textboxshape);
  56.     
  57.     FW_CStaticText(Environment* ev);
  58.                 
  59.     ~FW_CStaticText();
  60.     
  61. //----------------------------------------------------------------------------------------
  62. //    New API
  63. //    
  64.     void                GetText(Environment* ev, FW_CString& text) const;
  65.     void                SetText(Environment* ev, const FW_CString& text, FW_ERedrawVerb redraw = FW_kInvalidate);
  66.     FW_CTextBoxShape*    GetTextBoxShape(Environment* ev);
  67.     
  68.     void                SetEraseColor(const FW_CColor& eraseColor);
  69.     
  70. //----------------------------------------------------------------------------------------
  71. //    FW_CView API
  72. //    
  73.     virtual void         Draw (Environment* ev, ODFacet* facet, ODShape* invalidShape);
  74.  
  75. //----------------------------------------------------------------------------------------
  76. //    Archiving
  77. //    
  78.     static void*        Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
  79.     static void            Destroy(void* object, FW_ClassTypeConstant type);
  80.     virtual void        Flatten(Environment* ev, FW_CWritableStream& stream) const;
  81.     virtual void        InitializeFromStream(Environment* ev, FW_CReadableStream& stream);
  82.     
  83. private:
  84.     void                 Initialize(Environment* ev, 
  85.                                     const FW_CRect& bounds, 
  86.                                     const FW_CString& text,
  87.                                     const FW_CFont& font, 
  88.                                     FW_TextBoxOptions options, 
  89.                                     const FW_CInk& ink);
  90. private:
  91.     FW_CTextBoxShape*    fTextBoxShape;
  92.     FW_CColor            fEraseColor;
  93.     FW_Boolean            fEraseOnDraw;
  94. };
  95.  
  96. //----------------------------------------------------------------------------------------
  97. //    FW_CStaticText::GetTextBoxShape
  98. //----------------------------------------------------------------------------------------
  99. inline FW_CTextBoxShape* FW_CStaticText::GetTextBoxShape(Environment*)
  100. {
  101.     return fTextBoxShape;
  102. }
  103.  
  104. //----------------------------------------------------------------------------------------
  105. //    FW_CStaticText::GetText
  106. //----------------------------------------------------------------------------------------
  107. inline void    FW_CStaticText::GetText(Environment*, FW_CString& text) const
  108. {
  109.     fTextBoxShape->GetString(text);
  110. }
  111.  
  112. //----------------------------------------------------------------------------------------
  113. //    FW_CStaticText::SetEraseColor
  114. //----------------------------------------------------------------------------------------
  115. inline void FW_CStaticText::SetEraseColor(const FW_CColor& eraseColor)
  116. {
  117.     fEraseColor = eraseColor;
  118. }
  119.  
  120. //========================================================================================
  121. //    class FW_CGroupBox
  122. //========================================================================================
  123.  
  124. class FW_CGroupBox: public FW_CStaticText
  125. {
  126. public:
  127.     FW_DECLARE_CLASS
  128.     FW_DECLARE_AUTO(FW_CGroupBox)
  129.  
  130.     FW_CGroupBox (Environment* ev, 
  131.                     FW_CSuperView* container, 
  132.                     const FW_CRect& bounds,
  133.                     ODID viewID,
  134.                     const FW_CString& text, 
  135.                     const FW_CFont& font = FW_kNormalFont,  
  136.                     FW_TextBoxOptions options = FW_kTextBoxClipToBox,
  137.                     const FW_CInk& textInk = FW_kNormalTextInk,  
  138.                     const FW_CInk& frameInk = FW_kNormalInk);
  139.  
  140.     FW_CGroupBox (Environment* ev, 
  141.                     FW_CSuperView* container,
  142.                     ODID viewID,
  143.                     const FW_CTextBoxShape& textbox,
  144.                     const FW_CInk& frameInk = FW_kNormalInk);
  145.                     
  146.     FW_CGroupBox(Environment* ev);
  147.                 
  148.     ~FW_CGroupBox();
  149.     
  150. //----------------------------------------------------------------------------------------
  151. //    FW_CView API
  152. //
  153.     virtual void         Draw (Environment* ev, ODFacet* facet, ODShape* invalidShape);
  154.  
  155. //----------------------------------------------------------------------------------------
  156. //    Archiving
  157. //
  158.     static void*        Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
  159.     static void            Destroy(void* object, FW_ClassTypeConstant type);
  160.     virtual void        Flatten(Environment* ev, FW_CWritableStream& stream) const;
  161.     virtual void        InitializeFromStream(Environment* ev, FW_CReadableStream& stream);
  162.     
  163. protected:
  164.     void        SetLabelRect(Environment* ev, FW_CGraphicContext& gc, FW_CRect& rect);
  165.  
  166. private:
  167.     FW_CInk        fFrameInk;
  168. };
  169.  
  170.  
  171. #endif
  172.  
  173.  
  174.