bool	VRect::Contains (const VRect& inRect) const
{
	return ((inRect.GetLeft() - GetLeft()) > -kREAL_PIXEL_PRECISION &&
			(inRect.GetRight() - GetRight()) < kREAL_PIXEL_PRECISION &&
			(inRect.GetTop() - GetTop()) > -kREAL_PIXEL_PRECISION &&
			(inRect.GetBottom() - GetBottom()) < kREAL_PIXEL_PRECISION);
}
void VRect::Union (const VRect& inRect)
{
	GReal	newLeft = Min(fX, inRect.fX);
	GReal	newTop = Min(fY, inRect.fY);
	GReal	newRight = Max(GetRight(), inRect.GetRight());
	GReal	newBottom = Max(GetBottom(), inRect.GetBottom());
	
	SetCoords(newLeft, newTop, newRight - newLeft, newBottom - newTop);
}
void VRect::Intersect (const VRect& inRect)
{
	GReal	newLeft = Max(fX, inRect.GetX());
	GReal	newTop = Max(fY, inRect.GetY());
	GReal	newRight = Min(GetRight(), inRect.GetRight());
	GReal	newBottom = Min(GetBottom(), inRect.GetBottom());
	
	if (newRight > newLeft && newBottom > newTop)
		SetCoords(newLeft, newTop, newRight - newLeft, newBottom - newTop);
	else
		SetCoords(0, 0, 0, 0);
}
VPictureData_GDIPlus::VPictureData_GDIPlus(PortRef inPortRef,VRect inBounds)
{
	HDC dstdc;
	HBITMAP dstbm,olbdm;
	
	dstdc=CreateCompatibleDC(inPortRef);
	dstbm=CreateCompatibleBitmap(inPortRef,inBounds.GetWidth(),inBounds.GetHeight());
	olbdm=(HBITMAP)SelectObject(dstdc,dstbm);
	::BitBlt(dstdc,0,0,inBounds.GetWidth(),inBounds.GetHeight(),inPortRef,0,0,SRCCOPY);
	::SelectObject(dstdc,olbdm);
	::DeleteDC(dstdc);
	
	fBitmap=new xgdiplusbitmap(dstbm,NULL);
	fBounds.SetCoords(0,0,fBitmap->GetWidth(),fBitmap->GetHeight());
	_SetSafe();
}
Beispiel #5
0
void VRect::Union (const VRect& inRect)
{
	if (IsEmpty())
	{
		fX = inRect.fX;
		fY = inRect.fY;
		fWidth = inRect.fWidth;
		fHeight = inRect.fHeight;
	}
	else if (!inRect.IsEmpty())
	{
		GReal	newLeft = Min(fX, inRect.fX);
		GReal	newTop = Min(fY, inRect.fY);
		GReal	newRight = Max(GetRight(), inRect.GetRight());
		GReal	newBottom = Max(GetBottom(), inRect.GetBottom());
		
		SetCoords(newLeft, newTop, newRight - newLeft, newBottom - newTop);
	}
}
void VRegion::FromRect (const VRect& inRect)
{
	_Release();
	

#if !USE_GDIPLUS

#if DEBUG_GDI_LIMITS
	assert(inRect.GetWidth() <= kMAX_GDI_RGN_COORD);
	assert(inRect.GetHeight() <= kMAX_GDI_RGN_COORD);
#endif
	VRect bounds(inRect);
	bounds.NormalizeToInt(); //normalize to prevent artifacts due to invalidating or clipping region being cropped down

	// Make sure region isn't too big for GDI
	sLONG	newWidth = Min((sLONG)bounds.GetWidth(), (sLONG)kMAX_GDI_RGN_COORD);
	sLONG	newHeight = Min((sLONG)bounds.GetHeight(), (sLONG)kMAX_GDI_RGN_COORD);
	fRegion = ::CreateRectRgn(0, 0, newWidth, newHeight);
	
	fOffset.SetPosTo(bounds.GetX(), bounds.GetY());
#else
	Gdiplus::RectF r(inRect.GetX(),inRect.GetY(),inRect.GetWidth(),inRect.GetHeight());
	fRegion = new Gdiplus::Region(r);
#endif

	_ComputeBounds();
}
	/** Add any child window derived from VWindow to the VReBar control. This
	function will determine the size of the child window and create a band
	in the rebar that matches the size of the child window. The band will be
	identified by the ID that was passed to the Create() method of the child
	window. The nIndex paramater specifies the zero based index where the
	band will be inserted.  If you set this parameter to -1, the control will
	add the new band at the last location. The pszText parameter can be used
	to add a label to the rebar band, which will be displayed in front of
	the child window. The nIndex paramater specifies the zero based index
	where the band will be inserted. If you set this parameter to -1, the
	control will add the new band at the last location.  The nStyle
	parameter can be a combination of the following styles:

	RBBS_BREAK - The band is on a new line.

	RBBS_CHILDEDGE - The band has an edge at the top and bottom of the
	child window.

	RBBS_FIXEDSIZE - The band can't be sized. With this style, the sizing
	grip is not displayed on the band.

	RBBS_GRIPPERALWAYS - Version 4.71. The band will always have a sizing
	grip, even if it is the only band in the rebar.

	RBBS_HIDDEN - The band will not be visible.

	RBBS_CHEVRON - Version 5.00. The band will have a chevron.

	RBBS_NOGRIPPER - Version 4.71. The band will never have a sizing grip,
	even if there is more than one band in the rebar.

	RBBS_VARIABLEHEIGHT - Version 4.71. The band can be resized by the
	rebar control.

	If you need more control over the method used to insert the band into
	the rebar control, see the InsertBand() method.*/
	VBOOL		InsertWindow(	VWindow const&	window,
								VSTRING_CONST	pszText = NULL,
								VINT			nIndex = -1,
								VUINT			nStyle =
												RBBS_GRIPPERALWAYS |
												RBBS_CHILDEDGE |
												RBBS_NOVERT) const
	{
		/** Get the size of the child window.*/
		VRect r;
		window.GetRect(r);

		/* Initialize the structure needed to add the window.*/
		REBARBANDINFO rbi;
		VZEROSTRUCT(rbi);
		rbi.cbSize     =	sizeof(rbi);
		rbi.fMask      =	RBBIM_CHILD | RBBIM_SIZE | RBBIM_CHILDSIZE |
							RBBIM_STYLE | RBBIM_ID | RBBIM_IDEALSIZE;
		rbi.fStyle     =	nStyle;
		rbi.cxMinChild =	r.GetWidth();
		rbi.cyMinChild =	r.GetHeight();
		rbi.cyMaxChild =	r.GetHeight();
		rbi.cyChild    =	r.GetHeight();
		rbi.cx         =	r.GetWidth();
		rbi.cxIdeal    =	r.GetWidth();
		rbi.wID        =	window.Long(GWL_ID);
		rbi.hwndChild  =	window.GetHandle();

		if ( pszText )
		{
			rbi.fMask |=	RBBIM_TEXT;
			rbi.lpText =	(VSTRING)pszText;
		}

		/* Insert the child window into the rebar control.*/
		return InsertBand(rbi, nIndex);
	}
Beispiel #8
0
void VFileBitmap::GetBounds(VRect &outRect) const
{
	outRect.SetLeft(0);
	outRect.SetTop(0);
#if VERSIONWIN
	Gdiplus::SizeF size;
	fBitmap->GetPhysicalDimension(&size);
	outRect.SetWidth(size.Width);
	outRect.SetHeight(size.Height);
 #endif
 #if VERSIONMAC
	size_t w = CGImageGetWidth(fBitmap);
	size_t h = CGImageGetHeight(fBitmap);
	outRect.SetWidth(w);
	outRect.SetHeight(h);
 #endif
 
}
	/** Attempts to find the best layout of the bands for the given rectangle.
	The r paramater specifies the rectangle to which the rebar control
	should be sized. The rebar bands will be arranged and wrapped as
	necessary to fit the rectangle. Bands that have the RBBS_VARIABLEHEIGHT
	style will be resized as evenly as possible  to fit the rectangle. The
	height of a horizontal rebar or the width of a vertical rebar may change,
	depending on the new layout. Returns VTRUE if a layout change occurred.*/
	VBOOL		SizeToRect(VRect const& r) const
		{ return VWINDOW_SMB2(RB_SIZETORECT, 0, r.GetPointer()); }
	/** Retrieves the bounding rectangle for a given band in a rebar control.
	The r VRect object paramater will receive the bounds of the rebar band.
	The rebar band is identified by the ID of the band or by the zero based
	index of the band. This method will first translate the nID parameter to
	the corresponding band index. If there is no corresponding band index,
	the method will assume that nID is a band index.*/
	VBOOL		GetBandRect(VUINT nID, VRect& r) const
	{
		return VWINDOW_SMB2(RB_GETRECT, BandIDToIndexOrID(nID), r.GetPointer());
	}
	/** Retrieves the borders of a band. The result of this function can be
	used to calculate the usable area in a band. The r VRect object will
	receive the band borders. If the rebar control has the RBS_BANDBORDERS
	style, each member of this structure will receive the number of pixels,
	on the corresponding side  of the band that constitute the border. If
	the rebar control does not have the RBS_BANDBORDERS style, only the left
	value receives valid information. The rebar band is identified by the ID
	of the band or by the zero based index of the band. This method will
	first translate the nID parameter to the corresponding band index. If
	there is no corresponding band index, the method will assume that nID is
	a band index.*/
	void		GetBandBorders(VUINT nID, VRect& r) const
	{
		VWINDOW_SM2(RB_GETBANDBORDERS, BandIDToIndexOrID(nID), r.GetPointer());
	}
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
}
void VGraphicPath::AddOval(const VRect& inBounds)
{
#if !GRAPHIC_MIXED_GDIPLUS_D2D
	if (!VWinD2DGraphicContext::IsAvailable())
	{
#endif
		Gdiplus::RectF rect(inBounds.GetLeft(), inBounds.GetTop(), inBounds.GetWidth(), inBounds.GetHeight());
		fPath->AddEllipse(rect);
#if !GRAPHIC_MIXED_GDIPLUS_D2D
	}
#endif

#if ENABLE_D2D
	if (VWinD2DGraphicContext::IsAvailable())
	{
		if (!fGeomSink)
		{
			Begin();
			if (!fGeomSink)
				return;
		}

		if (!fFigureIsClosed)
			fGeomSink->EndFigure( D2D1_FIGURE_END_OPEN);
		fFigureIsClosed = true;

		GReal radiusX = inBounds.GetWidth()*0.5f;
		GReal radiusY = inBounds.GetHeight()*0.5f;
		D2D1_POINT_2F center = D2D1::Point2F( inBounds.GetLeft()+radiusX, inBounds.GetTop()+radiusY);
		D2D1_POINT_2F s = D2D1::Point2F(center.x-radiusX, center.y);
		D2D1_POINT_2F d = D2D1::Point2F(center.x+radiusX, center.y);

		fGeomSink->BeginFigure( s, D2D1_FIGURE_BEGIN_FILLED);
		fGeomSink->AddArc( D2D1::ArcSegment( d, D2D1::SizeF(radiusX, radiusY), 0.0f, D2D1_SWEEP_DIRECTION_CLOCKWISE, D2D1_ARC_SIZE_SMALL));
		fGeomSink->AddArc( D2D1::ArcSegment( s, D2D1::SizeF(radiusX, radiusY), 0.0f, D2D1_SWEEP_DIRECTION_CLOCKWISE, D2D1_ARC_SIZE_SMALL));
		fGeomSink->EndFigure( D2D1_FIGURE_END_OPEN);
	}
#endif

	fPolygon.AddPoint(inBounds.GetTopLeft());
	fPolygon.AddPoint(inBounds.GetTopRight());
	fPolygon.AddPoint(inBounds.GetBotRight());
	fPolygon.AddPoint(inBounds.GetBotLeft());

	if (fComputeBoundsAccurate)
		_addRectToBounds( inBounds);
	_ComputeBounds();

	if (fCreateStorageForCrispEdges)
		fDrawCmds.push_back( VGraphicPathDrawCmd( GPDCT_ADD_OVAL, inBounds));
}