home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / owlsrc.pak / RADIOBUT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  2.5 KB  |  98 lines

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