home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / df3os2.zip / DESKTOP.CPP < prev    next >
C/C++ Source or Header  |  1993-09-02  |  1KB  |  71 lines

  1. // --------------- desktop.cpp
  2.  
  3. #include <new.h>
  4. #include "desktop.h"
  5.  
  6. DeskTop desktop;
  7.  
  8. void NoMemory()
  9. {
  10.     exit(-1);
  11. }
  12.  
  13. DeskTop::DeskTop()
  14. {
  15.     apwnd = 0;
  16.     infocus = 0;
  17.     focuscapture = 0;
  18.     set_new_handler(NoMemory);
  19.     syscursor.Hide();
  20.     drive = getdisk();
  21.     path = new char[129];
  22.     getcwd(path, 129);
  23. }
  24.  
  25. DeskTop::~DeskTop()
  26. {
  27.     syscursor.Show();
  28.     setdisk(drive);
  29.     chdir(path);
  30.     delete [] path;
  31. }
  32.  
  33. Bool DeskTop::DispatchEvents()
  34. {
  35.     syskeyboard.DispatchEvent();
  36.     sysmouse.DispatchEvent();
  37.     sysclock.DispatchEvent();
  38.     return (Bool) (apwnd != 0);
  39. }
  40.  
  41. inline Bool inShadow(Rect &rc, int x, int y)
  42. {
  43.     return (Bool)
  44.     (((x == rc.Right()+1) && (y > rc.Top() && y < rc.Bottom()+2))
  45.                             ||
  46.     ((y == rc.Bottom()+1) && (x > rc.Left() && x < rc.Right()+2)));
  47. }
  48.  
  49. // ---- find the window that coordinates are in
  50. DFWindow *DeskTop::inWindow(DFWindow *Wnd, int x, int y)
  51. {
  52.     DFWindow *hWnd;
  53.     if (Wnd != 0)    {
  54.         // ------ search window's children
  55.         DFWindow *sWnd = Wnd->Last();
  56.         while (sWnd != 0)    {
  57.             hWnd = inWindow(sWnd, x, y);
  58.             if (hWnd != 0)
  59.                 return hWnd;
  60.             sWnd = sWnd->Prev();
  61.         }
  62.         // ---- test this window
  63.         if (!Wnd->isVisible() || !Wnd->WindowRect().Inside(x, y))
  64.             Wnd = 0;
  65.     }
  66.     return Wnd;
  67. }
  68.  
  69.  
  70.  
  71.