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

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1991, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Defines class TCheckBox.  This defines the basic behavior
  6. //   for all check boxes.
  7. //----------------------------------------------------------------------------
  8. #if !defined(OWL_CHECKBOX_H)
  9. #define OWL_CHECKBOX_H
  10.  
  11. #if !defined(OWL_BUTTON_H)
  12. # include <owl/button.h>
  13. #endif
  14.  
  15. class _OWLCLASS TGroupBox;
  16.  
  17. //
  18. // Checkbox flags indicating check state
  19. //
  20. enum {
  21.   BF_CHECKED   = 0x01,
  22.   BF_GRAYED    = 0x02,
  23.   BF_UNCHECKED = 0x0
  24. };
  25.  
  26. //
  27. //  class TCheckBox
  28. //  ----- ---------
  29. //
  30. class _OWLCLASS TCheckBox : public TButton {
  31.   public:
  32.     TGroupBox*  Group;
  33.  
  34.     TCheckBox(TWindow*        parent,
  35.               int             id,
  36.               const char far* title,
  37.               int x, int y, int w, int h,
  38.               TGroupBox*      group = 0,
  39.               TModule*        module = 0);
  40.  
  41.     TCheckBox(TWindow*   parent,
  42.               int        resourceId,
  43.               TGroupBox* group = 0,
  44.               TModule*   module = 0);
  45.  
  46.     void       Check() {SetCheck(BF_CHECKED);}
  47.     void       Uncheck() {SetCheck(BF_UNCHECKED);}
  48.     void       Toggle();
  49.  
  50.     uint       GetCheck() const;
  51.     void       SetCheck(uint check);
  52.  
  53.     uint       GetState() const;
  54.     void       SetState(uint state) {SendMessage(BM_SETSTATE, state);}
  55.  
  56.     void       SetStyle(uint style, bool redraw);
  57.  
  58.     //
  59.     // Override TWindow virtual member functions
  60.     //
  61.     uint       Transfer(void* buffer, TTransferDirection direction);
  62.  
  63.   protected:
  64.     //
  65.     //  override TButton's processing so drawable check boxes and radio
  66.     //  buttons work properly
  67.     //
  68.     uint       EvGetDlgCode(MSG far*) {return (uint)DefaultProcessing();}
  69.  
  70.     //
  71.     // child id notification
  72.     //
  73.     void       BNClicked();  // BN_CLICKED
  74.  
  75.     char far*  GetClassName();
  76.  
  77.   private:
  78.     //
  79.     // hidden to prevent accidental copying or assignment
  80.     //
  81.     TCheckBox(const TCheckBox&);
  82.     TCheckBox& operator =(const TCheckBox&);
  83.  
  84.   DECLARE_RESPONSE_TABLE(TCheckBox);
  85.   DECLARE_STREAMABLE(_OWLCLASS, TCheckBox, 1);
  86. };
  87.  
  88. inline uint TCheckBox::GetCheck() const {
  89.   return (uint)CONST_CAST(TCheckBox*, this)->SendMessage(BM_GETCHECK);
  90. }
  91.  
  92. inline uint TCheckBox::GetState() const {
  93.   return (uint)CONST_CAST(TCheckBox*, this)->SendMessage(BM_GETSTATE);
  94. }
  95.  
  96. inline void TCheckBox::SetStyle(uint style, bool redraw) {
  97.   SendMessage(BM_SETSTYLE, style, MAKELPARAM(redraw,0));
  98. }
  99.  
  100. #endif  // OWL_CHECKBOX_H
  101.