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

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