Beispiel #1
0
void _draw_screen_shape_at_x_y(
	shape_descriptor shape,
	short x,
	short y)
{
	PixMapHandle pixmap;
	RGBColor old_fore, old_back;
	Rect destination;

	/* Avoid unwanted coloring.. */
	GetForeColor(&old_fore);
	GetBackColor(&old_back);
	RGBForeColor(&rgb_black);
	RGBBackColor(&rgb_white);
	
	/* Draw the panels... */
	pixmap= get_shape_pixmap(shape, FALSE);
	
	/* Offset to zero base, and add in x, y */
	destination= (*pixmap)->bounds;
	OffsetRect(&destination, x-destination.left, y-destination.top);
	
	/* Slam the puppy...  */
	assert(destination_graphics_port);
	CopyBits((BitMapPtr) *pixmap, &destination_graphics_port->portBits, //&screen_window->portBits,
		&(*pixmap)->bounds, &destination, srcCopy, (RgnHandle) nil);

	/* Restore the colors.. */
	RGBForeColor(&old_fore);
	RGBBackColor(&old_back);
}
static pascal void drawProc(ControlRef inControl, SInt16 inPart)
{
	#pragma unused(inControl, inPart)
	
	int i;
	RGBColor saveForeColor;
	RGBColor saveBackColor;
	PenState savePenState;

	GetForeColor(&saveForeColor);	
	GetBackColor(&saveBackColor);	
	GetPenState(&savePenState);

	RGBForeColor(&rgbBlack);
	RGBBackColor(&rgbWhite);
	PenNormal();
	
	for (i = 0; i < sNumMonitors; i++)
	{
		RGBForeColor(&rgbGray);
		PaintRect(&sMonitors[i].scaledRect);
		if (sMonitors[i].isMain)
		{
			Rect r = sMonitors[i].scaledRect;
			InsetRect(&r, 1, 1);
			r.bottom = r.top + 6;
			RGBForeColor(&rgbWhite);
			PaintRect(&r);
			RGBForeColor(&rgbBlack);
			PenSize(1,1);
			MoveTo(r.left, r.bottom);
			LineTo(r.right, r.bottom);
		}
		if (sMonitors[i].device == sSelectedDevice)
		{
			PenSize(3,3);
			RGBForeColor(&rgbBlack);
			FrameRect(&sMonitors[i].scaledRect);
		}
		else
		{
			PenSize(1,1);
			RGBForeColor(&rgbBlack);
			FrameRect(&sMonitors[i].scaledRect);
		}
	}
	
	// restore the original pen state and colors
	RGBForeColor(&saveForeColor);	
	RGBBackColor(&saveBackColor);	
	SetPenState(&savePenState);
}
Beispiel #3
0
void _draw_screen_shape_centered(
	shape_descriptor shape,
	screen_rectangle *rectangle,
	short flags)
{
	PixMapHandle pixmap;
	RGBColor old_fore, old_back;
	Rect destination, source;
	short left_offset, top_offset;
return;
	/* Avoid unwanted coloring.. */
	GetForeColor(&old_fore);
	GetBackColor(&old_back);
	RGBForeColor(&rgb_black);
	RGBBackColor(&rgb_white);
	
	/* Draw the panels... */
	pixmap= get_shape_pixmap(shape, FALSE);
	
	/* Offset to zero base, and add in x, y */
	destination= source= (*pixmap)->bounds;
	
	if(flags & _center_horizontal)
	{
		left_offset= (RECTANGLE_WIDTH(rectangle)-RECTANGLE_WIDTH(&source))/2;
	} else {
		left_offset= 0;
	}
	
	if(flags & _center_vertical)
	{
		top_offset= (RECTANGLE_HEIGHT(rectangle)-RECTANGLE_HEIGHT(&source))/2;
	} else if (flags & _bottom_justified) {
		top_offset= RECTANGLE_HEIGHT(rectangle)-RECTANGLE_HEIGHT(&destination);
	} else {
		top_offset= 0;
	}
	
	OffsetRect(&destination, rectangle->left+left_offset, 
		rectangle->top+top_offset);
	
	/* Slam the puppy...  */
	assert(destination_graphics_port);
	CopyBits((BitMapPtr) *pixmap, &destination_graphics_port->portBits, // &screen_window->portBits,
		&source, &destination, srcCopy, (RgnHandle) nil);

	/* Restore the colors.. */
	RGBForeColor(&old_fore);
	RGBBackColor(&old_back);
}
Beispiel #4
0
/* If source==NULL, source= the shapes bounding rectangle */
void _draw_screen_shape(
	shape_descriptor shape_id, 
	screen_rectangle *destination, 
	screen_rectangle *source)
{
	PixMapHandle pixmap;
	RGBColor old_fore, old_back;
	Rect actual_source;

	/* Avoid unwanted coloring.. */
	GetForeColor(&old_fore);
	GetBackColor(&old_back);
	RGBForeColor(&rgb_black);
	RGBBackColor(&rgb_white);
	
	/* Draw the panels... */
	pixmap= get_shape_pixmap(shape_id, FALSE);
	if(!source)
	{
		actual_source= (*pixmap)->bounds;
#ifdef DEBUG
{
	short dest_width, source_width;
	short dest_height, source_height;
	
	dest_width= destination->right-destination->left;
	source_width= (*pixmap)->bounds.right-(*pixmap)->bounds.left;
	dest_height= destination->bottom-destination->top;
	source_height= (*pixmap)->bounds.bottom-(*pixmap)->bounds.top;
	if(source_height != dest_height || source_width != dest_width)
	{
		dprintf("Changing size of %d Original: %d %d New: %d %d", shape_id,
			source_width, source_height, dest_width, dest_height);
	}
}
#endif
	} else {
		actual_source= *((Rect *) source);
	}

	assert(destination_graphics_port);
	CopyBits((BitMapPtr) *pixmap, &destination_graphics_port->portBits,
		&actual_source, (Rect *) destination, srcCopy, (RgnHandle) nil);

	/* Restore the colors.. */
	RGBForeColor(&old_fore);
	RGBBackColor(&old_back);
}
Beispiel #5
0
void
ShowTxt(void)
{	    
	switch (gCurrWin)
	{
		case kLicenseID:
			if(gControls->lw->licTxt)
			{
			    RGBColor backColorOld;
			    Rect     textRect;
			    
			    // get back color
			    GetBackColor(&backColorOld);
			    
			    // set to white
			    BackColor(whiteColor);
			    
			    // erase rect and update
			    textRect = (**(gControls->lw->licTxt)).viewRect;
			    EraseRect(&textRect);
				TEUpdate(&textRect, gControls->lw->licTxt);
				
				// restore back color
				RGBBackColor(&backColorOld);
			}
			break;
		default:
			break;
	}		
}
void _HYPlatformGraphicPane::_EndDraw	 (void)
{
	UnlockPixels (GetGWorldPixMap(thePane));
	SetGWorld 	 (savedPort,savedDevice);
	RGBForeColor (&saveFG);
	RGBBackColor (&saveBG);
}				
Beispiel #7
0
void
UpdateAdditionsWin(void)
{
	Rect		r;
	Cell		c;
	int			i;
	GrafPtr		oldPort;
	GetPort(&oldPort);
	
	SetPort(gWPtr);
	
	MoveTo( gControls->aw->compListBox.left, gControls->aw->compListBox.top - kInterWidgetPad + 1);
	HLock(gControls->cfg->selAddMsg);
	DrawString( CToPascal(*gControls->cfg->selAddMsg));
	HUnlock(gControls->cfg->selAddMsg);
	
#if 0
	RGBColor backColorOld;
    Rect adjustedRect, *clRect = &gControls->aw->compListBox;
    SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1);
    GetBackColor(&backColorOld);
    BackColor(whiteColor);
    EraseRect(&adjustedRect);
    RGBBackColor(&backColorOld);
#endif
   
	LUpdate( (*gControls->aw->compList)->port->visRgn, gControls->aw->compList);
	SetRect(&r, gControls->aw->compListBox.left, gControls->aw->compListBox.top,
	            gControls->aw->compListBox.right + 1, gControls->aw->compListBox.bottom);
	FrameRect(&r);	
	
	SetPt(&c, 0, 0);
	if (LGetSelect(true, &c, gControls->aw->compList))
	{
		HLock((Handle)gControls->aw->compDescTxt);
		SetRect(&r, (*gControls->aw->compDescTxt)->viewRect.left,
					(*gControls->aw->compDescTxt)->viewRect.top,
					(*gControls->aw->compDescTxt)->viewRect.right,
					(*gControls->aw->compDescTxt)->viewRect.bottom);
		HUnlock((Handle)gControls->aw->compDescTxt);
		TEUpdate(&r, gControls->aw->compDescTxt);	
	}
	
	DrawDiskSpaceMsgs( gControls->opt->vRefNum );
	
	for (i = 0; i < numRows; i++)
	{
		if (gControls->cfg->comp[rowToComp[i]].highlighted)
		{
			AddInitRowHighlight(i);
			break;
		}
	}
	
	SetPort(oldPort);
}
Beispiel #8
0
void _scroll_window(
	short dy, 
	short rectangle_id, 
	short background_color_index)
{
	Rect *destination= _get_interface_rect(rectangle_id);
	RgnHandle updateRgn;
	RGBColor old_color, new_color;

	GetBackColor(&old_color);
	_get_interface_color(background_color_index, &new_color);
	RGBBackColor(&new_color);

	updateRgn= NewRgn();
	ScrollRect(destination, 0, dy, updateRgn);
	DisposeRgn(updateRgn);

	RGBBackColor(&old_color);
}
Beispiel #9
0
P1(PUBLIC pascal trap, void, BackColor, LONGINT, c)
{
  GrafPtr the_port;

  the_port = thePort;
  if (the_port)
    {
      if (CGrafPort_p (the_port))
	RGBBackColor (ROMlib_qd_color_to_rgb (c));
      else
	PORT_BK_COLOR_X (the_port) = CL (c);
    }
}
Beispiel #10
0
void RestoreQDDrawingState( QDDrawingState *inDrawingState, const Boolean inDisposeNow )
{//	PixPatHandle	tempPixPat;

#if !(ALIST_USEAPPEARANCEMGR && TARGET_RT_MAC_CFM )
	#pragma unused( inDisposeNow )	// Eliminate compiler warnings in 68K targets because PixPatHandle stuff is screwed up!
#endif

	Assert( inDrawingState != nil );

	// Restore the pen/foreground state.
/*	if ( !inDisposeNow && inDrawingState->penPixPatH != nil ) {
		// Make a copy of the penPixPatH so we can put it somewhere else later because we're not supposed to dispose of it now.
		tempPixPat = NewPixPat( );
		if ( tempPixPat != nil )
			CopyPixPat( inDrawingState->penPixPatH, tempPixPat );
	} else
		tempPixPat = nil;
	PenPixPat( inDrawingState->penPixPatH );
	inDrawingState->penPixPatH = tempPixPat;
*/	RGBForeColor( &inDrawingState->foreColor );
	SetPenState( &inDrawingState->penState );

	// Restore the background state.
/*	if ( !inDisposeNow && inDrawingState->backPixPatH != nil ) {
		// Make a copy of the backPixPatH so we can put it somewhere else later because we're not supposed to dispose of it now.
		tempPixPat = NewPixPat( );
		if ( tempPixPat != nil )
			CopyPixPat( inDrawingState->backPixPatH, tempPixPat );
	} else
		tempPixPat = nil;
	BackPixPat( inDrawingState->backPixPatH );
	inDrawingState->penPixPatH = tempPixPat;
*/	RGBBackColor( &inDrawingState->backColor );

	// Optionally restore the text state.
	if ( inDrawingState->haveTextState ) {
		TextFont( inDrawingState->textStyle.tsFont );
		TextFace( inDrawingState->textStyle.tsFace );
		TextSize( inDrawingState->textStyle.tsSize );
		TextMode( inDrawingState->textMode );
	}

#if ALIST_USEAPPEARANCEMGR && TARGET_RT_MAC_CFM
	// If we're running under CFM and have Appearance Mgr 1.1 or later, use the ThemeDrawingState routines.
	if ( inDrawingState->haveThemeState ) {
		SetThemeDrawingState( inDrawingState->themeState, inDisposeNow );
		if ( inDisposeNow )
			inDrawingState->themeState = nil;
	}
#endif
}
void _HYPlatformGraphicPane::_SetBColor  (_HYColor c)
{
	RGBColor      	 sysColor;
	sysColor.red   = c.R*256;
	sysColor.green = c.G*256;
	sysColor.blue  = c.B*256;
	
	if (c.R+c.B+(long)c.G==765)
		sysColor = (RGBColor){0xffff,0xffff,0xffff};
		
	RGBBackColor (&sysColor);
	//MakeRGBPat (backColor,&sysColor);
	//BackPat	   (backColor);
}
Beispiel #12
0
/****************************************************************
  PopInvert() inverts the given popup.
****************************************************************/
void PopInvert(DialogPtr theDialog, short itemNum)
{
   GrafPtr savePort;
   short itemType;
   Handle itemHandle;
   Rect itemBox;
   //SysEnvRec theWorld;
   RGBColor SaveBack, DefaultBack, DefaultFore, saveHilite;
	
   GetPortGrafPtr(&savePort);
   SetPortDialogPort(theDialog);

   GetDialogItem(theDialog, itemNum, &itemType, &itemHandle, &itemBox);

  // SysEnvirons(curSysEnvVers,&theWorld);

   //if (!theWorld.hasColorQD) {
   if (ColorQDAvailable()) {
      InvertRect( &itemBox );
      return;
   }

   GetBackColor(&SaveBack);
	LMGetHiliteRGB(&saveHilite);
   DefaultMenuColors(&DefaultFore, &DefaultBack);

   RGBBackColor(&DefaultBack);
   HiliteColor(&DefaultFore);
	LMSetHiliteMode(LMGetHiliteMode() & 0x7F); // clear 0th bit = pHiliteBit
   InvertRect( &itemBox );
	
   HiliteColor(&saveHilite);
   RGBBackColor(&SaveBack);
	
   SetPortGrafPort(savePort);
}
Beispiel #13
0
void
SimplePluginInstance::EndDraw(nsPluginWindow* window)
{
    CGrafPtr myPort;
    NP_Port* port = (NP_Port*) window->window;
    SetOrigin(gSavePort.portRect.left, gSavePort.portRect.top);
    SetClip(gSavePort.clipRgn);
    GetPort((GrafPtr*)&myPort);
    myPort->txFont = gSavePort.txFont;
    myPort->txFace = gSavePort.txFace;
    myPort->txMode = gSavePort.txMode;
    RGBForeColor(&gSavePort.rgbFgColor);
    RGBBackColor(&gSavePort.rgbBkColor);
    SetPort((GrafPtr)gOldPort);
}
Beispiel #14
0
PRBool
SimplePluginInstance::StartDraw(nsPluginWindow* window)
{
    NP_Port* port;
    Rect clipRect;
    RGBColor  col;
	
    if (window == NULL)
        return FALSE;
    port = (NP_Port*) window->window;
    if (window->clipRect.left < window->clipRect.right)
    {
	/* Preserve the old port */
        GetPort((GrafPtr*)&gOldPort);
        SetPort((GrafPtr)port->port);
	/* Preserve the old drawing environment */
        gSavePort.portRect = port->port->portRect;
        gSavePort.txFont = port->port->txFont;
        gSavePort.txFace = port->port->txFace;
        gSavePort.txMode = port->port->txMode;
        gSavePort.rgbFgColor = port->port->rgbFgColor;
        gSavePort.rgbBkColor = port->port->rgbBkColor;
        GetClip(gSavePort.clipRgn);
	/* Setup our drawing environment */
        clipRect.top = window->clipRect.top + port->porty;
        clipRect.left = window->clipRect.left + port->portx;
        clipRect.bottom = window->clipRect.bottom + port->porty;
        clipRect.right = window->clipRect.right + port->portx;
        SetOrigin(port->portx,port->porty);
        ClipRect(&clipRect);
        clipRect.top = clipRect.left = 0;
        TextSize(12);
        TextFont(geneva);
        TextMode(srcCopy);
        col.red = col.green = col.blue = 0;
        RGBForeColor(&col);
        col.red = col.green = col.blue = 65000;
        RGBBackColor(&col);
        return TRUE;
    }
    else
        return FALSE;
}
Beispiel #15
0
static int open_PlayerWin()
		/*success-> return 0;*/
{
	int	i;
	OSErr	err;
	RGBColor	back={0,0,0},
				fore={65535,65535,65535};
	
	open_window( &win, kPlayerWinID);
	position_window(&win);
	
	SetPortWindowPort(win.ref);
	RGBForeColor(&fore);
	RGBBackColor(&back);
	logo= GetPicture(128);
	logoDown= GetPicture(132);
	
	for(i=0; i<6; i++)
		button[i]= GetCIcon(i+200);
	iconPlay=GetCIcon(210);
	iconPause=GetCIcon(211);
	iconVol=GetCIcon(206);
	iconTab=GetCIcon(207);
	iconNotLoop=GetCIcon(208);
	iconLoop=GetCIcon(209);
	
	if(gHasDragMgr)
	{
		receiveRgn=NewRgn();
		if( receiveRgn )
		{
			GetWindowContentRgn(win.ref, receiveRgn);
			err=InstallTrackingHandler(NewDragTrackingHandlerProc(DragTrackingProc),
								(WindowPtr)win.ref, 0);
			if(err) ExitToShell();
			
			err=InstallReceiveHandler(NewDragReceiveHandlerProc(DragReceiveFunc),
							(WindowPtr)win.ref, 0);
			if(err) ExitToShell();
		}
	}
	return 0;
}
void _HYPlatformGraphicPane::_StartDraw	 (void)
{	
	_HYGraphicPane * parent = (_HYGraphicPane*)this;
	GetGWorld (&savedPort,&savedDevice);
	::GetForeColor (&saveFG);
	::GetBackColor (&saveBG);
	SetGWorld (thePane,nil);
	LockPixels (GetGWorldPixMap(thePane));
	RGBColor c  = {256*parent->bColor.R,256*parent->bColor.G,256*parent->bColor.B};
	if (parent->bColor.R+parent->bColor.B+(long)parent->bColor.G==765)
		c = (RGBColor){0xffff,0xffff,0xffff};
	RGBBackColor (&c);
	c = (RGBColor){256*parent->color.R,256*parent->color.G,256*parent->color.B};
	RGBForeColor (&c);
	//if (parent->depth>1)
		TextMode 	 (srcOr);
	//else
		//TextMode 	 (srcCopy);
}
Beispiel #17
0
TechkonDialog::TechkonDialog(ProfileDoc *dc,RawData *pD):InputDialog(dc,pD,1)
{
	short		iType;
	Handle		iHandle;
	Handle		sHandle;
	Rect 		iRect, r,pRect,tRect;	
	UserItemUPP  box3D;
	
	QDErr		error;
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	RGBColor	c,oldbackcolor,oldforecolor;
	WindowPtr	oldP;
	OSErr			err;
	int32 		i,wi,hi;
	double w,h;
	short		gtsl_ids[] = GTSL_IDS;
	Str255		theString;
	PixMapHandle	bigPixMap;
	McoStatus  	state;
	
	for (i=0; i<NumInputIDS; i++) ids[i] = gtsl_ids[i];

	WinType = TechkonWindow;
	WinNum = 0;

	setDialog(Input_Dialog);
	frame_button(ids[Ok_Box]);	

	

	
	// Added by James, 3D the box
	threeD_box(ids[ThreeDBox]);
	
	HideDItem(dp,ids[Redo]);
	
	GetDItem ( dp,ids[Message], &iType, (Handle*)&iHandle, &iRect );
	GetIndString(theString,Message_List_ID,6);
	SetIText(iHandle,theString);
	
	Scramble = FALSE;	
	
	if (Scramble)
		{
		voice_set = 1;
		}	
	else
		{
		Disable(dp,ids[VoiceSet]);
		voice_set = 2;
		}

	// initialize comminications with the device
	state = doc->openInputDevice(0,0,0);
	if (state != MCO_SUCCESS) McoErrorAlert(state);
	
	// initialize the big gworld 
	GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect);
	tRect = iRect;
	OffsetRect(&tRect,-iRect.left,-iRect.top);
	error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 );
	if (error != 0) 
		{
		delete this;
		return;
		} 
	GetGWorld(&oldGW,&oldGD);
	SetGWorld(BigGW,nil);	
	
	
//	GetBackColor(&oldbackcolor);
	GetForeColor(&oldforecolor);
	c.red = 65535;
	c.green = 65535;
	c.blue = 65535;
	RGBBackColor(&c);
	c.red = 0;
	c.green = 0;
	c.blue = 0;
	RGBForeColor(&c);		
	bigPixMap = GetGWorldPixMap ( BigGW );
	if (LockPixels ( bigPixMap ))	EraseRect( &tRect );
	
	SetGWorld(oldGW,oldGD);	
//	RGBBackColor(&oldbackcolor);
	RGBForeColor(&oldforecolor);	

//	SetPort(oldP);
		
	GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect);
	num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top);
	top_patch = 0;
						
//init the static members
	//current_patch = total_patches-1;
	//current_patch = 0;
	current_patch = 0;
	current_strip = 0;
	current_sheet = 0;
 		
 	_done = 0;
 	_waiting = 0;
	
	
	SetSheetStripText();
	
	current_top = current_patch - 2*num_display_patch/3;
	current_bottom = current_top + num_display_patch - 1;
	if (current_top < 0) 
		{
		current_top = 0;
		current_bottom = current_top + num_display_patch - 1;
		}
	if (current_bottom >= total_patches-1)
		{
		current_bottom = total_patches - 1;
		current_top = current_bottom - num_display_patch + 1;
		}
	
	current_disp = 2*num_display_patch/3;
	
	init();	
	getpatchRGB();
	
	
	Disable(dp,ids[Redo]);

	
	GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect);
	SetCtlMin((ControlHandle)iHandle,0);
	SetCtlMax((ControlHandle)iHandle,total_patches-1);
	
	GetDItem(dp, ids[VoiceSet], &iType, (Handle*)&iHandle, &pRect);
	SetCtlValue((ControlHandle)iHandle,1);
	//voice_set = 1;
	checkFinished();
	DrawWindow();
}	
Beispiel #18
0
/* ----------------------------------------------------------------------------
   _ApplyTransparentColor
   Set destination port background color to transparent color.
   Returns nothing.                
   ---------------------------------------------------------------------------- */
static  void  _ApplyTransparentColor (RGBColorPtr pBackColor)
{
RGBColor            rgbColor;
short               qdColor;

	GetBackColor(pBackColor);
	if (fHasColorQuickdraw) //fColorQuickdrawAvailable(true))
	{
		switch (_TransparentColor)
		{
			case TBIT_White:
				rgbColor.red = 0xFFFF;
				rgbColor.green = 0xFFFF;
				rgbColor.blue = 0xFFFF;
				break;
			case TBIT_Black:
				rgbColor.red = 0x0000;
				rgbColor.green = 0x0000;
				rgbColor.blue = 0x0000;
				break;
			case TBIT_Red:
				rgbColor.red = 0xDD6B;
				rgbColor.green = 0x08C2;
				rgbColor.blue = 0x06A2;
				break;
			case TBIT_Green:
				rgbColor.red = 0x0000;
				rgbColor.green = 0x8000;
				rgbColor.blue = 0x11B0;
				break;
			case TBIT_Blue:
				rgbColor.red = 0x0000;
				rgbColor.green = 0x0000;
				rgbColor.blue = 0xD400;
				break;
			default:
				rgbColor.red = 0x0000;
				rgbColor.green = 0x0000;
				rgbColor.blue = 0x0000;
				break;
		}
		RGBBackColor(&rgbColor);
	}
	else
	{
		switch (_TransparentColor)
		{
			case TBIT_White:
				qdColor = whiteColor;
				break;
			case TBIT_Black:
				qdColor = blackColor;
				break;
			case TBIT_Red:
				qdColor = redColor;
				break;
			case TBIT_Green:
				qdColor = greenColor;
				break;
			case TBIT_Blue:
				qdColor = blueColor;
				break;
			default:
				qdColor = blackColor;
				break;
		}
		BackColor(qdColor);
	}
}
VPictureData_MacPicture::VPictureData_MacPicture(PortRef inPortRef, const VRect& inBounds)
{
	_SetDecoderByExtension(sCodec_pict);
	fPicHandle = NULL;
	fMetaFile = NULL;
	fTrans = NULL;
#if VERSIONWIN
	inPortRef; // pp pour warning
	inBounds;
	fGdiplusMetaFile = NULL;
#endif
#if VERSIONMAC
	GrafPtr oldPort;
	GetPort(&oldPort);
	SetPort(inPortRef);
	RGBColor saveFore, saveBack, white = { 0xffff, 0xffff, 0xffff }, black = { 0, 0, 0 };
	Rect r;

	inBounds.MAC_ToQDRect(r);

	GetBackColor(&saveFore);
	GetForeColor(&saveFore);

	RGBBackColor(&white);
	RGBForeColor(&black);

	PicHandle	newPicture = ::OpenPicture(&r);
	const BitMap*	portBits = ::GetPortBitMapForCopyBits(inPortRef);

	::ClipRect(&r);
	::CopyBits(portBits, portBits, &r, &r, srcCopy, NULL);
	::ClosePicture();

	RGBBackColor(&saveFore);
	RGBForeColor(&saveFore);

	SetPort(oldPort);
	fPicHandle = newPicture;

#if VERSIONWIN
	qtime::Rect rect;
	QDGetPictureBounds((qtime::Picture**)fPicHandle, &rect);
	fBounds.SetCoords(0, 0, rect.right - rect.left, rect.bottom - rect.top);
#else
	Rect rect;
	QDGetPictureBounds((Picture**) fPicHandle, &rect);
	fBounds.SetCoords(0, 0, rect.right - rect.left, rect.bottom - rect.top);
#endif

#if VERSIONMAC
	if (fPicHandle)
	{
		GetMacAllocator()->Lock(fPicHandle);
		CGDataProviderRef dataprov = xV4DPicture_MemoryDataProvider::CGDataProviderCreate(*(char**) fPicHandle, GetMacAllocator()->GetSize(fPicHandle), true);
		GetMacAllocator()->Unlock(fPicHandle);
		fMetaFile = QDPictCreateWithProvider(dataprov);
		CGDataProviderRelease(dataprov);
	}
#endif
#endif
}
Beispiel #20
0
void 
XCopyArea(
    Display* display,		/* Display. */
    Drawable src,		/* Source drawable. */
    Drawable dest,		/* Destination drawable. */
    GC gc,			/* GC to use. */
    int src_x,			/* X & Y, width & height */
    int src_y,			/* define the source rectangle */
    unsigned int width,		/* the will be copied. */
    unsigned int height,
    int dest_x,			/* Dest X & Y on dest rect. */
    int dest_y)
{
    Rect srcRect, destRect;
    BitMapPtr srcBit, destBit;
    MacDrawable *srcDraw = (MacDrawable *) src;
    MacDrawable *destDraw = (MacDrawable *) dest;
    GWorldPtr srcPort, destPort;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    short tmode;
    RGBColor origForeColor, origBackColor, whiteColor, blackColor;

    destPort = TkMacGetDrawablePort(dest);
    srcPort = TkMacGetDrawablePort(src);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);
    GetForeColor(&origForeColor);
    GetBackColor(&origBackColor);
    whiteColor.red = 0;
    whiteColor.blue = 0;
    whiteColor.green = 0;
    RGBForeColor(&whiteColor);
    blackColor.red = 0xFFFF;
    blackColor.blue = 0xFFFF;
    blackColor.green = 0xFFFF;
    RGBBackColor(&blackColor);
    

    TkMacSetUpClippingRgn(dest);
    
    /*
     *  We will change the clip rgn in this routine, so we need to 
     *  be able to restore it when we exit.
     */
     
    if (tmpRgn2 == NULL) {
        tmpRgn2 = NewRgn();
    }
    GetClip(tmpRgn2);

    if (((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) {
	RgnHandle clipRgn = (RgnHandle)
	        ((TkpClipMask*)gc->clip_mask)->value.region;
	
	int xOffset, yOffset;
	
	if (tmpRgn == NULL) {
	    tmpRgn = NewRgn();
	}
	
	xOffset = destDraw->xOff + gc->clip_x_origin;
	yOffset = destDraw->yOff + gc->clip_y_origin;
	
	OffsetRgn(clipRgn, xOffset, yOffset);
	
	GetClip(tmpRgn);
	SectRgn(tmpRgn, clipRgn, tmpRgn);
	
	SetClip(tmpRgn);
	
	OffsetRgn(clipRgn, -xOffset, -yOffset);
    }
    
    srcBit = &((GrafPtr) srcPort)->portBits;
    destBit = &((GrafPtr) destPort)->portBits;
    SetRect(&srcRect, (short) (srcDraw->xOff + src_x),
	    (short) (srcDraw->yOff + src_y),
	    (short) (srcDraw->xOff + src_x + width),
	    (short) (srcDraw->yOff + src_y + height));	
    SetRect(&destRect, (short) (destDraw->xOff + dest_x),
	    (short) (destDraw->yOff + dest_y), 
	    (short) (destDraw->xOff + dest_x + width),
	    (short) (destDraw->yOff + dest_y + height));	
    tmode = srcCopy;

    CopyBits(srcBit, destBit, &srcRect, &destRect, tmode, NULL);
    RGBForeColor(&origForeColor);
    RGBBackColor(&origBackColor);
    SetClip(tmpRgn2);
    SetGWorld(saveWorld, saveDevice);
}
// --------------------------------------------------------------------------------------
static void drawIconListCell(ListHandle theList, const Rect *cellRect, 
								IconListCellDataRec *theCellData, Boolean selected)
{
	GrafPtr savedPort;
	CGrafPtr listPort;
	ThemeDrawingState savedState;
	Boolean active;
	Rect iconRect, textRect;
	short savedFont, savedSize;
	Style savedFace;
	CFStringRef cellName;
	
	GetPort(&savedPort);
	listPort = GetListPort(theList);
	SetPort((GrafPtr)listPort);
	
	GetThemeDrawingState(&savedState);
	
	if (selected)						// we don't need to change the background 
	{									// color if this Cell isn't highlighted
		Pattern whitePattern;
		RGBColor highlightColor;
		
		GetQDGlobalsWhite(&whitePattern);	// set the background pattern so that 
		BackPat(&whitePattern);				// the color is properly set as a solid color
		
		LMGetHiliteRGB(&highlightColor);
		RGBBackColor(&highlightColor);		// set the background to the highlight color
	}
	
	EraseRect(cellRect);
	
	calculateDrawingBounds(cellRect, &iconRect, &textRect);	// get the drawing Rects
	active = GetListActive(theList);
	
		// draw the IconRef using Icon Services
	PlotIconRef(&iconRect, kAlignNone, active ? kTransformNone : kTransformDisabled, 
				kIconServicesNormalUsageFlag, theCellData->icon);
	
#if TARGET_API_MAC_OS8		// draw TextEdit text in Classic
#pragma unused (cellName)
	savedFont = GetPortTextFont(listPort);	// Get/SetThemeDrawingState doesn't save or 
	savedFace = GetPortTextFace(listPort);	// restore these
	savedSize = GetPortTextSize(listPort);
	
	UseThemeFont(kThemeViewsFont, smCurrentScript);
	TETextBox(&theCellData->name[1], theCellData->name[0], &textRect, teCenter);
	
	TextFont(savedFont);
	TextFace(savedFace);
	TextSize(savedSize);
#else						// draw Appearance text in Carbon
#pragma unused (savedFont, savedSize, savedFace)
	cellName = CFStringCreateWithPascalString(kCFAllocatorDefault, theCellData->name, 
												GetApplicationTextEncoding());
	DrawThemeTextBox(cellName, kThemeViewsFont, 
						active ? kThemeStateActive : kThemeStateInactive, true, 
						&textRect, teCenter, NULL);
	CFRelease(cellName);
#endif
	
	SetThemeDrawingState(savedState, true);
	SetPort(savedPort);
} // drawIconListCell
Beispiel #22
0
void
ShowAdditionsWin(void)
{
	Str255		next, back;
	Str255		compDescTitle;
	StringPtr	selCompMsg;
	Handle		listBoxRect;
	Rect 		dataBounds, listBoxFrame, viewRect;
	short		reserr;
	int			totalRows = 0, i, instChoice;
	Point		cSize;
	Boolean		bCellSelected;
	GrafPtr		oldPort;
	GetPort(&oldPort);
		
	SetPort(gWPtr);
	
	gCurrWin = kAdditionsID; 
	/* gControls->aw = (CompWin *) NewPtrClear(sizeof(CompWin)); */
	
	GetResourcedString(next, rInstList, sNextBtn);
	GetResourcedString(back, rInstList, sBackBtn);

	// get controls
	listBoxRect = Get1Resource('RECT', rCompListBox);
	reserr = ResError(); 
	if (reserr == noErr && listBoxRect != NULL)
	{
		HLock((Handle)listBoxRect);
		SetRect(&gControls->aw->compListBox, 	((Rect*)*listBoxRect)->left,
												((Rect*)*listBoxRect)->top,
												((Rect*)*listBoxRect)->right,
												((Rect*)*listBoxRect)->bottom);
		HUnlock((Handle)listBoxRect);
	}
	else
	{
		ErrorHandler(reserr, nil);
		return;
	}
	gControls->aw->compDescBox = NULL;
	gControls->aw->compDescBox = GetNewControl(rCompDescBox, gWPtr);
	if (!gControls->aw->compDescBox)
	{
		ErrorHandler(eMem, nil);
		return;
	}

	gControls->aw->compListBox.right -= kScrollBarWidth;
	instChoice = gControls->opt->instChoice-1;
	for (i=0; i<kMaxComponents; i++)
	{
		if (totalRows >= gControls->cfg->numComps)
			break;
		if (!gControls->cfg->comp[i].invisible && gControls->cfg->comp[i].additional &&
			(gControls->cfg->st[instChoice].comp[i] == kInSetupType))
			totalRows++;
	}
		
	SetRect(&dataBounds, 0, 0, 1, totalRows);
	SetPt( &cSize, 0, 0);
	gControls->aw->compList = LNew((const Rect*)&gControls->aw->compListBox, (const Rect*)&dataBounds,
									cSize, rCheckboxLDEF, gWPtr, true, false, false, true);
	(*gControls->aw->compList)->selFlags = lExtendDrag + lUseSense + lDoVAutoscroll;
	
	HLock((Handle)gControls->aw->compDescBox);
	SetRect(&viewRect, (*gControls->aw->compDescBox)->contrlRect.left,
					   (*gControls->aw->compDescBox)->contrlRect.top,
					   (*gControls->aw->compDescBox)->contrlRect.right,
					   (*gControls->aw->compDescBox)->contrlRect.bottom);
	HUnlock((Handle)gControls->aw->compDescBox);
	viewRect.top += kInterWidgetPad;
	SetRect(&viewRect, viewRect.left + kTxtRectPad,
						viewRect.top + kTxtRectPad,
						viewRect.right - kTxtRectPad,
						viewRect.bottom - kTxtRectPad);
	TextFont(applFont);
	TextSize(9);
	gControls->aw->compDescTxt = TENew(&viewRect, &viewRect);
	TextFont(systemFont);
	TextSize(12);
	
	// populate controls
	bCellSelected = AddPopulateCompInfo();
	
	// show controls
	GetResourcedString(compDescTitle, rInstList, sCompDescTitle);
	SetControlTitle(gControls->aw->compDescBox, compDescTitle);
	
	MoveTo( gControls->aw->compListBox.left, gControls->aw->compListBox.top - kInterWidgetPad);
	HLock(gControls->cfg->selCompMsg);
	selCompMsg = CToPascal(*gControls->cfg->selAddMsg);
	if (selCompMsg)
		DrawString( selCompMsg );
	HUnlock(gControls->cfg->selCompMsg);
	SetRect(&listBoxFrame, gControls->aw->compListBox.left, 
						 --gControls->aw->compListBox.top,
						   gControls->aw->compListBox.right + kScrollBarWidth,
						 ++gControls->aw->compListBox.bottom);
	FrameRect(&listBoxFrame);
	ShowNavButtons( back, next );
	if (bCellSelected)
		AddSetOptInfo(true);
	else
		DrawDiskSpaceMsgs( gControls->opt->vRefNum );

	// default highlight first row
	AddInitRowHighlight(0);

#if 0	    
	RGBColor backColorOld;
    Rect adjustedRect, *clRect = &gControls->aw->compListBox;
    SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1);
    GetBackColor(&backColorOld);
    BackColor(whiteColor);
    EraseRect(&adjustedRect);
    RGBBackColor(&backColorOld);
#endif
    
	SetPort(oldPort);
}
Beispiel #23
0
SpChInDialog::SpChInDialog(ProfileDoc *dc,RawData *pD):TableDialog(dc,pD)
{
	short		iType;
	Handle		iHandle;
	Handle		sHandle;
	Rect 		iRect, r,pRect,tRect;	
	UserItemUPP box3D;
	
	QDErr		error;
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	RGBColor	c,oldbackcolor,oldforecolor;
	WindowPtr	oldP;
	OSErr		err;
	int32 		i,wi,hi;
	double		w,h;
	short		spc_ids[] = SPC_IDS;
	McoStatus  	state;
	int 		papernum;
	
	for (i=0; i<NumInputIDS; i++) ids[i] = spc_ids[i];

	WinType = StripDialog;
	WinNum = 0;

	setDialog(Input_Dialog);
	frame_button(ids[Ok_Box]);	

	
	SetSheetStripText();
	
	// Added by James, 3D the box
	threeD_box(ids[ThreeDBox]);
	
	// initialize comminications with the specrolino
	state = doc->openInputDevice(0,0,0);	
	if (state != MCO_SUCCESS) McoErrorAlert(state);

	w = patchD->patches.width;
	h = patchD->patches.height;
	
	if (patchD->type == CMYKPatches) papernum = 0;
	else if (patchD->type == RGBPatches) papernum = patchD->format.total;
	
	if (doc->tcom != 0L) ((SpectroChart*)(doc->tcom))->setUpPatches(patchD->patches.columns,patchD->patches.rows,w,h,patchD->patches.starting,patchD->patches.direction,papernum);

	if (doc->tcom->device_num != DT_GretagTable) 
		{
		McoErrorAlert(MCO_FAILURE);
		}
	
	// initialize the big gworld 
	GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect);
	tRect = iRect;
	OffsetRect(&tRect,-iRect.left,-iRect.top);
	error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 );
	if (error != 0) 
		{
		delete this;
		return;
		} 
	GetGWorld(&oldGW,&oldGD);
	SetGWorld(BigGW,nil);	
	
	
//	GetBackColor(&oldbackcolor);
	GetForeColor(&oldforecolor);
	c.red = 65535;
	c.green = 65535;
	c.blue = 65535;
	RGBBackColor(&c);
	c.red = 0;
	c.green = 0;
	c.blue = 0;
	RGBForeColor(&c);		
//	EraseRect( &tRect );
	
	SetGWorld(oldGW,oldGD);	
//	RGBBackColor(&oldbackcolor);
	RGBForeColor(&oldforecolor);	

//	SetPort(oldP);
		
	GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect);
	num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top);
	top_patch = 0;
	
	current_top = current_patch - 2*num_display_patch/3;
	current_bottom = current_top + num_display_patch - 1;
	if (current_top < 0) 
		{
		current_top = 0;
		current_bottom = current_top + num_display_patch - 1;
		}
	if (current_bottom >= total_patches-1)
		{
		current_bottom = total_patches - 1;
		current_top = current_bottom - num_display_patch + 1;
		}
	
	current_disp = 2*num_display_patch/3;
	
	init();	
	getpatchRGB();
	dtype = DType_Density;
	
	Disable(dp,ids[Redo]);

	
	GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect);
	SetCtlMin((ControlHandle)iHandle,0);
	SetCtlMax((ControlHandle)iHandle,total_patches-1);
	
	
	if (ids[VoiceSet] > -1)
		{
		GetDItem(dp, ids[VoiceSet], &iType, (Handle*)&iHandle, &pRect);
		SetCtlValue((ControlHandle)iHandle,1);
		}	
	//voice_set = 1;
	
	if (ids[Lift] > -1) HideDItem(dp,ids[Lift]);
	
	checkFinished();
	DrawWindow();
}	
//********************************************************************************
void	HersheyDisplayFontList(RECT *displayRect, boolean showSize)
{
int			xLoc, yLoc;
int			xLoc2;
int			ii;
char		theFontName[32];
long		fontDataLen;
short		myDisplayWidth;
RGBColor	myColor;
Boolean		drawHeader;

#ifdef _USE_WHITE_BACKGROUND_
	SetRGBcolor(&myColor, 255, 255, 255);
	fill(255);
#else
	SetRGBcolor(&myColor, 0, 0, 0);
#endif
	RGBBackColor(&myColor);
	
	myDisplayWidth	=	displayRect->right - displayRect->left;
	
	EraseRect(displayRect);

#ifdef _USE_WHITE_BACKGROUND_
	SetRGBcolor(&myColor, 0, 0, 0);
#else
	SetRGBcolor(&myColor, random(100, 255), random(100, 255), random(100, 255));
#endif

	RGBForeColor(&myColor);

	if (myDisplayWidth < 200)
	{
		xLoc	=	5;
	}
	else
	{
		xLoc	=	25;
	}
	xLoc2		=	myDisplayWidth / 2;
	drawHeader	=	true;

	for (ii = kHershey_FirstFontNumber; ii <kHersheyFont_last; ii++)
	{
		if (drawHeader)
		{
			EraseScreen();
		//	EraseRect(displayRect);
			FrameRect(displayRect);
			yLoc	=	10;
			DrawCString(5, yLoc, "Installed Hershey Fonts");
			yLoc	+=	16;
			drawHeader	=	false;
		}
		GetHersheyFontName(ii, theFontName);
		DrawCString(xLoc, yLoc, theFontName);
		if (myDisplayWidth > 150)
		{
			if (showSize)
			{
				fontDataLen	=	GetHersheyFontTableSize(ii);
		
				sprintf(theFontName, "%ld bytes", fontDataLen);
				DrawCString((displayRect->left + xLoc2), yLoc, theFontName);
			}
			else
			{
				//*	print some sample text
				HersheyDrawCString(ii, xLoc2, yLoc + 7, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",   15, 0, 1);
				
			}
		}
		yLoc	+=	16;

		if (yLoc > displayRect->bottom)
		{
			delay(2000);
			drawHeader	=	true;
		}
	}
}
Beispiel #25
0
/****************************************************************
   PopDraw() is the function associated with the user item that
   invokes the popup menu.  We draw the box to look like a menu
   cell, and then call the appropriate drawProc to fill in the
   cell with the actual contents.  If the drawProc is nil, we
   draw the menu item as text.  We gray the cell if the menu
   is disabled.  Finally, we draw a down arrow to indicate that
   the button is a popup menu.

   If the popup item is static, we only draw the cell contents.
 ****************************************************************/
pascal_ifMac void PopDraw(DialogPtr theDialog, short itemNum)
{
   GrafPtr        savePort;
   short          theType;
   Handle         itemHandle;
   Rect           itemBox;
   Rect           cellBox;
   MenuHandle     theMenu;
   //SysEnvRec      theWorld;
   RGBColor       SaveBack, SaveFore, DefaultBack, DefaultFore;
   char           name[256];
   short          i;
   short          drawStringFlag;

   // Added by Glen to code for support of Type-in Pop-Up menus
   // if drawStringFlag  = 1 then we don't draw text string ...
	
   drawStringFlag = 0;

   for ( i = 0 ; i < sa_numPopUps ; i++ )
      if ( (sa_popTable[i].dialogPtr == theDialog) && (sa_popTable[i].popupItemNum == itemNum) )
         break;
                              if (i == sa_numPopUps)
      { SysBeep(1); return; }    // should not happen since the dialog must have been registered
                                             // for PopDraw to have been called

   GetPortGrafPtr(&savePort);
   SetPortDialogPort(theDialog);
  // SysEnvirons(curSysEnvVers,&theWorld);

  // if (theWorld.hasColorQD) {
  if (ColorQDAvailable()) {
      GetForeColor(&SaveFore);
      GetBackColor(&SaveBack);
      DefaultMenuColors(&DefaultFore, &DefaultBack);
      if (sa_popTable[i].bStatic) {
         DefaultFore = SaveFore;
         DefaultBack = SaveBack;
      }
   }

   theMenu = GetMenuHandle(sa_popTable[i].menuID);
   if (!theMenu) { SysBeep(1); return; }
   
   /* change item's width to match the menu */
   GetDialogItem(theDialog,itemNum,&theType,&itemHandle,&itemBox);
   CalcMenuSize(theMenu);
   if (sa_popTable[i].itemWidth == 0) {
      if (sa_popTable[i].drawProc == nil)
        // itemBox.right = itemBox.left + (**theMenu).menuWidth + 20 + 2;
         itemBox.right = itemBox.left + GetMenuWidth(theMenu) + 20 + 2;
      else
         //itemBox.right = itemBox.left + (**theMenu).menuWidth + 2;
         itemBox.right = itemBox.left + GetMenuWidth(theMenu) + 2;
   }
   else if (sa_popTable[i].itemWidth == -1) {  // Type-in Pop-Up Menu
      itemBox.right = itemBox.left + 20 + 2;
      drawStringFlag = 1;
   }
   else
      itemBox.right = itemBox.left + sa_popTable[i].itemWidth + 2;
   SetDialogItem(theDialog,itemNum,theType,itemHandle,&itemBox);

   /* draw the box */
   if (TRUE) { // !sa_popTable[i].bStatic
     // if (theWorld.hasColorQD) RGBBackColor(&DefaultBack);
     if (ColorQDAvailable()) RGBBackColor(&DefaultBack);
      EraseRect( &itemBox );
     // if (theWorld.hasColorQD) RGBForeColor(&SaveFore);
     if (ColorQDAvailable())  RGBForeColor(&SaveFore);
      PenNormal();
	 // if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&qd.gray);
	  //if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&GRAY_BRUSH());
	  //if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&GRAY_BRUSH);
	  if (sa_popTable[i].bStatic) PenPatQDGlobalsGray();
      FrameRect(&itemBox);
      /* draw the shadow */
      MoveTo(itemBox.left + 3, itemBox.bottom);
      Line((itemBox.right - itemBox.left) - 3, 0);
      Line(0, -((itemBox.bottom - itemBox.top) - 2));
      PenNormal();
   }
   else
      EraseRect( &itemBox );

   /* draw the current item in the box */

  // if (theWorld.hasColorQD) RGBForeColor(&DefaultFore);
    if (ColorQDAvailable()) RGBForeColor(&DefaultFore);

   // Draw text if no Type-in Pop-Up
   if(drawStringFlag == 0){
      if (sa_popTable[i].drawProc != nil) {
         cellBox = itemBox;
         InsetRect(&cellBox, 1, 1);
         (* sa_popTable[i].drawProc) (theMenu,
                                                sa_popTable[i].lastItemSelected,
                                                &cellBox,         // so the drawProc gets the same-size rect,
                                                                      // whether it's drawing in the menu or in the pop-box
                                                true,           // since we are indeed drawing a pop box item
                                                //&theWorld,
                                                &DefaultFore,
                                                &DefaultBack);
      }
      else {
         MoveTo(itemBox.left + 15, itemBox.top + 4 + (itemBox.bottom - itemBox.top)/2);
         GetMenuItemText(theMenu, sa_popTable[i].lastItemSelected, (unsigned char *)name);
         DrawString((unsigned char *)name);
      }
   }

   if (TRUE) { // !sa_popTable[i].bStatic
      /* cover the item in gray if the menu is disabled */
     // if (!((**theMenu).enableFlags & ENABLE_BIT)) {
	  #if TARGET_API_MAC_CARBON
	 	 Boolean menuIsEnabled = IsMenuItemEnabled(theMenu,0);
	 #else
	 	 Boolean menuIsEnabled = (**theMenu).enableFlags & ENABLE_BIT;
	 #endif
      if (!menuIsEnabled) {
         //PenPat((ConstPatternParam)&qd.gray);
         //PenPat((ConstPatternParam)&GRAY_BRUSH);
		 PenPatQDGlobalsGray();
         PenMode(patOr);
         //if (theWorld.hasColorQD) RGBForeColor(&DefaultBack);
         if (ColorQDAvailable()) RGBForeColor(&DefaultBack); 
         else ForeColor(whiteColor);
         PaintRect(&itemBox);
         PenNormal();
        // if (theWorld.hasColorQD) RGBForeColor(&DefaultFore);
         if (ColorQDAvailable()) RGBForeColor(&DefaultFore);
         else ForeColor(blackColor);
      }

      /* draw the down arrow */
      itemBox.left = itemBox.right - 20;
      DrawArrow(&itemBox, kDown, sa_popTable[i].bStatic);
   }

   //if (theWorld.hasColorQD) {
   if (ColorQDAvailable()) {
     RGBForeColor(&SaveFore);
     RGBBackColor(&SaveBack);
   }

   SetPortGrafPort(savePort);
}
Beispiel #26
0
void
XCopyPlane(
    Display* display,		/* Display. */
    Drawable src,		/* Source drawable. */
    Drawable dest,		/* Destination drawable. */
    GC gc,			/* The GC to use. */
    int src_x,			/* X, Y, width & height */
    int src_y,			/* define the source rect. */
    unsigned int width,
    unsigned int height,
    int dest_x,			/* X & Y on dest where we will copy. */
    int dest_y,
    unsigned long plane)	/* Which plane to copy. */
{
    Rect srcRect, destRect;
    BitMapPtr srcBit, destBit, maskBit;
    MacDrawable *srcDraw = (MacDrawable *) src;
    MacDrawable *destDraw = (MacDrawable *) dest;
    GWorldPtr srcPort, destPort, maskPort;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    RGBColor macColor; 
    TkpClipMask *clipPtr = (TkpClipMask*)gc->clip_mask;
    short tmode;

    destPort = TkMacGetDrawablePort(dest);
    srcPort = TkMacGetDrawablePort(src);
    
    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacSetUpClippingRgn(dest);

    srcBit = &((GrafPtr) srcPort)->portBits;
    destBit = &((GrafPtr) destPort)->portBits;
    SetRect(&srcRect, (short) (srcDraw->xOff + src_x),
	    (short) (srcDraw->yOff + src_y),
	    (short) (srcDraw->xOff + src_x + width),
	    (short) (srcDraw->yOff + src_y + height));
    SetRect(&destRect, (short) (destDraw->xOff + dest_x),
	    (short) (destDraw->yOff + dest_y), 
	    (short) (destDraw->xOff + dest_x + width),
	    (short) (destDraw->yOff + dest_y + height));
    tmode = srcOr;
    tmode = srcCopy + transparent;

    if (TkSetMacColor(gc->foreground, &macColor) == true) {
	RGBForeColor(&macColor);
    }

    if (clipPtr == NULL || clipPtr->type == TKP_CLIP_REGION) {

	/*
	 * Case 1: opaque bitmaps.
	 */

	TkSetMacColor(gc->background, &macColor);
	RGBBackColor(&macColor);
	tmode = srcCopy;
	CopyBits(srcBit, destBit, &srcRect, &destRect, tmode, NULL);
    } else if (clipPtr->type == TKP_CLIP_PIXMAP) {
	if (clipPtr->value.pixmap == src) {
	    /*
	     * Case 2: transparent bitmaps.  If it's color we ignore
	     * the forecolor.
	     */
	    if ((**(srcPort->portPixMap)).pixelSize == 1) {
		tmode = srcOr;
	    } else {
		tmode = transparent;
	    }
	    CopyBits(srcBit, destBit, &srcRect, &destRect, tmode, NULL);
	} else {
	    /*
	     * Case 3: two arbitrary bitmaps.	 
	     */
	    tmode = srcCopy;
	    maskPort = TkMacGetDrawablePort(clipPtr->value.pixmap);
	    maskBit = &((GrafPtr) maskPort)->portBits;
	    CopyDeepMask(srcBit, maskBit, destBit, &srcRect, &srcRect, &destRect, tmode, NULL);
	}
    }

    SetGWorld(saveWorld, saveDevice);
}
// Will draw in center of view rectangle in the current QD graphics context;
// modeled after fps display.
// It won't try to clip the ends of the lines.
bool Crosshairs_Render(Rect &ViewRect)
{
	if (!_Crosshairs_IsActive) return _Crosshairs_IsActive;
	
	// Get the crosshair data
	CrosshairData &Crosshairs = GetCrosshairData();
	
	// Push previous state
	PenState OldPen;
	RGBColor OldBackColor, OldForeColor;
	
	GetPenState(&OldPen);
	GetBackColor(&OldBackColor);
	GetForeColor(&OldForeColor);
	
	// Get ready to draw the crosshairs
	PenNormal();
	
	// Drawing color
	RGBForeColor(&Crosshairs.Color);

	// Get the center location from the view rectangle	
	// Shift it down one, so that even line widths can come out right.
	short XCen = ((ViewRect.left + ViewRect.right) >> 1) - 1;
	short YCen = ((ViewRect.top + ViewRect.bottom) >> 1) - 1;
	
	// Separate for X and Y; the points are three on top/left and three on top/right:
	// Line-split position
	// Octagon vertex (half-way)
	// Farthest extent
	short OctaPoints[2][6];
	short Len;
	
	switch(Crosshairs.Shape)
	{
	case CHShape_RealCrosshairs:
	
		PenSize(1,Crosshairs.Thickness);
		
		// Left
		MoveTo(XCen-Crosshairs.FromCenter+Crosshairs.Thickness-1,YCen);
		Line(-Crosshairs.Length,0);
		
		// Right
		MoveTo(XCen+Crosshairs.FromCenter,YCen);
		Line(Crosshairs.Length,0);
		
		PenSize(Crosshairs.Thickness,1);
		
		// Top
		MoveTo(XCen,YCen-Crosshairs.FromCenter+Crosshairs.Thickness-1);
		Line(0,-Crosshairs.Length);
		
		// Bottom
		MoveTo(XCen,YCen+Crosshairs.FromCenter);
		Line(0,Crosshairs.Length);
		
		break;
		
	case CHShape_Circle:
		// This will really be an octagon, for OpenGL-rendering convenience
		
		// Precalculate the line endpoints, for convenience
		
		Len = Crosshairs.Length;
		OctaPoints[0][0] = XCen - Len;
		OctaPoints[0][5] = XCen + Len;
		OctaPoints[1][0] = YCen - Len;
		OctaPoints[1][5] = YCen + Len;
		
		Len = Len/2;
		OctaPoints[0][1] = XCen - Len;
		OctaPoints[0][4] = XCen + Len;
		OctaPoints[1][1] = YCen - Len;
		OctaPoints[1][4] = YCen + Len;
		
		Len = MIN(Len,Crosshairs.FromCenter);
		OctaPoints[0][2] = XCen - Len;
		OctaPoints[0][3] = XCen + Len;
		OctaPoints[1][2] = YCen - Len;
		OctaPoints[1][3] = YCen + Len;
		
		// We need to do 12 line segments, so we do them in 2*2*3 fashion
		
		for (int ix=0; ix<2; ix++)
		{
			int ixi = (ix > 0) ? 5 : 0;
			int ixid = (ix > 0) ? -1 : 1;
			for (int iy=0; iy<2; iy++)
			{
				int iyi = (iy > 0) ? 5 : 0;
				int iyid = (iy > 0) ? -1 : 1;
				
				// Vertical
				PenSize(Crosshairs.Thickness,1);
				MoveTo(OctaPoints[0][ixi],OctaPoints[1][iyi+2*iyid]);
				LineTo(OctaPoints[0][ixi],OctaPoints[1][iyi+iyid]);
				
				// Diagonal
				PenSize(Crosshairs.Thickness,Crosshairs.Thickness);
				LineTo(OctaPoints[0][ixi+ixid],OctaPoints[1][iyi]);
				
				// Horizontal
				PenSize(1,Crosshairs.Thickness);
				LineTo(OctaPoints[0][ixi+2*ixid],OctaPoints[1][iyi]);
			}
		}
		
		break;
	}
	
	// Pop previous state
	SetPenState(&OldPen);
	RGBBackColor(&OldBackColor);
	RGBForeColor(&OldForeColor);
		
	return _Crosshairs_IsActive;
}
Beispiel #28
0
static PF_Err
DrawEvent(	
	PF_InData		*in_data,
	PF_OutData		*out_data,
	PF_ParamDef		*params[],
	PF_LayerDef		*output,
	PF_EventExtra	*event_extra)
{
	PF_Err			err		=	PF_Err_NONE;
	
	AEGP_SuiteHandler suites(in_data->pica_basicP);
	

	event_extra->evt_out_flags = 0;
	

	if (!(event_extra->evt_in_flags & PF_EI_DONT_DRAW) && params[EXTRACT_DATA]->u.arb_d.value != NULL)
	{
		if(PF_EA_CONTROL == event_extra->effect_win.area)
		{
			ArbitraryData *arb_data = (ArbitraryData *)PF_LOCK_HANDLE(params[EXTRACT_DATA]->u.arb_d.value);
			ExtractStatus *extract_status = (ExtractStatus *)PF_LOCK_HANDLE(in_data->sequence_data);
		
		#define MAX_MESSAGE_LEN 127
			A_char	red_message[MAX_MESSAGE_LEN],
					green_message[MAX_MESSAGE_LEN],
					blue_message[MAX_MESSAGE_LEN],
					alpha_message[MAX_MESSAGE_LEN];
					
			A_char	*channel_message[4] = {	red_message,
											green_message,
											blue_message,
											alpha_message };
			
			ChannelStatus *channel_status[4] = {	&extract_status->red,
													&extract_status->green,
													&extract_status->blue,
													&extract_status->alpha };
												
			ChannelData *channel_data[4] = {	&arb_data->red,
												&arb_data->green,
												&arb_data->blue,
												&arb_data->alpha };
		
			// set up the messages
			for(int i=0; i<4; i++)
			{
				if(channel_data[i]->action == DO_COPY)
				{
					strcpy(channel_message[i], "(copy)");
				}
				else if(channel_data[i]->action == DO_EXTRACT)
				{
					// start with the name
					strcpy(channel_message[i], channel_data[i]->name);
					
					// process status returned from Render()
					if(channel_status[i]->status == STATUS_NOT_FOUND)
					{
						strcat(channel_message[i], " (not found)");
					}
					else if(channel_status[i]->status == STATUS_NO_CHANNELS)
					{
						strcat(channel_message[i], " (none available)");
					}
					else if(channel_status[i]->status == STATUS_ERROR)
					{
						strcat(channel_message[i], " (error)");
					}
					// can't change params during draw, need a click
					//else if(channel_status[i]->status == STATUS_INDEX_CHANGE)
					//{
					//	channel_data[i]->index = channel_status[i]->index;
					//	params[EXTRACT_DATA]->uu.change_flags = PF_ChangeFlag_CHANGED_VALUE;
					//}
				}
			}
			
			PF_Rect control_rect = event_extra->effect_win.current_frame;
			
			
#if PF_AE_PLUG_IN_VERSION < PF_AE100_PLUG_IN_VERSION

		// old-school Carbon/Win32 drawing code

		#ifdef WIN_ENV
			void*			dp = (*(event_extra->contextH))->cgrafptr;
			HDC				ecw_hdc	=	0;
			PF_GET_CGRAF_DATA(dp, PF_CGrafData_HDC, (void **)&ecw_hdc);
			PF_Point		pen;
		#endif

			PF_App_Color	pf_bg_color;
			suites.AppSuite()->PF_AppGetBgColor(&pf_bg_color);
			
		#ifdef MAC_ENV
			RGBColor titleColor, itemColor;
			RGBColor		bg_color;
	
			bg_color.red	=	pf_bg_color.red;
			bg_color.green	=	pf_bg_color.green;
			bg_color.blue	=	pf_bg_color.blue;
			
			RGBBackColor(&bg_color);
		
			EraseRect(&control_rect);
			
			GetForeColor(&itemColor);
			
			titleColor.red   = TITLE_COMP(itemColor.red);
			titleColor.green = TITLE_COMP(itemColor.green);
			titleColor.blue  = TITLE_COMP(itemColor.blue);
				
			RGBForeColor(&titleColor);
		#endif

		#ifdef MAC_ENV
		#define DRAW_STRING(STRING)	DrawText(STRING, 0, strlen(STRING));
		#define MOVE_TO(H, V)		MoveTo( (H), (V) );
		#else
		#define DRAW_STRING(STRING) \
			do{ \
				WCHAR u_string[100]; \
				UTF8toUTF16(STRING, (utf16_char *)u_string, 99); \
				TextOut(ecw_hdc, pen.h, pen.v, u_string, strlen(STRING)); \
			}while(0);
		#define MOVE_TO(H, V)		MoveToEx(ecw_hdc, (H), (V), NULL); pen.h = (H); pen.v = (V);
		#endif

		
#else // PF_AE_PLUG_IN_VERSION >= PF_AE100_PLUG_IN_VERSION

			// new-school Drawbot drawing code
			
			DRAWBOT_DrawRef			drawbot_ref = NULL;
			suites.PFEffectCustomUISuite()->PF_GetDrawingReference(event_extra->contextH, &drawbot_ref);
			
			DRAWBOT_SupplierRef		supplier_ref = NULL;
			DRAWBOT_SurfaceRef		surface_ref = NULL;

			suites.DBDrawbotSuite()->GetSupplier(drawbot_ref, &supplier_ref);
			suites.DBDrawbotSuite()->GetSurface(drawbot_ref, &surface_ref);
				
			DRAWBOT_ColorRGBA title_color = {0.8f, 0.8f, 0.8f, 1.0f};
			DRAWBOT_ColorRGBA item_color = title_color;
			
			item_color.red *= (1.0 - kUI_TITLE_COLOR_SCALEDOWN);
			item_color.green *= (1.0 - kUI_TITLE_COLOR_SCALEDOWN);
			item_color.blue *= (1.0 - kUI_TITLE_COLOR_SCALEDOWN);
			
			DRAWBOT_BrushP title_brushP(suites.DBSupplierSuite(), supplier_ref, &title_color);
			DRAWBOT_BrushP item_brushP(suites.DBSupplierSuite(), supplier_ref, &item_color);
			
			float default_font_sizeF = 0.0;
			suites.DBSupplierSuite()->GetDefaultFontSize(supplier_ref, &default_font_sizeF);
			
			DRAWBOT_FontP fontP(suites.DBSupplierSuite(), supplier_ref, default_font_sizeF);
			
			DRAWBOT_PointF32 text_origin = {0.f, 0.f};
			
			DRAWBOT_BrushP *current_brush = &title_brushP;
			
		#define MOVE_TO(H, V) \
			text_origin.x = (H) + 0.5f; \
			text_origin.y = (V) + 0.5f;
		
		#define DRAW_STRING(STRING) \
			do{ \
				DRAWBOT_UTF16Char u_str[100]; \
				UTF8toUTF16(STRING, u_str, 99); \
				suites.DBSurfaceSuite()->DrawString(surface_ref, current_brush->Get(), fontP.Get(), u_str, \
						&text_origin, kDRAWBOT_TextAlignment_Default, kDRAWBOT_TextTruncation_None, 0.0f); \
			}while(0);
			
#endif //PF_AE_PLUG_IN_VERSION >= PF_AE100_PLUG_IN_VERSION


			// Property Headings
			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_RED, control_rect.top) );
			DRAW_STRING("Red");
			
			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_GREEN, control_rect.top) );
			DRAW_STRING("Green");

			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_BLUE, control_rect.top) );
			DRAW_STRING("Blue");

			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_ALPHA, control_rect.top) );
			DRAW_STRING("Alpha");
			
			//Property Items
			PF_Point prop_origin;
			prop_origin.v = control_rect.top;
			
	#if PF_AE_PLUG_IN_VERSION < PF_AE100_PLUG_IN_VERSION
		#ifdef MAC_ENV
			RGBForeColor(&itemColor);
			prop_origin.h = control_rect.left + TextWidth("Alpha", 0, strlen("Alpha"));
		#else
			SIZE text_dim = {15, 8};
			GetTextExtentPoint(ecw_hdc, TEXT("Alpha"), strlen("Alpha"), &text_dim);
			prop_origin.h = control_rect.left + text_dim.cx;
		#endif
	#else
			current_brush = &item_brushP;
			prop_origin.h = control_rect.left + 50;
	#endif
			
			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_RED, prop_origin.v) );
			DRAW_STRING(red_message);
			
			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_GREEN, prop_origin.v) );
			DRAW_STRING(green_message);

			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_BLUE, prop_origin.v) );
			DRAW_STRING(blue_message);

			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_ALPHA, prop_origin.v) );
			DRAW_STRING(alpha_message);
			

			event_extra->evt_out_flags = PF_EO_HANDLED_EVENT;

			PF_UNLOCK_HANDLE(params[EXTRACT_DATA]->u.arb_d.value);
			PF_UNLOCK_HANDLE(in_data->sequence_data);
		}
	}

	return err;
}
Beispiel #29
0
DisplayDialog::DisplayDialog(ProfileDoc *dc,RawData *pD,int wn):InputDialog(dc,pD,1)
{
	short		iType;
	Handle		iHandle;
	Handle		sHandle;
	Rect 		iRect, r,pRect,tRect;	
	UserItemUPP  box3D;
	
	QDErr		error;
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	RGBColor	c,oldbackcolor,oldforecolor;
	WindowPtr	oldP;
	OSErr			err;
	int32 		i,wi,hi;
	double w,h;
	short		dtp_ids[] = DISPPATCH_IDS;
	Str255		theString,name;
	
	for (i=0; i<NumInputIDS; i++) ids[i] = dtp_ids[i];

	WinType = DisplayWindow;
	WinNum = wn;

	setDialog(Input_Dialog);

	
	GetIndString(theString,Display_Title,1);
	
	SetWTitle( dp, theString);
	
	// Added by James, 3D the box
	threeD_box(ids[ThreeDBox]);
	

	//playSound(8193);
	
	
	// initialize the big gworld 
	GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect);
	tRect = iRect;
	OffsetRect(&tRect,-iRect.left,-iRect.top);
	error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 );
	if (error != 0) 
		{
		delete this;
		return;
		} 
	GetGWorld(&oldGW,&oldGD);
	SetGWorld(BigGW,nil);	
	
	
//	GetBackColor(&oldbackcolor);
	GetForeColor(&oldforecolor);
	c.red = 65535;
	c.green = 65535;
	c.blue = 65535;
	RGBBackColor(&c);
	c.red = 0;
	c.green = 0;
	c.blue = 0;
	RGBForeColor(&c);		
//	EraseRect( &tRect );
	
	SetGWorld(oldGW,oldGD);	
//	RGBBackColor(&oldbackcolor);
	RGBForeColor(&oldforecolor);	

//	SetPort(oldP);
		
	GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect);
	num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top);
	top_patch = 0;
						
//init the static members
	//current_patch = total_patches-1;
	//current_patch = 0;
	current_patch = 0;
	current_strip = 0;
	current_sheet = 0;
 		
 	_done = 0;
 	_waiting = 0;
	
	SetSheetStripText();
	
	current_top = current_patch - 2*num_display_patch/3;
	current_bottom = current_top + num_display_patch - 1;
	if (current_top < 0) 
		{
		current_top = 0;
		current_bottom = current_top + num_display_patch - 1;
		}
	if (current_bottom >= total_patches-1)
		{
		current_bottom = total_patches - 1;
		current_top = current_bottom - num_display_patch + 1;
		}
	
	current_disp = 2*num_display_patch/3;
	
	init();	
	getpatchRGB();
	
	
	Disable(dp,ids[Redo]);

	
	GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect);
	SetCtlMin((ControlHandle)iHandle,0);
	SetCtlMax((ControlHandle)iHandle,total_patches-1);
	
//	GetDItem ( dp,ids[Message], &iType, (Handle*)&iHandle, &pRect );
//	SetIText(iHandle,"\p");
	
	GetDItem ( dp,PatchLabel, &iType, (Handle*)&iHandle, &pRect );
	GetIndString(theString,Message_List_ID,Patch_Message);
	SetIText(iHandle,theString);
	
	strcpy((char*)name,pD->desc);
	ctopstr((char*)name);
	SetWTitle( dp, name);
	
	DrawWindow();
}