drawRect in COffscreenContext [Solved]

Hi,

I’m trying to draw a view container and its subview in a COffscreenContext.
I can’t achieve this, but don’t see where miss something.


The code is quite simple yet, overwriting CViewContainer:

void CViewContainerPanel:drawRect (CDrawContext* pContext, const CRect& updateRect)
{
COffscreenContext * pContextCourant = COffscreenContext::create(getFrame(), Image->getWidth(), Image->getHeight());
pContextCourant->beginDraw ();
CViewContainer::drawRect (pContextCourant, updateRect);
pContextCourant->endDraw ();

Panel = pContextCourant->getBitmap();
Panel->draw(pContext, size,Point (0,0));
pContextCourant->forget();

}
But only the CViewContainer::drawRect do nothing.

If I replace pContextCourant with pContext, removing the image draw, it’s working fine

Any help would be appreciated

Thanks in advance

Best regards
Xavier

Hi,

For those who need it, adding the transform translate helps

Best regards
Xavier

void CViewContainerPanel:drawRect (CDrawContext* pContext, const CRect& updateRect)
{
COffscreenContext * pContextCourant = COffscreenContext::create(getFrame(), Image->getWidth(), Image->getHeight());
pContextCourant->beginDraw ();
CDrawContext::Transform transform (*pContextCourant, CGraphicsTransform ().translate (-getViewSize ().left, -getViewSize ().top));

CViewContainer::draw (pContextCourant);
pContextCourant->endDraw ();

Panel = pContextCourant->getBitmap();
Panel->draw(pContext, size,Point (0,0));
pContextCourant->forget();

}