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

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