home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / MACtive Desktop / Source / Sources / BaseWindowManager.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-11  |  3.4 KB  |  231 lines  |  [TEXT/CWIE]

  1. #include "LayerManager.h"
  2. #include "MenuManager.h"
  3. #include "BaseWindowManager.h"
  4.  
  5.  
  6.  
  7.  
  8.  
  9. extern MenuManager                    *gMenuManager;
  10.  
  11.  
  12.  
  13.  
  14.  
  15. BaseWindowManager::BaseWindowManager(void)
  16. {
  17.     fSuspended = false;
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24. BaseWindowObject *BaseWindowManager::GetWindowObject(WindowPtr window)
  25. {
  26.     BaseWindowObject    *obj;
  27.     
  28.     
  29.     obj = fWindowList.GetFirst();
  30.     while(obj && (obj->fWindowID != window))
  31.         obj = obj->next;
  32.     
  33.     return obj;
  34. }
  35.  
  36.  
  37. #pragma mark -
  38.  
  39.  
  40. void BaseWindowManager::DoAddWindow(Window *window)
  41. {
  42.     BaseWindowObject    *obj;
  43.     
  44.     
  45.     obj = new BaseWindowObject;
  46.     if (obj != NULL)
  47.     {
  48.         obj->fWindowID = window->fWindow;
  49.         obj->fWindowObject = window;
  50.         fWindowList.Append(obj);
  51.         gMenuManager->DoWindowNotice(window,true);
  52.     }
  53. }
  54.  
  55.  
  56.  
  57.  
  58.  
  59. void BaseWindowManager::DoDeleteWindow(Window *window)
  60. {
  61.     BaseWindowObject    *obj;
  62.     
  63.     
  64.     obj = GetWindowObject(window->fWindow);
  65.     if (obj != NULL)
  66.     {
  67.         gMenuManager->DoWindowNotice(window,false);
  68.         fWindowList.Delete(obj);
  69.         delete obj;    
  70.     }
  71. }
  72.  
  73.  
  74.  
  75.  
  76.  
  77. void BaseWindowManager::DoClick(Point where,UInt32 modifiers,WindowPtr window,SInt32 part)
  78. {
  79.     Window    *win = DoGetWindow(window);
  80.     Window    *top;
  81.     
  82.     
  83.     // Don't let any other window have input or be able
  84.     // to layer switch if a modal dialog is the topmost
  85.     top = DoGetFrontWindow();
  86.     if ((win != top) && ((top->fFlags & (kDialog | kModal)) == (kDialog | kModal)))
  87.         return;
  88.     
  89.     if (win != NULL)
  90.         win->DoClick(where,modifiers,part);
  91. }
  92.  
  93.  
  94.  
  95.  
  96.  
  97. void BaseWindowManager::DoIdleTime(EventRecord *event,Point mouse,UInt32 modifiers)
  98. {
  99.     BaseWindowObject    *obj;
  100.     WindowPtr            window;
  101.     Window                *win;
  102.     SInt32                part;
  103.     
  104.     
  105.     if (!fSuspended)
  106.     {
  107.         win = NULL;
  108.         if (!FindSystemWindow(mouse,&window))
  109.         {
  110.             part = FindWindow(mouse,&window);
  111.             if (part == inContent)
  112.             {
  113.                 win = DoGetWindow(window);
  114.                 if ((win != NULL) && (win->fFlags & kActive))
  115.                     win->DoUpdateCursor(mouse,modifiers);
  116.                 else
  117.                     win = NULL;
  118.             }
  119.         }
  120.         
  121.         if (win == NULL)
  122.             SetCursor(&qd.arrow);
  123.     }
  124.     
  125.     obj = fWindowList.GetFirst();
  126.     while(obj != NULL)
  127.     {
  128.         obj->fWindowObject->DoIdleTime(event,mouse,modifiers);
  129.         obj = obj->next;
  130.     }
  131. }
  132.  
  133.  
  134.  
  135.  
  136.  
  137. void BaseWindowManager::DoActivation(WindowPtr window,Boolean isActivating)
  138. {
  139.     Window    *win;
  140.     
  141.     
  142.     win = DoGetWindow(window);
  143.     if (win != NULL)
  144.     {
  145.         win->DoSetActivationState(isActivating);
  146.         gMenuManager->DoWindowActivation(win,isActivating);
  147.     }
  148. }
  149.  
  150.  
  151.  
  152.  
  153.  
  154. void BaseWindowManager::DoSuspendResume(EventRecord *event,Boolean isSuspend)
  155. {
  156.     BaseWindowObject    *obj;
  157.     
  158.     
  159.     obj = fWindowList.GetFirst();
  160.     while(obj != NULL)
  161.     {
  162.         obj->fWindowObject->DoSetSuspensionState(event,isSuspend);
  163.         obj = obj->next;
  164.     }
  165.     
  166.     fSuspended = isSuspend;
  167. }
  168.  
  169.  
  170. #pragma mark -
  171.  
  172.  
  173. Window *BaseWindowManager::DoGetFrontWindow(void)
  174. {
  175.     WindowPtr    window;
  176.     Window        *win;
  177.     
  178.     
  179.     // Floating windows are system windows
  180.     // do this actually is correct
  181.     window = FrontWindow();
  182.     while(window != NULL)
  183.     {
  184.         if (((WindowPeek)window)->visible)
  185.         {
  186.             win = DoGetWindow(window);
  187.             if (win != NULL)
  188.                 return win;
  189.         }
  190.         
  191.         window = (WindowPtr)((WindowPeek)window)->nextWindow;
  192.     }
  193.     
  194.     return NULL;
  195. }
  196.  
  197.  
  198.  
  199.  
  200.  
  201. Window *BaseWindowManager::DoGetNextWindow(Window *window)
  202. {
  203.     WindowPtr    next;
  204.     
  205.     
  206.     next = (WindowPtr)((WindowPeek)window->fWindow)->nextWindow;
  207.     while(next != NULL)
  208.     {
  209.         window = DoGetWindow(next);
  210.         if ((window != NULL) && ((WindowPeek)window)->visible)
  211.             return window;
  212.         
  213.         next = (WindowPtr)((WindowPeek)next)->nextWindow;
  214.     }
  215.     
  216.     return NULL;
  217. }
  218.  
  219.  
  220.  
  221.  
  222.  
  223. Window *BaseWindowManager::DoGetWindow(WindowPtr window)
  224. {
  225.     BaseWindowObject    *obj;
  226.     
  227.     
  228.     obj = GetWindowObject(window);
  229.     return obj ? obj->fWindowObject : NULL;
  230. }
  231.