Beispiel #1
0
void MacIdle(void)
{
  extern logical anywarns;
  static long time = 0;

  EventRecord myEvent;
  WindowPtr whichWindow;
#if TARGET_API_MAC_CARBON
  Rect tempRect;
#endif
  char theChar;

  if (TickCount()<time) return;
  if (mac_quit_now) {
    anywarns = FALSE;  /* kludge so that window doesn't sit around */
    my_exit(1);
  }
#if !TARGET_API_MAC_CARBON
  SystemTask();
#endif
  if (WaitNextEvent(everyEvent, &myEvent, 1, nil)) {

    if (!SIOUXHandleOneEvent(&myEvent)) switch (myEvent.what) {

    case mouseDown:
      switch (FindWindow(myEvent.where,&whichWindow)) {

      case inMenuBar:
	MenuSelect(myEvent.where);
	break;
#if !TARGET_API_MAC_CARBON
      case inSysWindow:
	SystemClick(&myEvent,whichWindow);
	break;
#endif
      case inContent:
	SelectWindow(whichWindow);
	break;
      case inDrag:
#if TARGET_API_MAC_CARBON
	GetRegionBounds(GetGrayRgn(),&tempRect);
	DragWindow(whichWindow,myEvent.where,&tempRect);
#else
	DragWindow(whichWindow,myEvent.where,&qd.screenBits.bounds);
#endif
	break;
      }
      break;
    case keyDown:
      theChar = myEvent.message & charCodeMask;
      break;
    case updateEvt:
      BeginUpdate((WindowPtr) myEvent.message);
      EndUpdate((WindowPtr) myEvent.message);
      break;
    }
  }
  time=TickCount()+20;
}
Beispiel #2
0
void doMouseDown(EventRecord *eventStrucPtr)
{
    WindowRef      windowRef;
    WindowPartCode partCode, zoomPart;
    BitMap         screenBits;
    Rect           constraintRect, mainScreenRect;
    Point          standardStateHeightAndWidth;
    long           newSize;

    partCode = FindWindow(eventStrucPtr->where,&windowRef);

    switch(partCode)
    {
    case inMenuBar:
        break;

    case inContent:
        if(windowRef != FrontWindow())
            SelectWindow(windowRef);
        else
            doInContent(eventStrucPtr,windowRef);
        break;

    case inDrag:
        DragWindow(windowRef,eventStrucPtr->where,NULL);
        break;

    case inGoAway:
        break;

    case inGrow:
        constraintRect.top   = 75;
        constraintRect.left = 250;
        constraintRect.bottom = constraintRect.right = 32767;
        newSize = GrowWindow(windowRef,eventStrucPtr->where,&constraintRect);
        if (newSize != 0)
            SizeWindow(windowRef,LoWord(newSize),HiWord(newSize),true);
        window_adjust_scrollbars(windowRef);
        window_invalidate(windowRef);
        break;

    case inZoomIn:
    case inZoomOut:
        mainScreenRect = GetQDGlobalsScreenBits(&screenBits)->bounds;
        standardStateHeightAndWidth.v = mainScreenRect.bottom;
        standardStateHeightAndWidth.h = mainScreenRect.right;

        if(IsWindowInStandardState(windowRef,&standardStateHeightAndWidth,NULL))
            zoomPart = inZoomIn;
        else
            zoomPart = inZoomOut;

        if(TrackBox(windowRef,eventStrucPtr->where,partCode))
        {
            ZoomWindowIdeal(windowRef,zoomPart,&standardStateHeightAndWidth);
            window_adjust_scrollbars(windowRef);
        }
        break;
    }
}
Beispiel #3
0
Datei: ugView.c Projekt: rolk/ug
static void ProcessEvent ()
{
  EventRecord myEvent;
  WindowPtr whichWindow;

  /* do system tasks */
  SystemTask();

  /* get event */
  if (GetNextEvent(everyEvent,&myEvent))
  {
    switch (myEvent.what)
    {
    case mouseDown :
      switch (FindWindow(myEvent.where,&whichWindow))
      {
      case inSysWindow :
        SystemClick(&myEvent,whichWindow);
        break;
      case inMenuBar :
        DoCommand(MenuSelect(myEvent.where));
        break;
      case inDrag :
        DragWindow(whichWindow,myEvent.where,&dragRect);
        break;
      case inContent :
        if (whichWindow!=FrontWindow())
          SelectWindow(whichWindow);
        else
        {
          /*DoContentClick(whichWindow,&myEvent);*/
        }
        break;
      case inGrow :
        /*DoGrowWindow(whichWindow,&myEvent);*/
        break;
      case inGoAway :
        /*DoGoAway(whichWindow,&myEvent);*/
        break;
      }
      break;                           /* mouseDown */

    case keyDown :
    case autoKey :
      DoKey(&myEvent);
      break;

    case activateEvt :
      /*DoActivate(&myEvent);*/
      break;

    case updateEvt :
      whichWindow = (WindowPtr) myEvent.message;
      /*DoUpdate(whichWindow,&myEvent);*/
      break;
    }
  }
} /* ProcessEvent */
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 DoDrag(WindowPtr myWindow, Point mouseloc)
{
	Rect	dragBounds;
	
	dragBounds = (**GetGrayRgn()).rgnBBox;
	DragWindow(myWindow,mouseloc,&dragBounds);

	aglUpdateContext(aglGetCurrentContext());
}
Beispiel #6
0
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);
			}
		}
	}
}
Beispiel #7
0
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;
	}
}
Beispiel #8
0
void
dodragwin (Point start, WindowPtr wp)
{
  Rect r;

  SetRect (&r, 4, HOTBANDBOTTOM + 4 + start.v -
	   (*((WindowPeek) wp)->strucRgn)->rgnBBox.top,
	   qd.screenBits.bounds.right - 4, qd.screenBits.bounds.bottom - 4);
  DragWindow (wp, start, &r);
}
void NCarbonWindowManager::StartDragWindow(NWindow* windToDrag, NPoint2D & ptStart)
{
	WindowRef macWindow = GetMacWindowFromNWindow(windToDrag);
	Point pt = ptStart.AsQDPoint();
	Rect rNewRect;

	DragWindow(macWindow, pt, NULL);
	
	GetWindowBounds(macWindow, kWindowContentRgn, &rNewRect);
	windToDrag->SetPosition(rNewRect.left, rNewRect.top);
}
Beispiel #10
0
static void handledrag (EventRecord *ev, WindowPtr w) {
	
	Rect r;

	r = qd.screenBits.bounds; 
	
	r.top = r.top + GetMBarHeight (); 
	
	InsetRect (&r, 4, 4);
	
	DragWindow (w, (*ev).where, &r);
	} /*handledrag*/
Beispiel #11
0
INT DragGraphWindow (GRAPH_WINDOW *gw, EventRecord *theEvent, DOC_DRAG_EVENT *docDrag)
{
  WindowPtr theWindow;
  int TopOld, BottomOld, LeftOld, RightOld, Left, Right, Top, Bottom, DelLeft, DelRight, DelTop, DelBottom;
  Rect currentRect;
  Rect theDragRect;
  Point MouseLoc;

  theWindow = MAC_WIN(gw);

        #warning do we need kWindowContentRgn instead of kWindowStructureRgn?
  GetWindowBounds(theWindow, kWindowStructureRgn, &currentRect);
  /* store old corners of the window */
  TopOld     = currentRect.top;
  BottomOld  = currentRect.bottom;
  LeftOld    = currentRect.left;
  RightOld   = currentRect.right;

  /* set drag rect */
  GetMouse(&MouseLoc);
  LocalToGlobal(&MouseLoc);
  Left   = DragRect()->left       + MouseLoc.h - LeftOld;
  Right  = DragRect()->right      + MouseLoc.h - RightOld;
  Top    = DragRect()->top        + MouseLoc.v - TopOld;
  Bottom = DragRect()->bottom + MouseLoc.v - BottomOld;
  SetRect(&theDragRect,Left,Top,Right,Bottom);

  /* drag window */
  DragWindow (theWindow,theEvent->where,&theDragRect);

  /* report new size */
        #warning do we need kWindowContentRgn instead of kWindowStructureRgn?
  GetWindowBounds(theWindow, kWindowStructureRgn, &currentRect);
  Left   = currentRect.left;
  Right  = currentRect.right;
  Top    = currentRect.top;
  Bottom = currentRect.bottom;
  DelLeft         = Left  - LeftOld;
  DelRight        = Right - RightOld;
  DelTop          = Top   - TopOld;
  DelBottom       = Bottom- BottomOld;

  if (DelLeft==0 && DelRight==0 && DelTop==0 && DelBottom)
    return (NO_POS_CHANGE);

  docDrag->Global_LL[0] = gw->Global_LL[0] += DelLeft;
  docDrag->Global_LL[1] = gw->Global_LL[1] += DelBottom;
  docDrag->Global_UR[0] = gw->Global_UR[0] += DelRight;
  docDrag->Global_UR[1] = gw->Global_UR[1] += DelTop;

  return (POS_CHANGE);
}
Beispiel #12
0
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;
	}
}
Beispiel #13
0
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);
		}
	}
}
Beispiel #14
0
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));
	    }
	}
    }
}
Beispiel #15
0
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;
    }
}
Beispiel #16
0
void DoEvent(EventRecord *event)
{
    short	part;
    Boolean	hit;
    char	key;
    Rect	tempRect;
    WindowRef	whichWindow;
        
    switch (event->what) 
    {
        case mouseDown:
            part = FindWindow(event->where, &whichWindow);
            switch (part)
            {
                case inMenuBar:  /* process a moused menu command */
                    DoMenuCommand(MenuSelect(event->where));
                    break;
                    
                case inSysWindow:
                    break;
                
                case inContent:
                    if (whichWindow != FrontWindow()) 
                        SelectWindow(whichWindow);
                    break;
                
                case inDrag:	/* pass screenBits.bounds */
                    GetRegionBounds(GetGrayRgn(), &tempRect);
                    DragWindow(whichWindow, event->where, &tempRect);
                    break;
                    
                case inGrow:
                    break;
                    
                case inGoAway:
                    DisposeWindow(whichWindow);
                    ExitToShell();
                    break;
                    
                case inZoomIn:
                case inZoomOut:
                    hit = TrackBox(whichWindow, event->where, part);
                    if (hit) 
                    {
                        SetPort(GetWindowPort(whichWindow));   // window must be current port
                        EraseRect(GetWindowPortBounds(whichWindow, &tempRect));   // inval/erase because of ZoomWindow bug
                        ZoomWindow(whichWindow, part, true);
                        InvalWindowRect(whichWindow, GetWindowPortBounds(whichWindow, &tempRect));	
                    }
                    break;
                }
                break;
		
                case keyDown:
		case autoKey:
                    key = event->message & charCodeMask;
                    if (event->modifiers & cmdKey)
                        if (event->what == keyDown)
                            DoMenuCommand(MenuKey(key));
		case activateEvt:	       /* if you needed to do something special */
                    break;
                    
                case updateEvt:
			DrawWindow((WindowRef) event->message);
			break;
                        
                case kHighLevelEvent:
			AEProcessAppleEvent( event );
			break;
		
                case diskEvt:
			break;
	}
}
Beispiel #17
0
MODULE_SCOPE int
TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
{
    Tk_Window tkwin;
    Point where, where2;
    int result;
    TkDisplay * dispPtr;
    OSStatus err;
    MouseEventData mouseEventData, * medPtr = &mouseEventData;
    int isFrontProcess;

    switch (eventPtr->eKind) {
	case kEventMouseDown:
	case kEventMouseUp:
	case kEventMouseMoved:
	case kEventMouseDragged:
	case kEventMouseWheelMoved:
	    break;
	default:
	    return false;
	    break;
    }
    err = ChkErr(GetEventParameter, eventPtr->eventRef,
	    kEventParamMouseLocation,
	    typeQDPoint, NULL,
	    sizeof(where), NULL,
	    &where);
    if (err != noErr) {
	GetGlobalMouse(&where);
    }
    err = ChkErr(GetEventParameter, eventPtr->eventRef,
	    kEventParamWindowRef,
	    typeWindowRef, NULL,
	    sizeof(WindowRef), NULL,
	    &medPtr->whichWin);
    if (err == noErr) {
	err = ChkErr(GetEventParameter, eventPtr->eventRef,
		kEventParamWindowPartCode,
		typeWindowPartCode, NULL,
		sizeof(WindowPartCode), NULL,
		&medPtr->windowPart);
    }
    if (err != noErr) {
	medPtr->windowPart = FindWindow(where, &medPtr->whichWin);
    }
    medPtr->window = TkMacOSXGetXWindow(medPtr->whichWin);
    if (medPtr->whichWin != NULL && medPtr->window == None) {
	return false;
    }
    if (eventPtr->eKind == kEventMouseDown) {
	if (IsWindowActive(medPtr->whichWin) && IsWindowPathSelectEvent(
		medPtr->whichWin, eventPtr->eventRef)) {
	    ChkErr(WindowPathSelect, medPtr->whichWin, NULL, NULL);
	    return false;
	}
	if (medPtr->windowPart == inProxyIcon) {
	    TkMacOSXTrackingLoop(1);
	    err = ChkErr(TrackWindowProxyDrag, medPtr->whichWin, where);
	    TkMacOSXTrackingLoop(0);
	    if (err == errUserWantsToDragWindow) {
		medPtr->windowPart = inDrag;
	    } else {
		return false;
	    }
	}
    }
    isFrontProcess = Tk_MacOSXIsAppInFront();
    if (isFrontProcess) {
	medPtr->state = ButtonModifiers2State(GetCurrentEventButtonState(),
		GetCurrentEventKeyModifiers());
    } else {
	medPtr->state = ButtonModifiers2State(GetCurrentButtonState(),
		GetCurrentKeyModifiers());
    }
    medPtr->global = where;
    err = ChkErr(GetEventParameter, eventPtr->eventRef,
	    kEventParamWindowMouseLocation,
	    typeQDPoint, NULL,
	    sizeof(Point), NULL,
	    &medPtr->local);
    if (err == noErr) {
	if (medPtr->whichWin) {
	    Rect widths;
	    GetWindowStructureWidths(medPtr->whichWin, &widths);
	    medPtr->local.h -=	widths.left;
	    medPtr->local.v -=	widths.top;
	}
    } else {
	medPtr->local = where;
	if (medPtr->whichWin) {
	    QDGlobalToLocalPoint(GetWindowPort(medPtr->whichWin),
		    &medPtr->local);
	}
    }
    medPtr->activeNonFloating = ActiveNonFloatingWindow();
    dispPtr = TkGetDisplayList();
    tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window);

    if (eventPtr->eKind != kEventMouseDown) {
	int res = false;

	switch (eventPtr->eKind) {
	    case kEventMouseUp:
		/*
		 * The window manager only needs to know about mouse down
		 * events and sometimes we need to "eat" the mouse up.
		 * Otherwise, we just pass the event to Tk.
		 */
		if (TkMacOSXGetEatButtonUp()) {
		    TkMacOSXSetEatButtonUp(false);
		} else {
		    res = GenerateButtonEvent(medPtr);
		}
		break;
	    case kEventMouseWheelMoved:
		err = ChkErr(GetEventParameter, eventPtr->eventRef,
			kEventParamMouseWheelDelta, typeLongInteger, NULL,
			sizeof(long), NULL, &medPtr->delta);
		if (err != noErr ) {
		    statusPtr->err = 1;
		} else {
		    EventMouseWheelAxis axis;
		    err = ChkErr(GetEventParameter, eventPtr->eventRef,
			    kEventParamMouseWheelAxis, typeMouseWheelAxis,
			    NULL, sizeof(EventMouseWheelAxis), NULL, &axis);
		    if (err == noErr && axis == kEventMouseWheelAxisX) {
			 medPtr->state |= ShiftMask;
		    }
		    res = GenerateMouseWheelEvent(medPtr);
		}
		break;
	    case kEventMouseMoved:
	    case kEventMouseDragged:
		res = GeneratePollingEvents(medPtr);
		break;
	    default:
		Tcl_Panic("Unknown mouse event !");
	}
	if (res) {
		statusPtr->stopProcessing = 1;
	}
	return res;
    }
    TkMacOSXSetEatButtonUp(false);
    if (medPtr->whichWin) {
	/*
	 * We got a mouse down in a window
	 * See if this is the activate click
	 * This click moves the window forward. We don't want
	 * the corresponding mouse-up to be reported to the application
	 * or else it will mess up some Tk scripts.
	 */

	if (!(TkpIsWindowFloating(medPtr->whichWin))
		&& (medPtr->whichWin != medPtr->activeNonFloating
		|| !isFrontProcess)) {
	    int frontWindowOnly = 1;
	    int cmdDragGrow = ((medPtr->windowPart == inDrag ||
		    medPtr->windowPart == inGrow) && medPtr->state & Mod1Mask);

	    if (!cmdDragGrow) {
		Tk_Window grabWin = GetGrabWindowForWindow(tkwin);

		frontWindowOnly = !grabWin;
		if (grabWin && grabWin != tkwin) {
		    TkMacOSXSetEatButtonUp(true);
		    BringWindowForward(TkMacOSXDrawableWindow(
			    ((TkWindow*)grabWin)->window), isFrontProcess,
			    frontWindowOnly);
		    return false;
		}
	    }

	    /*
	     * Clicks in the titlebar widgets are handled without bringing the
	     * window forward.
	     */
	    if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
		statusPtr->stopProcessing = 1;
		return result;
	    } else {
		/*
		 * Only windows with the kWindowNoActivatesAttribute can
		 * receive mouse events in the background.
		 */
		if (!(((TkWindow *)tkwin)->wmInfoPtr->attributes &
			kWindowNoActivatesAttribute)) {
		    /*
		     * Allow background window dragging & growing with Command
		     * down.
		     */
		    if (!cmdDragGrow) {
			TkMacOSXSetEatButtonUp(true);
			BringWindowForward(medPtr->whichWin, isFrontProcess,
				frontWindowOnly);
		    }
		    /*
		     * Allow dragging & growing of windows that were/are in the
		     * background.
		     */
		    if (!(medPtr->windowPart == inDrag ||
			    medPtr->windowPart == inGrow)) {
			return false;
		    }
		}
	    }
	} else {
	    if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
		statusPtr->stopProcessing = 1;
		return result;
	    }
	}
	switch (medPtr->windowPart) {
	    case inDrag: {
		WindowAttributes attributes;

		GetWindowAttributes(medPtr->whichWin, &attributes);
		if (!(attributes & kWindowAsyncDragAttribute)) {
		    TkMacOSXTrackingLoop(1);
		    DragWindow(medPtr->whichWin, where, NULL);
		    TkMacOSXTrackingLoop(0);
		    where2.h = where2.v = 0;
		    QDLocalToGlobalPoint(GetWindowPort(medPtr->whichWin),
			    &where2);
		    if (EqualPt(where, where2)) {
			return false;
		    }
		    return true;
		}
		break;
	    }
	    case inGrow:
		/*
		 * Generally the content region is the domain of Tk
		 * sub-windows. However, one exception is the grow
		 * region. A button down in this area will be handled
		 * by the window manager. Note: this means that Tk
		 * may not get button down events in this area!
		 */
		if (TkMacOSXGrowToplevel(medPtr->whichWin, where) == true) {
		    statusPtr->stopProcessing = 1;
		    return true;
		} else {
		    return GenerateButtonEvent(medPtr);
		}
		break;
	    case inContent:
		return GenerateButtonEvent(medPtr);
		break;
	    default:
		return false;
		break;
	}
    }
    return false;
}
Beispiel #18
0
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;
			}
		}
	}
}
// --------------------------------------------------------------------------------------
static void handleEvents(EventRecord *event)
{
	WindowRef window;
	Boolean activate;
	WindowPartCode partCode;
	OSErr error;
	Rect tempRect, newSize;
	long menuChoice;
	MenuCommand commandID;
	RgnHandle grayRegion;
	
	switch (event->what)	// handle events according to the priority 
	{						// determined by the system
		case activateEvt:
			window = (WindowRef)event->message;
			activate = (event->modifiers & activeFlag) != 0;
			HandleActivate(window, activate);
			break;
		
		case mouseDown:
			partCode = FindWindow(event->where, &window);
			
			switch(partCode)
			{
				case inMenuBar:
					menuChoice = MenuSelect(event->where);
					error = GetMenuItemCommandID(GetMenuRef(HiWord(menuChoice)), 
 													LoWord(menuChoice), &commandID);
					if (error == noErr)
					{
						if (commandID == 0)		// if the menu item clicked on does not have 
							commandID = (MenuCommand)menuChoice;	// a command ID
						HandleMenuChoice(commandID);
					}
					break;
				
				case inSysWindow:
					if (window != NULL)
						SystemClick(event, window);
					break;
				
				case inContent:		// the following window part codes will only be returned 
					if (window != FrontWindow())				// for the preferences window
						SelectWindow(window);
					else
						HandleContentClick(window, event->where, event->modifiers);
					break;
				
				case inDrag:
					grayRegion = GetGrayRgn();
					DragWindow(window, event->where, &((*grayRegion)->rgnBBox));
					break;
				
				case inGrow:	
					SetRect(&tempRect, kPrefsWindowPlatinumWidth, kPrefsWindowPlatinumHeight, 
							SHRT_MAX, SHRT_MAX);
					ResizeWindow(window, event->where, &tempRect, &newSize);
					AdjustControls(window);
					break;
				
				case inGoAway:
					ClosePrefsWindow(window);
					break;
			}
			break;
		
		case keyDown:
		case autoKey:	// a separate auto key handler would go after disk events
			if ((event->modifiers & cmdKey) != 0)
			{
				UInt32 keyMenuChoice;
				
				keyMenuChoice = MenuEvent(event);
				error = GetMenuItemCommandID(GetMenuRef(HiWord(keyMenuChoice)), 
												LoWord(keyMenuChoice), &commandID);
				if (error == noErr)
				{
					if (commandID == 0)		// if the menu item chosen does not have a 
						commandID = (MenuCommand)keyMenuChoice;		// command ID 
					HandleMenuChoice(commandID);					// (but they all should)
				}
			}
			else
			{
				window = FrontNonFloatingWindow();
				if (window != NULL)
				{
					char keyCode = (event->message & keyCodeMask) >> 8;
					
					HandleKeyDown(keyCode, window);
				}
			}
			break;
		
		case diskEvt:
			if (HiWord(event->message) != noErr) 
			{
				Point where;
			
				SetPt(&where, 70, 50);
				ShowCursor();
				DIBadMount(where, event->message);
			}		
			break;
		
		case updateEvt:
			window = (WindowRef)event->message;
			SetPortWindowPort(window);
			
			BeginUpdate(window);
			HandleDrawContent(window);
			EndUpdate(window);
			break;
		
		case kHighLevelEvent:		// an OS Event handler would go before high level events
			AEProcessAppleEvent(event);
			break;
	}
Beispiel #20
0
Boolean ThermDialog::DisplayTherm(int k,int maxk,unsigned char *st)
{

    Rect r;
    int	maxr;
    Handle h;
    short itemType;
    long 	temp;
    GrafPtr	tdp;
    WindowPtr   	window;
    short       	thePart;
    Rect        	screenRect, updateRect;
    Point			aPoint = {100, 100};
    Boolean 		QuitFlag = FALSE;
    short			item = 0;
    EventRecord 	event;
    short		the_part;
    DialogPtr 	hitdp;

    GetPort(&tdp);
    SetPort(dp);

    if (st != NULL)
    {
        GetDItem (dp,ids[THERM_TEXT], &itemType, &h, &r);
        SetIText(h,st);
    }


    GetDItem (dp, ids[THERM_BOX], &itemType, &h, &r);

    if (k == -1) k = old_k;
    if (maxk == -1) maxk = old_maxk;

    maxr = r.right;
    temp = ((long)k*((long)r.right - (long)r.left))/(long)maxk;
    r.right = r.left + temp;
    if (r.right>maxr) r.right=maxr;

    old_k = k;
    old_maxk = maxk;

    PenNormal ();
    PenPat(&qd.gray);
    PaintRect(&r);

    PenNormal ();

    SetPort(tdp);

    if (GetNextEvent(0xFFFF,&event))
    {
        if (event.what == mouseDown)
        {
            the_part = FindWindow(event.where, &window);
            if (IsDialogEvent(&event))
            {
                DialogSelect(&event,&hitdp,&item);
                if ((hitdp == dp) && (item == ids[THERM_CANCEL]))
                {
                    Quit = TRUE;
                    return FALSE;
                }
            }
            else switch (the_part) {
                case inSysWindow:
                    SystemClick (&event, window);
                    break;
                case inDrag:
                    screenRect = (**GetGrayRgn()).rgnBBox;
                    DragWindow( window, event.where, &screenRect );
                    break;
                }
        }
        else if (event.what == keyDown)
        {
            if ((event.modifiers & 0x0100) && ( (event.message) & charCodeMask == 0x02E))
            {
                Quit = TRUE;
                return FALSE;
            }
        }
        else if (event.what == updateEvt)
        {
            window = (WindowPtr)event.message;
            updateRect = (**(window->visRgn)).rgnBBox;
            SetPort( window ) ;
            BeginUpdate( window );
            DrawDialog( window );
            if (dp == window) box_d_item(dp,ids[THERM_BOX]);
            EndUpdate( window );
        }
    }
    if (Quit) return FALSE;
    return TRUE;
}
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;	
}
Beispiel #22
0
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) ) );
				}
			}
		}
	}
}
Beispiel #23
0
void Render::DragWindow(vec2 level)
{
	DragWindow(level,CT::GetCurDataID());
}
Beispiel #24
0
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;
}
Beispiel #25
0
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
}