home *** CD-ROM | disk | FTP | other *** search
-
-
- #include "CSmartDesktop.h"
- #include "CSmartWindow.h" /* for modal window support */
- #include "CBartender.h"
-
- extern CBartender *gBartender;
- extern CBureaucrat *gGopher;
- extern Boolean gInBackground;
-
- /**********************************************************************/
- void CSmartDesktop::ISmartDesktop(CBureaucrat *aSupervisor)
- {
- CDesktop::IDesktop( aSupervisor);
-
- } /* CSmartDesktop::ISmartDesktop */
- /**********************************************************************/
- void CSmartDesktop::DispatchClick(register EventRecord *macEvent)
- {
- Int16 thePart; /* Location of mouse click */
- WindowPeek macWindow; /* Window where click occurred */
- register CWindow *theWindow; /* Corresponding window object */
- register Int32 menuChoice; /* Selection from a menu */
-
- thePart = FindWindow(macEvent->where, &macWindow);
-
- if (macWindow != NULL) {
- theWindow = (CWindow*) GetWRefCon(macWindow);
- if (!theWindow) return; /* DLP */
- }
-
- /* DLP support for modal windows */
- {
- CSmartWindow *topWind = (CSmartWindow*) topWindow;
- if (member( topWind, CSmartWindow))
- {
- if ((theWindow != topWind)&& topWind->IsModal())
- {
- SysBeep(3);
- return;
- }
- }
- }
-
- switch (thePart) { /* Take appropriate action */
-
- case inDesk: /* Click on insignificant area of */
- /* the Desktop */
- CountClicks(this, macEvent);
- DoClick(macEvent->where, macEvent->modifiers, macEvent->when);
- break;
-
- case inMenuBar: /* Pull-down menus */
- gBartender->UpdateAllMenus();
- menuChoice = MenuSelect(macEvent->where);
- if (HiShort(menuChoice)) { /* A selection was made. Execute */
- /* the corresponding command. */
- gGopher->DoCommand(gBartender->FindCmdNumber
- (HiShort(menuChoice), LoShort(menuChoice)));
- HiliteMenu(0); /* Unhighlight the menu title */
- }
- break;
-
- case inSysWindow: /* Click inside a DA window */
- SystemClick(macEvent, macWindow);
- break;
-
- case inContent:
- if (!theWindow->active || ( (theWindow->floating &&
- ((WindowPtr)macWindow != FrontWindow())))) {
- /* This is an inactive window or */
- /* an underlying floater */
- theWindow->Select();
-
- if (!theWindow->actClick) {
- break; /* Exit here unless window want to */
- } /* process activating click */
- }
-
- if (theWindow->wantsClicks) {
- UpdateWindows(); /* Window handles clicks. Make sure */
- /* all windows are updated before */
- /* responding to the click. */
- theWindow->DispatchClick(macEvent);
-
- } else { /* Window ignores clicks. Handle */
- /* same as a click on the desktop */
- CountClicks(this, macEvent);
- DoClick(macEvent->where, macEvent->modifiers, macEvent->when);
- }
- break;
-
- case inDrag:
- theWindow->Drag(macEvent);
- break;
-
- case inGrow:
- theWindow->Resize(macEvent);
- break;
-
- case inGoAway:
- if (TrackGoAway(macWindow, macEvent->where))
- theWindow->Close();
- break;
-
- case inZoomIn:
- case inZoomOut:
- if (TrackBox(macWindow, macEvent->where, thePart))
- theWindow->Zoom(thePart);
- break;
- }
-
- } /* CSmartDesktop::DispatchClick */
- /**********************************************************************/
- void CSmartDesktop::DispatchCursor(Point where, RgnHandle mouseRgn)
- {
- WindowPeek macWindow; /* Window containing the mouse */
- CWindow *theWindow; /* Corresponding window object */
- Int16 thePart; /* Part of window containing mouse */
- Rect mbarRect;
-
- if (gInBackground) { /* Do nothing if we are not the */
- return; /* foreground process */
- }
-
- /* Determine which window contains */
- /* the mouse */
- thePart = FindWindow(where, &macWindow);
-
- if ( (thePart == inContent) || (thePart == inGrow) ) {
- /* Mouse is within the content */
- /* region of a window. Check if */
- /* that window is active. */
- theWindow = (CWindow*) GetWRefCon(macWindow);
- if (!theWindow) return; /* DLP */
- if (theWindow->IsActive()) {/* Window containing the mouse is */
- /* active. Tell it to adjust the */
- /* cursor shape. */
- theWindow->DispatchCursor(where, mouseRgn);
- return; /* Jump to end */
- }
-
- } else if (thePart == inMenuBar) {
- SetCursor(&arrow); /* Use arrow cursor in menu bar */
- mbarRect = screenBits.bounds;
- mbarRect.bottom = mbarRect.top + GetMBarHeight();
- RectRgn(mouseRgn, &mbarRect);
- return; /* Jump to end */
- }
- /* All checks have failed. Mouse is */
- /* in some insignificant area of */
- /* the Desktop */
- AdjustCursor(where, mouseRgn);
- } /* CSmartDesktop::DispatchCursor */
- /**********************************************************************/
-