示例#1
0
void bmImage::render(wxDC& dc) {
	bitmap = wxBitmap(aswxImage);

	dc.Clear();

	// few variables to make life easier
	cv::Vec2f pScale = cv::Vec2f(((bmImageFrame*)this->GetParent())->scale);
	cv::Vec2f pVOffScale = cv::Vec2f(((bmImageFrame*)this->GetParent())->voff);
	cv::Vec2f pScroll = cv::Vec2f(((bmImageFrame*)this->GetParent())->scroll);

	wxPoint orgp = dc.GetLogicalOrigin();
	wxPoint trp(pScroll[0], pScroll[1]);
	if (asCvMat.cols * pScale[0] < this->GetSize().GetWidth()) {
		trp.x = -(this->GetSize().GetWidth() - asCvMat.cols * pScale[0]) / 2 / pScale[0];
	}
	if (asCvMat.rows * pScale[1] < this->GetSize().GetHeight()) {
		trp.y = -(this->GetSize().GetHeight() - asCvMat.rows * pScale[1]) / 2 / pScale[1];
	}/*
	trp += wxPoint(
		-(this->GetSize().GetWidth() - asCvMat.cols * pVOffScale[0]) / 2 / pVOffScale[0],
		-(this->GetSize().GetHeight() - asCvMat.rows * pVOffScale[1]) / 2 / pVOffScale[1]
		);*/
	trp += wxPoint(
		-asCvMat.cols * (pVOffScale[0] - 1.0f) / 2,
		-asCvMat.rows * (pVOffScale[1] - 1.0f) / 2
		);
	dc.SetLogicalOrigin(trp.x, trp.y);
	dc.SetUserScale(pScale[0], pScale[1]);
	dc.DrawBitmap(bitmap, wxPoint(0, 0), false);
	dc.SetLogicalOrigin(orgp.x, orgp.y);
}
示例#2
0
bool wxWindow::DoDrawBackground(wxDC& dc)
{
    wxRect rect;

    wxSize size = GetSize();  // Why not GetClientSize() ?
    rect.x = 0;
    rect.y = 0;
    rect.width = size.x;
    rect.height = size.y;

    wxWindow * const parent = GetParent();
    if ( HasTransparentBackground() && !UseBgCol() && parent )
    {
        // DirectFB paints the parent first, then its child windows, so by
        // the time this code is called, parent's background was already
        // drawn and there's no point in (imperfectly!) duplicating the work
        // here:
#ifndef __WXDFB__
        wxASSERT( !IsTopLevel() );

        wxPoint pos = GetPosition();

        AdjustForParentClientOrigin( pos.x, pos.y, 0 );

        // Adjust DC logical origin
        wxCoord org_x, org_y, x, y;
        dc.GetLogicalOrigin( &org_x, &org_y );
        x = org_x + pos.x;
        y = org_y + pos.y;
        dc.SetLogicalOrigin( x, y );

        // Adjust draw rect
        rect.x = pos.x;
        rect.y = pos.y;

        // Let parent draw the background
        parent->EraseBackground( dc, rect );

        // Restore DC logical origin
        dc.SetLogicalOrigin( org_x, org_y );
#endif // !__WXDFB__
    }
    else
    {
        // Draw background ourselves
        EraseBackground( dc, rect );
    }

    return true;
}
示例#3
0
bool wxWindow::DoDrawBackground(wxDC& dc)
{
    wxRect rect;

    wxSize size = GetSize();  // Why not GetClientSize() ?
    rect.x = 0;
    rect.y = 0;
    rect.width = size.x;
    rect.height = size.y;

    wxWindow * const parent = GetParent();
    if ( HasTransparentBackground() && parent )
    {
        wxASSERT( !IsTopLevel() );

        wxPoint pos = GetPosition();

        AdjustForParentClientOrigin( pos.x, pos.y, 0 );

        // Adjust DC logical origin
        wxCoord org_x, org_y, x, y;
        dc.GetLogicalOrigin( &org_x, &org_y );
        x = org_x + pos.x;
        y = org_y + pos.y;
        dc.SetLogicalOrigin( x, y );

        // Adjust draw rect
        rect.x = pos.x;
        rect.y = pos.y;

        // Let parent draw the background
        parent->EraseBackground( dc, rect );

        // Restore DC logical origin
        dc.SetLogicalOrigin( org_x, org_y );
    }
    else
    {
        // Draw background ourselves
        EraseBackground( dc, rect );
    }

    return true;
}