コード例 #1
0
ファイル: tkMacDraw.c プロジェクト: BTHUNTERCN/cygwin
void
TkMacSetUpClippingRgn(
    Drawable drawable)		/* Drawable to update. */
{
    MacDrawable *macDraw = (MacDrawable *) drawable;

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

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

	if (macDraw->clipRgn != NULL) {
	    if (tkUseMenuCascadeRgn == 1) {
	    	Point scratch = {0, 0};
	    	GDHandle saveDevice;
	    	GWorldPtr saveWorld;
	    	
	    	GetGWorld(&saveWorld, &saveDevice);
	    	SetGWorld(TkMacGetDrawablePort(drawable), NULL);
	    	LocalToGlobal(&scratch);
	    	SetGWorld(saveWorld, saveDevice);
	    	if (tmpRgn == NULL) {
	    	    tmpRgn = NewRgn();
	    	}
	    	CopyRgn(tkMenuCascadeRgn, tmpRgn);
	    	OffsetRgn(tmpRgn, -scratch.h, -scratch.v);
	    	DiffRgn(macDraw->clipRgn, tmpRgn, tmpRgn);
	    	SetClip(tmpRgn);
	    	macDraw->toplevel->flags |= TK_DRAWN_UNDER_MENU;
	    } else {
	    	SetClip(macDraw->clipRgn);
	    }
	}
    }
}
コード例 #2
0
ファイル: PlatQt.cpp プロジェクト: Nikitaterm/rdo_studio
void SurfaceImpl::DrawTextClipped(PRectangle rc,
                                  Font &font,
                                  XYPOSITION ybase,
                                  const char *s,
                                  int len,
                                  ColourDesired fore,
                                  ColourDesired back)
{
	SetClip(rc);
	DrawTextNoClip(rc, font, ybase, s, len, fore, back);
	GetPainter()->setClipping(false);
}
コード例 #3
0
ファイル: Minimap.cpp プロジェクト: HoverRace/HoverRace
/**
 * Constructor.
 * @param display The display child elements will be attached to.
 */
Minimap::Minimap(Display &display) :
    SUPER(display), rescale(1.0), mapScale(0, 0), mapPic(), playerIcon()
{
    typedef UiViewModel::Alignment Alignment;

    SetSize(MAP_WIDTH, MAP_HEIGHT);
    SetClip(false);

    mapPic = NewChild<Picture>(std::shared_ptr<Res<Texture>>(),
                               MAP_WIDTH, MAP_HEIGHT);

    playerIcon = NewChild<SymbolIcon>(10, 10, ICON_SYMBOL);
    playerIcon->SetAlignment(Alignment::CENTER);
}
コード例 #4
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);
}
コード例 #5
0
ファイル: lcd.c プロジェクト: CNMAT/CNMAT-Externs
void LCD_doLineTo(Lcd *x, Symbol *s, short argc, Atom *argv)
{
	PaletteHandle pH;
	RGBColor fColor;
	GrafPort *gp;
	RgnHandle cur;
	long deltaX, deltaY;
	
	EnterCallback();
	deltaX = argv->a_w.w_long;
	deltaY = (argv+1)->a_w.w_long;
#ifdef debug
	post("LineTo");
#endif
	gp = patcher_setport(x->lcd_box.b_patcher);

	if (gp) {
		if (!box_nodraw((void *)x)) {
			cur = NewRgn();
			GetClip(cur);
			SetClip(x->lcd_region);
			setUpPalette(x,&fColor,&pH);

			LCD_MoveTo(x,(long)(x->lcd_where.h),(long)(x->lcd_where.v));
			LineTo(x->lcd_box.b_rect.left+1+(short)deltaX,x->lcd_box.b_rect.top+1+(short)deltaY);
			x->lcd_where.h = (short)deltaX;
			x->lcd_where.v = (short)deltaY;

			restorePalette(x,&fColor,&pH);
			SetClip(cur);
			DisposeRgn(cur);
		}
		SetPort(gp);
	}
	ExitCallback();
}
コード例 #6
0
ファイル: XOPDialogsMac.c プロジェクト: jgreenb2/DFMLoadWave
/*	DisplayDialogCmd(theDialog, dlogItemNo, cmd)

	Displays the command in an IGOR-style dialog. See GBLoadWaveDialog.c
	for an example.
	
	dlogItemNo is the item number of the dialog item in which the command
	is to be displayed. On the Macintosh, this must be a user item. On Windows,
	it must be an EDITTEXT item.

	Thread Safety: DisplayDialogCmd is not thread-safe.
*/
void
DisplayDialogCmd(DialogPtr theDialog, int dlogItemNo, const char* cmd)
{
	WindowRef theWindow;
	CGrafPtr thePort;
	Rect box;
	int font, size;
	int lineHeight;
	FontInfo info;
	RgnHandle saveClipRgnH;
	
	theWindow = GetDialogWindow(theDialog);
	thePort = GetWindowPort(theWindow);
	
	font = GetPortTextFont(thePort);		// Save text characteristics.
	size = GetPortTextSize(thePort);

	TextFont(kFontIDMonaco);
	TextSize(9);
	GetFontInfo(&info);
	lineHeight = info.ascent + info.descent + info.leading;
	
	GetDBox(theDialog, dlogItemNo, &box);
	saveClipRgnH = NewRgn();
	if (saveClipRgnH != NULL) {
		GetClip(saveClipRgnH);
		ClipRect(&box);
		InsetRect(&box, 2, 2);
		EraseRect(&box);
		if (*cmd != 0) {
			MoveTo(box.left+2, box.top + info.ascent + 2);
			DrawDialogCmd(cmd, lineHeight);
		}
		SetClip(saveClipRgnH);
		DisposeRgn(saveClipRgnH);
	}

	TextFont(font);									// Restore font, size, style.
	TextSize(size);
}
コード例 #7
0
ファイル: macevlog.c プロジェクト: rdebath/sgt
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);
}
コード例 #8
0
ファイル: HIScrollingTextBox.c プロジェクト: 0b1kn00b/xcross
OSStatus ScrollingTextBoxDraw(CGContextRef context, const HIRect * bounds, const ScrollingTextBoxData * myData)
	{
	HIRect textBounds = { {kMargin, kMargin}, {bounds->size.width - kMargin - kMargin, myData->height} };
	HIRect clipBounds = CGRectInset(*bounds, kMargin + 1.0, kMargin + 1.0);

//
// If we're building on Panther (or later) then HIThemeDrawTextBox is available, else we use DrawThemeTextBox
//
#if PANTHER_BUILD
//
// Furthermore, if we're running on Panther then we can call HIThemeDrawTextBox else we call DrawThemeTextBox
//
	if (GetHIToolboxVersion() >= Panther_HIToolbox_Version)
		{
		CGContextClipToRect(context, clipBounds);

		HIThemeTextInfo textInfo = {0, kThemeStateActive, kScrollingTextBoxFontID, kHIThemeTextHorizontalFlushLeft, kHIThemeTextVerticalFlushTop, kHIThemeTextBoxOptionStronglyVertical, kHIThemeTextTruncationNone, 0, false};
		HIThemeDrawTextBox(myData->theText, &textBounds, &textInfo, context, kHIThemeOrientationNormal);
		}
	else
#endif
		{
		Rect QDTextBounds = HI2QDRECT(textBounds);
		Rect QDClipBounds = HI2QDRECT(clipBounds);

		RgnHandle saveClip = NewRgn();
		GetClip(saveClip);
		ClipRect(&QDClipBounds);

		DrawThemeTextBox(myData->theText, kScrollingTextBoxFontID, kThemeStateActive, true, &QDTextBounds, teJustLeft, context);

		SetClip(saveClip);
		DisposeRgn(saveClip);
		}

	return noErr;
	}
コード例 #9
0
void CPROC EditResizeCallback( uintptr_t dwUser  )
{
	PEDITOR pe = (PEDITOR)dwUser;
	//PFACETSET *ppfs;
	//PFACET pf;

	//PLINESEGPSET *pplps;
	//PMYLINESEGSET *ppls;
	//PMYLINESEG pl;
	//int l;
	// ShowCurrent();
	//ClearImage( surface );
	{
		//IMAGE_RECTANGLE r;
		//GetDisplayPosition( pe->hVideo, pe->ptUpperLeft, pe->ptUpperLeft + 1, NULL, NULL );
		/*
		GetWindowRect( pe->hVideo->hWndOutput, &r );
		pe->ptUpperLeft[0] = r.left //+ GetSystemMetrics( SM_CXBORDER )
									  + GetSystemMetrics( SM_CXFRAME );
		pe->ptUpperLeft[1] = r.top + GetSystemMetrics( SM_CYBORDER )
									 + GetSystemMetrics( SM_CYFRAME )
									 + GetSystemMetrics( SM_CYCAPTION );
									 */
	}
#if 0
	SetClip( (RCOORD)GetDisplayImage( pe->hVideo )->width,
				(RCOORD)GetDisplayImage( pe->hVideo )->height );
	ppfs = pe->pCurrent->objinfo->ppFacetPool;
	ppls = GetFromSet( LINEPSEG, pe->pCurrent->objinfo->ppLinePool );
	//ForAllInSet( FACET, &pe->pCurrent->objinfo->ppFacetPool, DrawLineSegs );
	//int f;
	//for( f = 0; f < ; f++ )
	{
		int lines;
		//pf = GetFromSet( FACET, pfs->pFacets + f;
		pplps = &pf->pLineSet;
		lines = CountUsedInSet( LINESEGP, pf->pLineSet );
		for( l = 0; l < lines; l++ )
		{
			RAY ld; // local directional...
			PLINESEGP plsp = GetSetMember( LINESEGP, pplps, l );
			pl = GetSetMember( MYLINESEG, ppls, plsp->nLine );
			if( pl == pe->pCurrentLine )
			{
				ApplyInverseR( pe->TView, &ld, &pl->r );
				DrawLine(surface, ld.o, ld.n, pl->dFrom-5, pl->dFrom, Color( 192, 192, 0 ) );
				DrawLine(surface, ld.o, ld.n, pl->dFrom, pl->dTo, Color( 0, 150, 0 ) );
				DrawLine(surface, ld.o, ld.n, pl->dTo, pl->dTo+5, Color( 192, 192, 0 ) );
				GetViewPoint(surface, &pe->ptO, ld.o );
				add( ld.o, ld.o, ld.n ); // add one slope to origin to get slope point
				GetViewPoint(surface, &pe->ptN, ld.o );
				MarkOrigin( pe, surface );
				MarkSlope( pe,surface );
			}
			else
			if( pf = pe->pCurrentFacet )
			{
				ApplyInverseR( pe->TView, &ld, &pl->r );
				DrawLine(surface, ld.o, ld.n, pl->dFrom, pl->dTo, Color( 0, 0, 150 ) );
			}
			else
			{
				ApplyInverseR( pe->TView, &ld, &pl->r );
				DrawLine(surface, ld.o, ld.n, pl->dFrom, pl->dTo, Color( 92, 92, 92 ) );
			}
		}
	}
	UpdateDisplay( pe->hVideo );
#endif
}
コード例 #10
0
ファイル: SDL_romvideo.c プロジェクト: 3bu1/crossbridge
static void ROM_ShowMenuBar(_THIS)
{
#if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */
	RgnHandle		drawRgn = nil;
	RgnHandle		menuRgn = nil;
	RgnHandle		tempRgn = nil;
	RgnHandle		grayRgn = nil;
	WindowPtr		window = nil;
	GrafPtr			wMgrPort;
	GrafPtr			savePort;
	Rect			menuRect;
	long			response;
	short			height;
	EventRecord		theEvent;
	RGBColor		saveRGB;
	RGBColor		blackRGB = { 0, 0, 0 };

	height = GetMBarHeight();
	
	if ((height <= 0) && (gSaveMenuBar > 0)) {
		drawRgn = NewRgn();
		menuRgn = NewRgn();
		tempRgn = NewRgn();
		if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) {
			goto CLEANUP;
		}
		grayRgn = GetGrayRgn(); /* No need to check for this */
	
		GetPort(&savePort);
		GetWMgrPort(&wMgrPort);

		/* Set the height properly */
		LMSetMBarHeight(gSaveMenuBar);

		/* Restore the old GrayRgn: rounded corners, etc, but not
		   the menubar -- subtract that out first! */
		if (gSaveGrayRgn)
			{
			menuRect = (*GetMainDevice())->gdRect;
			menuRect.bottom = menuRect.top + gSaveMenuBar;
			RectRgn(menuRgn, &menuRect);

			DiffRgn(grayRgn, gSaveGrayRgn, drawRgn); 	/* What do we inval? */
			DiffRgn(drawRgn, menuRgn, drawRgn);			/* Clip out the menu */
			
			/* Now redraw the corners and other bits black */
			SetPort(wMgrPort);
			GetClip(tempRgn);
			SetClip(drawRgn);
			GetForeColor(&saveRGB);
			RGBForeColor(&blackRGB);
			PaintRgn(drawRgn);
			RGBForeColor(&saveRGB);
			SetClip(tempRgn);
			SetPort(savePort);
			
			UnionRgn(drawRgn, menuRgn, drawRgn);		/* Put back the menu */

			/* Now actually restore the GrayRgn */
			CopyRgn(gSaveGrayRgn, grayRgn);
			DisposeRgn(gSaveGrayRgn);
			gSaveGrayRgn = nil;
			}

		/* Modify the vis regions of exposed windows and draw menubar */
		window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L;
		PaintBehind(window, drawRgn);
		CalcVisBehind(window, drawRgn);
		DrawMenuBar();

		SetPort(savePort);
		gSaveMenuBar = 0;

		/* Now show the control strip if it's present */
		if (!Gestalt(gestaltControlStripAttr, &response) && 
				(response & (1L << gestaltControlStripExists)))
			{
			if (gSaveCSVis && !SBIsControlStripVisible())
				SBShowHideControlStrip(true);
			gSaveCSVis = true;
			}

		/* Yield time so that floaters can catch up */
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		}

CLEANUP:

	if (drawRgn) DisposeRgn(drawRgn);
	if (menuRgn) DisposeRgn(menuRgn);
	if (tempRgn) DisposeRgn(tempRgn);
#endif /* !TARGET_API_MAC_CARBON */
}
コード例 #11
0
/* ------------ Local code */
static void add_overhead_thumbnail(
    FileSpecifier &File)
{
    PicHandle picture;
    PicHandle preview;
    RgnHandle clip_region;
    FontInfo info;
    short text_x, text_y;
    short text_length;
    Str255 temporary;
    GWorldPtr old_gworld;
    GDHandle old_device;
    struct overhead_map_data overhead_data;
    Rect bounds;
    AEDesc aeFileSpec;
    FSSpec *SpecPtr;

    // Skip all this if there's no nav services to install the preview
    if(!machine_has_nav_services() || NavLibraryVersion() < kNavServicesVersion_2_0)
        return;

    GetGWorld(&old_gworld, &old_device);
    SetGWorld(world_pixels, (GDHandle) NULL);

    // Note well. We're using world_pixels to create our thumbnail pict within.
    // If world_pixels is runing as a postage stamp (low-res + small display space)
    // Then it is actually smaller than the size we're looking to build a thumbnail
    // within. But seeing as we're generating pict images and using drawing commands
    // instead of bit-wise operations. It all works out.

    /* Create the bounding rectangle */
    SetRect(&bounds, 0, 0, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);

    /* Start recording.. */
    picture= OpenPicture(&bounds);

    PaintRect(&bounds);

    overhead_data.scale= OVERHEAD_MAP_MINIMUM_SCALE;
    overhead_data.origin.x= local_player->location.x;
    overhead_data.origin.y= local_player->location.y;
    overhead_data.half_width= RECTANGLE_WIDTH(&bounds)/2;
    overhead_data.half_height= RECTANGLE_HEIGHT(&bounds)/2;
    overhead_data.width= RECTANGLE_WIDTH(&bounds);
    overhead_data.height= RECTANGLE_HEIGHT(&bounds);
    overhead_data.mode= _rendering_saved_game_preview;

    _render_overhead_map(&overhead_data);

    RGBForeColor(&rgb_black);
    PenSize(1, 1);
    TextFont(0);
    TextFace(normal);
    TextSize(0);

    ClosePicture();

    // JTP: Add Nav Services style preview
    SetRect(&bounds, 0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT);
    preview= OpenPicture(&bounds);

    SetRect(&bounds, PREVIEW_IMAGE_X, PREVIEW_IMAGE_Y,
            THUMBNAIL_WIDTH + PREVIEW_IMAGE_X, THUMBNAIL_HEIGHT + PREVIEW_IMAGE_Y);
    clip_region= NewRgn();
    GetClip(clip_region);
    ClipRect(&bounds);
    DrawPicture(picture, &bounds);
    SetClip(clip_region);

    /* Center the text in the rectangle */
    // LP: Classic doesn't have this function
#ifdef TARGET_API_MAC_CARBON
    CopyCStringToPascal(static_world->level_name, temporary);
#else
    strncpy((char *)temporary,static_world->level_name,LEVEL_NAME_LENGTH);
    c2pstr((char *)temporary);
#endif
    // LP: fix to allow lengths more than 127 bytes (not really necessary, but...)
    text_length = *ptemporary;
    TruncText(PREVIEW_WIDTH, (char *)temporary+1, &text_length, smTruncEnd);
    *ptemporary = text_length;

    GetFontInfo(&info);
    text_y= PREVIEW_HEIGHT - info.descent;
    text_x= PREVIEW_LABEL_X + (PREVIEW_WIDTH-StringWidth(temporary))/2;
    MoveTo(text_x, text_y);
    DrawString(temporary);

    ClosePicture();

    // This requires NavServices 2.0, what's the inline check?
    // From FSS get a AEDesc
    OSStatus err;
    SpecPtr = &File.GetSpec();
    err = AECreateDesc(typeFSS, SpecPtr, sizeof(FSSpec), &aeFileSpec);

    HLock((Handle)preview);
    err = NavCreatePreview(&aeFileSpec, 'PICT', *preview, GetHandleSize((Handle)preview));
    HUnlock((Handle)preview);

    AEDisposeDesc(&aeFileSpec);
    KillPicture(preview);
    KillPicture(picture);
    DisposeRgn(clip_region);

    SetGWorld(old_gworld, old_device);
}
コード例 #12
0
void DrawNoSectPolyRecursive (CMap *theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings,Rect subRect)
{
	long			PointCount, PlotCount = 0, PointIndex;
	LongPoint		MatrixPt;
	Point			LastScrPt, ThisScrPt, FirstScrPt;
	LongPoint		**RgnPtsHdl;
	PolyHandle		PolyHdl = nil;
	
	////////////
	Boolean  alwaysIn123 = true;
	Boolean  alwaysIn174 = true;
	Boolean  alwaysIn456 = true;
	Boolean  alwaysIn386 = true;
	Boolean canSkipDrawingPolygon = false;
	//    1 7 4
	//    2 0 5
	//    3 8 6
	////////////////

	PointCount = GetPolyPointCount (MapPolyHdl);
	RgnPtsHdl = GetPolyPointsHdl (MapPolyHdl);
	Boolean bDrawBlackAndWhite = (sharedPrinting && settings.printMode != COLORMODE);

	#define MAXNUMSEGMENTS  8000 // JLM, It seems the limit is 32K not 64K at the documentation says
	short thisSectionOfPlane,prevSectionOfPlane;
	Boolean canSkipThisPt,skippedAPt,offQuickDrawPlane=false;
	Point lastSkippedPt;
	Rect  fuzzyRect = subRect;
	long lineWidth = 1, esiCode;
	long outsetPixels = 2*lineWidth+2; // needs to be wider that the line width
	//long penWidth = 3;
	long penWidth = 2;
	long halfPenWidth = 0;
	InsetRect(&fuzzyRect,-outsetPixels,-outsetPixels);

	if (RgnPtsHdl != nil)
	{

		// must clip to this rect in addtion to the original clip
		Rect clippingRect = subRect;
		RgnHandle saveClip = NewRgn(), addition = NewRgn() , newClip = NewRgn();

		GetClip(saveClip);
		GetClip(newClip);
		RectRgn(addition, &clippingRect);
		SectRgn(newClip, addition, newClip);
		SetClip(newClip);
		if(newClip) DisposeRgn(newClip);
		if(addition) DisposeRgn(addition);


		if (drawSettings -> fillCode != kNoFillCode)
			PolyHdl = OpenPoly ();
		else
		{
			PolyHdl = OpenPoly ();
			//Our_PmForeColor (gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);
			Our_PmForeColor (drawSettings -> foreColorInd);
		}

		GetObjectESICode ((ObjectRecHdl) MapPolyHdl,&esiCode); 
		if (esiCode>0) 	// -500 is the default
		{
			//halfPenWidth = penWidth/2;
#ifdef MAC
			PenSize(penWidth,penWidth);
#else
			PenStyle(BLACK,penWidth);
#endif
		}
		for (PointIndex = 0,skippedAPt = false,prevSectionOfPlane = -1; PointIndex < PointCount; ++PointIndex)
		{
			MatrixPt = (*RgnPtsHdl) [PointIndex];
//			theMap -> GetScrPoint (&MatrixPt, &ThisScrPt);

			//ThisScrPt.h = SameDifferenceX(MatrixPt.h);
			//ThisScrPt.v = (gRect.bottom + gRect.top) - SameDifferenceY(MatrixPt.v);
			ThisScrPt = GetQuickDrawPt(MatrixPt.h, MatrixPt.v, &gRect, &offQuickDrawPlane);

			// code goes here, what to do when point is off quickdraw plane?
			//if (offQuickDrawPlane) break;
			
			ThisScrPt.h += drawSettings -> offsetDx;
			ThisScrPt.v += drawSettings -> offsetDy;
			
			if(PolyHdl)
			{  //// JLM 2/18/99
				// for points outside the drawing area, it is not necessary to move to the correct point,
				// as long as we preserve the winding.  This allows us to ignore many of the points outside 
				// the drawing rectangle gRect
				thisSectionOfPlane = SectionOfPlane(&fuzzyRect,ThisScrPt);
				if( 	thisSectionOfPlane > 0 // outside of the rectangle
						&& thisSectionOfPlane == prevSectionOfPlane // we have not changed sections of the plane
						&& PointIndex < PointCount -1) // not the last point
					canSkipThisPt = true;
				else canSkipThisPt = false;
				prevSectionOfPlane = thisSectionOfPlane;
				if(canSkipThisPt) 
				{
					skippedAPt = true;
					lastSkippedPt =ThisScrPt;
					continue;
				}
				/// JLM 3/6/01
				switch(thisSectionOfPlane) {
					case 1: 															alwaysIn456 = false; alwaysIn386 = false; break;
					case 2: 								alwaysIn174 = false; alwaysIn456 = false; alwaysIn386 = false; break;
					case 3: 								alwaysIn174 = false; alwaysIn456 = false; 							break;
					case 4:	alwaysIn123 = false; 														alwaysIn386 = false; break;
					case 5:	alwaysIn123 = false;	alwaysIn174 = false; 							alwaysIn386 = false; break;
					case 6:	alwaysIn123 = false;	alwaysIn174 = false; 														break;
					case 7:	alwaysIn123 = false;								alwaysIn456 = false; alwaysIn386 = false; break;
					case 8:	alwaysIn123 = false;	alwaysIn174 = false; alwaysIn456 = false; 							break;
					default: alwaysIn123 = false;	alwaysIn174 = false; alwaysIn456 = false; alwaysIn386 = false; break;
				}
				//////
				if(skippedAPt)
				{	// then we have to draw to the previous point 
					// before we draw to the current point 
					PointIndex--; //so we do the previous point below
					ThisScrPt = lastSkippedPt; // restore the coordinates of the previous point
					prevSectionOfPlane = -1; // force the next point to not be skipped
				}
				skippedAPt = false;
				if(PlotCount > MAXNUMSEGMENTS)
				{	// there is a bug on the max when the number of points gets too large
					// try recusion
					ClosePoly();
					KillPoly(PolyHdl);
					SetClip(saveClip);// JLM 8/4/99
					goto recursion;
				}
				//////////////
			}


			if (PointIndex == 0)
			{
				MyMoveTo (ThisScrPt.h-halfPenWidth, ThisScrPt.v-halfPenWidth);
				FirstScrPt = ThisScrPt;
				LastScrPt = ThisScrPt;
				PlotCount = 0;
			}
			else
			{
				if (LastScrPt.h != ThisScrPt.h || LastScrPt.v != ThisScrPt.v)
				{
					MyLineTo (ThisScrPt.h-halfPenWidth, ThisScrPt.v-halfPenWidth);
					LastScrPt = ThisScrPt;
					++PlotCount;
				}
			}
		}

		if (drawSettings -> bClosed)	/* draw a line from last point to first point if requested */
		{
			MyLineTo (FirstScrPt.h-halfPenWidth, FirstScrPt.v-halfPenWidth);
			++PlotCount;
		}

		if (PolyHdl != nil)
		{
			ClosePoly ();
			////////////// JLM 3/6/01
			if(alwaysIn123 || alwaysIn174 || alwaysIn456 || alwaysIn386)
				canSkipDrawingPolygon = true;
			if(canSkipDrawingPolygon) PlotCount = 0; // so that we skip the code below
			////////////
			if (PlotCount > 0)
			{
				if (PlotCount > 2)			/* polygon must contain more than 2 line-to points */
				{
					if (drawSettings -> bErase || (drawSettings -> fillCode == kNoFillCode && drawSettings -> backColorInd == kWaterColorInd))
						ErasePoly (PolyHdl);
	
					if (drawSettings -> fillCode == kPaintFillCode)
					{
						// this is the usual drawing code
						Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM
						if(bDrawBlackAndWhite) SetPenPat(UPSTRIPES);
						PaintPoly(PolyHdl);//JLM
						if(bDrawBlackAndWhite) SetPenPat(BLACK);
					}
					else if (drawSettings -> fillCode == kPatFillCode)
						FillPoly (PolyHdl, &(drawSettings -> backPattern));
				}

				if (drawSettings -> frameCode == kPaintFrameCode)
				{
					Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);
					FramePoly (PolyHdl);
				}
				else if (drawSettings -> frameCode == kPatFrameCode)
				{
					PenPat (&(drawSettings -> forePattern));
					FramePoly (PolyHdl);
				}
			}
			
			KillPoly (PolyHdl);
		}
		
		SetClip(saveClip);
		if(saveClip) DisposeRgn(saveClip);

	}

#ifdef MAC
	PenSize(1,1);
#else
	PenStyle(BLACK,1);
#endif
	return;
	
	////////////////////////////////
recursion:
	////////////////////////////////
	{
		#define MAXRECURSION 20 
		static short sRecursionValue = 0;
	
		if(sRecursionValue >= MAXRECURSION) 
		{
			printError("max recusion exceeded");
		}
		else
		{
			// use recursion
			Rect subBoundingRect;
			long middleH = (subRect.left+subRect.right)/2;
			long middleV = (subRect.top+subRect.bottom)/2;
			long index;
			
			sRecursionValue++;
		
			// divide the points up and Draw again
			for(index = 0; index < 4; index++)
			{
				subBoundingRect = subRect;
				switch(index)
				{
					case 0: 
						subBoundingRect.top  = middleV;
						subBoundingRect.left  = middleH;
						break;
					case 1: 
						subBoundingRect.top  = middleV;
						subBoundingRect.right  = middleH;
						break;
					case 2: 
						subBoundingRect.bottom  = middleV;
						subBoundingRect.left  = middleH;
						break;
					default: 
						subBoundingRect.bottom  = middleV;
						subBoundingRect.right  = middleH;
						break;
				}
				
				// the recursive call
				DrawNoSectPolyRecursive (theMap,MapPolyHdl,drawSettings,subBoundingRect);
				
			}
			// all done
			sRecursionValue--;
			return;
		}
	}
	
}
コード例 #13
0
ファイル: grafx.c プロジェクト: devmabbott/cdogs-sdl
/* Initialises the video subsystem.

   Note: dynamic resolution change is not supported. */
int InitVideo(void)
{	
	char title[32];
	SDL_Surface *new_screen = NULL;
	int sdl_flags = 0;
	int w, h = 0;
	int rw, rh;

	sdl_flags |= SDL_HWPALETTE;
	sdl_flags |= SDL_SWSURFACE;

	if (Hint(HINT_FULLSCREEN)) sdl_flags |= SDL_FULLSCREEN;

	if (screen == NULL) {
		rw = w = Hint(HINT_WIDTH);
		rh = h = Hint(HINT_HEIGHT);
	} else {
		/* We do this because the game dies horribly if you try to
		dynamically change the _virtual_ resolution */
		rw = w = screen_w;
		rh = h = screen_h;
	}

	if (Hint(HINT_SCALEFACTOR) > 1) {
		rw *= Hint(HINT_SCALEFACTOR);
		rh *= Hint(HINT_SCALEFACTOR);
	}

	if (!Hint(HINT_FORCEMODE)) {
		if (!ValidMode(w, h)) {
			printf("!!! Invalid Video Mode %dx%d\n", w, h);
			return -1;
		}
	} else {
		printf("\n");
		printf("  BIG FAT WARNING: If this blows up in your face,\n");
		printf("  and mutilates your cat, please don't cry.\n");
		printf("\n");
	}

	printf("Window dimensions:\t%dx%d\n", rw, rh);
	new_screen = SDL_SetVideoMode(rw, rh, 8, sdl_flags);

	if (new_screen == NULL) {
		printf("ERROR: InitVideo: %s\n", SDL_GetError() );
		return -1;
	}	

	if (screen == NULL) { /* only do this the first time */
		debug(D_NORMAL, "setting caption and icon...\n");
		sprintf(title, "C-Dogs %s [Port %s]", CDOGS_VERSION, CDOGS_SDL_VERSION);
		SDL_WM_SetCaption(title, NULL);
		SDL_WM_SetIcon(SDL_LoadBMP(GetDataFilePath("cdogs_icon.bmp")), NULL);
		SDL_ShowCursor(SDL_DISABLE);
	} else {
		debug(D_NORMAL, "Changed video mode...\n");
	}

	if (screen == NULL) {
		screen_w = Hint(HINT_WIDTH);
		screen_h = Hint(HINT_HEIGHT);
	}

	screen = new_screen;
	
	SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
	debug(D_NORMAL, "Internal dimensions:\t%dx%d\n", SCREEN_WIDTH, SCREEN_HEIGHT);

	SetPalette(gPalette);
			
	return 0;
}
コード例 #14
0
ファイル: lcd.c プロジェクト: CNMAT/CNMAT-Externs
void LCD_drawTxt(Lcd *x, char *stng)     /* drawn in response to update event */
{
	GrafPort *gp;
	short		chars;
	Rect	r,area;
	PaletteHandle pH;
	RGBColor fColor;
	RgnHandle cur;
	short		font,size;
	
	gp = patcher_setport(x->lcd_box.b_patcher);
	if (gp) {
		font = gp->txFont;
		size = gp->txSize;
		r = x->lcd_box.b_rect;
		if (x->f_width == -1) { /* window not visible before */
			if (!x->font && !x->f_size) {
				x->font = font;
				x->f_size = size;
			}
			LCD_calcfont(x);
			LCD_resize(x);
		}
		TextFont(x->font);
		TextSize(x->f_size);

		if ((x->lcd_row+1)<=x->rows) {
			if (!box_nodraw((void *)x)) {
				/* chars = x->cols-x->lcd_col;  DDZ removed this stuff */
				if (/* chars > 0 */ 1) {
#ifdef never
					MoveTo(	(x->lcd_col*x->f_width)+r.left+BORDER_WIDTH,
							(x->lcd_row+1)*x->f_height+(x->lcd_row)*x->f_lineSpace+r.top-x->f_descent);

					/* erase area where we will write */
					area.top = (x->lcd_row*x->f_height)+r.top+BORDER_HEIGHT;
					area.bottom = ((x->lcd_row+1)*x->f_height)+r.top+BORDER_HEIGHT;
					area.left = (x->lcd_col*x->f_width)+r.left+BORDER_WIDTH;
					area.right = ((x->lcd_col+chars)*x->f_width)+r.left+BORDER_WIDTH;
#else
					MoveTo(x->lcd_where.h+r.left+BORDER_WIDTH,x->lcd_where.v+r.top);
#endif
					/* chars = MIN(chars,(short)strlen(stng)); */
					chars = strlen(stng);  /* DDZ just made it draw any string */
					
					cur = NewRgn();
					GetClip(cur);
					SetClip(x->lcd_region);
#ifdef never
					EraseRect(&area);
#endif
					setUpPalette(x,&fColor,&pH);

					DrawText(stng,0,chars);
					x->lcd_where.h += TextWidth(stng,0,chars);
					restorePalette(x,&fColor,&pH);
					SetClip(cur);
					DisposeRgn(cur);
					x->lcd_col += chars;		/* advance cursor */
					if (x->lcd_col > x->cols-1 )
						x->lcd_col--;			/* make it stick to last col */
				}
			}
		}
		TextFont(font);
		TextSize(size);

		SetPort(gp);
	}
}
コード例 #15
0
ファイル: shellscroll.c プロジェクト: dvincent/frontier
static void EnableDrawing ( void ) {

	SetClip ( gSaveClip );
	
	return;
	} /*EnableDrawing*/
コード例 #16
0
ファイル: lcd.c プロジェクト: CNMAT/CNMAT-Externs
void LCD_doreson(Lcd *x, Symbol *s, short argc, Atom *argv)
{
	short i,x1,y1,y2,height,width;
	double	freq,ampl,band;
	Rect	r;
	PaletteHandle pH;
	RGBColor fColor;
	GrafPort *gp;
	RgnHandle cur;
	Rect	 b;
	double xscale;
	double bscale;
	double yscale;				
	
	EnterCallback();

	if((argc%3)!=0)
	{
		post("bad number of resonance parameters %d", argc);
	} else {
		gp = patcher_setport(x->lcd_box.b_patcher);

		if (gp) {
			if (!box_nodraw((void *)x)) {
				cur = NewRgn();
				GetClip(cur);
				SetClip(x->lcd_region);
				setUpPalette(x,&fColor,&pH);
				
				r = x->lcd_box.b_rect;
				width	= r.right-r.left;
				height	= r.bottom-r.top;
				xscale=width/(x->reson_sampleRate);
				bscale = (0.1*height);
				yscale = height/x->reson_spectScale;
				for (i=0;i<argc;i++)
				{
					freq = (double)argv[i].a_w.w_float;
					ampl =argv[++i].a_w.w_float;
					if(ampl<0.0f)
						ampl = -ampl;
					ampl = 20.0*log10(ampl);
					band = (double)argv[++i].a_w.w_float;
					if(freq>0.0 && freq<(x->reson_sampleRate)	&& band>0.0)
					{
						x1 = (freq*xscale);
						{
							float ydisp = ampl*yscale;
							if(ydisp>(r.bottom-r.top))
								y1 = r.bottom -r. top;
							else
								y1= ydisp;
						}
						y2 = bscale*3.1415926/sqrt(MINMAX(band,0.1,40.0));
				
						if (x->lcd_debug)
							post("x1: %d y1: %d y2: %d",x1,y1,y2);
								
						MoveTo(r.left+x1,r.top+y1);
						Line(0,y2);
					}
				}
		
				restorePalette(x,&fColor,&pH);
				SetClip(cur);
				DisposeRgn(cur);
			}
			SetPort(gp);
		}
	
	}
	ExitCallback();
}
コード例 #17
0
ファイル: MultiFontsDemo.c プロジェクト: Athuli7/Microchip
/************************************************************************
 Function: void AnimateText(BYTE mov)
                                                                       
 Overview: Routine to move or animate the text.
  		                                         
 Input: mov - number of pixels the text will be moved
                                                                       
 Output: none
************************************************************************/
void AnimateText(BYTE mov)
{
    static SHORT    xPos = STXXPOS, yPos = STXYPOS;
    static SHORT    x, y;
    SHORT           width;
    SHORT           height;

    SHORT           newX, newY, oldX, oldY;
    XCHAR           NewChar, *pString;

    // set the clipping region
    SetClip(CLIP_ENABLE);
    SetClipRgn(STXXPOS + 2, STXYPOS + 2, STXXPOS + STXWIDTH - 2, STXYPOS + STXHEIGHT - 2);

    // set the font
    SetFont(pHWData->pHWFont);

    // calculate string width & height	
    width = GetTextWidth((XCHAR *)pHWData->pHWStr, pHWData->pHWFont);
    height = GetTextHeight(pHWData->pHWFont);

    //-----------------------------------------------------------------
    // interlace the erasing and printing of characters
    // check first if we need to move in the positive or negative direction
    if((xPos + width) >= (STXXPOS + STXWIDTH))
        x = -(mov);
    if(xPos <= (STXXPOS))
        x = (mov);

    if((yPos + height) >= (STXYPOS + STXHEIGHT))
        y = -(mov);
    if(yPos <= (STXYPOS))
        y = (mov);

    pString = pHWData->pHWStr;
    oldX = xPos;
    oldY = yPos;
    newX = xPos + x;
    newY = yPos + y;
    while((XCHAR)15 < (XCHAR)(NewChar = *pString++))
    {

        // remove the old position of the character
        SetColor(FontScheme2->CommonBkColor);
        MoveTo(oldX, oldY);
        WAIT_UNTIL_FINISH(OutChar(NewChar));
        oldX = GetX();
        oldY = GetY();

        // display the character in the new position
        SetColor(BRIGHTBLUE);
        MoveTo(newX, newY);
        WAIT_UNTIL_FINISH(OutChar(NewChar));
        newX = GetX();
        newY = GetY();
    }

    xPos += x;
    yPos += y;

    // disable the clipping
    SetClip(CLIP_DISABLE);
}
コード例 #18
0
ファイル: DigitalMeter.c プロジェクト: Anvidi/cpassgen
/*********************************************************************
* Function: WORD DmDraw(void *pObj)
*
* Notes: This is the state machine to display the changing numbers.
*
**********************************************************************/
WORD DmDraw(void *pObj)
{
    typedef enum
    {
        DM_STATE_IDLE,
        DM_STATE_FRAME,
        DM_STATE_DRAW_FRAME,
        DM_STATE_INIT,
        DM_STATE_SETALIGN,
        DM_STATE_SETTEXT,
        DM_STATE_ERASETEXT,
        DM_STATE_DRAWTEXT,
        DM_STATE_WRAPUP
    } DM_DRAW_STATES;

    DIGITALMETER *pDm = NULL;
    static DM_DRAW_STATES state = DM_STATE_IDLE;
    static SHORT charCtr = 0, lineCtr = 0;
    static XCHAR CurValue[DM_WIDTH], PreValue[DM_WIDTH];
    static SHORT textWidth = 0;
    static XCHAR ch = 0, pch = 0;

    pDm = (DIGITALMETER *)pObj;

    while(1)
    {

    if(IsDeviceBusy())
        return (0);
    
        switch(state)
        {
            case DM_STATE_DRAW_FRAME:
                if(Rectangle(pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom) == 0)
                    return (0);
                state = DM_STATE_INIT;
                break;

            case DM_STATE_IDLE:
                SetClip(CLIP_DISABLE);
    
#ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                GFX_DRIVER_SetupDrawUpdate( pDm->hdr.left,
                                            pDm->hdr.top,
                                            pDm->hdr.right,
                                            pDm->hdr.bottom);
#endif
                if(GetState(pDm, DM_HIDE) || GetState(pDm, DM_DRAW))
                {
    	            SetColor(pDm->hdr.pGolScheme->CommonBkColor);
    	            if(Bar(pDm->hdr.left, pDm->hdr.top, pDm->hdr.right, pDm->hdr.bottom) == 0)
    	            	return (0);
    			}
                // if the draw state was to hide then state is still IDLE STATE so no need to change state
                if (GetState(pDm, DM_HIDE))
                {
#ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
                    GFX_DRIVER_CompleteDrawUpdate(   pDm->hdr.left,
                                                    pDm->hdr.top,
                                                    pDm->hdr.right,
                                                    pDm->hdr.bottom);
#endif
                	return (1);
                }
                state = DM_STATE_FRAME;	
    
            case DM_STATE_FRAME:
    
    			if(GetState(pDm, DM_DRAW | DM_FRAME) == (DM_DRAW | DM_FRAME))
                {
                    // show frame if specified to be shown
                    SetLineType(SOLID_LINE);
                    SetLineThickness(NORMAL_LINE);
                    if(!GetState(pDm, DM_DISABLED))
                    {
    
                        // show enabled color
                        SetColor(pDm->hdr.pGolScheme->Color1);
                    }
                    else
                    {
    
                        // show disabled color
                        SetColor(pDm->hdr.pGolScheme->ColorDisabled);
                    }
                    state = DM_STATE_DRAW_FRAME;
                    break;
                }
                else 
                {
                    state = DM_STATE_INIT;
                }
    
            case DM_STATE_INIT:
                if(IsDeviceBusy())
                    return (0);
    
                // set clipping area, text will only appear inside the static text area.
                SetClip(CLIP_ENABLE);
                SetClipRgn(pDm->hdr.left + DM_INDENT, pDm->hdr.top, pDm->hdr.right - DM_INDENT, pDm->hdr.bottom);
    
                // set the text color
                if(!GetState(pDm, DM_DISABLED))
                {
                    SetColor(pDm->hdr.pGolScheme->TextColor0);
                }
                else
                {
                    SetColor(pDm->hdr.pGolScheme->TextColorDisabled);
                }
    
                // convert the values to be displayed in string format
                NumberToString(pDm->Pvalue, PreValue, pDm->NoOfDigits, pDm->DotPos);
                NumberToString(pDm->Cvalue, CurValue, pDm->NoOfDigits, pDm->DotPos);
    
                // use the font specified in the object
                SetFont(pDm->hdr.pGolScheme->pFont);
    
                state = DM_STATE_SETALIGN;  // go to drawing of text
    
            case DM_STATE_SETALIGN:
                if(!charCtr)
                {
    
                    // set position of the next character (based on alignment and next character)
                    textWidth = GetTextWidth(CurValue, pDm->hdr.pGolScheme->pFont);
    
                    // Display text with center alignment
                    if(GetState(pDm, (DM_CENTER_ALIGN)))
                    {
                        MoveTo((pDm->hdr.left + pDm->hdr.right - textWidth) >> 1, pDm->hdr.top + (lineCtr * pDm->textHeight));
                    }
    
                    // Display text with right alignment
                    else if(GetState(pDm, (DM_RIGHT_ALIGN)))
                    {
                        MoveTo((pDm->hdr.right - textWidth - DM_INDENT), pDm->hdr.top + (lineCtr * pDm->textHeight));
                    }
    
                    // Display text with left alignment
                    else
                    {
                        MoveTo(pDm->hdr.left + DM_INDENT, pDm->hdr.top + (lineCtr * pDm->textHeight));
                    }
                }
コード例 #19
0
ファイル: checklst.cpp プロジェクト: gitrider/wxsj2
static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, Rect *drawRect,
                                     Cell cell, short dataOffset, short dataLength,
                                     ListHandle listHandle )
{
    wxCheckListBox*          list;
    list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
    if ( list == NULL )
        return ;
    
    GrafPtr savePort;
    GrafPtr grafPtr;
    RgnHandle savedClipRegion;
    SInt32 savedPenMode;
    GetPort(&savePort);
    SetPort((**listHandle).port);
    grafPtr = (**listHandle).port ;
    // typecast our refCon
    
    //  Calculate the cell rect.
    
    switch( message ) {
        case lInitMsg:
            break;

        case lCloseMsg:
            break;

        case lDrawMsg:
        {
            const wxString text = list->m_stringArray[cell.v] ;
            int checked = list->m_checks[cell.v] ;

            //  Save the current clip region, and set the clip region to the area we are about
            //  to draw.
            
            savedClipRegion = NewRgn();
            GetClip( savedClipRegion );

            ClipRect( drawRect );
            EraseRect( drawRect );
            
            const wxFont& font = list->GetFont();
            if ( font.Ok() )
            {
                ::TextFont( font.GetMacFontNum() ) ;
                ::TextSize( font.GetMacFontSize())  ;
                ::TextFace( font.GetMacFontStyle() ) ;
            }
                       
            ThemeButtonDrawInfo info ;
            info.state = kThemeStateActive ;
            info.value = checked ? kThemeButtonOn : kThemeButtonOff ;
            info.adornment = kThemeAdornmentNone ;
            Rect checkRect = *drawRect ;
                        
            
            checkRect.left +=0 ;
            checkRect.top +=0 ;
            checkRect.right = checkRect.left + list->m_checkBoxWidth ;
            checkRect.bottom = checkRect.top + list->m_checkBoxHeight ;
            DrawThemeButton(&checkRect,kThemeCheckBox,
                &info,NULL,NULL, NULL,0);
            
            MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset );
            
            DrawText(text, 0 , text.Length());
            //  If the cell is hilited, do the hilite now. Paint the cell contents with the
            //  appropriate QuickDraw transform mode.
            
            if( isSelected ) {
                savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
                SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode );
                PaintRect( drawRect );
                SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode );
            }
            
            //  Restore the saved clip region.
            
            SetClip( savedClipRegion );
            DisposeRgn( savedClipRegion );
        }
        break;
        case lHiliteMsg:
            
            //  Hilite or unhilite the cell. Paint the cell contents with the
            //  appropriate QuickDraw transform mode.
            
            GetPort( &grafPtr );
            savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
            SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode );
            PaintRect( drawRect );
            SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode );
            break;
        default :
          break ;
    }
    SetPort(savePort);  
}
コード例 #20
0
/*********************************************************************
* Function: WORD StDraw(STATICTEXT *pSt)
*
* Notes: This is the state machine to draw the static text.
*
********************************************************************/
WORD StDraw(STATICTEXT *pSt)
{
typedef enum {
	ST_STATE_IDLE,
	ST_STATE_CLEANAREA,
	ST_STATE_INIT,
	ST_STATE_SETALIGN,
	ST_STATE_DRAWTEXT
} ST_DRAW_STATES;

static ST_DRAW_STATES state = ST_STATE_IDLE;
static SHORT charCtr = 0, lineCtr = 0;
static XCHAR *pCurLine = NULL;
SHORT textWidth;
XCHAR   ch = 0;


    if(IsDeviceBusy())
        return 0;
        
    switch(state){

        case ST_STATE_IDLE:
        
            SetClip(CLIP_DISABLE);

           	if (GetState(pSt, ST_HIDE)) {
   	   	        SetColor(pSt->hdr.pGolScheme->CommonBkColor);
    	        if(!Bar(pSt->hdr.left,pSt->hdr.top,pSt->hdr.right,pSt->hdr.bottom))
    	            return 0;
    	        // State is still IDLE STATE so no need to set
    	        return 1;
    	    }    
	        
	        if (GetState(pSt, ST_DRAW)) {   	
		       	if (GetState(pSt, ST_FRAME)) {
			       	// show frame if specified to be shown
	   	   	        SetLineType(SOLID_LINE);
	   	   	        SetLineThickness(NORMAL_LINE);
		            if(!GetState(pSt,ST_DISABLED)){
			            // show enabled color
	    	   	        SetColor(pSt->hdr.pGolScheme->Color1);
		    	        if(!Rectangle(pSt->hdr.left,pSt->hdr.top,pSt->hdr.right,pSt->hdr.bottom))
		    	            return 0;
	
	            	}
		            else {
	       	        	// show disabled color
	    	   	        SetColor(pSt->hdr.pGolScheme->ColorDisabled);
			            if(!Rectangle(pSt->hdr.left,pSt->hdr.top,pSt->hdr.right,pSt->hdr.bottom))
			                return 0;
	    	        }
	    	    }    
    	    }
    	    // set clipping area, text will only appear inside the static text area.    
            SetClip(CLIP_ENABLE);
            SetClipRgn(pSt->hdr.left+ST_INDENT, pSt->hdr.top,   		\
                       pSt->hdr.right-ST_INDENT, pSt->hdr.bottom);    
            state = ST_STATE_CLEANAREA;

        case ST_STATE_CLEANAREA:
        
			// clean area where text will be placed.
			SetColor(pSt->hdr.pGolScheme->CommonBkColor);
    	    if(!Bar(pSt->hdr.left+1,pSt->hdr.top + 1,pSt->hdr.right-1,pSt->hdr.bottom-1))
    	        return 0;
            state = ST_STATE_INIT;
    	    
        case ST_STATE_INIT:
        
            if(IsDeviceBusy())
                return 0;

			// set the text color
	        if(!GetState(pSt,ST_DISABLED)){
	   	        SetColor(pSt->hdr.pGolScheme->TextColor0);
	        }    
	        else {
	   	        SetColor(pSt->hdr.pGolScheme->TextColorDisabled);
	        }    
	        // use the font specified in the object
	        SetFont(pSt->hdr.pGolScheme->pFont);
			pCurLine = pSt->pText;						// get first line of text
			state = ST_STATE_SETALIGN;					// go to drawing of text

        case ST_STATE_SETALIGN:
          
st_state_alignment:

			if (!charCtr) {
				// set position of the next character (based on alignment and next character)
			    textWidth = GetTextWidth(pCurLine, pSt->hdr.pGolScheme->pFont);  
			
				// Display text with center alignment
				if (GetState(pSt, (ST_CENTER_ALIGN))) { 			
					MoveTo((pSt->hdr.left+pSt->hdr.right-textWidth) >> 1,	\
					       pSt->hdr.top+(lineCtr * pSt->textHeight));
				}	
				// Display text with right alignment
コード例 #21
0
ファイル: listbox.cpp プロジェクト: Bluehorn/wxPython
static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
                                     Cell cell, short dataOffset, short dataLength,
                                     ListHandle listHandle )
{
    wxListBox*          list;
    list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
    if ( list == NULL )
        return ;

    GrafPtr savePort;
    GrafPtr grafPtr;
    RgnHandle savedClipRegion;
    SInt32 savedPenMode;
    GetPort(&savePort);
    SetPort((**listHandle).port);
    grafPtr = (**listHandle).port ;
    // typecast our refCon

    //  Calculate the cell rect.

    switch( message ) {
    case lInitMsg:
        break;

    case lCloseMsg:
        break;

    case lDrawMsg:
        {
            const wxString linetext = list->m_stringArray[cell.v] ;

            //  Save the current clip region, and set the clip region to the area we are about
            //  to draw.

            savedClipRegion = NewRgn();
            GetClip( savedClipRegion );

            ClipRect( drawRect );
            EraseRect( drawRect );

            const wxFont& font = list->GetFont();
            if ( font.Ok() )
            {
                ::TextFont( font.GetMacFontNum() ) ;
                ::TextSize( font.GetMacFontSize() ) ;
                ::TextFace( font.GetMacFontStyle() ) ;
            }
            else
            {
                ::TextFont( kFontIDMonaco ) ;
                ::TextSize( 9  );
                ::TextFace( 0 ) ;
            }

#if TARGET_CARBON
            {
                Rect frame = { drawRect->top, drawRect->left + 4,
                               drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ;
                CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , wxMacCFStringHolder(linetext , list->GetFont().GetEncoding()) ) ;
                ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ;
                ::DrawThemeTextBox( mString,
                                    kThemeCurrentPortFont,
                                    kThemeStateActive,
                                    false,
                                    &frame,
                                    teJustLeft,
                                    nil );
                                    CFRelease( mString ) ;
            }
#else
            {
                wxCharBuffer text = linetext.mb_str( wxConvLocal) ;
                MoveTo(drawRect->left + 4 , drawRect->top + 10 );
                DrawText(text, 0 , strlen(text) );
            }
#endif
            //  If the cell is hilited, do the hilite now. Paint the cell contents with the
            //  appropriate QuickDraw transform mode.

            if( isSelected ) {
                savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
                SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode );
                PaintRect( drawRect );
                SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode );
            }

            //  Restore the saved clip region.

            SetClip( savedClipRegion );
            DisposeRgn( savedClipRegion );
        }
        break;
    case lHiliteMsg:

        //  Hilite or unhilite the cell. Paint the cell contents with the
        //  appropriate QuickDraw transform mode.

        GetPort( &grafPtr );
        savedPenMode = GetPortPenMode( (CGrafPtr)grafPtr );
        SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode );
        PaintRect( drawRect );
        SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode );
        break;
    default :
        break ;
    }
    SetPort(savePort);
}
コード例 #22
0
ファイル: game.c プロジェクト: insin/cdogs-wii
void DrawScreen(struct Buffer *b, TActor * player1, TActor * player2)
{
	static int x = 0;
	static int y = 0;
	int xNoise, yNoise;

	if (screenShaking) {
		xNoise = rand() & 7;
		yNoise = rand() & 7;
	} else
		xNoise = yNoise = 0;

	if (player1 && player2) {
		if (abs(player1->tileItem.x - player2->tileItem.x) < gOptions.xSplit
		    && abs(player1->tileItem.y - player2->tileItem.y) < gOptions.ySplit) {
			SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
			// One screen
			x = (player1->tileItem.x +
			     player2->tileItem.x) / 2;
			y = (player1->tileItem.y +
			     player2->tileItem.y) / 2;

			SetBuffer(x + xNoise, y + yNoise, b, X_TILES);
			if (fLOS) {
				LineOfSight(player1->tileItem.x,
					    player1->tileItem.y, b,
					    IS_SHADOW);
				LineOfSight(player2->tileItem.x,
					    player2->tileItem.y, b,
					    IS_SHADOW2);
				FixBuffer(b, IS_SHADOW | IS_SHADOW2);
			}
			DrawBuffer(b, 0);
		} else {
			SetClip(0, 0, (SCREEN_WIDTH / 2) - 1, SCREEN_HEIGHT - 1);
			DoBuffer(b, player1->tileItem.x, player1->tileItem.y, 0, X_TILES_HALF, xNoise, yNoise);
			SetLeftEar(player1->tileItem.x, player1->tileItem.y);
			SetClip((SCREEN_WIDTH / 2) + 1, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
			DoBuffer(b, player2->tileItem.x, player2->tileItem.y, (SCREEN_WIDTH / 2) + 1, X_TILES_HALF, xNoise, yNoise);
			SetRightEar(player2->tileItem.x, player2->tileItem.y);
			x = player1->tileItem.x;
			y = player1->tileItem.y;
			BlackLine();
		}
	} else if (player1) {
		SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
		DoBuffer(b, player1->tileItem.x, player1->tileItem.y, 0,
			 X_TILES, xNoise, yNoise);
		SetLeftEar(player1->tileItem.x, player1->tileItem.y);
		SetRightEar(player1->tileItem.x, player1->tileItem.y);
		x = player1->tileItem.x;
		y = player1->tileItem.y;
	} else if (player2) {
		SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
		DoBuffer(b, player2->tileItem.x, player2->tileItem.y, 0,
			 X_TILES, xNoise, yNoise);
		SetLeftEar(player2->tileItem.x, player2->tileItem.y);
		SetRightEar(player2->tileItem.x, player2->tileItem.y);
		x = player2->tileItem.x;
		y = player2->tileItem.y;
	} else
		DoBuffer(b, x, y, 0, X_TILES, xNoise, yNoise);
	SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
}
コード例 #23
0
ファイル: game.c プロジェクト: insin/cdogs-wii
int gameloop(void)
{
	struct Buffer *buffer;
	int ticks;
	int c = 0;
	int cmd1, cmd2;
	int done = NO;
	time_t t;
	struct tm *tp;

	buffer = NewBuffer();
	SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);

	if (ModuleStatus() != MODULE_OK)
		DisplayMessage(ModuleMessage());

	gameIsPaused = NO;

	missionTime = 0;
	//screenShaking = 0;
	while (!done) {
		frames++;

		Ticks_FrameBegin();

		ticks = Ticks_Synchronize();

		if (gOptions.displaySlices)
			SetColorZero(32, 0, 0);

		DrawScreen(buffer, gPlayer1, gPlayer2);

		if (gOptions.displaySlices)
			SetColorZero(0, 0, 0);

		if (screenShaking) {
			screenShaking -= ticks;
			if (screenShaking < 0)
				screenShaking = 0;
		}

		debug(D_VERBOSE, "frames... %d\n", frames);

		if (Ticks_TimeElapsed(TICKS_PER_SEC)) {
			fps = frames;
			debug(D_NORMAL, "fps = %d\n", fps);
			frames = 0;

			t = time(NULL);
			tp = localtime(&t);
			timeHours = tp->tm_hour;
			timeMinutes = tp->tm_min;
		}

		if (messageTicks > 0)
			messageTicks -= ticks;

		StatusDisplay();

		if (!gameIsPaused) {
			missionTime += ticks;
			if ((gPlayer1 || gPlayer2) && MissionCompleted()) {
				if (gMission.pickupTime == PICKUP_LIMIT)
					PlaySound(SND_DONE, 0, 255);
				gMission.pickupTime -= ticks;
				if (gMission.pickupTime <= 0)
					done = YES;
			} else
				gMission.pickupTime = PICKUP_LIMIT;
		}

		if (gOptions.displaySlices)
			SetColorZero(0, 0, 32);

		if (gOptions.displaySlices)
			SetColorZero(0, 0, 0);

		CopyToScreen();

		if (!gameIsPaused) {
			if (!gOptions.slowmotion || (frames & 1) == 0) {
				UpdateAllActors(ticks);
				UpdateMobileObjects();

				GetPlayerInput(&cmd1, &cmd2);

				if (gPlayer1 && !PlayerSpecialCommands(
							gPlayer1, cmd1, &gPlayer1Data)) {
					CommandActor(gPlayer1, cmd1);
				}
				if (gPlayer2 && !PlayerSpecialCommands(
							gPlayer2, cmd2, &gPlayer2Data)) {
					CommandActor(gPlayer2, cmd2);
				}

				if (gOptions.badGuys)
					CommandBadGuys();

				UpdateWatches();
			}
		} else {
			GetPlayerInput(&cmd1, &cmd2);
		}

		if (!gPlayer1 && !gPlayer2) {
			done = YES;
			c = 0;
		} else {
			c = HandleKey(&done, cmd1 | cmd2);
		}

		Ticks_FrameEnd();
	}
	free(buffer);

	return c != keyEsc;
}
コード例 #24
0
ファイル: tkMacDraw.c プロジェクト: BTHUNTERCN/cygwin
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);
}
コード例 #25
0
ファイル: ESVideo.cpp プロジェクト: kozarovv/mednafen-ps3
void					ESVideo::Flip					()
{
	ESVideoPlatform::Flip();
	SetClip(Area(0, 0, GetScreenWidth(), GetScreenHeight()));
	glClear(GL_COLOR_BUFFER_BIT); glSplat();
}