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

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1991, 1993 by Borland International
  3. //   source\owl\groupbox.cpp
  4. //   Implementation of class TGroupBox.  This defines the basic behavior
  5. //   for all group boxes.
  6. //----------------------------------------------------------------------------
  7. #pragma hdrignore SECTION
  8. #include <owl\owlpch.h>
  9. #include <owl\groupbox.h>
  10. #include <owl\applicat.h>
  11. #include <bwcc.h>
  12.  
  13. #if !defined(SECTION) || SECTION == 1
  14.  
  15. //
  16. // constructor for a TGroupBox object
  17. //
  18. // by default, the parent window is notified when the state of the group box's
  19. // selection boxes has changed
  20. //
  21. TGroupBox::TGroupBox(TWindow*        parent,
  22.                      int             id,
  23.                      const char far* text,
  24.                      int x, int y, int w, int h,
  25.                      TModule*        module)
  26.   : TControl(parent, id, text, x, y, w, h, module)
  27. {
  28.   NotifyParent = TRUE;
  29.   Attr.Style = (Attr.Style | BS_GROUPBOX) & ~WS_TABSTOP;
  30. }
  31.  
  32. //
  33. // Return name of predefined BWCC shade or Windows groupbox class
  34. //
  35. char far* 
  36. TGroupBox::GetClassName()
  37. {
  38.   if (GetApplication()->BWCCEnabled())
  39.     return SHADE_CLASS;
  40.   else
  41.     return "BUTTON";
  42. }
  43.  
  44. //
  45. // constructor for a TGroupBox to be associated with a MS-Windows interface
  46. // element created by MS-Windows from a resource definition
  47. //
  48. // by default, the parent window is notified when the state of the group box's
  49. // selection boxes has changed
  50. //
  51. // disables transfer of state data for the TGroupBox
  52. //
  53. TGroupBox::TGroupBox(TWindow*   parent,
  54.                      int        resourceId,
  55.                      TModule*   module)
  56.   : TControl(parent, resourceId, module)
  57. {
  58.   NotifyParent = TRUE;
  59.   DisableTransfer();
  60. }
  61.  
  62. //
  63. // notifies parent that the selection in the associated groupbox has
  64. // changed
  65. //
  66. // this method is called by TCheckBoxes grouped in the groupbox when
  67. // their state changes
  68. //
  69. void
  70. TGroupBox::SelectionChanged(int controlId)
  71. {
  72.   if (NotifyParent)
  73.     #if defined(__WIN32__)
  74.       Parent->PostMessage(WM_COMMAND, MAKEWPARAM(Attr.Id, controlId),
  75.                           (LPARAM) HWindow);
  76.     #else
  77.       Parent->PostMessage(WM_COMMAND, Attr.Id, MAKELPARAM(HWindow, controlId));
  78.     #endif
  79. }
  80.  
  81. #endif
  82. #if !defined(SECTION) || SECTION == 2
  83.  
  84. IMPLEMENT_STREAMABLE1(TGroupBox, TControl);
  85.  
  86. //
  87. // reads an instance of TGroupBox from the passed ipstream
  88. //
  89. void*
  90. TGroupBox::Streamer::Read(ipstream& is, uint32 /*version*/) const
  91. {
  92.   ReadBaseObject((TControl*)GetObject(), is);
  93.   is >> GetObject()->NotifyParent;
  94.   return GetObject();
  95. }
  96.  
  97. //
  98. // writes the TGroupBox to the passed opstream
  99. //
  100. void
  101. TGroupBox::Streamer::Write(opstream& os) const
  102. {
  103.   WriteBaseObject((TControl*)GetObject(), os);
  104.   os << GetObject()->NotifyParent;
  105. }
  106. #endif
  107.