当前位置: 首页>>代码示例>>C++>>正文


C++ wxDC::GetClippingBox方法代码示例

本文整理汇总了C++中wxDC::GetClippingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::GetClippingBox方法的具体用法?C++ wxDC::GetClippingBox怎么用?C++ wxDC::GetClippingBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxDC的用法示例。


在下文中一共展示了wxDC::GetClippingBox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Draw

////////////////////////////////////////////////////////////////////
// Method:	Draw
// Class:	CCamView
// Purose:	camera drawing
// Input:	reference to dc
// Output:	nothing
////////////////////////////////////////////////////////////////////
void CCamView::Draw( wxDC& dc )
{
	// check if dc available
	if( !dc.Ok( ) || m_bDrawing == true ){ return; }

		m_bDrawing = true;

		dc.BeginDrawing();

		int x,y,w,h;
		dc.GetClippingBox( &x, &y, &w, &h );
		// if there is a new image to draw
		if( m_bNewImage )
		{
			dc.DrawBitmap( m_pBitmap, x, y );
			m_bNewImage = false;
		} else
		{
			// draw inter frame ?
		}

		dc.EndDrawing();
		m_bDrawing = false;

	return;
}
开发者ID:adams-n-d,项目名称:panya,代码行数:33,代码来源:camview.cpp

示例2: DrawTab

void wxRibbonAUIArtProvider::DrawTab(wxDC& dc,
                 wxWindow* WXUNUSED(wnd),
                 const wxRibbonPageTabInfo& tab)
{
    if(tab.rect.height <= 1)
        return;

    dc.SetFont(m_tab_label_font);
    dc.SetPen(*wxTRANSPARENT_PEN);
    if(tab.active || tab.hovered || tab.highlight)
    {
        if(tab.active)
        {
            dc.SetFont(m_tab_active_label_font);
            dc.SetBrush(m_background_brush);
            dc.DrawRectangle(tab.rect.x, tab.rect.y + tab.rect.height - 1,
                tab.rect.width - 1, 1);
        }
        wxRect grad_rect(tab.rect);
        grad_rect.height -= 4;
        grad_rect.width -= 1;
        grad_rect.height /= 2;
        grad_rect.y = grad_rect.y + tab.rect.height - grad_rect.height - 1;
        dc.SetBrush(m_tab_active_top_background_brush);
        dc.DrawRectangle(tab.rect.x, tab.rect.y + 3, tab.rect.width - 1,
            grad_rect.y - tab.rect.y - 3);
        if(tab.highlight)
        {
            dc.GradientFillLinear(grad_rect, m_tab_highlight_top_colour, m_tab_highlight_top_gradient_colour, wxSOUTH);
        }
        else
        {
            dc.GradientFillLinear(grad_rect, m_tab_active_background_colour,
                m_tab_active_background_gradient_colour, wxSOUTH);
        }
    }
    else
    {
        wxRect btm_rect(tab.rect);
        btm_rect.height -= 4;
        btm_rect.width -= 1;
        btm_rect.height /= 2;
        btm_rect.y = btm_rect.y + tab.rect.height - btm_rect.height - 1;
        dc.SetBrush(m_tab_hover_background_brush);
        dc.DrawRectangle(btm_rect.x, btm_rect.y, btm_rect.width,
            btm_rect.height);
        wxRect grad_rect(tab.rect);
        grad_rect.width -= 1;
        grad_rect.y += 3;
        grad_rect.height = btm_rect.y - grad_rect.y;
        dc.GradientFillLinear(grad_rect, m_tab_hover_background_top_colour,
            m_tab_hover_background_top_gradient_colour, wxSOUTH);
    }

    wxPoint border_points[5];
    border_points[0] = wxPoint(0, 3);
    border_points[1] = wxPoint(1, 2);
    border_points[2] = wxPoint(tab.rect.width - 3, 2);
    border_points[3] = wxPoint(tab.rect.width - 1, 4);
    border_points[4] = wxPoint(tab.rect.width - 1, tab.rect.height - 1);

    dc.SetPen(m_tab_border_pen);
    dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y);

    wxRect old_clip;
    dc.GetClippingBox(old_clip);
    bool is_first_tab = false;
    wxRibbonBar* bar = wxDynamicCast(tab.page->GetParent(), wxRibbonBar);
    if(bar && bar->GetPage(0) == tab.page)
        is_first_tab = true;

    wxBitmap icon;
    if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
    {
        icon = tab.page->GetIcon();
        if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0)
        {
            if(icon.IsOk())
            {
            int x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2;
            dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 -
                icon.GetHeight()) / 2, true);
            }
        }
    }
    if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
    {
        wxString label = tab.page->GetLabel();
        if(!label.IsEmpty())
        {
            dc.SetTextForeground(m_tab_label_colour);
            dc.SetBackgroundMode(wxTRANSPARENT);

            int offset = 0;
            if(icon.IsOk())
                offset += icon.GetWidth() + 2;
            int text_height;
            int text_width;
            dc.GetTextExtent(label, &text_width, &text_height);
            int x = (tab.rect.width - 2 - text_width - offset) / 2;
//.........这里部分代码省略.........
开发者ID:AaronDP,项目名称:wxWidgets,代码行数:101,代码来源:art_aui.cpp

示例3: CheckBox

void ClippingBoxTestCaseBase::CheckBox(int x, int y, int width, int height)
{
    // Check clipping box boundaries.
    int clipX, clipY, clipW, clipH;
    m_dc->GetClippingBox(&clipX, &clipY, &clipW, &clipH);

    wxString msgPos;
    if ( x != clipX || y != clipY )
    {
        msgPos =
            wxString::Format(wxS("Invalid position: Actual: (%i, %i)  Expected: (%i, %i)"),
                                clipX, clipY, x, y);
    }
    wxString msgDim;
    if ( width != clipW || height != clipH )
    {
        msgDim =
            wxString::Format(wxS("Invalid dimension: Actual: %i x %i  Expected: %i x %i"),
                                clipW, clipH, width, height);
    }

    wxString msg;
    if ( !msgPos.empty() )
    {
        msg = msgPos;
        if ( !msgDim.empty() )
        {
            msg += wxS("\n- ");
            msg += msgDim;
        }
    }
    else if ( !msgDim.empty() )
    {
        msg = msgDim;
    }

    // We will examine pixels directly in the underlying bitmap
    // so we need to get device coordinates of examined area.
    x = m_dc->LogicalToDeviceX(x);
    y = m_dc->LogicalToDeviceY(y);
    width = m_dc->LogicalToDeviceXRel(width);
    height = m_dc->LogicalToDeviceYRel(height);

    // Update wxDC contents.
    FlushDC();

    // Check whether diagonal corners of the clipping box
    // are actually drawn at the edge of the clipping region.
#if wxUSE_IMAGE
    // For some renderers it's not possible to get pixels
    // value from wxDC so we would have to examine pixels
    // in the underlying bitmap.
    wxImage img;
    img = m_bmp.ConvertToImage();
#else
    return;
#endif // wxUSE_IMAGE

    // Check area near the top-left corner
    int ymin = y-1;
    int xmin = x-1;
    int ymax = y+1;
    int xmax = x+1;
    ymin = wxMin(wxMax(ymin, 0), s_dcSize.GetHeight()-1);
    xmin = wxMin(wxMax(xmin, 0), s_dcSize.GetWidth()-1);
    ymax = wxMin(wxMax(ymax, 0), s_dcSize.GetHeight()-1);
    xmax = wxMin(wxMax(xmax, 0), s_dcSize.GetWidth()-1);

    for( int py = ymin; py <= ymax; py++ )
        for( int px = xmin; px <= xmax; px++ )
        {
            wxColour c;
#if wxUSE_IMAGE
            unsigned char r = img.GetRed(px, py);
            unsigned char g = img.GetGreen(px, py);
            unsigned char b = img.GetBlue(px, py);
            c.Set(r, g, b);
#else
            // We cannot get pixel value
            break;
#endif // wxUSE_IMAGE / !wxUSE_IMAGE

            wxString msgColour;
            if ( px >= x && px <= x + (width-1) &&
                 py >= y && py <= y + (height-1) )
            {
                // Pixel inside the box.
                if ( c != s_fgColour )
                {
                    msgColour =
                        wxString::Format(wxS("Invalid colour drawn at (%i, %i): Actual: %s  Expected: %s"),
                                px, py, c.GetAsString().mbc_str(), s_fgColour.GetAsString().mbc_str());

                }
            }
            else
            {
                // Pixel outside the box.
                if ( c != s_bgColour )
                {
//.........这里部分代码省略.........
开发者ID:CodeTickler,项目名称:wxWidgets,代码行数:101,代码来源:clippingbox.cpp


注:本文中的wxDC::GetClippingBox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。