Пример #1
0
void LToG (Rect *r) 
{
	Point	p1, p2;

	p1 = topLeft (*r);
	p2 = botRight (*r);
	LocalToGlobal (&p1);
	LocalToGlobal (&p2);
	Pt2Rect (p1, p2, r);
}
Пример #2
0
// --------------------------------------------------------------------------------------
void DisplayHelpBalloons(WindowRef prefsWindow)
{
	GrafPtr savedPort;
	Point mouseLocation;
	Rect hotRects[3];
	short hotRectID;
	static int previousHotRectID = kNotInHotRect;
	
	GetPort(&savedPort);
	SetPortWindowPort(prefsWindow);
	
	GetMouse(&mouseLocation);
	
	GetWindowProperty(prefsWindow, kAppSignature, kHotRectsTag, 3 * sizeof(Rect), NULL, 
						hotRects);
	
	for (hotRectID = kInList; hotRectID < kNotInHotRect; hotRectID++)
	{
		if (PtInRect(mouseLocation, &hotRects[hotRectID]))
		{
			if (hotRectID != previousHotRectID)
			{
				HMMessageRecord helpMessage;
				Point tips[3];
				
				helpMessage.hmmHelpType = khmmStringRes;
				helpMessage.u.hmmStringRes.hmmResID = rHelpStrings;
				helpMessage.u.hmmStringRes.hmmIndex = hotRectID + 1;
				
				GetWindowProperty(prefsWindow, kAppSignature, kBalloonTipsTag, 
									3 * sizeof(Point), NULL, tips);
				LocalToGlobal(&tips[hotRectID]);
				
				LocalToGlobal(&topLeft(hotRects[hotRectID]));
				LocalToGlobal(&botRight(hotRects[hotRectID]));
				
				HMShowBalloon(&helpMessage, tips[hotRectID], &hotRects[hotRectID], NULL, 
								kBalloonWDEFID, kTopLeftTipPointsLeftVariant, 
								kHMRegularWindow);
			}
				
			break;
		}
	}
	
	previousHotRectID = hotRectID;
	SetPort(savedPort);
}
Пример #3
0
// Create a DC representing the whole screen
wxScreenDC::wxScreenDC()
{
    m_macPort = CreateNewPort() ;
    GrafPtr port ;
    GetPort( &port ) ;
    SetPort( (GrafPtr) m_macPort ) ;
    Point pt = { 0,0 } ;
    LocalToGlobal( &pt ) ;     
    SetPort( port ) ;
    m_macLocalOrigin.x = -pt.h ;
    m_macLocalOrigin.y = -pt.v ;
#if wxMAC_USE_CORE_GRAPHICS
    m_macLocalOriginInPort = m_macLocalOrigin ;
#endif
    BitMap screenBits;
    GetQDGlobalsScreenBits( &screenBits );
    m_minX = screenBits.bounds.left ;

    SInt16 height ;
    GetThemeMenuBarHeight( &height ) ;
    m_minY = screenBits.bounds.top + height ;

    m_maxX = screenBits.bounds.right  ;
    m_maxY = screenBits.bounds.bottom ;

#if wxMAC_USE_CORE_GRAPHICS
    m_graphicContext = new wxMacCGContext( port ) ;    
#else
    MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
    OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
    CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
#endif
    m_ok = TRUE ;    
}
Пример #4
0
static void SetMouse(const Point *cp) {

#if TARGET_API_MAC_CARBON

	CGPoint	pt;

	pt.x = (float)cp->h;
	pt.y = (float)cp->v;
	CGWarpMouseCursorPosition(pt);

#else
	CursorDevice	*curdev;
	Point			pt;
	WindowPtr		saveport;

	curdev = NULL;
	CursorDeviceNextDevice(&curdev);
	if (curdev != NULL) {
		pt.h = cp->h;
		pt.v = cp->v;
		GetPort(&saveport);
		SetPort(hWndMain);
		LocalToGlobal(&pt);
		SetPort(saveport);
		CursorDeviceMoveTo(curdev, pt.h, pt.v);
	}
#endif
}
Пример #5
0
boolean clickcolorpopup (Point pt, RGBColor *rgb) {
	
	long result;
	short lo, hi;
	
	if (!flpopupinit)
		flpopupinit = initcolorpopup ();
	
	setcursortype (cursorisarrow);
	
	CalcMenuSize (colormenu);
	
	InsertMenu (colormenu, hierMenu);

	LocalToGlobal (&pt);
	
	result = PopUpMenuSelect (colormenu, pt.v, pt.h, -1);

	DeleteMenu ((**colormenu).menuID);
	
	lo = LoWord (result);
	
	hi = HiWord (result);
	
	if (hi > 0) { /*something was selected*/
	
		*rgb = (*ctable) [lo - 1].rgb;
		
		return (true);
		}
	
	return (false);
	} /*clickcolorpopup*/
Пример #6
0
void MCStack::setgeom()
{
	//set stack(window) size or position from script
	if (MCnoui || !opened)
		return;
	
	// MW-2009-09-25: Ensure things are the right size when doing
	//   remote dialog/menu windows.
	if (window == DNULL)
	{
		// MW-2011-08-18: [[ Redraw ]] Update to use redraw.
		MCRedrawLockScreen();
		state &= ~CS_NEED_RESIZE;
		resize(rect . width, rect . height);
		MCRedrawUnlockScreen();
		mode_setgeom();
		return;
	}
	
	// MW-2011-09-12: [[ MacScroll ]] Make sure we apply the current scroll setting.
	applyscroll();
	
	Rect windRect;
	GetPortBounds(GetWindowPort((WindowPtr)window->handle.window), &windRect);
	SetGWorld(GetWindowPort((WindowPtr)window->handle.window), GetMainDevice());
	Point p;
	p.h = windRect.left;
	p.v = windRect.top;
	LocalToGlobal(&p);
	int2 curWidth = windRect.right - windRect.left;
	int2 curHeight = windRect.bottom - windRect.top;
	if (IsWindowVisible((WindowPtr)window->handle.window))
	{
		if (mode != WM_SHEET && mode != WM_DRAWER
		        && (rect.x != p.h || rect.y != p.v))
		{
			MoveWindow((WindowPtr)window->handle.window, rect.x, rect.y, False);
			state |= CS_BEEN_MOVED;
		}
		if (rect.width != curWidth || rect.height != curHeight)
		{
			SizeWindow((WindowPtr)window->handle.window, rect.width, rect.height, True);
			resize(curWidth, curHeight + getscroll());
		}
		state &= ~CS_NEED_RESIZE;
	}
	else
	{
		if (mode != WM_SHEET && mode != WM_DRAWER)
			MoveWindow((WindowPtr)window->handle.window, rect.x, rect.y, False);
		if (rect.width != curWidth || rect.height != curHeight)
		{
			SizeWindow((WindowPtr)window->handle.window, rect.width, rect.height, True);
			resize(curWidth, curHeight + getscroll());

		}
		state &= ~(CS_BEEN_MOVED | CS_NEED_RESIZE);
	}
}
Пример #7
0
static void 
GenerateEditEvent(
    int flag)
{
    XVirtualEvent event;
    Point where;
    Tk_Window tkwin;
    Window window;
    TkDisplay *dispPtr;

    if (TkMacHaveAppearance() >= 0x110) {
        window = TkMacGetXWindow(FrontNonFloatingWindow());
    } else {
        window = TkMacGetXWindow(FrontWindow());
    }
    dispPtr = TkGetDisplayList();
    tkwin = Tk_IdToWindow(dispPtr->display, window);
    tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr;
    if (tkwin == NULL) {
	return;
    }

    event.type = VirtualEvent;
    event.serial = Tk_Display(tkwin)->request;
    event.send_event = false;
    event.display = Tk_Display(tkwin);
    event.event = Tk_WindowId(tkwin);
    event.root = XRootWindow(Tk_Display(tkwin), 0);
    event.subwindow = None;
    event.time = TkpGetMS();
    
    GetMouse(&where);
    tkwin = Tk_TopCoordsToWindow(tkwin, where.h, where.v, 
	    &event.x, &event.y);
    LocalToGlobal(&where);
    event.x_root = where.h;
    event.y_root = where.v;
    event.state = TkMacButtonKeyState();
    event.same_screen = true;
    
    switch (flag) {
	case EDIT_CUT:
	    event.name = Tk_GetUid("Cut");
	    break;
	    
	case EDIT_COPY:
	    event.name = Tk_GetUid("Copy");
	    break;
	    
	case EDIT_PASTE:
	    event.name = Tk_GetUid("Paste");
	    break;
	    
	case EDIT_CLEAR:
	    event.name = Tk_GetUid("Clear");
	    break;
    }
    Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
}
Пример #8
0
static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect)
{
    GetWindowPortBounds(window, inRect);
    Point pt = {inRect->left, inRect->top};
    SetPort((GrafPtr) GetWindowPort(window));
    LocalToGlobal(&pt);
    inRect->top = pt.v;
    inRect->left = pt.h;
    inRect->bottom += pt.v;
    inRect->right += pt.h;
}
Пример #9
0
bool CAI_LocalIdSpace::AddSymbol( const char *pszSymbol, int localId, const char *pszDebugSymbolType, const char *pszDebugOwner )
{
	AssertMsg( AI_IdIsLocal( localId ), ("Global symbol ID passed to CAI_LocalIdSpace::AddSymbol()") );
	
	if ( !m_pGlobalNamespace )
	{
		DevMsg( "ERROR: Adding symbol to uninitialized table %s\n", pszDebugOwner );
		return false;
	}
	
	if ( !IsLocalBaseSet() && !SetLocalBase( localId ) )
	{
		DevMsg( "ERROR: Bad %s LOCALID for %s\n", pszDebugSymbolType, pszDebugOwner );
		return false;
	}
	else if (localId < GetLocalBase() )
	{
		DevMsg("ERROR: %s First added %s must be first LOCALID!\n", pszDebugSymbolType, pszDebugOwner);
		return false;
	}

	AssertMsg3( LocalToGlobal( localId ) == -1 || !m_pGlobalNamespace->IdToSymbol( LocalToGlobal( localId ) ) , "Duplicate symbol ID passed to CAI_LocalIdSpace::AddSymbol(): %s (%d), had %s", pszSymbol, localId, m_pGlobalNamespace->IdToSymbol( LocalToGlobal( localId ) ) );
	AssertMsg( m_pGlobalNamespace->SymbolToId( pszSymbol ) == -1, "Duplicate symbol passed to CAI_LocalIdSpace::AddSymbol()" );

	if ( m_localTop != -1 )
	{
		if ( localId > m_localTop )
		{
			m_localTop = localId;
			m_globalTop = ( m_localTop - m_localBase ) + m_globalBase;
		}
	}
	else
	{
		m_localTop = m_localBase;
		m_globalTop = m_globalBase;
	}
	
	m_pGlobalNamespace->AddSymbol( pszSymbol, LocalToGlobal( localId ) );
	return true;
}
Пример #10
0
/*** MAKE GLOBAL ***/
void MakeGlobal( WindowRef window, Point localPoint, Point *globalPoint )
{
	GrafPtr oldPort;
	GetPort( &oldPort );
	SetPortWindowPort( window );
	
	globalPoint->h = localPoint.h;
	globalPoint->v = localPoint.v;
	LocalToGlobal( globalPoint );

	SetPort( oldPort );
}
Пример #11
0
//_______________________________________________________________________________
void WritePos (WindowPtr win, short	resFile)
{
	Handle h = NewHandle (sizeof(Point));
	if (h) {
		Point *p = (Point *)*h;
  		SetPort(win);
		p->h = win->portRect.left;
		p->v = win->portRect.top;
		LocalToGlobal(p);
		WriteRsrc (h, kWinPosRsrc, kWinposID, resFile);
	}
}
Пример #12
0
//_______________________________________________________________________________
void AdjustLocation (WindowPtr win)
{
	Point pt;
	
	pt.h = win->portRect.left + 6;	// 6 is enough to grab
	pt.v = win->portRect.top + 6;	// 6 is enough to grab
	LocalToGlobal(&pt);
	
	if (!PtInRgn( pt, GetGrayRgn())) {
		MoveWindow (win, qd.screenBits.bounds.left + 50,	qd.screenBits.bounds.top  + 50, false);
	}
}
Пример #13
0
Файл: MacGraph.c Проект: rolk/ug
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);
}
Пример #14
0
void close_default(MacWindow* macwin)
{
	Point	p;
	Rect	r;
	
	//Get Log Window position
	SetPortWindowPort(macwin->ref);
	p.v=p.h=0;
	LocalToGlobal(&p);
	macwin->X=p.h, macwin->Y=p.v;
	r= GetWindowPort(macwin->ref)->portRect;
	macwin->width= r.right-r.left;
	macwin->hight= r.bottom-r.top;
}
Пример #15
0
void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackground )
{
    GrafPtr formerPort ;
    GetPort( &formerPort ) ;
    SetPortWindowPort( (WindowRef)m_macWindow ) ;

    m_macNeedsErasing |= eraseBackground ;

    // if we already know that we will have to erase, there's no need to track the rest
    if ( !m_macNeedsErasing)
    {
        // we end only here if eraseBackground is false
        // if we already have a difference between m_macNoEraseUpdateRgn and UpdateRgn
        // we will have to erase anyway

        RgnHandle       updateRgn = NewRgn();
        RgnHandle       diffRgn = NewRgn() ;
        if ( updateRgn && diffRgn )
        {
            GetWindowUpdateRgn( (WindowRef)m_macWindow , updateRgn );
            Point pt = {0,0} ;
            LocalToGlobal( &pt ) ;
            OffsetRgn( updateRgn , -pt.h , -pt.v ) ;
            DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ;
            if ( !EmptyRgn( diffRgn ) )
            {
                m_macNeedsErasing = true ;
            }
        }
        if ( updateRgn )
            DisposeRgn( updateRgn );
        if ( diffRgn )
            DisposeRgn( diffRgn );

        if ( !m_macNeedsErasing )
        {
            RgnHandle rectRgn = NewRgn() ;
            SetRectRgn( rectRgn , ((Rect*)rect)->left , ((Rect*)rect)->top , ((Rect*)rect)->right , ((Rect*)rect)->bottom ) ;
            UnionRgn( (RgnHandle) m_macNoEraseUpdateRgn , rectRgn , (RgnHandle) m_macNoEraseUpdateRgn ) ;
            DisposeRgn( rectRgn ) ;
        }
    }
    InvalWindowRect( (WindowRef)m_macWindow , (Rect*)rect ) ;
    // turn this on to debug the refreshing cycle
#if wxMAC_DEBUG_REDRAW
    PaintRect( rect ) ;
#endif
    SetPort( formerPort ) ;
}
Пример #16
0
/*
 * Make sure the right cursor's being displayed.
 */
static void mac_adjustcursor(RgnHandle cursrgn)
{
    Point mouse;
    WindowPtr window, front;
    short part;
#if TARGET_API_MAC_CARBON
    Cursor arrow;
    RgnHandle visrgn;
#endif

    GetMouse(&mouse);
    LocalToGlobal(&mouse);
    part = FindWindow(mouse, &window);
    front = FrontWindow();
    if (part != inContent || window == NULL || window != front) {
	/* Cursor isn't in the front window, so switch to arrow */
#if TARGET_API_MAC_CARBON
	GetQDGlobalsArrow(&arrow);
	SetCursor(&arrow);
#else
	SetCursor(&qd.arrow);
#endif
	SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
	if (front != NULL) {
#if TARGET_API_MAC_CARBON
	    visrgn = NewRgn();
	    GetPortVisibleRegion(GetWindowPort(front), visrgn);
	    DiffRgn(cursrgn, visrgn, cursrgn);
	    DisposeRgn(visrgn);
#else
	    DiffRgn(cursrgn, front->visRgn, cursrgn);
#endif
	}
    } else {
	if (mac_wininfo(window)->adjustcursor != NULL)
	    (*mac_wininfo(window)->adjustcursor)(window, mouse, cursrgn);
	else {
#if TARGET_API_MAC_CARBON
	    GetQDGlobalsArrow(&arrow);
	    SetCursor(&arrow);
	    GetPortVisibleRegion(GetWindowPort(window), cursrgn);
#else
	    SetCursor(&qd.arrow);
	    CopyRgn(window->visRgn, cursrgn);
#endif
	}
    }
}
Пример #17
0
void mac_warp_mouse()      {
#ifndef ACTIVEGS
  Rect port_rect;
  Point win_origin_pt;
  CGPoint cgpoint;
  CGDisplayErr cg_err;

  GetPortBounds(GetWindowPort(g_main_window), &port_rect);
  SetPt(&win_origin_pt, port_rect.left, port_rect.top);
  LocalToGlobal(&win_origin_pt);

  cgpoint = CGPointMake( (float)(win_origin_pt.h + X_A2_WINDOW_WIDTH/2),
                         (float)(win_origin_pt.v + X_A2_WINDOW_HEIGHT/2));
  cg_err = CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
#endif
}
Пример #18
0
void SetMouse (int x, int y) {
	Point base;
	// This routine donated to MacMAME by John Stiles
	// Picked up for RadiosGL from the Mac GLQuake site
    Point *RawMouse   = (Point*) 0x82C;
    Point *MTemp      = (Point*) 0x828;
    Ptr    CrsrNew    = (Ptr)    0x8CE;
    Ptr    CrsrCouple = (Ptr)    0x8CF;
    
	base.v = y;
	base.h = x;
	LocalToGlobal(&base);
	
    *RawMouse = base;
    *MTemp    = base;
    *CrsrNew  = *CrsrCouple;
	}
Пример #19
0
static void CenterWindow(WindowPtr w, int top)
	{
		Rect scr; Point p;
		int rsize,size,margin,xoff,yoff;

		scr = qd.screenBits.bounds;
		SetPort(w);
		p.h = w->portRect.left; p.v = w->portRect.top;
		LocalToGlobal(&p);

		size = scr.right - scr.left;
		rsize = w->portRect.right - w->portRect.left;
		margin = size - rsize;
		if (margin > 0) {
			margin >>= 1;
			p.h = scr.left + margin;
			}
Пример #20
0
void wxTopLevelWindowMac::Maximize(bool maximize)
{
    wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ;
    wxMacWindowClipper clip (this);
    ZoomWindow( (WindowRef)m_macWindow , maximize ? inZoomOut : inZoomIn , false ) ;

    Rect tempRect ;
    GrafPtr port ;
    GetPort( &port ) ;
    Point pt = { 0, 0 } ;
    SetPortWindowPort((WindowRef)m_macWindow) ;
    LocalToGlobal( &pt ) ;
    SetPort( port ) ;

    GetWindowPortBounds((WindowRef)m_macWindow, &tempRect ) ;
    SetSize( pt.h , pt.v , tempRect.right-tempRect.left ,
        tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
}
Пример #21
0
void get_window_frame(
	WindowPtr window,
	Rect *frame)
{
	GrafPtr old_port;
	Point corner;
	
	GetPort(&old_port);
	SetPort(window);
	SetPt(&corner, 0, 0);
	LocalToGlobal(&corner);
	SetPort(old_port);
	
	*frame= window->portRect;
	OffsetRect(frame, corner.h-frame->left, corner.v-frame->top);

	return;
}
Пример #22
0
// Create a DC representing the whole screen
wxScreenDC::wxScreenDC()
{
#if wxMAC_USE_CORE_GRAPHICS
    CGRect cgbounds ;
    cgbounds = CGDisplayBounds(CGMainDisplayID());
    Rect bounds;
    bounds.top = (short)cgbounds.origin.y;
    bounds.left = (short)cgbounds.origin.x;
    bounds.bottom = bounds.top + (short)cgbounds.size.height;
    bounds.right = bounds.left  + (short)cgbounds.size.width;
    WindowAttributes overlayAttributes  = kWindowIgnoreClicksAttribute;
    CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow );
    ShowWindow((WindowRef)m_overlayWindow);
    SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) );
    m_width = (wxCoord)cgbounds.size.width;
    m_height = (wxCoord)cgbounds.size.height;
#else
    m_macPort = CreateNewPort() ;
    GrafPtr port ;
    GetPort( &port ) ;
    SetPort( (GrafPtr) m_macPort ) ;
    Point pt = { 0,0 } ;
    LocalToGlobal( &pt ) ;
    SetPort( port ) ;
    m_macLocalOrigin.x = -pt.h ;
    m_macLocalOrigin.y = -pt.v ;

    BitMap screenBits;
    GetQDGlobalsScreenBits( &screenBits );
    m_minX = screenBits.bounds.left ;

    SInt16 height ;
    GetThemeMenuBarHeight( &height ) ;
    m_minY = screenBits.bounds.top + height ;

    m_maxX = screenBits.bounds.right  ;
    m_maxY = screenBits.bounds.bottom ;

    MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
    OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
    CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
#endif
    m_ok = true ;
}
Пример #23
0
void CGraphics::Render() {
  CDisplayObject::Render();
  if (texture != NULL) {
    if (rect.w == 0) {
      if (src != NULL && src->w != 0) {
        rect.w = src->w;
        rect.h = src->h;
      } else {
        rect.w = texture->GetWidth();
        rect.h = texture->GetHeight();
      }
    }
    SDL_Point point = LocalToGlobal(SDL_Point{0, 0});
    //SDL_Point point = {rect.x, rect.y};
    //texture->RenderEx(point.x, point.y, src,
    //   rotation, &center, flip, rect.w, rect.h, alpha);
    //texture->Render(point.x, point.y);
    texture->Render(point.x, point.y, src, rect.w, rect.h, alpha);
  }
}
Пример #24
0
void
TkMacSetUpClippingRgn(
    Drawable drawable)		/* Drawable to update. */
{
    MacDrawable *macDraw = (MacDrawable *) drawable;

    if (macDraw->winPtr != NULL) {
	if (macDraw->flags & TK_CLIP_INVALID) {
	    TkMacUpdateClipRgn(macDraw->winPtr);
	}

	/*
	 * When a menu is up, the Mac does not expect drawing to occur and
	 * does not clip out the menu. We have to do it ourselves. This
	 * is pretty gross.
	 */

	if (macDraw->clipRgn != NULL) {
	    if (tkUseMenuCascadeRgn == 1) {
	    	Point scratch = {0, 0};
	    	GDHandle saveDevice;
	    	GWorldPtr saveWorld;
	    	
	    	GetGWorld(&saveWorld, &saveDevice);
	    	SetGWorld(TkMacGetDrawablePort(drawable), NULL);
	    	LocalToGlobal(&scratch);
	    	SetGWorld(saveWorld, saveDevice);
	    	if (tmpRgn == NULL) {
	    	    tmpRgn = NewRgn();
	    	}
	    	CopyRgn(tkMenuCascadeRgn, tmpRgn);
	    	OffsetRgn(tmpRgn, -scratch.h, -scratch.v);
	    	DiffRgn(macDraw->clipRgn, tmpRgn, tmpRgn);
	    	SetClip(tmpRgn);
	    	macDraw->toplevel->flags |= TK_DRAWN_UNDER_MENU;
	    } else {
	    	SetClip(macDraw->clipRgn);
	    }
	}
    }
}
Пример #25
0
void Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
#if !TARGET_API_MAC_CARBON
	CursorDevice *cursordevice;

	cursordevice = nil;
	CursorDeviceNextDevice(&cursordevice);
	if ( cursordevice != nil ) {
		WindowPtr saveport;
		Point where;

		GetPort(&saveport);
		SetPort(SDL_Window);
		where.h = x;
		where.v = y;
		LocalToGlobal(&where);
		SetPort(saveport);
		CursorDeviceMoveTo(cursordevice, where.h, where.v);
	}
#endif /* !TARGET_API_MAC_CARBON */
}
Пример #26
0
void DoMouseDown(EventRecord *event)
{	
	int			myPart;
	WindowPtr	myWindow;
	Point		point;

	myPart = FindWindow(event->where, &myWindow);
	
	switch(myPart)
	{
		case inMenuBar:
			DrawMenuBar();
			DoMenuCommand(MenuSelect(event->where));
		break;
		case inSysWindow:
			SystemClick(event, myWindow);
		break;
		case inDrag:
			DoDrag(myWindow, event->where);
			
			// update the vid_xpos / vid_ypos cvars
			point.h = 0;
			point.v = 0;
			LocalToGlobal( &point );
			Cvar_SetValue( "vid_xpos", point.h );
			Cvar_SetValue( "vid_ypos", point.v );
			return;
		break;
		case inGoAway:
			DoGoAwayBox(myWindow, event->where);
		break;

		case inContent:
			if (myWindow != FrontWindow())
			{
				SelectWindow(myWindow);
			}
		break;
	}
}
Пример #27
0
int
TkScrollWindow(
    Tk_Window tkwin,		/* The window to be scrolled. */
    GC gc,			/* GC for window to be scrolled. */
    int x,			/* Position rectangle to be scrolled. */
    int y,
    int width,
    int height,
    int dx,			/* Distance rectangle should be moved. */
    int dy,
    TkRegion damageRgn)		/* Region to accumulate damage in. */
{
    MacDrawable *destDraw = (MacDrawable *) Tk_WindowId(tkwin);
    RgnHandle rgn = (RgnHandle) damageRgn;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    GWorldPtr destPort;
    Rect srcRect, scrollRect;
    
    destPort = TkMacGetDrawablePort(Tk_WindowId(tkwin));

    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacSetUpClippingRgn(Tk_WindowId(tkwin));

    /*
     * Due to the implementation below the behavior may be differnt
     * than X in certain cases that should never occur in Tk.  The 
     * scrollRect is the source rect extended by the offset (the union 
     * of the source rect and the offset rect).  Everything
     * in the extended scrollRect is scrolled.  On X, it's possible
     * to "skip" over an area if the offset makes the source and
     * destination rects disjoint and non-aligned.
     */
       
    SetRect(&srcRect, (short) (destDraw->xOff + x),
	    (short) (destDraw->yOff + y),
	    (short) (destDraw->xOff + x + width),
	    (short) (destDraw->yOff + y + height));
    scrollRect = srcRect;
    if (dx < 0) {
	scrollRect.left += dx;
    } else {
	scrollRect.right += dx;
    }
    if (dy < 0) {
	scrollRect.top += dy;
    } else {
	scrollRect.bottom += dy;
    }

    /*
     * Adjust clip region so that we don't copy any windows
     * that may overlap us.
     */
    RectRgn(rgn, &srcRect);
    DiffRgn(rgn, destPort->visRgn, rgn);
    OffsetRgn(rgn, dx, dy);
    DiffRgn(destPort->clipRgn, rgn, destPort->clipRgn);
    SetEmptyRgn(rgn);
    
    /*
     * When a menu is up, the Mac does not expect drawing to occur and
     * does not clip out the menu. We have to do it ourselves. This
     * is pretty gross.
     */

    if (tkUseMenuCascadeRgn == 1) {
    	Point scratch = {0, 0};
    	MacDrawable *macDraw = (MacDrawable *) Tk_WindowId(tkwin);

	LocalToGlobal(&scratch);
	CopyRgn(tkMenuCascadeRgn, rgn);
	OffsetRgn(rgn, -scratch.h, -scratch.v);
	DiffRgn(destPort->clipRgn, rgn, destPort->clipRgn);
	SetEmptyRgn(rgn);
	macDraw->toplevel->flags |= TK_DRAWN_UNDER_MENU;
    }
	
    ScrollRect(&scrollRect, dx, dy, rgn);
    
    SetGWorld(saveWorld, saveDevice);
    
    /*
     * Fortunantly, the region returned by ScrollRect is symanticlly
     * the same as what we need to return in this function.  If the
     * region is empty we return zero to denote that no damage was
     * created.
     */
    if (EmptyRgn(rgn)) {
	return 0;
    } else {
	return 1;
    }
}
Пример #28
0
static void getMouseLoc(Point *mouseLoc)
{
	GetMouse(mouseLoc);
	LocalToGlobal(mouseLoc);
}
Пример #29
0
bool nuiSWF::Draw(nuiDrawContext* pContext)
{
  gameswf::set_render_handler(mpRenderHandler);

  nglTime now;
  if (mLastTime <= 0)
    mLastTime = now;
  double lap = now - mLastTime;
  mLastTime = now;
  /* double advance = lap * mFPS; unused */

  nuiRenderArray* pDummy = new nuiRenderArray(GL_POINTS);
  pContext->DrawArray(pDummy);

  glPushAttrib(GL_ALL_ATTRIB_BITS);
  
  float width, height;
  width = mpMovie->get_width_pixels();
  height = mpMovie->get_height_pixels();
  //glScalef(10/width, 10/height, 0);

  nuiSize x=0,y=0;
  LocalToGlobal(x,y);

  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_EDGE_FLAG_ARRAY);
  glDisableClientState(GL_INDEX_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  glDisableClientState(GL_VERTEX_ARRAY);

  mpMovieInterface->set_display_viewport(ToBelow(x), ToBelow(y), ToBelow(mRect.GetWidth()), ToBelow(mRect.GetHeight()));
  //mpMovieInterface->set_display_viewport(50, 50, 1, 1);
  mpMovieInterface->set_background_alpha(GetAlpha());
  if (IsPlaying())
    mpMovieInterface->advance((float)lap);               
  mpMovieInterface->display();       

  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_EDGE_FLAG_ARRAY);
  glDisableClientState(GL_INDEX_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  glDisableClientState(GL_VERTEX_ARRAY);

  // Restore state that gameswf kills
  glDisable(GL_TEXTURE_GEN_S);
  glDisable(GL_TEXTURE_GEN_T);

  // See if we should exit.
  if (mLoop == false 
    && (mpMovieInterface->get_current_frame() + 1 == mpMovie->get_frame_count() 
    || mpMovieInterface->get_play_state() == gameswf::character::STOP)
    )
  {
  // We're reached the end of the movie; exit.
    Stop();
  }

  glPopAttrib();
  pContext->SetTexture(NULL);
  return true;
}
Пример #30
0
/*