Example #1
0
void drawBackground()
{
	Rect		rect;
	RGBColor	color;
	Rect		tempRect1;
	
	color.red = color.green = color.blue = 8700;
	
	RGBForeColor( &color );
	PaintRect( GetPortBounds(GetWindowPort(gWindow), &tempRect1));
	
	TextFont( kFontIDTimes );
	TextMode( srcOr );
	TextSize( 24 );
	
	drawName( 85, 22, "\pSource Image" );
	drawName( GetPortBounds(GetWindowPort(gWindow), &tempRect1)->right - 215, 22, "\pNew Image" );
	
	GetPortBounds(GetWindowPort(gWindow), &tempRect1);
	SetRect( &rect, 15, tempRect1.bottom - 180, tempRect1.right - 15, tempRect1.bottom - 30);
	drawDeepBox( &rect );
	
	TextSize( 12 );
	
	drawName( tItem[0].rect.left, tItem[0].rect.top - 8, "\pTransfer Mode" );
	drawName( aItem[0].rect.left, aItem[0].rect.top - 8, "\pArithmetic Mode" );
	drawName( cItem[0].rect.left, cItem[0].rect.top - 8, "\pColorization" );
	drawName( dItem[0].rect.left, dItem[0].rect.top - 8, "\pDither" );
	drawName( mItem[0].rect.left, mItem[0].rect.top - 8, "\pColor Mapping" );
	drawName( bItem[0].rect.left, bItem[0].rect.top - 8, "\pDestination" );
	drawName( pItem[0].rect.left, pItem[0].rect.top - 8, "\pPaint Bucket" );
	drawName( lItem[0].rect.left, lItem[0].rect.top - 8, "\pLasso Tool" );
}
Example #2
0
void createWindow()
{
	int		width, height;
	int		left, top;
	Rect	rect;
	Rect	tempRect1;
	BitMap	bitMap;
	
	GetPortBounds(gGWorld, &tempRect1);
	
	width = 58 + (tempRect1.right - tempRect1.left) * 2;
	height = 230 + tempRect1.bottom - tempRect1.top;
	
	
	tempRect1 = GetQDGlobalsScreenBits(&bitMap)->bounds;
	
	left = (((tempRect1.right - tempRect1.left) - width) / 2);
	top = (((tempRect1.bottom - tempRect1.top) - height) / 2) + 20;

	SetRect( &rect, left, top, left + width, top + height );
	gWindow = NewCWindow( 0L, &rect, "\pQuickDraw Special Effects", true, noGrowDocProc,
							(WindowPtr)-1L, true, 0 );
							
	SetPortWindowPort( gWindow );
}
Example #3
0
static void mac_updatelicence(WindowPtr window)
{
    Handle h;
    int len;
    long fondsize;
    Rect textrect;

    SetPort((GrafPtr)GetWindowPort(window));
    BeginUpdate(window);
    fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
    TextFont(HiWord(fondsize));
    TextSize(LoWord(fondsize));
    h = Get1Resource('TEXT', wLicence);
    len = GetResourceSizeOnDisk(h);
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(window), &textrect);
#else
    textrect = window->portRect;
#endif
    if (h != NULL) {
	HLock(h);
	TETextBox(*h, len, &textrect, teFlushDefault);
	HUnlock(h);
    }
    EndUpdate(window);
}
void QTApp_Draw (WindowReference theWindow)
{
	GrafPtr 					mySavedPort = NULL;
	GrafPtr 					myWindowPort = NULL;
	WindowPtr					myWindow = NULL;
	Rect						myRect;
	
	GetPort(&mySavedPort);
	
	myWindowPort = QTFrame_GetPortFromWindowReference(theWindow);
	myWindow = QTFrame_GetWindowFromWindowReference(theWindow);
	
	if (myWindowPort == NULL)
		return;
		
	MacSetPort(myWindowPort);
	
#if TARGET_API_MAC_CARBON
	GetPortBounds(myWindowPort, &myRect);
#else
	myRect = myWindowPort->portRect;
#endif

	BeginUpdate(myWindow);

	// erase any part of a movie window that hasn't already been updated
	// by the movie controller
	if (QTFrame_IsMovieWindow(theWindow))
		EraseRect(&myRect);

	// ***insert application-specific drawing here***
	
	EndUpdate(myWindow);
	MacSetPort(mySavedPort);
}
Example #5
0
void createWindow()
{
	Rect 	wBounds;
	BitMap	bitMap;
	Rect 	tempRect1;
	int		top, left, width, height;
	
	GetQDGlobalsScreenBits(&bitMap);
	
	width = ((bitMap.bounds.right - bitMap.bounds.left) / 2);
	height = ((bitMap.bounds.bottom - bitMap.bounds.top) / 2);

	left = (((bitMap.bounds.right - bitMap.bounds.left) - width) / 2);
	top = (((bitMap.bounds.bottom - bitMap.bounds.top) - height) / 2);
	
	/* Create a window to display the final offscreen image. */
	
	//SetRect( &wBounds, WLEFT, WTOP, WLEFT + WWIDTH, WTOP + WHEIGHT );
	SetRect( &wBounds, left, top, left + width, top + height );
	
	gWindow = NewCWindow( 0L, &wBounds, "\pSnapshot Test", false, documentProc,
							(WindowPtr)-1L, true, 0L );
							
	//SetRect( &gBounds, 0, 0, gWindow->portRect.right - gWindow->portRect.left,
	//				gWindow->portRect.bottom - gWindow->portRect.top );
	GetPortBounds(GetWindowPort(gWindow), &tempRect1);
	SetRect( &gBounds, 0, 0, tempRect1.right - tempRect1.left, 
	 tempRect1.bottom - tempRect1.top);
							
	//SetPort( gWindow );
	SetPortWindowPort( gWindow );
}
void drawPixelImageData()
{
	int				row, col;
	Rect			rect;
	unsigned char	value;
	char			*image;
	int				index = 0;
	Str255			string;
	RGBColor		color = { 32000, 32000, 32000 };
	//Byte			mode;
	Rect			tempRect1;
	
	ForeColor( blackColor );
	
	SetRect( &rect, 0, 0, 20, 20 );
	
	/* For this example, let's just use only the upper left corner of the image. */
	
	// Draw the offscreen image to the screen to see what it looks like.
	//CopyBits( (BitMap *)*gPixmap, &gWindow->portBits, &rect,
	//		&gWindow->portRect, srcCopy, 0 );
	//(**gPixmap).rowBytes ^= 0x8000;
	CopyBits( (BitMap *)*gPixmap, GetPortBitMapForCopyBits(GetWindowPort(gWindow)), &rect,
			GetPortBounds(GetWindowPort(gWindow), &tempRect1), srcCopy, 0 );
	//(**gPixmap).rowBytes ^= 0x8000;
	
	RGBForeColor( &color );
	
	// Again, set the pointer to the beginning of the pixel image.
	image = GetPixBaseAddr( gPixmap );
	
	/***************************************************************/
	/* Finally let's display the pixel values on top of the image. */
	/***************************************************************/
	
	/* Loop through the first 20 rows of the pixel image. */
	for (row = 0; row < rect.bottom; row++)
	{
		// Loop through the first 20 columns of the pixel image. 
		for (index = 0, col = 0; col < rect.right; col++)
		{
			// Get the value at this index into the pixel image. 
			value = (unsigned char)*(image + index);
			
			MoveTo( col * 30, row * 20 );
			LineTo( col * 30, (row + 1) * 20 );
			LineTo( (col + 1) * 30, (row + 1) * 20 );
			
			MoveTo( (col * 30) + 6, (row * 20) + 14 );
			NumToString( (long)value, string );
			DrawString( string );
			
			index++;
		}
		
		// Increment the pointer to the next row of the pixel image. 
		image += ((**gPixmap).rowBytes & 0x7fff);
	}
}
Example #7
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);
	}
}
Example #8
0
void BURGER_API Burger::OkAlertMessage(const char *pMessage,const char *pTitle)
{
	Word8 *TitleStr;		/* Pointer to the window title */
	DialogPtr MyDialog;	/* My dialog pointer */
	Handle ItemList;	/* Handle to the item list */
	Rect DialogRect;	/* Rect of the dialog window */
	Word TitleLen;		/* Length of the title */
	Word MessLen;		/* Length of the caption */
	short ItemHit;		/* Junk */
	Rect WorkRect;
	GrafPtr MyPort;	/* My grafport */
	//Word Foo;
	
	//Foo = InputSetState(FALSE);
		
	GetPort(&MyPort);	/* Save the current port */
	
	/* Center my dialog to the screen */
#if ACCESSOR_CALLS_ARE_FUNCTIONS
	GetPortBounds(MyPort,&WorkRect);
#else
	WorkRect = MyPort->portRect;
#endif
	DialogRect.top = static_cast<short>((((WorkRect.bottom-WorkRect.top)-190)/2)+WorkRect.top);
	DialogRect.left = static_cast<short>((((WorkRect.right-WorkRect.left)-350)/2)+WorkRect.left);
	DialogRect.bottom = static_cast<short>(DialogRect.top+190);
	DialogRect.right = static_cast<short>(DialogRect.left+350);

	TitleLen = 0;			/* Assume no length */
	if (pTitle) {
		TitleLen = Burger::StringLength(pTitle);		/* Get the length of the title string */
	}
	TitleStr = (Word8 *)Burger::Alloc(TitleLen+1);	/* Get memory of pascal string */
	if (TitleStr) {			/* Did I get the memory? */
		MemoryCopy(TitleStr+1,pTitle,TitleLen);
		TitleStr[0] = static_cast<Word8>(TitleLen);		/* Set the pascal length */
		
		MessLen = Burger::StringLength(pMessage);	/* Size of the message */
		ItemList = NewHandle(static_cast<Size>(sizeof(Template)+MessLen));
		if (ItemList) {				/* Ok? */
			Template[sizeof(Template)-1]=static_cast<Word8>(MessLen);	/* Save the message length */
			MemoryCopy(ItemList[0],Template,sizeof(Template));	/* Copy the template */
			MemoryCopy((ItemList[0])+sizeof(Template),pMessage,MessLen);	/* Copy the message */
			MyDialog = NewDialog(0,&DialogRect,(Word8 *)TitleStr,TRUE,5,(WindowPtr)-1,FALSE,0,ItemList);
			if (MyDialog) {
				SetDialogDefaultItem(MyDialog,1);	/* Default for OK button */
				ModalDialog(0,&ItemHit);			/* Handle the event */
				DisposeDialog(MyDialog);			/* Kill the dialog */
			} else {
				DisposeHandle(ItemList);			/* I must kill this myself! */
			}
		}
		Burger::Free(TitleStr);				/* Kill the title */
	}
	SetPort(MyPort);			/* Restore my grafport */
	//InputSetState(Foo);
}
Example #9
0
void cPict::drawFullSheet(short num, Rect to_rect){
	Rect from_rect;
	if(!isSheetSet(SHEET_FULL,num)) throw xMissingSheet(SHEET_FULL,num);
	GWorldPtr from_gw = largeSheets[num];
	GetPortBounds(from_gw, &from_rect);
	to_rect.right = to_rect.left + (from_rect.right - from_rect.left);
	to_rect.bottom = to_rect.top + (from_rect.bottom - from_rect.top);
	rect_draw_some_item(from_gw, from_rect, to_rect, (Point){0,0});
}
Example #10
0
void drawExampleName()
{
	int			left, top;
	Rect		rect;
	Str255		label = "\pCurrent Example:  ";
	Str255		name[9] = {	"\p TRANSFER MODES", "\pARITHMETIC MODES", "\p   DITHERING",
							"\p  COLORIZATION", "\p  COLOR MAPPING", "\p  PAINT BUCKET",
							"\p   LASSO TOOL", "\pPIXEL AVERAGING", "\p    CUSTOM"	};
	Rect		tempRect1;
	
	left = 15;
	top = GetPortBounds(GetWindowPort(gWindow), &tempRect1)->bottom - 13;
	
	drawName( left, top, label );
	left += StringWidth( label );
	
	SetRect( &rect, left - 2, top - 12, left + 130, top + 4 );
	eraseRect( &rect );
	
	drawName( left, top, name[(gCurrentExample / 10) - 1] );
}

void drawTime( long ticks )
{
	Rect	rect;
	int		left, top;
	float	seconds;
	char	cString[40];
	Rect	tempRect1;
	
	GetPortBounds(GetWindowPort(gWindow), &tempRect1);
	left = tempRect1.right - 130;
	top = tempRect1.bottom - 13;
	
	
	SetRect( &rect, left - 2, top - 12, left + 90, top + 4 );
	eraseRect( &rect );
	
	seconds = (float)ticks / 60.0;
	sprintf( &cString[0], "Draw Time: %03.03f secs", seconds );
	
	drawName( left, top, C2PStr( cString ) );
}
Example #11
0
void getCurrentPortBounds(Rect* inRect)
{
    /*------------------------------------------------------
        Simple utility function to get the bounds of the
        current port.
    --------------------------------------------------------*/
    CGrafPtr thePort;
    GetPort(&thePort);
    GetPortBounds(thePort,inRect);
}
Example #12
0
int ioPositionOfWindow(wIndexType windowIndex)
{
	Rect portRect;
	if (windowHandleFromIndex(windowIndex) == nil)
		return -1;
		
	GetPortBounds(GetWindowPort(windowHandleFromIndex(windowIndex)),&portRect);
 	QDLocalToGlobalRect(GetWindowPort(windowHandleFromIndex(windowIndex)), &portRect);
	return (portRect.left << 16) | (portRect.top & 0xFFFF);  /* left is high 16 bits; top is low 16 bits */
}
Example #13
0
File: MacGraph.c Project: rolk/ug
void DrawInfoBox (WINDOWID win, const char *info)
{
  WindowPtr theMacWindow;
  Rect r,box,WinRect;
  CGrafPtr myPort;
  Rect myClipRect;
  short w;
  GRAPH_WINDOW *gw;
  Str255 pstr;

  gw = (GRAPH_WINDOW *)win;
  theMacWindow = MAC_WIN(gw);
  /* set port */
  myPort = GetWindowPort(theMacWindow);
  SetPort(myPort);

  GetPortBounds(myPort,&WinRect);

  PmForeColor(1);               /* black */
  GetPortBounds(myPort,&r);

  /* info box */
  SetRect(&box,r.left+1,r.bottom-14,r.right-121,r.bottom);

  /* set clipping region to info box */
  ClipRect(&box);

  EraseRect(&box);

  CopyCStringToPascal(info,pstr);
  w = StringWidth(pstr);
  MoveTo((box.left+box.right)/2-w/2,box.bottom-3);
  TextSize(9);
  DrawString(pstr);

  /* adjust clipping rectangle again to plottable area */
  myClipRect.left   = gw->Local_LL[0];
  myClipRect.right  = gw->Local_UR[0];
  myClipRect.bottom = gw->Local_LL[1];
  myClipRect.top    = gw->Local_UR[1];

  ClipRect(&myClipRect);
}
Example #14
0
/*
 * For some reason, LNew doesn't seem to respect the hasGrow
 * parameter, so we hammer the scrollbar into shape ourselves.
 */
static void mac_adjusteventlogscrollbar(Session *s)
{
#if TARGET_API_MAC_CARBON
    Rect winrect;

    GetPortBounds(GetWindowPort(s->eventlog_window), &winrect);
    SizeControl(GetListVerticalScrollBar(s->eventlog),
		16, winrect.bottom - 13);
#else
    SizeControl((*s->eventlog)->vScroll,
		16, s->eventlog_window->portRect.bottom - 13);
#endif
}
Example #15
0
void drawImage(WindowPtr theWindow)
{
	Rect tempRect1;
	/* Copy the offscreen image back onto the window. */

	//CopyBits( (BitMap *)&gPixMap, &gWindow->portBits, &gPixMap.bounds,
	//			&gWindow->portRect, srcCopy, 0l);
	
	CopyBits( (BitMap *)&gPixMap, GetPortBitMapForCopyBits(GetWindowPort(theWindow)), &gPixMap.bounds,
		GetPortBounds(GetWindowPort(gWindow), &tempRect1), srcCopy, 0L);
				
	ShowWindow( gWindow );
}
Example #16
0
static void getmaincenter(Point *cp) {

#if TARGET_API_MAC_CARBON
	Rect	rct;

	GetPortBounds(GetWindowPort(hWndMain), &rct);
	cp->h = (rct.right + rct.left) / 2;
	cp->v = (rct.bottom + rct.top) / 2;
#else
	cp->h = 320;
	cp->v = 200;
#endif
}
Example #17
0
int ioSizeOfWindow(wIndexType windowIndex)
{
	Rect portRect;
	int w, h;

	if (windowHandleFromIndex(windowIndex) == nil)
		return -1;


	GetPortBounds(GetWindowPort(windowHandleFromIndex(windowIndex)),&portRect);
	w =  portRect.right -  portRect.left;
	h =  portRect.bottom - portRect.top;
	return (w << 16) | (h & 0xFFFF);  /* w is high 16 bits; h is low 16 bits */
}
Example #18
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
}
Example #19
0
void drawGraphic( CGContextRef context, float x, float y )
{
    static GWorldPtr imageGW = NULL;
    static CGImageRef imageRef = NULL;
    static CGDataProviderRef dataProviderRef = NULL;

    Rect bounds;
    static size_t width;
    static size_t height;
    size_t bitsPerComponent;
    size_t bitsPerPixel;
    size_t bytesPerRow;
    PixMapHandle pmh;    
    
    //	Load the image if we haven't already
    if ( NULL == imageGW )
    {
        //	Load and create the GWorld
        imageGW = OpenImage();
        
        if ( imageGW != NULL )
        {
            
            GetPortBounds( imageGW, &bounds );
            width = bounds.right - bounds.left;
            height = bounds.bottom - bounds.top;
            
            pmh = GetPortPixMap( imageGW );
            bitsPerComponent = (**pmh).cmpSize;
            bitsPerPixel = (**pmh).pixelSize;
            bytesPerRow = GetPixRowBytes( pmh );
            
            LockPixels( pmh );
            
            dataProviderRef = CGDataProviderCreateWithData( NULL, GetPixBaseAddr( pmh ), height * bytesPerRow, releaseData );
            
            
            //	Create the imageRef for that GWorld
            imageRef = CGImageCreate( width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedFirst/*kCGImageAlphaNone*/, dataProviderRef, NULL, 0, kCGRenderingIntentDefault );
        }
    }
    
    
    //	Draw the image at 0,0
    CGContextDrawImage( context, CGRectMake( x - 20, y, 40, 40 * height / width ), imageRef );
    
}
Example #20
0
File: MacGraph.c Project: rolk/ug
INT WhichTool (WINDOWID win, const INT mp[2], INT *ChosenToolPtr)
{
  INT i;
  Rect WinRect;
  WindowPtr theWindow;

  theWindow = MAC_WIN((GRAPH_WINDOW*)win);

  GetPortBounds(GetWindowPort(theWindow),&WinRect);

  GET_CHOSEN_TOOL(i,WinRect,mp);

  *ChosenToolPtr = i;

  if (i==NO_TOOL_CHOSEN)
    return (0);

  return(1);
}
void MacVegaPrinterListener::SetGraphicsContext(CGrafPtr port)
{
#ifndef SIXTY_FOUR_BIT
	if (m_port) {
		CGContextRestoreGState(m_ctx);
		QDEndCGContext(m_port, &m_ctx);
	}
	m_port = port;
	m_ctx = NULL;
	if (m_port) {
		Rect bounds;
		GetPortBounds(m_port, &bounds);
		m_winHeight = bounds.bottom-bounds.top;
		QDBeginCGContext(m_port, &m_ctx);
		SetColor(0,0,0,255);
		CGContextSaveGState(m_ctx);
	}
#endif
}
Example #22
0
void drawSourceImage()
{
	Rect	rect;
	Rect	outlineRect;
	Rect	tempRect1;

	GetPortBounds(gGWorld, &tempRect1);		
	SetRect( &rect, 20, 37, 20 + tempRect1.right, 37 + tempRect1.bottom);

	outlineRect = rect;
	InsetRect( &outlineRect, -5, -5 );
	drawDeepBox( &outlineRect );
	
	ForeColor( blackColor );
	BackColor( whiteColor );
	
	CopyBits( (BitMap *)(*(GetPortPixMap(gGWorld))), GetPortBitMapForCopyBits(GetWindowPort(gWindow)),
				&((**(GetPortPixMap(gGWorld))).bounds), &rect, srcCopy, nil );
}
Example #23
0
static void mac_createeventlog(Session *s)
{
    Rect view;
    ListBounds bounds = { 0, 0, 0, 1 }; /* 1 column, 0 rows */
    Point csize = { 0, 0 };
    GrafPtr saveport;
    long fondsize;
    WinInfo *wi;

    s->eventlog_window = GetNewWindow(wEventLog, NULL, (WindowPtr)-1);
    wi = snew(WinInfo);
    memset(wi, 0, sizeof(*wi));
    wi->s = s;
    wi->wtype = wEventLog;
    wi->click = &mac_clickeventlog;
    wi->activate = &mac_activateeventlog;
    wi->grow = &mac_groweventlog;
    wi->update = &mac_updateeventlog;
    wi->close = &mac_closeeventlog;
    SetWRefCon(s->eventlog_window, (long)wi);
    GetPort(&saveport);
    SetPort((GrafPtr)GetWindowPort(s->eventlog_window));
    fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
    TextFont(HiWord(fondsize));
    TextSize(LoWord(fondsize));
    SetPort(saveport);
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(s->eventlog_window), &view);
#else
    view = s->eventlog_window->portRect;
#endif
    view.right -= 15; /* Scrollbar */
    s->eventlog = LNew(&view, &bounds, csize, 0, s->eventlog_window,
		       TRUE, TRUE, FALSE, TRUE);
    mac_adjusteventlogscrollbar(s);
#if TARGET_API_MAC_CARBON
    SetListSelectionFlags(s->eventlog, lExtendDrag | lNoDisjoint | lNoExtend);
#else
    (*s->eventlog)->selFlags = lExtendDrag | lNoDisjoint | lNoExtend;
#endif
}
Example #24
0
OSStatus SetCGContext(QuartzDesc *xd)
{
    Rect rect;
    OSStatus	err = noErr;
    CGRect    cgRect;

	if(xd->context){
		CGContextRelease(xd->context);
		xd->context = NULL;
	}

	if(xd->auxcontext){	
		CGContextRelease(xd->auxcontext);
		xd->auxcontext = NULL;
	}	
	if(xd->window)
		err = CreateCGContextForPort(GetWindowPort(xd->window), &xd->context);


    if(xd->window)
		GetPortBounds(GetWindowPort(xd->window), &rect);


    if(xd->context){
		CGContextTranslateCTM(xd->context,0, (float)(rect.bottom - rect.top));


/* Be aware that by performing a negative scale in the following line of
   code, your text will also be flipped
*/
		CGContextScaleCTM(xd->context, 1, -1);


  /* We apply here Antialiasing if necessary */
		CGContextSetShouldAntialias(xd->context, xd->Antialias);

		
	}
   return err;
}
Example #25
0
void IPlugProcess::SetViewPort (GrafPtr aPort)
{
  mMainPort = aPort;
  CEffectProcess::SetViewPort( mMainPort ); // call inherited first

  if(mMainPort)
  {
    if(mCustomUI)
    {
      void *windowPtr = NULL;
      #if WINDOWS_VERSION
      windowPtr = (void*)ASI_GethWnd((WindowPtr)mMainPort);
      #elif MAC_VERSION
      windowPtr = (void*)GetWindowFromPort(mMainPort); // WindowRef for Carbon, not GrafPtr (quickdraw)

      Rect portBounds;
      GetPortBounds(aPort, &portBounds);
      if ((portBounds.left <= 0 && portBounds.top <= 0) && (mLeftOffset == 0 && mTopOffset == 0))
      {
        mLeftOffset = -portBounds.left;
        mTopOffset = -portBounds.top;
      }
      #endif
      mCustomUI->Open(windowPtr, mLeftOffset, mTopOffset);
      
      #if WINDOWS_VERSION
      mCustomUI->Draw(mPluginWinRect.left, mPluginWinRect.top, mPluginWinRect.right, mPluginWinRect.bottom);
      #endif
    }
  }
  else
  {
    if(mCustomUI)
      mCustomUI->Close();

    if( mView )
      mView->SetEnable(false);
  }
  return;
}
Example #26
0
File: MacGraph.c Project: rolk/ug
INT Mac_UpdateOutput (WINDOWID win, INT tool)
{
  GRAPH_WINDOW *gw;
  WindowPtr theWindow;
  Rect myClipRect,*portRect = nil;

  gw = (GRAPH_WINDOW *) win;
  theWindow = MAC_WIN(gw);

  gw->currTool = tool;

  SetPort(GetWindowPort(theWindow));

  /* identify clipping rect with port */
  GetPortBounds(GetWindowPort(theWindow),portRect);
  ClipRect(portRect);

  BeginUpdate(theWindow);
  /* leave this out: uginterface will manage
     EraseRgn(((GrafPtr)theWindow)->visRgn);*/
  EndUpdate(theWindow);

  /* adjust cursor */
  if (theWindow == FrontWindow())
    ActivateMacWin (gw,tool);

  DrawGrowIcon(theWindow);
  DrawToolBox(gw,tool);

  /* reset clipping rectangle */
  myClipRect.left   = portRect->left;
  myClipRect.right  = portRect->right  - SCROLL_BAR;
  myClipRect.bottom = portRect->bottom - SCROLL_BAR;
  myClipRect.top    = portRect->top;

  ClipRect(&myClipRect);

  return (0);
}
Example #27
0
static void mac_draweventloggrowicon(Session *s)
{
    Rect clip;
    RgnHandle savergn;

    SetPort((GrafPtr)GetWindowPort(s->eventlog_window));
    /*
     * Stop DrawGrowIcon giving us space for a horizontal scrollbar
     * See Tech Note TB575 for details.
     */
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(s->eventlog_window), &clip);
#else
    clip = s->eventlog_window->portRect;
#endif
    clip.left = clip.right - 15;
    savergn = NewRgn();
    GetClip(savergn);
    ClipRect(&clip);
    DrawGrowIcon(s->eventlog_window);
    SetClip(savergn);
    DisposeRgn(savergn);
}
Example #28
0
File: MacGraph.c Project: rolk/ug
static void DrawToolBox (GRAPH_WINDOW *gw, INT tool)
{
  Rect r,dstRect;
  CGrafPtr myPort;
  PicHandle toolBox;
  WindowPtr theWindow;

  theWindow = MAC_WIN(gw);

  myPort = GetWindowPort(theWindow);
  SetPort(myPort);
  GetPortBounds(myPort,&r);

  toolBox = GetPicture(TOOLBOX_RSRC_ID);
  if (toolBox!=NULL)
  {
    SetRect(&dstRect,r.right-120,r.bottom-15,r.right-15,r.bottom);
    DrawPicture(toolBox,&dstRect);
  }

  SetRect(&dstRect,r.right-119+tool*15,r.bottom-14,r.right-104+tool*15,r.bottom);
  InvertRect(&dstRect);
}
Example #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();
}
Example #30
0
static pascal void MyTimerHandler( EventLoopTimerRef inTimer, void *inUserData )
{
    CGrafPtr            currentPort;
    Rect                currentPortRect;
    RgnHandle           flushRegion;

    SetPortWindowPort( (WindowRef) inUserData );

    //  Call the plug-in function "drawBall" which is defined in the plug-in interface.

    (*gDrawBallInterface)->drawBall( gDrawBallInterface );

    //  We are not drawing in response to an update or draw event, so if the window is buffered
    //  (i.e. on Mac OS X) we need to flush the content to be drawn in the window.

    GetPort( &currentPort );
    if( QDIsPortBuffered( currentPort ) ) {
    	GetPortBounds( currentPort, &currentPortRect );
    	flushRegion = NewRgn();
    	RectRgn( flushRegion, &currentPortRect );
        QDFlushPortBuffer( currentPort, flushRegion );
        DisposeRgn( flushRegion );
    }
}