void DoGoAwayBox(WindowPtr myWindow, Point mouseloc) { if(TrackGoAway(myWindow,mouseloc)) { DoCloseWindow(myWindow); } }
void doEventLoop() { EventRecord event; WindowPtr window; short clickArea; Rect screenRect; RgnHandle rgnHandle = NewRgn(); for (;;) { if (WaitNextEvent( everyEvent, &event, 0, nil )) { if (event.what == mouseDown) { clickArea = FindWindow( event.where, &window ); if (clickArea == inDrag) { //screenRect = (**GetGrayRgn ()).rgnBBox; GetRegionBounds(GetGrayRgn(), &screenRect); DragWindow( window, event.where, &screenRect ); } else if (clickArea == inContent) { if (window != FrontWindow()) SelectWindow( window ); } else if (clickArea == inGoAway) if (TrackGoAway( window, event.where )) return; } else if (event.what == updateEvt) { window = (WindowPtr)event.message; //SetPort( window ); SetPortWindowPort( window ); BeginUpdate( window ); drawPixelImageData(); EndUpdate( window ); QDFlushPortBuffer(GetWindowPort(window), GetPortVisibleRegion(GetWindowPort(window), rgnHandle)); } else if (event.what == activateEvt) { /*if (event.modifiers & activeFlag) { window = (WindowPtr)event.message; SetPortWindowPort(window); drawPixelImageData(); QDFlushPortBuffer(GetWindowPort(window), GetPortVisibleRegion(GetWindowPort(window), rgnHandle)); }*/ /*if (event.modifiers & activeFlag) PostEvent(updateEvt, (unsigned long)gWindow);*/ } } } DisposeRgn(rgnHandle); }
void doEventLoop() { EventRecord anEvent; WindowPtr evtWind; short clickArea; Rect screenRect; Point thePoint; Rect zoomFrom, zoomTo; zoomFrom.top = zoomTo.top = -1; while (!gDone) { if (WaitNextEvent( everyEvent, &anEvent, 0, nil )) { if (anEvent.what == mouseDown) { clickArea = FindWindow( anEvent.where, &evtWind ); if (clickArea == inDrag) { GetRegionBounds( GetGrayRgn(), &screenRect ); DragWindow( evtWind, anEvent.where, &screenRect ); } else if (clickArea == inContent) { if (evtWind != FrontWindow()) SelectWindow( evtWind ); else { thePoint = anEvent.where; GlobalToLocal( &thePoint ); //Handle click in window content here GetRect(&zoomFrom, &zoomTo); } } else if (clickArea == inGoAway) if (TrackGoAway( evtWind, anEvent.where )) gDone = true; } else if (anEvent.what == updateEvt) { evtWind = (WindowPtr)anEvent.message; SetPortWindowPort( evtWind ); BeginUpdate( evtWind ); //Call Draw Function here.... if (zoomFrom.top != -1) FrameRect(&zoomFrom); if (zoomTo.top != -1) FrameRect(&zoomTo); EndUpdate (evtWind); } } } }
void HandleMouseDown(EventRecord *event) { short part; WindowRef window; MacWindow *macwin; Rect growRect={100,100,32000,32000}; long size; part=FindWindow(event->where, &window); macwin = (MacWindow*)GetWRefCon(window); switch(part) { case inMenuBar: mac_AdjustMenus(event->modifiers); mac_HandleMenuSelect(MenuSelect(event->where), event->modifiers); HiliteMenu(0); break; case inContent: SetPortWindowPort(window); SelectWindow(window); GlobalToLocal(&event->where); if(macwin) macwin->click(event->where, event->modifiers); break; case inDrag: DragWindow(window, event->where, &qd.screenBits.bounds); break; case inGrow: SetPortWindowPort(window); size=GrowWindow(window, event->where, &growRect); if( size ) { SizeWindow(window, size&0x0000FFFF, size>>16, 0); EraseRect(&GetWindowPort(window)->portRect); InvalRect(&GetWindowPort(window)->portRect); if( macwin ) macwin->message(MW_GROW, size); } break; case inGoAway: if( TrackGoAway(window, event->where) ){ if( macwin ){ macwin->goaway(macwin); } } break; //case inZoomIn: //case inZoomOut: // break; } }
void doEventLoop() { EventRecord anEvent; WindowPtr evtWind; short clickArea; Rect screenRect; while (!gDone) { if (WaitNextEvent( everyEvent, &anEvent, 0, nil )) { if (anEvent.what == mouseDown) { clickArea = FindWindow( anEvent.where, &evtWind ); if (clickArea == inMenuBar) handleMenuSelection(MenuSelect(anEvent.where)); else if (clickArea == inDrag) { //screenRect = (**GetGrayRgn ()).rgnBBox; GetRegionBounds(GetGrayRgn(), &screenRect); DragWindow( evtWind, anEvent.where, &screenRect ); } else if (clickArea == inContent) { if (evtWind != FrontWindow()) SelectWindow( evtWind ); } else if (clickArea == inGoAway) if (TrackGoAway( evtWind, anEvent.where )) gDone = true; } else if (anEvent.what == updateEvt) { evtWind = (WindowPtr)anEvent.message; //SetPort( evtWind ); SetPortWindowPort( evtWind ); BeginUpdate( evtWind ); drawImage( evtWind ); EndUpdate (evtWind); } else if (anEvent.what == autoKey || anEvent.what == keyDown) handleKeyPress(&anEvent); } } }
P2(PUBLIC pascal trap, void, SystemClick, EventRecord *, evp, WindowPtr, wp) { Point p; LONGINT pointaslong, val; Rect bounds; LONGINT templ; if (wp) { p.h = CW(evp->where.h); p.v = CW(evp->where.v); if (PtInRgn (p, WINDOW_STRUCT_REGION (wp))) { pointaslong = ((LONGINT)p.v << 16)|(unsigned short)p.h; val = WINDCALL((WindowPtr) wp, wHit, pointaslong); switch (val) { case wInContent: if (WINDOW_HILITED_X (wp)) { templ = (LONGINT) (long) RM(evp); Control (WINDOW_KIND (wp), accEvent, (Ptr) &templ); } else SelectWindow(wp); break; case wInDrag: bounds.top = CW (CW (MBarHeight) + 4); bounds.left = CW (CW (GD_BOUNDS (MR (TheGDevice)).left) + 4); bounds.bottom = CW (CW (GD_BOUNDS (MR (TheGDevice)).bottom) - 4); bounds.right = CW (CW (GD_BOUNDS (MR (TheGDevice)).right) - 4); DragWindow(wp, p, &bounds); break; case wInGoAway: if (TrackGoAway(wp, p)) CloseDeskAcc (WINDOW_KIND (wp)); break; } } else { if (DeskHook) { ROMlib_hook(desk_deskhooknumber); EM_D0 = -1; EM_A0 = (LONGINT) (long) US_TO_SYN68K(evp); CALL_EMULATOR((syn68k_addr_t) (long) CL((long) DeskHook)); } } } }
static void HandleMouseDown(EventRecord *pevent) { WindowPtr hWnd; Rect rDrag; switch(FindWindow(pevent->where, &hWnd)) { case inMenuBar: if (np2running) { soundmng_stop(); mousemng_disable(MOUSEPROC_MACUI); HandleMenuChoice(MenuSelect(pevent->where)); mousemng_enable(MOUSEPROC_MACUI); soundmng_play(); } break; case inDrag: #if TARGET_API_MAC_CARBON { BitMap gscreenBits; GetQDGlobalsScreenBits(&gscreenBits); rDrag = gscreenBits.bounds; InsetRect(&rDrag, DRAG_THRESHOLD, DRAG_THRESHOLD); DragWindow(hWnd, pevent->where, &rDrag); } #else rDrag = qd.screenBits.bounds; InsetRect(&rDrag, DRAG_THRESHOLD, DRAG_THRESHOLD); DragWindow(hWnd, pevent->where, &rDrag); #endif break; case inContent: mousemng_buttonevent((pevent->modifiers & (1 << 12)) ?MOUSEMNG_RIGHTDOWN:MOUSEMNG_LEFTDOWN); break; case inGoAway: if (TrackGoAway(hWnd, pevent->where)) { } np2running = FALSE; break; } }
static void mac_event(EventRecord *event) { short part; WindowPtr window; switch (event->what) { case mouseDown: part = FindWindow(event->where, &window); switch (part) { case inMenuBar: mac_adjustmenus(); mac_menucommand(MenuSelect(event->where)); break; #if !TARGET_API_MAC_CARBON case inSysWindow: SystemClick(event, window); break; #endif case inContent: if (window != FrontWindow()) /* XXX: check for movable modal dboxes? */ SelectWindow(window); else mac_contentclick(window, event); break; case inGoAway: if (TrackGoAway(window, event->where)) mac_closewindow(window); break; case inDrag: /* XXX: moveable modal check? */ #if TARGET_API_MAC_CARBON { BitMap screenBits; GetQDGlobalsScreenBits(&screenBits); DragWindow(window, event->where, &screenBits.bounds); } #else DragWindow(window, event->where, &qd.screenBits.bounds); #endif break; case inGrow: mac_growwindow(window, event); break; case inZoomIn: case inZoomOut: if (TrackBox(window, event->where, part)) mac_zoomwindow(window, part); break; } break; case keyDown: case autoKey: mac_keypress(event); break; case activateEvt: mac_activatewindow((WindowPtr)event->message, event); break; case updateEvt: mac_updatewindow((WindowPtr)event->message); break; #if !TARGET_API_MAC_CARBON case diskEvt: if (HiWord(event->message) != noErr) { Point pt; SetPt(&pt, 120, 120); DIBadMount(pt, event->message); } break; #endif case osEvt: switch ((event->message & osEvtMessageMask) >> 24) { case suspendResumeMessage: mac_suspendresume(event); break; } break; case kHighLevelEvent: AEProcessAppleEvent(event); /* errors? */ break; } }
int HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin) { int result = INT_MAX; switch (medPtr->windowPart) { case inGoAway: case inCollapseBox: case inZoomIn: case inZoomOut: case inToolbarButton: if (!IsWindowActive(medPtr->whichWin)) { WindowRef frontWindow = FrontNonFloatingWindow(); WindowModality frontWindowModality = kWindowModalityNone; if (frontWindow && frontWindow != medPtr->whichWin) { ChkErr(GetWindowModality, frontWindow, &frontWindowModality, NULL); } if (frontWindowModality == kWindowModalityAppModal) { result = 0; } } break; default: result = -1; break; } if (result == INT_MAX) { result = 0; TkMacOSXTrackingLoop(1); switch (medPtr->windowPart) { case inGoAway: if (TrackGoAway(medPtr->whichWin, medPtr->global) && tkwin) { TkGenWMDestroyEvent(tkwin); result = 1; } break; case inCollapseBox: if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart) && tkwin) { TkpWmSetState((TkWindow *)tkwin, IconicState); result = 1; } break; case inZoomIn: case inZoomOut: if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) { result = TkMacOSXZoomToplevel(medPtr->whichWin, medPtr->windowPart); } break; case inToolbarButton: if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) { result = GenerateToolbarButtonEvent(medPtr); } break; } TkMacOSXTrackingLoop(0); } return result; }
void DoMouseDown(EventRecord e) { short partCode; WindowPtr whichWindow; Rect dragRect; Point pt; switch(partCode = FindWindow(e.where, &whichWindow)) { case inMenuBar: FixMenus(); ProcessMenu(MenuSelect(e.where)); break; case inSysWindow: SystemClick(&e, whichWindow); break; case inContent: if(whichWindow != FrontWindow()) SelectWindow(whichWindow); if(whichWindow==nesWind) DoClickInNES(e); if(whichWindow==wpWind) DoClickInWP(e); if(whichWindow==srchWind) DoClickInSrch(e); #ifdef GB_DEBUG if(whichWindow==statWind) DoClickInStat(e); if(whichWindow==patWind) DoClickInPat(e); #endif break; case inDrag: dragRect = qd.screenBits.bounds; InsetRect(&dragRect, 5, 5); DragWindow(whichWindow, e.where, &dragRect); if(whichWindow == nesWind) { SetPt(&pt,0,0); SetPort(nesWind); LocalToGlobal(&pt); MoveWindow(nesWind,pt.h & 0xfff8,pt.v,false); SetPt(&pt,0,0); LocalToGlobal(&pt); if( (pt.h < 0) || (pt.v < 20) ) MoveWindow(nesWind,8,40,false); SetPt(&pt,nesWind->portRect.right,nesWind->portRect.bottom); LocalToGlobal(&pt); if( (pt.h > scrnW) || (pt.v > scrnH) ) MoveWindow(nesWind,8,40,false); } WP_RepositionWind(); Srch_RepositionWind(); break; case inGoAway: if(TrackGoAway(whichWindow, e.where)) DoCloseWindow(whichWindow); break; default: break; } vVrtFrame = vActFrame; // keep timing code working }
static void process_event( EventRecord *event) { WindowPtr window; short part_code; Rect size_rect; long new_size; GrafPtr old_port; switch(event->what) { case kHighLevelEvent: AEProcessAppleEvent(event); break; case mouseDown: /* Did we hit one of the floaters? */ part_code= FindWindow(event->where, &window); switch (part_code) { case inSysWindow: break; case inMenuBar: do_menu_command(MenuSelect(event->where)); break; case inContent: if(window != FrontWindow()) SelectWindow(window); click_in_log_window(window,event->where,(event->modifiers & shiftKey) != 0); break; case inDrag: #ifdef OP_PLATFORM_MAC_CARBON_FLAG { Rect tempRect; GetRegionBounds(GetGrayRgn(), &tempRect); DragWindow(window, event->where, &tempRect); } #else DragWindow(window, event->where, &qd.screenBits.bounds); #endif break; case inGrow: #ifdef OP_PLATFORM_MAC_CARBON_FLAG GetRegionBounds(GetGrayRgn(), &size_rect); #else size_rect = qd.screenBits.bounds; #endif InsetRect(&size_rect, 4, 4); new_size= GrowWindow(window, event->where, &size_rect); if(new_size) { /* Resize the window */ SizeWindow(window, LoWord(new_size), HiWord(new_size), true); } break; case inGoAway: if(TrackGoAway(window, event->where)) { /* Close the window... */ handle_close(window); } break; case inZoomIn: case inZoomOut: if(TrackBox(window, event->where, part_code)) { GetPort(&old_port); SetPortWindowPort(window); #ifdef OP_PLATFORM_MAC_CARBON_FLAG { Rect windowBounds; GetWindowPortBounds(window, &windowBounds); EraseRect(&windowBounds); } #else EraseRect(&window->portRect); #endif ZoomWindow(window, part_code, true); SetPort(old_port); } break; } break; case keyDown: case autoKey: if(!process_key(event, event->message&charCodeMask)) { /* Not handled by anyone.. */ SysBeep(-1); } break; case updateEvt: /* Update the window.. */ update_window((WindowPtr)event->message); break; case activateEvt: /* Activate event->message, event->modifiers&activeFlag.. */ break; case osEvt: switch ((event->message>>24) & 0xff) { case suspendResumeMessage: if (event->message&resumeFlag) { /* resume */ #ifdef OP_PLATFORM_MAC_CARBON_FLAG { Cursor arrowCursor; SetCursor(GetQDGlobalsArrow(&arrowCursor)); } #else SetCursor(&qd.arrow); #endif } else { /* suspend */ } break; case mouseMovedMessage: break; } break; } return; }
void eventLoop() { EventRecord event; WindowPtr window; short clickArea; Rect screenRect; long sleep = 30; Point point; for (;;) { if (WaitNextEvent( everyEvent, &event, sleep, (RgnHandle)nil )) { if (event.what == mouseDown) { clickArea = FindWindow( event.where, &window ); if (clickArea == inDrag) { //screenRect = (**GetGrayRgn()).rgnBBox; GetRegionBounds(GetGrayRgn(), &screenRect); DragWindow(window, event.where, &screenRect ); } else if (clickArea == inGoAway) { if (TrackGoAway( window , event.where )) ExitToShell(); } else if (clickArea == inMenuBar) { adjustMenus(); handleMenu( MenuSelect( event.where ) ); } else if (clickArea == inContent) { if (window != FrontWindow()) SelectWindow( window ); else { point = event.where; GlobalToLocal( &point ); handleMouseDown( point ); } } } else if (event.what == updateEvt) { window = (WindowPtr)event.message; //SetPort( window ); SetPortWindowPort( window ); BeginUpdate( window ); updateWindow(); EndUpdate( window ); } else if (event.what == keyDown || event.what == autoKey) { if ((event.modifiers & cmdKey) != 0) { adjustMenus(); handleMenu( MenuKey( (char)(event.message & charCodeMask) ) ); } } } } }
int main( void ) { long result = 0; // initialize for carbon & QuickTime InitCursor(); if ( IsQuickTimeInstalled() ) EnterMovies(); else goto bail; GetQDGlobalsScreenBits( &screenBits ); Gestalt(gestaltMenuMgrAttr, &result); if (result & gestaltMenuMgrAquaLayoutMask) { // Mmmmmm...X SetMenuBar(GetNewMBar(129)); if (AEInstallEventHandler( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(doAEQuit), 0, false)) goto bail; } else { SetMenuBar(GetNewMBar(128)); } DrawMenuBar(); while (gDone == false) { EventRecord theEvent; WindowPtr pWhichWindow; short windowPart; Boolean SIOUXHandledEvent = false; WaitNextEvent(everyEvent, &theEvent, 0, NULL); #ifndef __MACH__ SIOUXHandledEvent = SIOUXHandleOneEvent(&theEvent); #endif if ( !SIOUXHandledEvent ) { switch (theEvent.what) { case updateEvt: pWhichWindow = (WindowPtr)theEvent.message; // we don't do anything for this simple sample BeginUpdate(pWhichWindow); EndUpdate(pWhichWindow); break; case keyDown: if (theEvent.modifiers & cmdKey) { doMenu(MenuKey(theEvent.message & charCodeMask)); } break; case mouseDown: windowPart = FindWindow(theEvent.where, &pWhichWindow); switch (windowPart) { case inDrag: DragWindow(pWhichWindow, theEvent.where, &screenBits.bounds); break; case inGoAway: if (TrackGoAway(pWhichWindow, theEvent.where)) DisposeWindow( pWhichWindow ); //gDone = true; break; case inContent: SelectWindow(pWhichWindow); break; case inMenuBar: doMenu(MenuSelect(theEvent.where)); break; } break; } } } bail: return 0; }
void dogoaway (Point start, WindowPtr wp) { if (TrackGoAway (wp, start)) disposedirwindow (wp); }
void RunLoop() { EventRecord theEvent; WindowPtr whichWindow; Rect txRect; txRect = qd.thePort->portRect; InsetRect(&txRect,4,0); textH = TENew(&txRect,&txRect); while (!quit) { SystemTask(); TEIdle(textH); if (GetNextEvent(everyEvent, &theEvent)) { switch (theEvent.what) { case mouseDown: { switch (FindWindow(theEvent.where, &whichWindow)) { case inSysWindow: { SystemClick(&theEvent, whichWindow); break; } case inMenuBar: { DoCommand(MenuSelect(theEvent.where)); break; } case inDrag: { DragWindow(whichWindow, theEvent.where, &qd.screenBits.bounds); break; } case inContent: { if (whichWindow != FrontWindow()) { SelectWindow(whichWindow); } else { GlobalToLocal(&theEvent.where); if (theEvent.modifiers&shiftKey) isShift = true; TEClick(theEvent.where, isShift, textH); } break; } case inGoAway: { if (TrackGoAway(whichWindow, theEvent.where)) { quit = true; } break; } default: break; } break; } case autoKey: case keyDown: { char theChar = (theEvent.message&charCodeMask); if (theEvent.modifiers&cmdKey) { DoCommand(MenuKey(theChar)); if (theChar == 'm') { quit = true; } } else { TEKey(theChar, textH); } break; } case activateEvt: { if (theEvent.modifiers&activeFlag) { TEActivate(textH); } else { TEDeactivate(textH); } break; } case updateEvt: { BeginUpdate((WindowPtr)theEvent.message); EraseRect(&(qd.thePort->portRect)); TEUpdate(&(qd.thePort->portRect), textH); EndUpdate((WindowPtr)theEvent.message); break; } default: break; } } } }