Ejemplo n.º 1
0
void GetRect(Rect *zoomFrom, Rect *zoomTo)
{
	static short numRects = 0;
	Rect theRect,drawRect;
	Point firstPt,curPt,oldPt;
	RgnHandle rgnHandle = NewRgn();
	GrafPtr	oldPort;
	
	GetPort(&oldPort);
	SetPort(GetWindowPort(gWindow));
	
	PenMode(patXor);
	
	GetMouse(&firstPt);
	oldPt = firstPt;
	SetRect(&theRect,firstPt.h,firstPt.v,firstPt.h,firstPt.v);
	
	while (Button()) {
		GetMouse(&curPt);
		if (!EqualPt(curPt,oldPt)) {
			FixRect(&theRect,&drawRect);
			FrameRect(&drawRect);
			oldPt = curPt;
			theRect.right = curPt.h;
			theRect.bottom = curPt.v;
			FixRect(&theRect,&drawRect);
			FrameRect(&drawRect);
			QDFlushPortBuffer(GetWindowPort(gWindow), GetPortVisibleRegion(GetWindowPort(gWindow), rgnHandle));
		}
	}
		
	FixRect(&theRect,&drawRect);
	if (numRects==0)
		*zoomFrom = drawRect;
	else
		*zoomTo = drawRect;
			
	numRects++;
		
	QDFlushPortBuffer(GetWindowPort(gWindow), GetPortVisibleRegion(GetWindowPort(gWindow), rgnHandle));
	
	if (numRects >= 2) {
		ZoomRect(kZoomLarger, zoomFrom, zoomTo);
		numRects = 0;
	}
	
	PenNormal();
	DisposeRgn(rgnHandle);
	SetPort(oldPort);

}
Ejemplo n.º 2
0
	void Importer::FillRect( const Rect &rect, const Color &color )
	{
		Rect pos;
		pos.x = rect.x;
		pos.y = rect.y;
		pos.w = max( 0, rect.w );
		pos.h = max( 0, rect.h );
		FixRect(pos);
		Trap::R_DrawStretchPic( (int)pos.x, (int)pos.y, (int)pos.w, (int)pos.h, 0, 0, 1, 1, (float*)(&color), Local::getWhiteShader() );
	}
Ejemplo n.º 3
0
	void Importer::DrawImage( Image img, const Rect &src, const Rect &dest, const Color &color, const float angle )
	{
		Rect pos;
		pos.x = dest.x + src.x; 
		pos.y = dest.y + src.y;
		pos.w = max( 0, src.w );
		pos.h = max( 0, src.h );
		FixRect(pos);

		if( fabs( angle ) < 0.001 ) {
			Trap::R_DrawStretchPic( (int)pos.x, (int)pos.y, (int)pos.w, (int)pos.h, 0, 0, 1, 1, (float*)(&color), img );
		} else {
			Trap::R_DrawRotatedStretchPic( (int)pos.x, (int)pos.y, (int)pos.w, (int)pos.h, 0, 0, 1, 1, angle, (float*)(&color), img );
		}
	}
Ejemplo n.º 4
0
bool
SelectionWindow::QuitRequested()
{
	Hide();
	BMessage message(fCommand);
	BBitmap *bitmap = NULL;	
	BRect selection = fView->SelectionRect();
	FixRect(selection);
	BScreen(this).GetBitmap(&bitmap, false, &selection);
	
	snooze(2000);
	message.AddRect("selection", selection);
	message.AddPointer("bitmap", bitmap);
	
	fTarget.SendMessage(&message);
	
		
	return BWindow::QuitRequested();
}
Ejemplo n.º 5
0
	void Importer::DrawString( const Rect &src, const Rect &dest, const char *text, const Font font, const Color &color )
	{
		// the src argument is the part of the image generated from the font that must be displayed.
		// when the text is fully displayed, src.x = 0 and src.w = stringWidth.
		// otherwise, it depends of the aligment of the font (eg: if centered, src.x = stringWidth - src.w)

		// Alignment offsets are already calculated at this point
		vec4_t clr;
		struct mufont_s *ft;
		Rect pos;

		if ( src.w <= 0 || src.h <= 0 )
			return;

		color.get( clr[0], clr[1], clr[2], clr[3] );

		if( !font )
			ft = Local::getFontSmall();
		else
			ft = (struct mufont_s *)font;

		pos.x = (dest.x + src.x);
		pos.y = (dest.y + src.y);
		pos.w = (dest.w);
		pos.h = (dest.h);
		FixRect(pos);

		if( src.w < dest.w || src.h < dest.h ) {
			Trap::SCR_DrawClampString( (int)pos.x, (int)pos.y, text, (int)pos.x, (int)pos.y,
										(int)round( (dest.x + src.x + src.w) * Local::getScaleX() ),
										(int)round( (dest.y + src.y + src.h) * Local::getScaleY() ),
										ft, clr );
			/*
			Trap::SCR_DrawClampString( x, y, text, x, y,
										x + (int)round( pos.x ),
										y + (int)round( pos.y ),
										ft, clr );
			*/
		} else {
			Trap::SCR_DrawString( (int)pos.x, (int)pos.y, ALIGN_TOP_LEFT, text, ft, clr );
		}
	}