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

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   source\owl\gadgetwi.cpp
  4. //   Defines class TGadgetWindow.
  5. //----------------------------------------------------------------------------
  6. #include <owl\owlpch.h>
  7. #include <owl\gadget.h>
  8. #include <owl\gadgetwi.h>
  9.  
  10. DEFINE_RESPONSE_TABLE1(TGadgetWindow, TWindow)
  11.   EV_WM_CTLCOLOR,
  12.   EV_WM_LBUTTONDOWN,
  13.   EV_WM_LBUTTONUP,
  14.   EV_WM_MOUSEMOVE,
  15.   EV_WM_SIZE,
  16.   EV_WM_SYSCOLORCHANGE,
  17. END_RESPONSE_TABLE;
  18.  
  19. static inline int
  20. HeightInPixels(int pointSize)
  21. {
  22.   TScreenDC  dc;
  23.  
  24.   return MulDiv(-pointSize, dc.GetDeviceCaps(LOGPIXELSY), 72);
  25. }
  26.  
  27. TGadgetWindowFont::TGadgetWindowFont(int pointSize, BOOL bold, BOOL italic)
  28.   : TFont("MS Sans Serif", HeightInPixels(pointSize), 0, 0, 0,
  29.           bold ? FW_BOLD : FW_NORMAL,
  30.           BYTE(VARIABLE_PITCH | FF_SWISS), BYTE(italic))
  31. {
  32. }
  33.  
  34. TGadgetWindow::TGadgetWindow(TWindow*       parent,
  35.                              TTileDirection direction,
  36.                              TFont*         font,
  37.                              TModule*       module)
  38.   : TWindow(parent, 0, module)
  39. {
  40.   PRECONDITION(font);
  41.  
  42.   Attr.Style |= WS_BORDER;
  43.   Capture = 0;
  44.   AtMouse = 0;
  45.   Font = font;
  46.   Direction = direction;
  47.   if (Direction == Horizontal) {
  48.     ShrinkWrapWidth = FALSE;
  49.     ShrinkWrapHeight = TRUE;
  50.  
  51.   } else {
  52.     ShrinkWrapWidth = TRUE;
  53.     ShrinkWrapHeight = FALSE;
  54.   }
  55.   HintMode = PressHints;
  56.  
  57.   WideAsPossible = 0;  // number of gadgets with "WideAsPossible" set
  58.   DirtyLayout = TRUE;
  59.   Gadgets = 0;
  60.   NumGadgets = 0;
  61.  
  62.   //
  63.   // compute the font height
  64.   //
  65.   TScreenDC   dc;
  66.   TEXTMETRIC  metrics;
  67.  
  68.   dc.SelectObject(*Font);
  69.   dc.GetTextMetrics(metrics);
  70.   FontHeight = metrics.tmHeight + metrics.tmExternalLeading;
  71.  
  72.   //
  73.   // choose a default height based on the height of the font plus room
  74.   // for a top and bottom border
  75.   //
  76.   Attr.H = FontHeight;
  77.  
  78.   if (Attr.Style & WS_BORDER)
  79.     Attr.H += 2 * GetSystemMetrics(SM_CYBORDER);
  80.  
  81.   SetBkgndColor(GetSysColor(COLOR_BTNFACE));
  82.   BkgndBrush = new TBrush(GetSysColor(COLOR_BTNFACE));
  83. }
  84.  
  85. TGadgetWindow::~TGadgetWindow()
  86. {
  87.   TGadget* gadget = Gadgets;
  88.  
  89.   while (gadget) {
  90.     TGadget*  tmp = gadget;
  91.  
  92.     gadget = gadget->Next;
  93.     delete tmp;
  94.   }
  95.  
  96.   delete Font;
  97.   delete BkgndBrush;
  98. }
  99.  
  100. void
  101. TGadgetWindow::EvSysColorChange()
  102. {
  103.   for (TGadget* g = Gadgets; g; g = g->NextGadget())
  104.     g->SysColorChange();
  105.   SetBkgndColor(GetSysColor(COLOR_BTNFACE));
  106.   delete BkgndBrush;
  107.   BkgndBrush = new TBrush(GetSysColor(COLOR_BTNFACE));
  108. }
  109.  
  110. BOOL
  111. TGadgetWindow::IdleAction(long idleCount)
  112. {
  113.   if (idleCount == 0) {
  114.     // See if we missed a mouse move & still need to send a MouseLeave to a 
  115.     // gadget 
  116.     //
  117.     if (AtMouse) {
  118.       TPoint crsPoint;
  119.       GetCursorPos(crsPoint);
  120.       if (WindowFromPoint(crsPoint) != HWindow)
  121.         HandleMessage(WM_MOUSEMOVE, 0, MAKELPARAM(-1,-1));  // nowhere
  122.     }
  123.  
  124.     // Let the gadgets do command enabling if they need to
  125.     //
  126.     for (TGadget* g = Gadgets; g; g = g->NextGadget())
  127.       g->CommandEnable();
  128.   }
  129.   return TWindow::IdleAction(idleCount);
  130. }
  131.  
  132. TGadget*
  133. TGadgetWindow::GadgetWithId(int id) const
  134. {
  135.   for (TGadget* g = Gadgets; g; g = g->NextGadget())
  136.     if (g->GetId() == id)
  137.       return g;
  138.  
  139.   return 0;
  140. }
  141.  
  142. void
  143. TGadgetWindow::SetShrinkWrap(BOOL shrinkWrapWidth, BOOL shrinkWrapHeight)
  144. {
  145.   ShrinkWrapWidth = shrinkWrapWidth;
  146.   ShrinkWrapHeight = shrinkWrapHeight;
  147. }
  148.  
  149. BOOL
  150. TGadgetWindow::GadgetSetCapture(TGadget& gadget)
  151. {
  152.   if (Capture)
  153.     return FALSE;
  154.  
  155.   else {
  156.     Capture = &gadget;
  157.     SetCapture();
  158.     return TRUE;
  159.   }
  160. }
  161.  
  162. void
  163. TGadgetWindow::GadgetReleaseCapture(TGadget& gadget)
  164. {
  165.   if (&gadget == Capture) {
  166.     Capture = 0;
  167.     ReleaseCapture();
  168.   }
  169. }
  170.  
  171. //
  172. // Simulate menu select & idle messages to our parent so that it can display
  173. // hint text the same way it does for menu commands
  174. //
  175. void
  176. TGadgetWindow::SetHintCommand(int id)
  177. {
  178.   if (Parent) {
  179.     if (id >= 0)
  180.       Parent->HandleMessage(WM_MENUSELECT, id, 0);
  181.  
  182.     else
  183.       // Send a menuselect w/ flags==0xFFFF and hMenu==0 to indicate end
  184.       //
  185.     #if defined(__WIN32__)
  186.       Parent->HandleMessage(WM_MENUSELECT, 0xFFFF0000, 0); // flags+item, hmenu
  187.     #else
  188.       Parent->HandleMessage(WM_MENUSELECT, 0, 0x0000FFFFL);// item, hmenu+flags
  189.     #endif
  190.     Parent->HandleMessage(WM_ENTERIDLE, MSGF_MENU);
  191.   }
  192. }
  193.  
  194. void
  195. TGadgetWindow::SetMargins(TMargins& margins)
  196. {
  197.   Margins = margins;
  198.   LayoutSession();
  199. }
  200.  
  201. int
  202. TGadgetWindow::LayoutUnitsToPixels(int units)
  203. {
  204.   const long  UnitsPerEM = 8;
  205.  
  206.   return int((long(units) * FontHeight + UnitsPerEM / 2) / UnitsPerEM);
  207. }
  208.  
  209. void
  210. TGadgetWindow::GetMargins(TMargins& margins,
  211.                           int& left, int& right, int& top, int& bottom)
  212. {
  213.   switch (margins.Units) {
  214.     case TMargins::Pixels:
  215.       left = margins.Left;
  216.       top = margins.Top;
  217.       right = margins.Right;
  218.       bottom = margins.Bottom;
  219.       break;
  220.  
  221.     case TMargins::LayoutUnits:
  222.       left = LayoutUnitsToPixels(margins.Left);
  223.       top = LayoutUnitsToPixels(margins.Top);
  224.       right = LayoutUnitsToPixels(margins.Right);
  225.       bottom = LayoutUnitsToPixels(margins.Bottom);
  226.       break;
  227.  
  228.     case TMargins::BorderUnits:
  229.       int  cxBorder = GetSystemMetrics(SM_CXBORDER);
  230.       int  cyBorder = GetSystemMetrics(SM_CYBORDER);
  231.  
  232.       left = margins.Left * cxBorder;
  233.       top = margins.Top * cyBorder;
  234.       right = margins.Right * cxBorder;
  235.       bottom = margins.Bottom * cyBorder;
  236.       break;
  237.   }
  238. }
  239.  
  240. void
  241. TGadgetWindow::LayoutSession()
  242. {
  243.   if (HWindow)
  244.     InvalidateRect(TileGadgets());
  245. }
  246.  
  247. void
  248. TGadgetWindow::GetDesiredSize(TSize& size)
  249. {
  250.   int       left, right, top, bottom;
  251.   int       maxWidth = 0, maxHeight = 0;
  252.   TGadget*  lastGadget = 0;
  253.  
  254.   GetMargins(Margins, left, right, top, bottom);
  255.  
  256.   if (ShrinkWrapWidth || ShrinkWrapHeight) {
  257.     for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next) {
  258.       TSize  size;
  259.  
  260.       gadget->GetDesiredSize(size);
  261.  
  262.       if (size.cx > maxWidth)
  263.         maxWidth = size.cx;
  264.  
  265.       if (size.cy > maxHeight)
  266.         maxHeight = size.cy;
  267.     }
  268.  
  269.     //
  270.     // in some cases we need to actually tile the gadgets in order to tell how
  271.     // much room is needed
  272.     //
  273.     if (Direction == Horizontal && ShrinkWrapWidth ||
  274.         Direction == Vertical && ShrinkWrapHeight) {
  275.       TileGadgets();
  276.  
  277.       for (lastGadget = Gadgets; lastGadget && lastGadget->Next; lastGadget = lastGadget->Next)
  278.         ;
  279.     }
  280.   }
  281.  
  282.   if (!ShrinkWrapWidth)
  283.     size.cx = Attr.W;
  284.  
  285.   else if (Direction == Horizontal) {
  286.     size.cx = right;
  287.  
  288.     if (lastGadget)
  289.       size.cx += lastGadget->GetBounds().right;
  290.  
  291.   } else {
  292.     size.cx = left + right + maxWidth;
  293.  
  294.     if (Attr.Style & WS_BORDER)
  295.       size.cx += 2 * GetSystemMetrics(SM_CXBORDER);
  296.   }
  297.  
  298.   if (!ShrinkWrapHeight)
  299.     size.cy = Attr.H;
  300.  
  301.   else if (Direction == Vertical) {
  302.     size.cx = bottom;
  303.  
  304.     if (lastGadget)
  305.       size.cx += lastGadget->GetBounds().bottom;
  306.  
  307.   } else {
  308.     size.cy = top + bottom + maxHeight;
  309.  
  310.     if (Attr.Style & WS_BORDER)
  311.       size.cy += 2 * GetSystemMetrics(SM_CYBORDER);
  312.   }
  313. }
  314.  
  315. BOOL
  316. TGadgetWindow::Create()
  317. {
  318.   TSize  size;
  319.  
  320.   GetDesiredSize(size);
  321.  
  322.   if (ShrinkWrapWidth)
  323.     Attr.W = size.cx;
  324.  
  325.   if (ShrinkWrapHeight)
  326.     Attr.H = size.cy;
  327.  
  328.   return TWindow::Create();
  329. }
  330.  
  331. //
  332. // Set direction, & default shrink wrap flags. If already created, then also
  333. // adjust shrink wrap dimension & re-layout
  334. //
  335. void
  336. TGadgetWindow::SetDirection(TTileDirection direction)
  337. {
  338.   if (Direction != direction) {
  339.     Direction = direction;
  340.     if (Direction == Horizontal) {
  341.       ShrinkWrapWidth = FALSE;
  342.       ShrinkWrapHeight = TRUE;
  343.  
  344.     } else {
  345.       ShrinkWrapWidth = TRUE;
  346.       ShrinkWrapHeight = FALSE;
  347.     }
  348.     //
  349.     // Swap margin's X & Y axis
  350.     //
  351.     int t = Margins.Left; Margins.Left = Margins.Top; Margins.Top = t;
  352.     t = Margins.Right; Margins.Right = Margins.Bottom; Margins.Bottom = t;
  353.  
  354.     if (HWindow) {
  355.       TSize  size;
  356.       GetDesiredSize(size);
  357.  
  358.       if (ShrinkWrapWidth)
  359.         Attr.W = size.cx;
  360.  
  361.       if (ShrinkWrapHeight)
  362.         Attr.H = size.cy;
  363.  
  364.       LayoutSession();
  365.     }
  366.   }
  367. }
  368.  
  369. void
  370. TGadgetWindow::GetInnerRect(TRect& rect)
  371. {
  372.   int left, right, top, bottom;
  373.   GetMargins(Margins, left, right, top, bottom);
  374.  
  375.   rect.left = left;
  376.   rect.right = Attr.W - right;
  377.   rect.top = top;
  378.   rect.bottom = Attr.H - bottom;
  379.  
  380.   if (Attr.Style & WS_BORDER) {
  381.     rect.right -= 2 * GetSystemMetrics(SM_CYBORDER);
  382.     rect.bottom -= 2 * GetSystemMetrics(SM_CXBORDER);
  383.   }
  384. }
  385.  
  386. void
  387. TGadgetWindow::PositionGadget(TGadget*, TGadget*, TPoint&)
  388. {
  389. }
  390.  
  391. TRect
  392. TGadgetWindow::TileHorizontally()
  393. {
  394.   TRect  innerRect;
  395.   TRect  invalidRect;
  396.   int    width = 0;
  397.   int    x;
  398.  
  399.   GetInnerRect(innerRect);
  400.   invalidRect.SetEmpty();
  401.  
  402.   //
  403.   // first pass tally the width of all gadgets that don't have "WideAsPossible"
  404.   // set
  405.   //
  406.   // NOTE: we must also take into account any adjustments to the gadget spacing
  407.   //
  408.   for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next) {
  409.     if (!gadget->WideAsPossible) {
  410.       TSize   desiredSize;
  411.  
  412.       gadget->GetDesiredSize(desiredSize);
  413.       width += desiredSize.cx;
  414.     }
  415.  
  416.     if (gadget->Next) {
  417.       TPoint  spacing(0, 0);
  418.  
  419.       PositionGadget(gadget, gadget->Next, spacing);
  420.       width += spacing.x;
  421.     }
  422.   }
  423.  
  424.   //
  425.   // now tile all the gadgets
  426.   //
  427.   x = innerRect.left;
  428.   for (gadget = Gadgets; gadget; gadget = gadget->Next) {
  429.     TRect  bounds = gadget->Bounds;
  430.     TRect  originalBounds(bounds);
  431.     TSize  desiredSize;
  432.  
  433.     bounds.left = x;
  434.     gadget->GetDesiredSize(desiredSize);
  435.     bounds.top = innerRect.top + (innerRect.Height() - desiredSize.cy) / 2;
  436.     bounds.bottom = bounds.top + desiredSize.cy;
  437.  
  438.     if (gadget->WideAsPossible)
  439.       bounds.right = bounds.left + (innerRect.Width() - width) / WideAsPossible;
  440.  
  441.     else
  442.       bounds.right = bounds.left + desiredSize.cx;
  443.  
  444.     if (bounds != originalBounds) {
  445.       gadget->SetBounds(bounds);
  446.       invalidRect |= bounds;
  447.  
  448.       if (originalBounds.TopLeft() != TPoint(0, 0))
  449.         invalidRect |= originalBounds;
  450.     }
  451.     x += bounds.Width();
  452.  
  453.     if (gadget->Next) {
  454.       TPoint  origin(x, 0);
  455.  
  456.       PositionGadget(gadget, gadget->Next, origin);
  457.       x = origin.x;
  458.     }
  459.   }
  460.   return invalidRect;
  461. }
  462.  
  463. TRect
  464. TGadgetWindow::TileVertically()
  465. {
  466.   TRect  innerRect;
  467.   TRect  invalidRect;
  468.   int    y;
  469.  
  470.   GetInnerRect(innerRect);
  471.   invalidRect.SetEmpty();
  472.  
  473.   //
  474.   // now tile all the gadgets
  475.   //
  476.   y = innerRect.top;
  477.   for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next) {
  478.     TRect  bounds = gadget->Bounds;
  479.     TRect  originalBounds(bounds);
  480.     TSize  desiredSize;
  481.  
  482.     gadget->GetDesiredSize(desiredSize);
  483.     bounds.top = y;
  484.     bounds.bottom = bounds.top + desiredSize.cy;
  485.     bounds.left = innerRect.left + (innerRect.Width() - desiredSize.cx) / 2;
  486.     bounds.right = bounds.left + desiredSize.cx;
  487.  
  488.     if (bounds != originalBounds) {
  489.       gadget->SetBounds(bounds);
  490.       invalidRect |= bounds;
  491.  
  492.       if (originalBounds.TopLeft () != TPoint (0, 0))
  493.         invalidRect |= originalBounds;
  494.     }
  495.  
  496.     y += bounds.Height();
  497.  
  498.     if (gadget->Next) {
  499.       TPoint  origin(0, y);
  500.  
  501.       PositionGadget(gadget, gadget->Next, origin);
  502.       y = origin.y;
  503.     }
  504.   }
  505.   return invalidRect;
  506. }
  507.  
  508. TRect
  509. TGadgetWindow::TileGadgets()
  510. {
  511.   return (Direction == Horizontal) ? TileHorizontally() : TileVertically();
  512. }
  513.  
  514. void
  515. TGadgetWindow::GadgetChangedSize(TGadget&)
  516. {
  517.   LayoutSession();
  518. }
  519.  
  520. void
  521. TGadgetWindow::Insert(TGadget& gadget, TPlacement placement, TGadget* sibling)
  522. {
  523.   PRECONDITION(!gadget.Window);
  524.  
  525.   TGadget**  g = &Gadgets;
  526.  
  527.   if (sibling || placement == After) {
  528.     while (*g && *g != sibling)
  529.       g = &(*g)->Next;
  530.  
  531.     CHECK(*g == sibling);
  532.   }
  533.  
  534.   if (placement == After && *g)
  535.     g = &(*g)->Next;
  536.  
  537.   gadget.Next = *g;
  538.   *g = &gadget;
  539.  
  540.   gadget.Window = this;
  541.   NumGadgets++;
  542.   gadget.Inserted();
  543.  
  544.   if (gadget.WideAsPossible)
  545.     WideAsPossible++;
  546. }
  547.  
  548. //
  549. // remove a gadget from the gadget window's list
  550. //
  551. TGadget*
  552. TGadgetWindow::Remove(TGadget& gadget)
  553. {
  554.   if (gadget.Window != this || !Gadgets)
  555.     return 0;
  556.  
  557.   //
  558.   // handle head-of-list case
  559.   //
  560.   if (&gadget == Gadgets) {
  561.     Gadgets = Gadgets->Next;
  562.  
  563.   //
  564.   // scan for gadget, looking one link ahead
  565.   //
  566.   } else {
  567.     TGadget* g = Gadgets;
  568.  
  569.     while (g->Next && g->Next != &gadget)
  570.       g = g->Next;
  571.  
  572.     if (!g->Next)   // not found
  573.       return 0;
  574.  
  575.     g->Next = g->Next->Next;
  576.   }
  577.  
  578.   NumGadgets--;
  579.  
  580.   //
  581.   // re-adjust gadget now that it doesn't live in a window
  582.   //
  583.   if (gadget.WideAsPossible)
  584.     WideAsPossible--;
  585.   if (&gadget == AtMouse)
  586.     AtMouse = 0;
  587.   GadgetReleaseCapture(gadget);
  588.   gadget.Removed();
  589.   gadget.Window = 0;
  590.   gadget.Next = 0;
  591.   gadget.GetBounds() -= gadget.GetBounds().TopLeft();
  592.  
  593.   return &gadget;
  594. }
  595.  
  596. void
  597. TGadgetWindow::EvSize(UINT sizeType, TSize& size)
  598. {
  599.   TWindow::EvSize(sizeType, size);
  600.  
  601.   if (DirtyLayout || WideAsPossible > 0) {
  602.     DirtyLayout = FALSE;
  603.     TileGadgets();
  604.     Invalidate();
  605.   }
  606. }
  607.  
  608. //
  609. // Iterate thru the gadget list and paint each one.
  610. //
  611. void
  612. TGadgetWindow::PaintGadgets(TDC& dc, BOOL, TRect& rect)
  613. {
  614.   for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next) {
  615.     if (gadget->Bounds.Touches(rect)) {
  616.       dc.SetViewportOrg((TPoint&)gadget->Bounds);
  617.  
  618.       if (gadget->Clip) {
  619.         dc.SaveDC();
  620.         dc.IntersectClipRect(gadget->Bounds);
  621.       }
  622.  
  623.       gadget->Paint(dc);
  624.  
  625.       if (gadget->Clip)
  626.         dc.RestoreDC();
  627.     }
  628.   }
  629. }
  630.  
  631. void
  632. TGadgetWindow::Paint(TDC& dc, BOOL erase, TRect& rect)
  633. {
  634.   dc.SelectObject(*Font);
  635.   PaintGadgets(dc, erase, rect);
  636. }
  637.  
  638. //
  639. // Return gadget that a given window-relative point is in, 0 if none
  640. //
  641. TGadget*
  642. TGadgetWindow::GadgetFromPoint(TPoint& point) const
  643. {
  644.   for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next)
  645.     if (gadget->PtIn(point - *(TSize*)&gadget->Bounds.TopLeft()))
  646.       break;
  647.  
  648.   return gadget;
  649. }
  650.  
  651. HBRUSH
  652. TGadgetWindow::EvCtlColor(HDC hDC, HWND /*hWndChild*/, UINT /*ctlType*/)
  653. {
  654.   ::SetBkColor(hDC, BkgndColor);
  655.   return HBRUSH(*BkgndBrush);
  656. }
  657.  
  658. //
  659. // Determine if the mouse down is in an enabled gadget, & if so pass it to
  660. // the gadget.
  661. //
  662. void
  663. TGadgetWindow::EvLButtonDown(UINT modKeys, TPoint& point)
  664. {
  665.   TGadget* gadget = Capture ? Capture : GadgetFromPoint(point);
  666.   if (gadget && gadget->GetEnabled())
  667.     gadget->LButtonDown(modKeys, point - *(TSize*)&gadget->Bounds.TopLeft());
  668.   TWindow::EvLButtonDown(modKeys, point);
  669. }
  670.  
  671. //
  672. // Forward mouse ups to the gadget that has captures the mouse, if any, or
  673. // to the gadget at the mouse pos
  674. //
  675. void
  676. TGadgetWindow::EvLButtonUp(UINT modKeys, TPoint& point)
  677. {
  678.   TGadget* gadget = Capture ? Capture : GadgetFromPoint(point);
  679.  
  680.   if (gadget && gadget->GetEnabled())
  681.     gadget->LButtonUp(modKeys, TPoint(point.x - gadget->Bounds.left,
  682.                                       point.y - gadget->Bounds.top));
  683.   TWindow::EvLButtonUp(modKeys, point);
  684. }
  685.  
  686. //
  687. // Forward mouse moves to the gadget that has captures the mouse, if any.
  688. // Otherwise checks for mouse entering & leaving gadgets
  689. //
  690. // Could enhance this by delaying mouse enter messages until mouse has been
  691. // in the same area for a while, or looking ahead in queue for mouse msgs.
  692. //
  693. void
  694. TGadgetWindow::EvMouseMove(UINT modKeys, TPoint& point)
  695. {
  696.   if (Capture) {
  697.     Capture->MouseMove(modKeys, TPoint(point.x - Capture->Bounds.left,
  698.                                        point.y - Capture->Bounds.top));
  699.  
  700.   } else {
  701.     TGadget* gadget = GadgetFromPoint(point);
  702.     if (gadget != AtMouse) {
  703.       if (AtMouse)
  704.         AtMouse->MouseLeave(modKeys, TPoint(point.x - AtMouse->Bounds.left,
  705.                                             point.y - AtMouse->Bounds.top));
  706.       AtMouse = gadget;
  707.       if (AtMouse)
  708.         AtMouse->MouseEnter(modKeys, TPoint(point.x - AtMouse->Bounds.left,
  709.                                             point.y - AtMouse->Bounds.top));
  710.     }
  711.   }
  712.   TWindow::EvMouseMove(modKeys, point);
  713. }
  714.