home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / RADIOBUT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  2.5 KB  |  95 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1991, 1993 by Borland International
  3. //   source\owl\radiobut.cpp
  4. //   Implementation of class TRadioButton.  This defines the basic behavior
  5. //   for all radio buttons.
  6. //----------------------------------------------------------------------------
  7. #pragma hdrignore SECTION
  8. #include <owl\owlpch.h>
  9. #include <owl\radiobut.h>
  10. #include <owl\groupbox.h>
  11. #include <owl\applicat.h>
  12. #include <bwcc.h>
  13.  
  14. #if !defined(SECTION) || SECTION == 1
  15.  
  16. DEFINE_RESPONSE_TABLE1(TRadioButton, TCheckBox)
  17.   EV_NOTIFY_AT_CHILD(BN_CLICKED, BNClicked),
  18. END_RESPONSE_TABLE;
  19.  
  20. //
  21. // constructor for a TRadioButton object
  22. //
  23. TRadioButton::TRadioButton(TWindow*        parent,
  24.                            int             id,
  25.                            const char far* title,
  26.                            int x, int y, int w, int h,
  27.                            TGroupBox*      group,
  28.                            TModule*        module)
  29.   : TCheckBox(parent, id, title, x, y, w, h, group, module)
  30. {
  31.   Attr.Style = WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON;
  32. }
  33.  
  34. TRadioButton::TRadioButton(TWindow*   parent,
  35.                            int        resourceId,
  36.                            TGroupBox* group,
  37.                            TModule*   module)
  38.   : TCheckBox(parent, resourceId, group, module)
  39. {
  40. }
  41.  
  42. //
  43. // Return name of predefined BWCC or Windows radio button class
  44. //
  45. char far*
  46. TRadioButton::GetClassName()
  47. {
  48.   if (GetApplication()->BWCCEnabled())
  49.     return RADIO_CLASS;
  50.   else
  51.     return "BUTTON";
  52. }
  53.  
  54. //
  55. // responds to an incoming BN_CLICKED message.
  56. //
  57. // need to see if it's checked because Windows generates two BN_CLICKED
  58. // messages on keyboard input such as up arrow(but only one on mouse input),
  59. // and we should only handle the one after it's checked
  60. //
  61. void
  62. TRadioButton::BNClicked()
  63. {
  64.   if (GetCheck())
  65.     TCheckBox::BNClicked();
  66.  
  67.   else
  68.     DefaultProcessing();
  69. }
  70.  
  71. #endif
  72. #if !defined(SECTION) || SECTION == 2
  73.  
  74. IMPLEMENT_STREAMABLE1(TRadioButton, TCheckBox);
  75.  
  76. //
  77. // reads an instance of TRadioButton from the passed ipstream
  78. //
  79. void*
  80. TRadioButton::Streamer::Read(ipstream& is, uint32 /*version*/) const
  81. {
  82.   ReadBaseObject((TCheckBox*)GetObject(), is);
  83.   return GetObject();
  84. }
  85.  
  86. //
  87. // writes the TRadioButton to the passed opstream
  88. //
  89. void
  90. TRadioButton::Streamer::Write(opstream& os) const
  91. {
  92.   WriteBaseObject((TCheckBox*)GetObject(), os);
  93. }
  94. #endif
  95.