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(); }
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)); }
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(); }
/** 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); }