home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / STATUSBA.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  3KB  |  98 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1992, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Class TStatusBar.
  6. //----------------------------------------------------------------------------
  7. #if !defined(OWL_STATUSBA_H)
  8. #define OWL_STATUSBA_H
  9.  
  10. #if !defined(OWL_MESSAGEB_H)
  11. # include <owl/messageb.h>
  12. #endif
  13. #if !defined(OWL_TEXTGADG_H)
  14. # include <owl/textgadg.h>
  15. #endif
  16.  
  17. //
  18. //  class TStatusBar
  19. //  ----- ----------
  20. //
  21. //  status bars have more options than a plain message bar: you can have
  22. //  multiple text gadgets, different style borders, and you can reserve space
  23. //  for mode indicators
  24. //
  25. class _OWLCLASS TStatusBar : public TMessageBar {
  26.   public:
  27.     enum TModeIndicator {
  28.       ExtendSelection = 1,
  29.       CapsLock        = 1 << 1,
  30.       NumLock         = 1 << 2,
  31.       ScrollLock      = 1 << 3,
  32.       Overtype        = 1 << 4,
  33.       RecordingMacro  = 1 << 5
  34.     };
  35.  
  36.     TStatusBar(TWindow*              parent = 0,
  37.                TGadget::TBorderStyle borderStyle = TGadget::Recessed,
  38.                uint                  modeIndicators = 0,
  39.                TFont*                font = new TGadgetWindowFont,
  40.                TModule*              module = 0);
  41.  
  42.     //
  43.     // by default, adds "gadget" after the existing text gadgets and before
  44.     // the mode indicator gadgets. sets the border style to the style specified
  45.     // during construction.
  46.     //
  47.     void        Insert(TGadget& gadget, TPlacement = After, TGadget* sibling = 0);
  48.  
  49.     TGadget*    operator [](uint index);  // can't access mode indicator gadgets
  50.  
  51.     //
  52.     // in order for the mode indicator status to appear you must have
  53.     // specified the mode when the window was constructed
  54.     //
  55.     bool        GetModeIndicator(TModeIndicator i) const 
  56.                   {return (ModeIndicatorState & i) ? 1 : 0;}
  57.     void        SetModeIndicator(TModeIndicator, bool state);
  58.     void        ToggleModeIndicator(TModeIndicator);
  59.  
  60.     struct TSpacing {
  61.       TMargins::TUnits  Units;
  62.       int               Value;
  63.  
  64.       TSpacing() {Units = TMargins::LayoutUnits; Value = 0;}
  65.     };
  66.  
  67.     //
  68.     // sets the spacing to be used between mode indicator gadgets
  69.     //
  70.     void        SetSpacing(TSpacing& spacing) {Spacing = spacing;}
  71.  
  72.   protected:
  73.     TGadget::TBorderStyle  BorderStyle;
  74.     TSpacing               Spacing;
  75.     uint                   NumModeIndicators;
  76.     uint                   ModeIndicators;
  77.     uint                   ModeIndicatorState;
  78.  
  79.     void        PositionGadget(TGadget* previous, TGadget* next, TPoint& point);
  80.     bool        PreProcessMsg(MSG& msg);
  81.     bool        IdleAction(long);
  82.  
  83.   private:
  84.     bool        GetGadgetAndStrings(TModeIndicator mode, TTextGadget*& gadget,
  85.                                     const char*& strOn, const char*& strOff);
  86.     bool        IsModeIndicator(TGadget* gadget);
  87.  
  88.     //
  89.     // hidden to prevent accidental copying or assignment
  90.     //
  91.     TStatusBar(const TStatusBar&);
  92.     TStatusBar& operator =(const TStatusBar&);
  93.  
  94.   DECLARE_CASTABLE;
  95. };
  96.  
  97. #endif  // OWL_STATUSBA_H
  98.