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

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