home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / TEXTGADG.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  1.6 KB  |  63 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   include\owl\textwidg.h
  4. //   Base class TGadget.
  5. //----------------------------------------------------------------------------
  6. #if !defined(__OWL_TEXTGADG_H)
  7. #define __OWL_TEXTGADG_H
  8.  
  9. #if !defined(__OWL_GADGET_H)
  10.   #include "owl\gadget.h"
  11. #endif
  12.  
  13. //
  14. //  class TTextGadget
  15. //  ----- -----------
  16. //
  17. //  when constructing the text gadget specify how many characters you want
  18. //  room for and how the text should be aligned horizontally
  19. //
  20. //  the inner bounds are computed by multiplying the number of characters by
  21. //  the maximum character width
  22. //
  23. class _OWLCLASS TTextGadget : public TGadget {
  24.   public:
  25.     enum TAlign {Left, Center, Right};
  26.  
  27.     TTextGadget(int id = 0, TBorderStyle = Recessed, TAlign = Left, UINT numChars = 10, const char* text = 0);
  28.    ~TTextGadget();
  29.  
  30.     const char*   GetText() const {return Text;}
  31.  
  32.     //
  33.     // makes a copy of the text
  34.     //
  35.     void    SetText(const char *text);
  36.  
  37.   protected:
  38.     //
  39.     // override virtual methods defined in TGadget
  40.     //
  41.     void    Paint(TDC& dc);
  42.     void    GetDesiredSize(TSize &size);
  43.     void    Invalidate();
  44.  
  45.   private:
  46.     UINT    GetMaxCharWidth();
  47.  
  48.   protected:
  49.     char*    Text;
  50.     UINT     TextLen;
  51.     TAlign   Align;
  52.     UINT     NumChars;
  53.  
  54.   private:
  55.     //
  56.     // hidden to prevent accidental copying or assignment
  57.     //
  58.     TTextGadget(const TTextGadget&);
  59.     TTextGadget& operator =(const TTextGadget&);
  60. };
  61.  
  62. #endif  // __OWL_TEXTGADG_H
  63.