Esempio n. 1
0
//	Creates an overlay window which will move with its parent.  This technique is typical for doing things like drawing on top of movies,
//	creating selection rectangles, drawing on top of GL windows, etc.
static	void	CreateOverlayWindow( WindowRef window )
{
	OSStatus					err;
	Rect						windowRect;
	WindowStorage				*windowStorage		= (WindowStorage*) GetWRefCon( window );
    WindowAttributes			overlayAttributes	= kWindowNoShadowAttribute | kWindowIgnoreClicksAttribute | kWindowNoActivatesAttribute | kWindowStandardHandlerAttribute;
	static	EventHandlerUPP		overlayWindowEventHandlerUPP;
	const EventTypeSpec	windowEvents[]	=
	    {
			{ kEventClassWindow, kEventWindowBoundsChanged },
			{ kEventClassWindow, kEventWindowShown },
			{ kEventClassWindow, kEventWindowClose }
		};

    SetPortWindowPort( window );
	GetWindowPortBounds( window, &windowRect );
	LocalToGlobalRect( &windowRect );											//	Window to be size of window it lies on
	err	= CreateNewWindow( kOverlayWindowClass, overlayAttributes, &windowRect, &windowStorage->overlayWindow );	
	if ( err != noErr ) goto Bail;

	SetWindowGroup( windowStorage->overlayWindow, GetWindowGroup(window) );		//	Put them in the same group so that their window layers are consistent

	if ( overlayWindowEventHandlerUPP == NULL ) overlayWindowEventHandlerUPP	= NewEventHandlerUPP( OverlayWindowEventHandlerProc );
	err	= InstallWindowEventHandler( windowStorage->overlayWindow, overlayWindowEventHandlerUPP, GetEventTypeCount(windowEvents), windowEvents, windowStorage, NULL );

	ShowWindow( windowStorage->overlayWindow );
Bail:
	return;
}
Esempio n. 2
0
void wxGLCanvas::SetViewport()
{
    // viewport is initially set to entire port
    // adjust glViewport to just this window
    int x = 0 ;
    int y = 0 ;
    
    wxWindow* iter = this ;
    while( iter->GetParent() )
    {
    	iter = iter->GetParent() ;
    }
    
    if ( iter && iter->IsTopLevel() )
    {
	    MacClientToRootWindow( &x , &y ) ;
	    int width, height;
	    GetClientSize(& width, & height);
	    Rect bounds ;
	    GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ;
	    GLint parms[4] ;
	    parms[0] = x ;
	    parms[1] = bounds.bottom - bounds.top - ( y + height ) ;
	    parms[2] = width ;
	    parms[3] = height ;
	    
	    if ( !m_macCanvasIsShown )
	    	parms[0] += 20000 ;
	    aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ;
   	}
}
Esempio n. 3
0
static
void resize_window(void)
{
  double max_width, max_height;
  int width, height;
  Rect wRect;

  max_width = MWIDTH;
  max_height = max_width * p->sheight / p->swidth;

  gks_fit_ws_viewport(p->viewport, max_width, max_height, 0.075);
  width = nint((p->viewport[1] - p->viewport[0]) / max_width * p->swidth);
  height = nint((p->viewport[3] - p->viewport[2]) / max_height * p->sheight);

  if (p->width != width || p->height != height)
    {
      p->width = width;
      p->height = height;

      SizeWindow(p->win, width, height, TRUE);

      GetWindowPortBounds(p->win, &wRect);
      ClipRect(&wRect);
    }
}
// Window Controls
WindowRef windowInitialize(GLWindow *glw)
{
    OSStatus err;
    
    if(glw == NULL)
    {
	err = -1;
	return NULL;
    }

#if __APPLE_CC__
    err = CreateNibReference(CFSTR("main"), &glw->nibRef);
    err = SetMenuBarFromNib(glw->nibRef, CFSTR("MenuBar"));
    err = CreateWindowFromNib(glw->nibRef, CFSTR("MainWindow"), &glw->pWin);
    err = CreateWindowFromNib(glw->nibRef, CFSTR("Window"), &glw->supportWindow); 
#else
    err = CreateNewWindow(kDocumentWindowClass, 
			  kWindowStandardDocumentAttributes | 
			  kWindowStandardHandlerAttribute,
			  &winRect, 
			  &glw->pWin);
    InitializeMenu();
#endif
    ShowWindow(glw->supportWindow);
    ShowWindow(glw->pWin);
    // Set our rectangle
    GetWindowPortBounds(glw->pWin, &glw->winRect);
    return glw->pWin;
}
Esempio n. 5
0
/* draw image to frame */
static void icvDrawImage( CvWindow* window )
{
    Assert( window != 0 );
    if( window->imageRef == 0 ) return;
    
    CGContextRef myContext;
    CvTrackbar* t; 
    CGRect rect;
    Rect portrect;
    int width = window->imageWidth;
    int height = window->imageHeight;
    
        GetWindowPortBounds(window->window, &portrect);
    
    if( window->flags & CV_WINDOW_AUTOSIZE ) 
	{ 
        CGPoint origin = {0,0}; 
        CGSize size = {portrect.right-portrect.left, portrect.bottom-portrect.top-window->trackbarheight};
        rect.origin = origin; rect.size = size;
    } 
	else 
	{
        CGPoint origin = {0, portrect.bottom - height - window->trackbarheight};
        CGSize size = {width, height};
        rect.origin = origin; rect.size = size;
    }
    
    /* To be sybnchronous we are using this, better would be to susbcribe to the draw event and process whenever requested, we might save SOME CPU cycles*/
    SetPortWindowPort (window->window);
    QDBeginCGContext (GetWindowPort (window->window), &myContext);
    CGContextSetInterpolationQuality (myContext, kCGInterpolationLow); 
    CGContextDrawImage(myContext,rect,window->imageRef);
    CGContextFlush(myContext);// 4
    QDEndCGContext (GetWindowPort(window->window), &myContext);// 5
}
Esempio n. 6
0
static void window_invalidate(WindowRef windowRef)
{
    Rect portRect;

    GetWindowPortBounds(windowRef, &portRect);
    InvalWindowRect(windowRef, &portRect);
}
Esempio n. 7
0
static void draw_window_contents(
	WindowPtr wp)
{
	GrafPtr old_port;

	GetPort(&old_port);
	SetPortWindowPort(wp);

	/* Any specific updating stuff.... */
	
#ifdef OP_PLATFORM_MAC_CARBON_FLAG
	{
		Rect	windowBounds;
		GetWindowPortBounds(wp, &windowBounds);
		EraseRect(&windowBounds);
	}
	#else
		EraseRect(&wp->portRect);
	#endif
	
	update_log(wp);

	SetPort(old_port);

	return;
}
Esempio n. 8
0
void wxGLCanvas::SetViewport()
{
#ifndef __LP64__
    // viewport is initially set to entire port
    // adjust glViewport to just this window
    int x = 0 ;
    int y = 0 ;

    wxWindow* iter = this ;
    while( iter->GetParent() )
    {
        iter = iter->GetParent() ;
    }

    if ( iter && iter->IsTopLevel() )
    {
        MacClientToRootWindow( &x , &y ) ;
        int width, height;
        GetClientSize(& width, & height);
        Rect bounds ;
#if 0
		// TODO in case we adopt point vs pixel coordinates, this will make the conversion
        GetWindowPortBounds( MAC_WXHWND(MacGetTopLevelWindowRef()) , &bounds ) ;
        HIRect hiRect = CGRectMake( x, y, width, height ) ;
        HIRectConvert( &hiRect, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceScreenPixel, NULL) ;
        HIRect hiBounds = CGRectMake( 0, 0, bounds.right - bounds.left , bounds.bottom - bounds.top ) ;
        HIRectConvert( &hiBounds, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceScreenPixel, NULL) ;
        GLint parms[4] ;
        parms[0] = hiRect.origin.x ;
        parms[1] = hiBounds.size.height - (hiRect.origin.y + hiRect.size.height) ;
        parms[2] = hiRect.size.width ;
        parms[3] = hiRect.size.height ;
#else
        GetWindowPortBounds( MAC_WXHWND(MacGetTopLevelWindowRef()) , &bounds ) ;
        GLint parms[4] ;
        parms[0] = x ;
        parms[1] = bounds.bottom - bounds.top - ( y + height ) ;
        parms[2] = width ;
        parms[3] = height ;
#endif
        if ( !m_macCanvasIsShown )
            parms[0] += 20000 ;
        aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ;
        aglUpdateContext(m_glContext->m_glContext);
   }
#endif
}
Esempio n. 9
0
void AquaGui::renderBuffer()
{
    _glue.render();

      Rect rectPort;
      GetWindowPortBounds (myWindow, &rectPort);
      InvalWindowRect (myWindow,  &rectPort); // force redrow
}
Esempio n. 10
0
void doUpdateWindow(EventRecord *eventStrucPtr)
{
    IMAGE *img;
    WindowRef    windowRef;
    Rect         srcRect, destRect, fillRect;
    PixMapHandle srcPixmapHdl, destPixmapHdl;
    RGBColor     grayColour = { 0xC000,0xC000,0xC000 };
    SInt32  hScroll, vScroll;

    windowRef = (WindowRef) eventStrucPtr->message;
    img = (IMAGE*)GetWRefCon(windowRef);
    srcPixmapHdl = img->pixmapHdl;
    destPixmapHdl = GetPortPixMap(GetWindowPort(windowRef));
    hScroll = GetControl32BitValue(img->scrollbarHorizRef);
    vScroll = GetControl32BitValue(img->scrollbarVertRef);

    if (srcPixmapHdl)
    {
        PixMap *pixmap = *srcPixmapHdl;
        PixPatHandle hdlPixPat = NewPixPat();
        MakeRGBPat(hdlPixPat, &grayColour);

        GetWindowPortBounds(windowRef,&destRect);
        destRect.right  -= kScrollBarWidth;
        destRect.bottom -= kScrollBarWidth;

        if (destRect.right > pixmap->bounds.right)
        {
            fillRect.top = destRect.top;
            fillRect.bottom = destRect.bottom;
            fillRect.left = pixmap->bounds.right;
            fillRect.right = destRect.right;
            FillCRect(&fillRect, hdlPixPat);
            destRect.right = pixmap->bounds.right;
        }
        if (destRect.bottom > pixmap->bounds.bottom)
        {
            fillRect.top = pixmap->bounds.bottom;
            fillRect.bottom = destRect.bottom;
            fillRect.left = destRect.left;
            fillRect.right = destRect.right;
            FillCRect(&fillRect, hdlPixPat);
            destRect.bottom = pixmap->bounds.bottom;
        }
        DisposePixPat(hdlPixPat);

        srcRect = destRect;
        srcRect.left += hScroll;
        srcRect.right += hScroll;
        srcRect.top += vScroll;
        srcRect.bottom += vScroll;

        CopyBits((BitMap*)*srcPixmapHdl, (BitMap*)*destPixmapHdl,
                 &srcRect, &destRect, srcCopy, NULL);
    }

    DrawGrowIcon(windowRef);
}
static OSStatus handleWindowEvent(EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
    OSStatus err;

    // Get the window
    WindowRef window;
    err = GetEventParameter(event, kEventParamDirectObject, typeWindowRef, 0, sizeof(window), 0, &window);
    if (err != noErr)
        return err;

    // Handle the different kinds of events
    ::UInt32 eventKind = GetEventKind(event);
    switch (eventKind)
    {
    // Quit the application when the user closes the window
    case kEventWindowClose:
        QuitApplicationEventLoop();
        return noErr;

    // Draw the contents of the window
    case kEventWindowDrawContent:
        redraw();
        return noErr;

    case kEventWindowBoundsChanged:
        {
            // Update the GL context
            aglUpdateContext(win->getContext());

            // Find out if we have a move or a resize situation
            ::UInt32 attributes;
            GetEventParameter(event, kEventParamAttributes, typeUInt32, 0, sizeof(attributes), 0, &attributes);

            if ((attributes & kWindowBoundsChangeSizeChanged) != 0)
            {
                // Get the new bounds of the window
                Rect bounds;
                GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, 0, sizeof(Rect), 0, &bounds);

                // Resize the OpenSG Window
                GLsizei width = bounds.right - bounds.left;
                GLsizei height = bounds.bottom - bounds.top;
                win->resize(width, height);

                // Redraw the whole window
                Rect portRect;
                GetWindowPortBounds(window, &portRect);
                InvalWindowRect(window, &portRect);
            }

            return noErr;
        }

    default:
        return eventNotHandledErr;
    }
}
Esempio n. 12
0
static void CenterWindow(WindowRef ref)
{
    Rect rect, bounds;
    GetWindowPortBounds(ref, &rect);
    GetRegionBounds(GetGrayRgn(), &bounds);
    int lx = bounds.right - bounds.left;
    int ly = bounds.bottom - bounds.top;
    rect.left = bounds.left + ((lx - (rect.right - rect.left))/2);
    rect.top = bounds.top + ((ly - (rect.bottom - rect.top))/2);
    MoveWindow(ref, rect.left, rect.top, true);
}
Esempio n. 13
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;
}
Esempio n. 14
0
static
void clear_ws(void)
{
  Rect rect;

  set_clip_rect(0);
  set_color(0);

  GetWindowPortBounds(p->win, &rect);
  PaintRect(&rect);

  set_clip_rect(gkss->cntnr);
}
Esempio n. 15
0
static void window_adjust_scrollbars(WindowRef windowRef)
{
    IMAGE *img;
    Rect   portRect;

    img = (IMAGE*)GetWRefCon(windowRef);
    GetWindowPortBounds(windowRef,&portRect);

    /* Move the crollbars to the edges of the window */
    HideControl(img->scrollbarVertRef);
    HideControl(img->scrollbarHorizRef);

    MoveControl(img->scrollbarVertRef,portRect.right - kScrollBarWidth,
                portRect.top - 1);
    MoveControl(img->scrollbarHorizRef,portRect.left - 1,
                portRect.bottom - kScrollBarWidth);

    SizeControl(img->scrollbarVertRef,kScrollBarWidth + 1,
                portRect.bottom - portRect.top - kScrollBarWidth + 1);
    SizeControl(img->scrollbarHorizRef, portRect.right - portRect.left - kScrollBarWidth + 1,
                kScrollBarWidth + 1);

    /* Adjust the scroll position showing */
    if (img->pixmapHdl)
    {
        PixMap *pixmap = *(img->pixmapHdl);
        int visibleHeight = portRect.bottom - portRect.top - kScrollBarWidth;
        int visibleWidth = portRect.right - portRect.left - kScrollBarWidth;

        if (pixmap->bounds.bottom > visibleHeight)
        {
            SetControl32BitMaximum(img->scrollbarVertRef,
                                   pixmap->bounds.bottom - visibleHeight);
            SetControlViewSize(img->scrollbarVertRef,visibleHeight);
        }
        else
            SetControlMaximum(img->scrollbarVertRef, 0);

        if (pixmap->bounds.right > visibleWidth)
        {
            SetControl32BitMaximum(img->scrollbarHorizRef,
                                   pixmap->bounds.right - visibleWidth);
            SetControlViewSize(img->scrollbarHorizRef, visibleWidth);
        }
        else
            SetControlMaximum(img->scrollbarHorizRef, 0);
    }

    ShowControl(img->scrollbarVertRef);
    ShowControl(img->scrollbarHorizRef);
}
Esempio n. 16
0
void DrawWindow(WindowRef window)
{
    Rect		tempRect;
    GrafPtr		curPort;
	
    GetPort(&curPort);
    SetPort(GetWindowPort(window));
    BeginUpdate(window);
    EraseRect(GetWindowPortBounds(window, &tempRect));
    DrawControls(window);
    DrawGrowIcon(window);
    EndUpdate(window);
    SetPort(curPort);
}
void
GelatinePaneView::swapPortsAndDisplay()
{
  GrafPtr savedPort;
  GetPort(&savedPort);
  SetPort(GetWindowPort(_model._windowRef));
  aglSetDrawable(_model._aglContext, GetWindowPort(_model._windowRef));
  aglSetCurrentContext(_model._aglContext);
  display();

    Rect portRect;
    GetWindowPortBounds(getModel().getWindowRef(), &portRect);
    InvalWindowRect(getModel().getWindowRef(), &portRect);
  
  SetPort(savedPort);
}
pascal OSStatus gelatineRendererEventHandler(EventHandlerCallRef handler,
                                             EventRef event,
                                             void* userData)
{
  OSStatus result = eventNotHandledErr;
  GelatinePaneView* view = reinterpret_cast <GelatinePaneView*> (userData);
  UInt32 eventKind = GetEventKind(event);

  switch (eventKind) {

  case kEventControlInitialize:
    view->init();
    break;

  case kEventControlDispose:
    view->dispose();
    break;

  case kEventControlActivate:
    view->swapPortsAndDisplay();
    break;

  case kEventControlDeactivate:
    break;

  case kEventControlDraw:
    view->swapPortsAndDisplay();
    break;

  case kEventControlBoundsChanged:
    Rect* controlRect = view->getModel()._bounds;

    Rect portRect;
    GetWindowPortBounds(view->getModel().getWindowRef(), &portRect);
    InvalWindowRect(view->getModel().getWindowRef(), &portRect);

    view->resize(controlRect->left,
                 controlRect->top,
                 controlRect->right,
                 controlRect->bottom);
    view->swapPortsAndDisplay();
    break;

  }

  return result;
}
Esempio n. 19
0
OSStatus QuartzEventHandler( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData )
{
	OSStatus 	err = eventNotHandledErr;
	UInt32		eventKind = GetEventKind( inEvent ), RWinCode, devsize;
        int		devnum;
        WindowRef 	EventWindow;
        EventRef	REvent;
        NewDevDesc 	*dd;
 	
        if( GetEventClass(inEvent) != kEventClassWindow)
         return(err);
         
        GetEventParameter(inEvent, kEventParamDirectObject, typeWindowRef, NULL, sizeof(EventWindow),
                                NULL, &EventWindow);
                                
        if(GetWindowProperty(EventWindow, kRAppSignature, 'QRTZ', sizeof(int), NULL, &devnum) != noErr)
           return eventNotHandledErr;
                                
        switch(eventKind){
            case kEventWindowClose:
            {
                KillDevice(GetDevice(devnum));
                err= noErr; 
            }
            break;
         
            case kEventWindowBoundsChanged:
                if( (dd = ((GEDevDesc*) GetDevice(devnum))->dev) ){
                    QuartzDesc *xd = (QuartzDesc *) dd-> deviceSpecific;
                    Rect portRect;
                    GetWindowPortBounds ( xd->window, & portRect ) ;
                    if( (xd->windowWidth != portRect.right) || (xd->windowHeight != portRect.bottom) ){
					 xd->resize = true;
                     dd->size(&(dd->left), &(dd->right), &(dd->bottom), &(dd->top), dd);
					 xd->resize = false;
                     GEplayDisplayList((GEDevDesc*) GetDevice(devnum));      
                    }  
                    err = noErr;
                }
            break;

            default:
            break;
        }    
 	   
	return err;
}
Esempio n. 20
0
void texture_palette_setup(void)
{
	Rect			wbox;
	
	GetWindowPortBounds(mainwind,&wbox);
		
	txt_pixel_sz=((wbox.right-piece_wid)-(wbox.left+16))/txt_wind_column_count;
	if (txt_pixel_sz>txt_wind_max_pixel_sz) txt_pixel_sz=txt_wind_max_pixel_sz;
	
	txt_palette_high=(txt_wind_row_count*txt_pixel_sz);
	txt_palette_y=(wbox.bottom-txt_palette_high)-info_high;
	
	txt_palette_box.lx=wbox.left;
	txt_palette_box.rx=wbox.right-piece_wid;
	txt_palette_box.ty=txt_palette_y;
	txt_palette_box.by=txt_palette_box.ty+txt_palette_high;
}
Esempio n. 21
0
void QTApp_Idle (WindowReference theWindow)
{
	WindowObject 		myWindowObject = NULL;
	GrafPtr 			mySavedPort;
	
	GetPort(&mySavedPort);
	MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
	
	myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
	if (myWindowObject != NULL) {
		MovieController		myMC = NULL;
	
		myMC = (**myWindowObject).fController;
		if (myMC != NULL) {
			
			// run any idle-time tasks for the movie
			
#if TARGET_OS_MAC
			// restore the cursor to the arrow
			// if it's outside the front movie window or outside the window's visible region
			if (theWindow == QTFrame_GetFrontMovieWindow()) {
				Rect			myRect;
				Point			myPoint;
				RgnHandle		myVisRegion;
				Cursor			myArrow;
				
				GetMouse(&myPoint);
				myVisRegion = NewRgn();
				GetPortVisibleRegion(QTFrame_GetPortFromWindowReference(theWindow), myVisRegion);
				GetWindowPortBounds(theWindow, &myRect);
				if (!MacPtInRect(myPoint, &myRect) || !PtInRgn(myPoint, myVisRegion))
					MacSetCursor(GetQDGlobalsArrow(&myArrow));
					
				DisposeRgn(myVisRegion);
			}
#endif // TARGET_OS_MAC
		}
	}
	
	// grant the sequence grabber some processor time
	if (gSeqGrabber != NULL)
		SGIdle(gSeqGrabber);

	MacSetPort(mySavedPort);
}
Esempio n. 22
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);
}
Esempio n. 23
0
void QTApp_Idle (WindowReference theWindow)
{
	WindowObject 		myWindowObject = NULL;
	GrafPtr 			mySavedPort;
	
	GetPort(&mySavedPort);
	MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
	
	myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
	if (myWindowObject != NULL) {
		MovieController		myMC = NULL;
	
		myMC = (**myWindowObject).fController;
		if (myMC != NULL) {
			
			// run any idle-time tasks for the movie
			
#if TARGET_OS_MAC
			// restore the cursor to the arrow
			// if it's outside the front movie window or outside the window's visible region
			if (theWindow == QTFrame_GetFrontMovieWindow()) {
				Rect			myRect;
				Point			myPoint;
				RgnHandle		myVisRegion;
				Cursor			myArrow;
				
				GetMouse(&myPoint);
				myVisRegion = NewRgn();
				GetPortVisibleRegion(QTFrame_GetPortFromWindowReference(theWindow), myVisRegion);
				GetWindowPortBounds(theWindow, &myRect);
				if (!MacPtInRect(myPoint, &myRect) || !PtInRgn(myPoint, myVisRegion))
					MacSetCursor(GetQDGlobalsArrow(&myArrow));
					
				DisposeRgn(myVisRegion);
			}
#endif // TARGET_OS_MAC
		}
		
		// see whether the user has added a text track behind our backs (e.g. by pasting some text)
		QTText_SyncWindowData(myWindowObject);
	}
	
	MacSetPort(mySavedPort);
}
Esempio n. 24
0
static	pascal	OSStatus OverlayWindowEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData )
{
	#pragma unused( inCallRef )
	Rect				windowRect;
	CGRect				box;
	CGContextRef		cgContext;
	UInt32				eventKind		= GetEventKind( inEvent );
	UInt32				eventClass		= GetEventClass( inEvent );
	OSStatus			err				= eventNotHandledErr;
	WindowStorage		*windowStorage	= (WindowStorage*) inUserData;

	switch ( eventClass )
	{
		case kEventClassWindow:
			if ( eventKind == kEventWindowClose )
			{
				windowStorage->overlayWindow = NULL;		//	Let the default handler DisposeWindow() for us, just set our WindowRef to NULL
			}
			else if ( (eventKind == kEventWindowBoundsChanged) || (eventKind == kEventWindowShown) )	//	Draw the overlay window
			{
				GetWindowPortBounds( windowStorage->overlayWindow, &windowRect );
				//box.origin.x	= box.origin.y	= 0;
				//box.size.width	= windowRect.right - windowRect.left;
				//box.size.height	= windowRect.bottom - windowRect.top;
				box	= CGRectMake( 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top );
				
				QDBeginCGContext( GetWindowPort(windowStorage->overlayWindow), &cgContext );
				CGContextClearRect( cgContext, box );
				
				//	Paint a semi-transparent box in the middle of our window
				box.origin.x	= (windowRect.right - windowRect.left) / 4;
				box.size.width	= (windowRect.right - windowRect.left) / 2;
				CGContextSetRGBFillColor( cgContext, 0.5, 0.75, 0.75, 0.2 );
				CGContextFillRect( cgContext, box );
				
				CGContextFlush( cgContext );
				QDEndCGContext( GetWindowPort(windowStorage->overlayWindow), &cgContext );
			}
			break;
	}
	return( err );
}
Esempio n. 25
0
static
void get_pointer(double *x, double *y, int *state)
{
  Point mouse;
  EventModifiers modifiers;
  Rect rect;
  int mousex, mousey;

  GetWindowPortBounds(p->win, &rect);

  GetMouse(&mouse);
  mousex = mouse.h;
  mousey = mouse.v;
  crosshair(mousex, mousey);

  *state = GKS_K_STATUS_OK;
  do
    {  
      get_mouse(&mouse, &modifiers);

      if (mousex != mouse.h || mousey != mouse.v)
	{
	  crosshair(mousex, mousey);
	  mousex = mouse.h;
	  mousey = mouse.v;
	  crosshair(mousex, mousey);
	}
      usleep(10000);

      if (!(modifiers & 0x80) && modifiers & 0xff00)
	{
	  *state = GKS_K_STATUS_NONE;
	  break;
	}
    }
  while (modifiers);

  crosshair(mousex, mousey);

  DC_to_NDC(mousex, mousey, *x, *y);
}
Esempio n. 26
0
void wxGLCanvas::SetViewport()
{
    if ( !m_needsUpdate )
        return;

    m_needsUpdate = false;

//    AGLContext context = aglGetCurrentContext();
//    if ( !context )
//        return;

    // viewport is initially set to entire port, adjust it to just this window
    int x = 0,
        y = 0;
    MacClientToRootWindow(&x , &y);

    int width, height;
    GetClientSize(&width, &height);

    Rect bounds;
    GetWindowPortBounds(MAC_WXHWND(MacGetTopLevelWindowRef()) , &bounds);

    GLint parms[4];
    parms[0] = x;
    parms[1] = bounds.bottom - bounds.top - ( y + height );
    parms[2] = width;
    parms[3] = height;

    // move the buffer rect out of sight if we're hidden
    if ( !m_macCanvasIsShown )
        parms[0] += 20000;

    if ( !aglSetInteger(m_dummyContext, AGL_BUFFER_RECT, parms) )
        wxLogAGLError("aglSetInteger(AGL_BUFFER_RECT)");

    if ( !aglEnable(m_dummyContext, AGL_BUFFER_RECT) )
        wxLogAGLError("aglEnable(AGL_BUFFER_RECT)");

    if ( !aglUpdateContext(m_dummyContext) )
        wxLogAGLError("aglUpdateContext");
}
Esempio n. 27
0
static void 	Quartz_Size(double *left, double *right,
		     	 double *bottom, double *top, NewDevDesc *dd)
{
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
    Rect portRect;

    GetWindowPortBounds ( xd->window, & portRect ) ;

    *left = 0.0;
    *right = portRect.right;
    *bottom = portRect.bottom;
    *top = 0.0;

    if(xd->resize){
		xd->windowWidth = *right - *left;
		xd->windowHeight = *bottom - *top;
		SetCGContext(xd);
		xd->resize = false;
	}
    return;
}
Esempio n. 28
0
void
PaneView::resize(short left, short top, short right, short bottom)
{
  aglSetCurrentContext(_model._aglContext);
  aglUpdateContext(_model._aglContext);

  short width = right - left;
  short height = bottom - top;
  float aspectRatio =  (float) width / (float) height;
  //  float fieldOfViewY = 45.0f * _model.getSpace().getCurrentShot().getCamera().getZoom();
  float fieldOfViewY = 45.0f * _model.getSpace().getShots().next().getCamera().getZoom();

  Rect portRect;
  GetWindowPortBounds(_model._windowRef, &portRect);
  short portHeight = portRect.bottom - portRect.top;

  GLint bufferRect[4];
  bufferRect[0] = _model._bounds->left; // x
  bufferRect[1] = portHeight - _model._bounds->bottom; // y
  bufferRect[2] = _model._bounds->right - _model._bounds->left; // width
  bufferRect[3] = _model._bounds->bottom - _model._bounds->top; // height

  aglSetInteger(_model._aglContext, AGL_BUFFER_RECT, bufferRect);
  aglEnable(_model._aglContext, AGL_BUFFER_RECT);

  //  aglSetInteger(inData->mContext, AGL_CLIP_REGION, (const GLint*)rgn);
  //  aglEnable(inData->mContext, AGL_CLIP_REGION);

  glViewport(0, 0, width, height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(fieldOfViewY, aspectRatio, 1.0f, 1000.0f);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  InvalWindowRect(_model._windowRef, &portRect);
  _model.getSpace().resize(width, height);
}
Esempio n. 29
0
static
void create_window(ws_state_list *p)
{
  Rect screenRect, wRect;
  CGrafPtr screenPort;

  screenPort = CreateNewPort();
  GetPortBounds(screenPort, &screenRect);
  DisposePort(screenPort);

  p->width = p->height = 500;
  p->swidth = screenRect.right - screenRect.left;
  p->sheight = screenRect.bottom - screenRect.top;

  p->window[0] = p->window[2] = 0.0;
  p->window[1] = p->window[3] = 1.0;
  p->viewport[0] = p->viewport[2] = 0;
  p->viewport[1] = (double)p->width * MWIDTH / p->swidth;
  p->viewport[3] = (double)p->height * MWIDTH / p->sheight;

  SetRect(&wRect, 0, 0, p->width, p->height);
  CreateNewWindow(
    kDocumentWindowClass,
    kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute,
    &wRect, &p->win);

  SetWindowTitleWithCFString(p->win, CFSTR("GKS 5"));
  ChangeWindowAttributes(p->win, 0,
                         kWindowCloseBoxAttribute | kWindowResizableAttribute);
  RepositionWindow(p->win, NULL, kWindowCascadeOnMainScreen);
  ShowWindow(p->win);

  GetWindowPortBounds(p->win, &wRect);
  ClipRect(&wRect);

  set_xform();
}
Esempio n. 30
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;
	}
}