home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / owlsrc.pak / CONTROLG.CPP < prev    next >
C/C++ Source or Header  |  1997-07-23  |  2KB  |  85 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1992, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Implementation of class TControlGadget.
  6. //----------------------------------------------------------------------------
  7. #include <owl/owlpch.h>
  8. #include <owl/controlg.h>
  9. #include <owl/gadgetwi.h>
  10.  
  11. TControlGadget::TControlGadget(TWindow& control, TBorderStyle border)
  12. :
  13.   TGadget(control.Attr.Id, border)
  14. {
  15.   Control = &control;
  16. }
  17.  
  18. TControlGadget::~TControlGadget()
  19. {
  20.   Control->Destroy(0);
  21.   delete Control;
  22. }
  23.  
  24. void
  25. TControlGadget::SetBounds(TRect& bounds)
  26. {
  27.   TGadget::SetBounds(bounds);
  28.   Control->Attr.X = Bounds.left;
  29.   Control->Attr.Y = Bounds.top;
  30.   Control->Attr.W = Bounds.Width();
  31.   Control->Attr.H = Bounds.Height();
  32.   if (Control->HWindow)
  33.     Control->MoveWindow(Bounds);  
  34. }
  35.  
  36. void
  37. TControlGadget::GetDesiredSize(TSize& size)
  38. {
  39.   TGadget::GetDesiredSize(size);
  40.  
  41.   if (ShrinkWrapWidth)
  42.     size.cx += Control->Attr.W;
  43.   if (ShrinkWrapHeight)
  44.     size.cy += Control->Attr.H;
  45. }
  46.  
  47. void
  48. TControlGadget::Inserted()
  49. {
  50.   Control->SetParent(Window);
  51.   if (Window->HWindow && !Control->HWindow) {
  52.     Control->Create();
  53.     Control->ShowWindow(SW_NORMAL);
  54.   }
  55. }
  56.  
  57. void
  58. TControlGadget::Removed()
  59. {
  60.   Control->SetParent(0);
  61. }
  62.  
  63. void
  64. TControlGadget::InvalidateRect(const TRect& rect, bool erase)
  65. {
  66.   if (Control->HWindow)
  67.     Control->InvalidateRect(rect, erase);
  68. }
  69.  
  70. void
  71. TControlGadget::Invalidate(bool erase)
  72. {
  73.   InvalidateRect(TRect(0, 0, Bounds.Width(), Bounds.Height()), erase);
  74. }
  75.  
  76. //
  77. // cause owning window to paint now if possible
  78. //
  79. void
  80. TControlGadget::Update()
  81. {
  82.   if (Control->HWindow)
  83.     Control->UpdateWindow();
  84. }
  85.