• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ wxDC类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: WXUNUSED

void wxHtmlFontCell::DrawInvisible(wxDC& dc, int WXUNUSED(x), int WXUNUSED(y),
                                   wxHtmlRenderingInfo& WXUNUSED(info))
{
    dc.SetFont(m_Font);
}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:5,代码来源:htmlcell.cpp


示例2: GetTabSize

void NbStyleVC71::DrawTab(wxDC& dc, wxWindow* wnd,
                            const wxAuiNotebookPage& page,
                            const wxRect& in_rect, int close_button_state,
                            wxRect* out_tab_rect, wxRect* out_button_rect,
                            int* x_extent)
{
    // Visual studio 7.1 style
    // This code is based on the renderer included in wxFlatNotebook:
    // http://svn.berlios.de/wsvn/codeblocks/trunk/src/sdk/wxFlatNotebook/src/wxFlatNotebook/renderer.cpp?rev=5106

    // figure out the size of the tab

    wxSize tab_size = GetTabSize(dc,
                                 wnd,
                                 page.caption,
                                 page.bitmap,
                                 page.active,
                                 close_button_state,
                                 x_extent);

#if wxCHECK_VERSION(2, 9, 3)
    wxCoord tab_height = m_tabCtrlHeight - 3;
#else
    wxCoord tab_height = m_tab_ctrl_height - 3;
#endif
    wxCoord tab_width = tab_size.x;
    wxCoord tab_x = in_rect.x;
    wxCoord tab_y = in_rect.y + in_rect.height - tab_height;
    int clip_width = tab_width;
    if (tab_x + clip_width > in_rect.x + in_rect.width - 4)
        clip_width = (in_rect.x + in_rect.width) - tab_x - 4;
    dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3);
    if(m_flags & wxAUI_NB_BOTTOM)
        tab_y--;

    dc.SetPen((page.active) ? wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT)) : wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
    dc.SetBrush((page.active) ? wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)) : wxBrush(*wxTRANSPARENT_BRUSH));

    if (page.active)
    {
//        int tabH = (m_flags & wxAUI_NB_BOTTOM) ? tab_height - 5 : tab_height - 2;
        int tabH = tab_height - 2;

        dc.DrawRectangle(tab_x, tab_y, tab_width, tabH);

        int rightLineY1 = (m_flags & wxAUI_NB_BOTTOM) ? c_vertical_border_padding - 2 : c_vertical_border_padding - 1;
        int rightLineY2 = tabH + 3;
        dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
        dc.DrawLine(tab_x + tab_width - 1, rightLineY1 + 1, tab_x + tab_width - 1, rightLineY2);
        if(m_flags & wxAUI_NB_BOTTOM)
            dc.DrawLine(tab_x + 1, rightLineY2 - 3 , tab_x + tab_width - 1, rightLineY2 - 3);
        dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW)));
        dc.DrawLine(tab_x + tab_width , rightLineY1 , tab_x + tab_width, rightLineY2);
        if(m_flags & wxAUI_NB_BOTTOM)
            dc.DrawLine(tab_x , rightLineY2 - 2 , tab_x + tab_width, rightLineY2 - 2);

    }
    else
    {
        // We dont draw a rectangle for non selected tabs, but only
        // vertical line on the right
        int blackLineY1 = (m_flags & wxAUI_NB_BOTTOM) ? c_vertical_border_padding + 2 : c_vertical_border_padding + 1;
        int blackLineY2 = tab_height - 5;
        dc.DrawLine(tab_x + tab_width, blackLineY1, tab_x + tab_width, blackLineY2);
    }

    wxPoint border_points[2];
    if (m_flags & wxAUI_NB_BOTTOM)
    {
        border_points[0] = wxPoint(tab_x, tab_y);
        border_points[1] = wxPoint(tab_x, tab_y + tab_height - 6);
    }
    else // if (m_flags & wxAUI_NB_TOP)
    {
        border_points[0] = wxPoint(tab_x, tab_y + tab_height - 4);
        border_points[1] = wxPoint(tab_x, tab_y + 2);
    }

    int drawn_tab_yoff = border_points[1].y;
    int drawn_tab_height = border_points[0].y - border_points[1].y;

    int text_offset = tab_x + 8;

    int bitmap_offset = 0;
    if (page.bitmap.IsOk())
    {
        bitmap_offset = tab_x + 8;

        // draw bitmap
        dc.DrawBitmap(page.bitmap,
                      bitmap_offset,
                      drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2),
                      true);

        text_offset = bitmap_offset + page.bitmap.GetWidth();
        text_offset += 3; // bitmap padding
    }
     else
    {
        text_offset = tab_x + 8;
//.........这里部分代码省略.........
开发者ID:DowerChest,项目名称:codeblocks,代码行数:101,代码来源:notebookstyles.cpp


示例3: PaintItems

void wxSwitcherItems::PaintItems(wxDC& dc, wxWindow* win)
{
    wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
    wxColour standardTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    wxColour selectionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
    wxColour selectionOutlineColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    wxColour selectionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
    wxFont standardFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    wxFont groupFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    groupFont.SetWeight(wxBOLD);

    if (GetBackgroundColour().Ok())
        backgroundColour = GetBackgroundColour();

    if (GetTextColour().Ok())
        standardTextColour = GetTextColour();

    if (GetSelectionColour().Ok())
        selectionColour = GetSelectionColour();

    if (GetSelectionOutlineColour().Ok())
        selectionOutlineColour = GetSelectionOutlineColour();

    if (GetSelectionTextColour().Ok())
        selectionTextColour = GetSelectionTextColour();

    if (GetItemFont().Ok())
    {
        standardFont = GetItemFont();
        groupFont = wxFont(standardFont.GetPointSize(), standardFont.GetFamily(), standardFont.GetStyle(),
            wxBOLD, standardFont.GetUnderlined(), standardFont.GetFaceName());
    }

    int textMarginX = wxSWITCHER_TEXT_MARGIN_X;

    dc.SetLogicalFunction(wxCOPY);
    dc.SetBrush(wxBrush(backgroundColour));
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.DrawRectangle(win->GetClientRect());
    dc.SetBackgroundMode(wxTRANSPARENT);

    size_t i;
    for (i = 0; i < m_items.GetCount(); i++)
    {
        wxSwitcherItem& item = m_items[i];
        bool selected = ((int) i == m_selection);

        if (selected)
        {
            dc.SetPen(wxPen(selectionOutlineColour));
            dc.SetBrush(wxBrush(selectionColour));
            dc.DrawRectangle(item.GetRect());
        }

        wxRect clippingRect(item.GetRect());
        clippingRect.Deflate(1, 1);

        dc.SetClippingRegion(clippingRect);

        if (selected)
            dc.SetTextForeground(selectionTextColour);
        else if (item.GetTextColour().Ok())
            dc.SetTextForeground(item.GetTextColour());
        else
            dc.SetTextForeground(standardTextColour);

        if (item.GetFont().Ok())
            dc.SetFont(item.GetFont());
        else
        {
            if (item.GetIsGroup())
                dc.SetFont(groupFont);
            else
                dc.SetFont(standardFont);
        }

        int w, h;
        dc.GetTextExtent(item.GetTitle(), & w, & h);

        int x = item.GetRect().x;

        x += textMarginX;

        if (!item.GetIsGroup())
        {
            if (item.GetBitmap().Ok() && item.GetBitmap().GetWidth() <= 16 && item.GetBitmap().GetHeight() <= 16)
            {
                dc.DrawBitmap(item.GetBitmap(), x, item.GetRect().y + (item.GetRect().height - item.GetBitmap().GetHeight()) / 2, true);
            }

            x += 16;

            x += textMarginX;
        }

        int y = item.GetRect().y + (item.GetRect().height - h)/2;
        dc.DrawText(item.GetTitle(), x, y);

        dc.DestroyClippingRegion();
    }
//.........这里部分代码省略.........
开发者ID:SaturnSDK,项目名称:Saturn-SDK-IDE,代码行数:101,代码来源:switcherdlg.cpp


示例4: DrawTool

void wxToolBar::DrawTool( wxDC& rDc, wxToolBarToolBase* pToolBase )
{
    wxToolBarTool* pTool = (wxToolBarTool *)pToolBase;
    wxColour gray85( 85,85,85 );
    wxPen vDarkGreyPen( gray85, 1, wxSOLID );
    wxBitmap vBitmap = pTool->GetNormalBitmap();
    bool bUseMask = false;
    wxMask* pMask = NULL;

    PrepareDC(rDc);

    if (!vBitmap.Ok())
        return;
    if ((pMask = vBitmap.GetMask()) != NULL)
        if (pMask->GetMaskBitmap() != NULLHANDLE)
            bUseMask = true;

    if (!pTool->IsToggled())
    {
        LowerTool(pTool, FALSE);
        if (!pTool->IsEnabled())
        {
            wxColour vColor(wxT("GREY"));

            rDc.SetTextForeground(vColor);
            if (!pTool->GetDisabledBitmap().Ok())
                pTool->SetDisabledBitmap(wxDisableBitmap( vBitmap
                                                         ,(long)GetBackgroundColour().GetPixel()
                                                        ));
            rDc.DrawBitmap( pTool->GetDisabledBitmap()
                           ,pTool->m_vX
                           ,pTool->m_vY
                           ,bUseMask
                          );
        }
        else
        {
            rDc.SetTextForeground(*wxBLACK);
            rDc.DrawBitmap( vBitmap
                           ,pTool->m_vX
                           ,pTool->m_vY
                           ,bUseMask
                          );
        }
        if (m_windowStyle & wxTB_3DBUTTONS)
        {
            RaiseTool(pTool);
        }
        if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull())
        {
            wxCoord                 vX;
            wxCoord                 vY;
            wxCoord                 vLeft = pTool->m_vX - (int)(pTool->GetWidth()/2);

            rDc.SetFont(GetFont());
            rDc.GetTextExtent( pTool->GetLabel()
                              ,&vX
                              ,&vY
                             );
            if (pTool->GetWidth() > vX) // large tools
            {
                vLeft = pTool->m_vX + (pTool->GetWidth() - vX);
                GetSize(&vX, &vY);
                rDc.DrawText( pTool->GetLabel()
                             ,vLeft
                             ,vY - m_vTextY - 1
                            );
            }
            else  // normal tools
            {
                vLeft += (wxCoord)((m_vTextX - vX)/2);
                rDc.DrawText( pTool->GetLabel()
                             ,vLeft
                             ,pTool->m_vY + m_vTextY - 1 // a bit of margin
                            );
            }
        }
    }
    else
    {
        wxColour vColor(wxT("GREY"));

        LowerTool(pTool);
        rDc.SetTextForeground(vColor);
        if (!pTool->GetDisabledBitmap().Ok())
            pTool->SetDisabledBitmap(wxDisableBitmap( vBitmap
                                                     ,(long)GetBackgroundColour().GetPixel()
                                                    ));
        rDc.DrawBitmap( pTool->GetDisabledBitmap()
                       ,pTool->m_vX
                       ,pTool->m_vY
                       ,bUseMask
                      );
        if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull())
        {
            wxCoord                 vX;
            wxCoord                 vY;
            wxCoord                 vLeft = pTool->m_vX - (int)(pTool->GetWidth()/2);

            rDc.SetFont(GetFont());
//.........这里部分代码省略.........
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:101,代码来源:toolbar.cpp


示例5: Draw

void GroupVisual::Draw ( wxDC& dc, InstanceCtrl* parent, wxRect limitingRect, bool hasSelection, int selectionIndex, bool hasFocus, int focusIndex, bool highlight )
{
	int i;
	int count = items.size();
	int style = 0;
	wxRect rect;
	
	// Draw the header
	if(!no_header)
	{
		wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);

		if (highlight)
		{
			textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
		}

		wxBrush brush(textColor);
		wxPen pen(textColor);
		dc.SetBrush(brush);
		dc.SetPen(pen);
		wxSize sz = dc.GetTextExtent(GetName());
		dc.SetTextForeground(textColor);
		
		dc.DrawText( GetName() , 20, y_position + 5 );
		int atheight = y_position + header_height / 2;
		if(sz.x + 30 < limitingRect.width - 10)
			dc.DrawLine(sz.x + 30,atheight, limitingRect.width - 10, atheight);
		
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.SetPen(textColor);
		
		// Ungrouped can't be hidden, so don't draw the box.
		if (m_group)
		{
			dc.DrawRectangle(5,atheight -5, 10,10);
			dc.DrawRectangle(7,atheight -1, 6,2);
			if(!IsExpanded())
			{
				dc.DrawRectangle(9,atheight -3, 2,6);
			}
		}
	}
	
	if(IsExpanded()) for (i = 0; i < count; i++)
	{
		parent->GetItemRect(VisualCoord(index,i), rect, false);

		if (!limitingRect.Intersects(rect))
			continue;
		style = 0;
		if (hasSelection && selectionIndex == i)
			style |= wxINST_SELECTED;
		if (hasFocus && i == focusIndex)
			style |= wxINST_IS_FOCUS;

		InstanceVisual& item = items[i];
		item.Draw(dc, parent, rect, style);
	}
}
开发者ID:Glought,项目名称:MultiMC4,代码行数:60,代码来源:instancectrl.cpp


示例6: DrawSash

void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, const wxRect& rect)
{
#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
    wxUnusedVar(window);
    wxUnusedVar(orientation);

    HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height );
    CGContextRef cgContext ;
    wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
    cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext() ;

    HIThemeSplitterDrawInfo drawInfo ;
    drawInfo.version = 0 ;
    drawInfo.state = kThemeStateActive ;
    drawInfo.adornment = kHIThemeSplitterAdornmentNone ;
    HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;

#elif defined(__WXGTK__)
    // clear out the rectangle first
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_sash_brush);
    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);

#if 0
    GdkRectangle gdk_rect;
    if (orientation == wxVERTICAL )
    {
        gdk_rect.x = rect.x;
        gdk_rect.y = rect.y;
        gdk_rect.width = m_sash_size;
        gdk_rect.height = rect.height;
    }
    else
    {
        gdk_rect.x = rect.x;
        gdk_rect.y = rect.y;
        gdk_rect.width = rect.width;
        gdk_rect.height = m_sash_size;
    }
#endif

    if (!window) return;
    if (!window->m_wxwindow) return;
    if (!GTK_WIDGET_DRAWABLE(window->m_wxwindow)) return;

    gtk_paint_handle
    (
        window->m_wxwindow->style,
        window->GTKGetDrawingWindow(),
        // flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
        GTK_STATE_NORMAL,
        GTK_SHADOW_NONE,
        NULL /* no clipping */,
        window->m_wxwindow,
        "paned",
        rect.x,
        rect.y,
        rect.width,
        rect.height,
        (orientation == wxVERTICAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
    );

#else
    wxUnusedVar(window);
    wxUnusedVar(orientation);
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_sash_brush);
    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
#endif
}
开发者ID:jonntd,项目名称:dynamica,代码行数:70,代码来源:dockart.cpp


示例7: DrawPaneButton

void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc, wxWindow *WXUNUSED(window),
                                      int button,
                                      int button_state,
                                      const wxRect& _rect,
                                      wxAuiPaneInfo& pane)
{
    wxBitmap bmp;
    if (!(&pane))
        return;
    switch (button)
    {
        default:
        case wxAUI_BUTTON_CLOSE:
            if (pane.state & wxAuiPaneInfo::optionActive)
                bmp = m_active_close_bitmap;
            else
                bmp = m_inactive_close_bitmap;
            break;
        case wxAUI_BUTTON_PIN:
            if (pane.state & wxAuiPaneInfo::optionActive)
                bmp = m_active_pin_bitmap;
            else
                bmp = m_inactive_pin_bitmap;
            break;
        case wxAUI_BUTTON_MAXIMIZE_RESTORE:
            if (pane.IsMaximized())
            {
                if (pane.state & wxAuiPaneInfo::optionActive)
                    bmp = m_active_restore_bitmap;
                else
                    bmp = m_inactive_restore_bitmap;
            }
            else
            {
                if (pane.state & wxAuiPaneInfo::optionActive)
                    bmp = m_active_maximize_bitmap;
                else
                    bmp = m_inactive_maximize_bitmap;
            }
            break;
    }


    wxRect rect = _rect;

    int old_y = rect.y;
    rect.y = rect.y + (rect.height/2) - (bmp.GetHeight()/2);
    rect.height = old_y + rect.height - rect.y - 1;


    if (button_state == wxAUI_BUTTON_STATE_PRESSED)
    {
        rect.x++;
        rect.y++;
    }

    if (button_state == wxAUI_BUTTON_STATE_HOVER ||
        button_state == wxAUI_BUTTON_STATE_PRESSED)
    {
        if (pane.state & wxAuiPaneInfo::optionActive)
        {
            dc.SetBrush(wxBrush(wxAuiStepColour(m_active_caption_colour, 120)));
            dc.SetPen(wxPen(wxAuiStepColour(m_active_caption_colour, 70)));
        }
        else
        {
            dc.SetBrush(wxBrush(wxAuiStepColour(m_inactive_caption_colour, 120)));
            dc.SetPen(wxPen(wxAuiStepColour(m_inactive_caption_colour, 70)));
        }

        // draw the background behind the button
        dc.DrawRectangle(rect.x, rect.y, 15, 15);
    }


    // draw the button itself
    dc.DrawBitmap(bmp, rect.x, rect.y, true);
}
开发者ID:jonntd,项目名称:dynamica,代码行数:78,代码来源:dockart.cpp


示例8: renderPreview

void dovo_mainFrame::renderPreview(wxDC& dc)
{
	dc.DrawBitmap(image, 0, 0, false );
}
开发者ID:fvpolpeta,项目名称:dovo,代码行数:4,代码来源:dovo_mainFrame.cpp


示例9: Draw

void wxSheetCellRolColLabelRendererRefData::Draw(wxSheet& sheet,
        const wxSheetCellAttr& attr,
        wxDC& dc,
        const wxRect& rectCell,
        const wxSheetCoords& coords,
        bool isSelected)
{
    // erase this cells background
    wxRect rect(rectCell);

#ifdef FIXME_CANT_SET_COLOURS_FOR_NATIVE_RENDERER // __WXGTK20__
    SetTextColoursAndFont(sheet, attr, dc, isSelected);

    wxWindow *win = sheet.GetWindowForCoords(coords);
    wxCHECK_RET(win, wxT("Invalid coords in wxSheetCellRolColLabelRendererRefData::Draw"));
    wxRendererNative::Get().DrawHeaderButton( win, dc, rect, 0 );

#else // !__WXGTK20__

    wxSheetCellRendererRefData::Draw(sheet, attr, dc, rect, coords, isSelected);

    int left   = rectCell.x;
    int top    = rectCell.y;
    int right  = rectCell.GetRight();
    int bottom = rectCell.GetBottom();

    //dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) );
    // right side
    //dc.DrawLine( right, top, right, bottom );
    // left side
    //if (coords.m_col == -1)
    //    dc.DrawLine( left, top, left, bottom );
    // top side
    //if (coords.m_row == -1)
    //    dc.DrawLine( left, top, right, top );
    // bottom
    //dc.DrawLine( left, bottom, right, bottom );

    dc.SetPen( *wxWHITE_PEN );
    // left highlight
    dc.DrawLine( left, top, left, bottom );
    // top highlight
    dc.DrawLine( left, top, right, top );

#endif // __WXGTK__

    SetTextColoursAndFont(sheet, attr, dc, isSelected);

    wxString value( sheet.GetCellValue(coords) );

    if (!value.IsEmpty())
    {
        int align  = attr.GetAlignment();
        int orient = attr.GetOrientation();
        rect.Deflate(2); // want margins
        sheet.DrawTextRectangle(dc, value, rect, align, orient);
    }

#if 0
    // test code for sizing, draws corner tick marks
    if (1)
    {
        rect = rectCell;
        dc.SetPen(*wxGREEN_PEN);
        dc.DrawLine(left, top, left+25, top);
        dc.DrawLine(right-25, bottom, right, bottom);
        dc.DrawLine(left, top, left, top+10);
        dc.DrawLine(right, bottom-10, right, bottom);
        wxRect r(rectCell);
        dc.SetPen(*wxCYAN_PEN);
        dc.DrawLine(r.x, r.y, r.x+25, r.y);
        dc.DrawLine(r.GetRight()-25, r.GetBottom(), r.GetRight(), r.GetBottom());
        dc.DrawLine(r.x, r.y, r.x, r.y+10);
        dc.DrawLine(r.GetRight(), r.GetBottom()-10, r.GetRight(), r.GetBottom());
    }
#endif // 0
}
开发者ID:stahta01,项目名称:wxCode_components,代码行数:77,代码来源:sheetren.cpp


示例10: DrawGutter

void GutterCtrl::DrawGutter(wxDC& dc) {
	//if (!m_editorCtrl) return; // We can be called before editorCtrl is valid
	Lines& lines = m_editorCtrl.m_lines;

	const wxSize size = GetClientSize();
	m_mdc.Clear();

	const unsigned int bg_xpos = m_gutterLeft ? size.x-1 : 0;
	const unsigned int edge_xpos = m_gutterLeft ? size.x-2 : 1;

	// Draw the edge
	m_mdc.SetPen(m_theme.backgroundColor);
	m_mdc.DrawLine(bg_xpos, 0, bg_xpos, size.y);
	m_mdc.SetPen(m_edgecolor);
	m_mdc.DrawLine(edge_xpos, 0, edge_xpos, size.y);

	// Draw the line numbers
	m_mdc.SetTextForeground(m_numbercolor);
	wxString number;
	const int scrollPos = m_editorCtrl.scrollPos;

	const unsigned int firstline = lines.GetLineFromYPos(scrollPos);
	const unsigned int linecount = lines.GetLineCount();

	// Prepare for foldings
	const vector<EditorCtrl::cxFold>& folds = m_editorCtrl.GetFolds();
	vector<EditorCtrl::cxFold>::const_iterator nextFold = folds.begin();
	const unsigned int line_middle = lines.GetLineHeight() / 2;
	vector<const EditorCtrl::cxFold*> foldStack;
	if (m_showFolds) {
		m_editorCtrl.UpdateFolds();

#ifdef __WXDEBUG__
		bool debug = false;
		if (debug) {
			for (vector<EditorCtrl::cxFold>::const_iterator f = folds.begin(); f != folds.end(); ++f) {
				const wxString indent(wxT('.'), f->indent);
				wxLogDebug(wxT("%d: %s%d"), f->line_id, indent.c_str(), f->type);
			}
		}
#endif

		for (nextFold = folds.begin(); nextFold != folds.end() && nextFold->line_id < firstline; ++nextFold) {
			if (nextFold->type == EditorCtrl::cxFOLD_END) {
				// check if end marker matches any starter on the stack
				for (vector<const EditorCtrl::cxFold*>::reverse_iterator p = foldStack.rbegin(); p != foldStack.rend(); ++p) {
					if ((*p)->indent == nextFold->indent) {
						foldStack.erase(p.base()-1, foldStack.end()); // pop
						break;
					}
				}
			}
			else {
				foldStack.push_back(&*nextFold);
			}
		}
	}

	// Prepare for bookmarks
	const vector<cxBookmark>& bookmarks = m_editorCtrl.GetBookmarks();
	vector<cxBookmark>::const_iterator nextBookmark = bookmarks.begin();
	while(nextBookmark != bookmarks.end() && nextBookmark->line_id < firstline) ++nextBookmark;

	// Draw each line
	for (unsigned int i = firstline; i < linecount; ++i) {
		number.Printf(wxT("%*u"), m_max_digits, i+1);
		const int ypos = lines.GetYPosFromLine(i) - scrollPos;
		if (ypos > size.y) break;

		// Highlight selections
		if (m_currentSel != -1 &&
			((i >= m_sel_startline && i <= m_sel_endline) ||
			 (i >= m_sel_endline && i <= m_sel_startline))) {

			const int ypos2 = lines.GetBottomYPosFromLine(i) - scrollPos;
			m_mdc.SetPen(m_hlightcolor);
			m_mdc.SetBrush(wxBrush(m_hlightcolor, wxSOLID));
			m_mdc.DrawRectangle(0, ypos, size.x-2, ypos2-ypos);
		}

		// Draw bookmark
		if (m_showBookmarks && nextBookmark != bookmarks.end() && nextBookmark->line_id == i) {
			//m_mdc.DrawText(wxT("\u066D"), 3, ypos);
			m_mdc.DrawBitmap(m_bmBookmark, 2, ypos + line_middle - 5);
			++nextBookmark;
		}

		// Draw the line number
		m_mdc.DrawText(number, m_numberX, ypos);

		// Draw fold markers
		if (m_showFolds) {
			bool drawFoldLine = (!foldStack.empty());

			if (nextFold != folds.end() && nextFold->line_id == i) {
				if (nextFold->type == EditorCtrl::cxFOLD_START) {
					const int ypos2 = lines.GetBottomYPosFromLine(i) - scrollPos;
					const unsigned int box_y = ypos + line_middle - 5;
					m_mdc.DrawBitmap(m_bmFoldOpen, m_foldStartX, box_y);

//.........这里部分代码省略.........
开发者ID:lenoval,项目名称:e,代码行数:101,代码来源:GutterCtrl.cpp


示例11: Draw

void SkinColor::Draw(wxDC& dc, const wxRect& rect, int n) {
    dc.SetBrush(brush);
    dc.SetPen(pen);
    dc.DrawRectangle(rect);
}
开发者ID:niterain,项目名称:digsby,代码行数:5,代码来源:skinbrush.cpp


示例12: DrawTab

void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page,
                             const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect,
                             wxRect* out_button_rect, int* x_extent)
{
    GtkWidget *widget = wnd->GetHandle();
    GtkStyle *style_notebook = gtk_widget_get_style(wxGTKPrivate::GetNotebookWidget());

    wxRect const &window_rect = wnd->GetRect();

    int focus_width = 0;

    gtk_widget_style_get(wxGTKPrivate::GetNotebookWidget(),
                         "focus-line-width", &focus_width,
                         NULL);

    int tab_pos;
    if (m_flags &wxAUI_NB_BOTTOM)
        tab_pos = wxAUI_NB_BOTTOM;
    else //if (m_flags & wxAUI_NB_TOP) {}
        tab_pos = wxAUI_NB_TOP;

    // TODO: else if (m_flags &wxAUI_NB_LEFT) {}
    // TODO: else if (m_flags &wxAUI_NB_RIGHT) {}

    // figure out the size of the tab
    wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap,
                                    page.active, close_button_state, x_extent);

    wxRect tab_rect = in_rect;
    tab_rect.width = tab_size.x;
    tab_rect.height = tab_size.y;
    tab_rect.y += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;

    if (page.active)
        tab_rect.height += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;

    int gap_rect_height = 10 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
    int gap_rect_x = 1, gap_start = 0, gap_width = 0;
    int gap_rect_y = tab_rect.y - gap_rect_height;
    int gap_rect_width = window_rect.width;

    switch (tab_pos)
    {
        case wxAUI_NB_TOP:
            tab_rect.y -= 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
            if (!page.active)
                tab_rect.y += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
            gap_rect_y = tab_rect.y + tab_rect.height - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2;
            // fall through
        case wxAUI_NB_BOTTOM:
            gap_start = tab_rect.x - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder / 2;
            gap_width = tab_rect.width;
            break;
        // TODO: case wxAUI_NB_LEFT: break;
        // TODO: case wxAUI_NB_RIGHT: break;
    }
    tab_rect.y += GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2;
    gap_rect_y += GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2;

    int padding = focus_width + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;

    int clip_width = tab_rect.width;
    if (tab_rect.x + tab_rect.width > in_rect.x + in_rect.width)
        clip_width = (in_rect.x + in_rect.width) - tab_rect.x;

    dc.SetClippingRegion(tab_rect.x, tab_rect.y - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder, clip_width, tab_rect.height + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder);

    GdkRectangle area;
    area.x = tab_rect.x - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder;
    area.y = tab_rect.y - 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
    area.width = clip_width + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder;
    area.height = tab_rect.height + 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;

    wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
    GdkWindow* window = impldc->GetGDKWindow();

    // Before drawing the active tab itself, draw a box without border, because some themes
    // have transparent gaps and a line would be visible at the bottom of the tab
    if (page.active)
        gtk_paint_box(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
                      NULL, widget,
                      const_cast<char*>("notebook"),
                      gap_rect_x, gap_rect_y,
                      gap_rect_width, gap_rect_height);

    if (tab_pos == wxAUI_NB_BOTTOM)
    {
        if (page.active)
        {
            gtk_paint_box_gap(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
                              NULL, widget,
                              const_cast<char*>("notebook"),
                              gap_rect_x, gap_rect_y,
                              gap_rect_width, gap_rect_height,
                              GTK_POS_BOTTOM, gap_start , gap_width);
        }
        gtk_paint_extension(style_notebook, window,
                           page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
                           &area, widget,
                           const_cast<char*>("tab"),
//.........这里部分代码省略.........
开发者ID:BauerBox,项目名称:wxWidgets,代码行数:101,代码来源:tabartgtk.cpp


示例13: Draw

void wxHtmlWordCell::Draw(wxDC& dc, int x, int y,
                          int WXUNUSED(view_y1), int WXUNUSED(view_y2),
                          wxHtmlRenderingInfo& info)
{
#if 0 // useful for debugging
    dc.SetPen(*wxBLACK_PEN);
    dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width /* VZ: +1? */ ,m_Height);
#endif

    bool drawSelectionAfterCell = false;

    if ( info.GetState().GetSelectionState() == wxHTML_SEL_CHANGING )
    {
        // Selection changing, we must draw the word piecewise:
        wxHtmlSelection *s = info.GetSelection();
        wxString txt;
        int w, h;
        int ofs = 0;

        wxPoint priv = (this == s->GetFromCell()) ?
                       s->GetFromPrivPos() : s->GetToPrivPos();

        // NB: this is quite a hack: in order to compute selection boundaries
        //     (in word's characters) we must know current font, which is only
        //     possible inside rendering code. Therefore we update the
        //     information here and store it in wxHtmlSelection so that
        //     ConvertToText can use it later:
        if ( priv == wxDefaultPosition )
        {
            SetSelectionPrivPos(dc, s);
            priv = (this == s->GetFromCell()) ?
                   s->GetFromPrivPos() : s->GetToPrivPos();
        }

        int part1 = priv.x;
        int part2 = priv.y;

        if ( part1 > 0 )
        {
            txt = m_Word.Mid(0, part1);
            dc.DrawText(txt, x + m_PosX, y + m_PosY);
            dc.GetTextExtent(txt, &w, &h);
            ofs += w;
        }

        SwitchSelState(dc, info, true);

        txt = m_Word.Mid(part1, part2-part1);
        dc.DrawText(txt, ofs + x + m_PosX, y + m_PosY);

        if ( (size_t)part2 < m_Word.length() )
        {
            dc.GetTextExtent(txt, &w, &h);
            ofs += w;
            SwitchSelState(dc, info, false);
            txt = m_Word.Mid(part2);
            dc.DrawText(txt, ofs + x + m_PosX, y + m_PosY);
        }
        else
            drawSelectionAfterCell = true;
    }
    else
    {
        wxHtmlSelectionState selstate = info.GetState().GetSelectionState();
        // Not changing selection state, draw the word in single mode:
        if ( selstate != wxHTML_SEL_OUT &&
                dc.GetBackgroundMode() != wxBRUSHSTYLE_SOLID )
        {
            SwitchSelState(dc, info, true);
        }
        else if ( selstate == wxHTML_SEL_OUT &&
                  dc.GetBackgroundMode() == wxBRUSHSTYLE_SOLID )
        {
            SwitchSelState(dc, info, false);
        }
        dc.DrawText(m_Word, x + m_PosX, y + m_PosY);
        drawSelectionAfterCell = (selstate != wxHTML_SEL_OUT);
    }

    // NB: If the text is justified then there is usually some free space
    //     between adjacent cells and drawing the selection only onto cells
    //     would result in ugly unselected spaces. The code below detects
    //     this special case and renders the selection *outside* the sell,
    //     too.
    if ( m_Parent->GetAlignHor() == wxHTML_ALIGN_JUSTIFY &&
            drawSelectionAfterCell )
    {
        wxHtmlCell *nextCell = m_Next;
        while ( nextCell && nextCell->IsFormattingCell() )
            nextCell = nextCell->GetNext();
        if ( nextCell )
        {
            int nextX = nextCell->GetPosX();
            if ( m_PosX + m_Width < nextX )
            {
                dc.SetBrush(dc.GetBackground());
                dc.SetPen(*wxTRANSPARENT_PEN);
                dc.DrawRectangle(x + m_PosX + m_Width, y + m_PosY,
                                 nextX - m_PosX - m_Width, m_Height);
            }
//.........这里部分代码省略.........
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:101,代码来源:htmlcell.cpp


示例14: Split

// Splits m_Word into up to three parts according to selection, returns
// substring before, in and after selection and the points (in relative coords)
// where s2 and s3 start:
void wxHtmlWordCell::Split(const wxDC& dc,
                           const wxPoint& selFrom, const wxPoint& selTo,
                           unsigned& pos1, unsigned& pos2) const
{
    wxPoint pt1 = (selFrom == wxDefaultPosition) ?
                  wxDefaultPosition : selFrom - GetAbsPos();
    wxPoint pt2 = (selTo == wxDefaultPosition) ?
                  wxPoint(m_Width, wxDefaultCoord) : selTo - GetAbsPos();

    // if the selection is entirely within this cell, make sure pt1 < pt2 in
    // order to make the rest of this function simpler:
    if ( selFrom != wxDefaultPosition && selTo != wxDefaultPosition &&
            selFrom.x > selTo.x )
    {
        wxPoint tmp = pt1;
        pt1 = pt2;
        pt2 = tmp;
    }

    unsigned len = m_Word.length();
    unsigned i = 0;
    pos1 = 0;

    // adjust for cases when the start/end position is completely
    // outside the cell:
    if ( pt1.y < 0 )
        pt1.x = 0;
    if ( pt2.y >= m_Height )
        pt2.x = m_Width;

    // before selection:
    // (include character under caret only if in first half of width)
#ifdef __WXMAC__
    // implementation using PartialExtents to support fractional widths
    wxArrayInt widths ;
    dc.GetPartialTextExtents(m_Word,widths) ;
    while( i < len && pt1.x >= widths[i] )
        i++ ;
    if ( i < len )
    {
        int charW = (i > 0) ? widths[i] - widths[i-1] : widths[i];
        if ( widths[i] - pt1.x < charW/2 )
            i++;
    }
#else // !__WXMAC__
    wxCoord charW, charH;
    while ( pt1.x > 0 && i < len )
    {
        dc.GetTextExtent(m_Word[i], &charW, &charH);
        pt1.x -= charW;
        if ( pt1.x >= -charW/2 )
        {
            pos1 += charW;
            i++;
        }
    }
#endif // __WXMAC__/!__WXMAC__

    // in selection:
    // (include character under caret only if in first half of width)
    unsigned j = i;
#ifdef __WXMAC__
    while( j < len && pt2.x >= widths[j] )
        j++ ;
    if ( j < len )
    {
        int charW = (j > 0) ? widths[j] - widths[j-1] : widths[j];
        if ( widths[j] - pt2.x < charW/2 )
            j++;
    }
#else // !__WXMAC__
    pos2 = pos1;
    pt2.x -= pos2;
    while ( pt2.x > 0 && j < len )
    {
        dc.GetTextExtent(m_Word[j], &charW, &charH);
        pt2.x -= charW;
        if ( pt2.x >= -charW/2 )
        {
            pos2 += charW;
            j++;
        }
    }
#endif // __WXMAC__/!__WXMAC__

    pos1 = i;
    pos2 = j;

    wxASSERT( pos2 >= pos1 );
}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:93,代码来源:htmlcell.cpp


示例15: MouseMove

void Game::MouseMove(wxDC& dc, int mx, int my)
{
    if (m_liftedCard)
    {
        wxMemoryDC memoryDC;
        memoryDC.SelectObject(*m_bmap);

        int dx = mx + m_xOffset - m_xPos;
        int dy = my + m_yOffset - m_yPos;

        if (abs(dx) >= CardWidth || abs(dy) >= CardHeight)
        {
            // Restore the area under the card
            dc.Blit(m_xPos, m_yPos, CardWidth, CardHeight,
               &memoryDC, 0, 0, wxCOPY);

            // Copy the area under the card in the new position
            memoryDC.Blit(0, 0, CardWidth, CardHeight,
               &dc, m_xPos + dx, m_yPos + dy, wxCOPY);
        }
        else if (dx >= 0)
        {
            // dx >= 0
            dc.Blit(m_xPos, m_yPos, dx, CardHeight, &memoryDC, 0, 0, wxCOPY);
            if (dy >= 0)
            {
                // dy >= 0
                dc.Blit(m_xPos + dx, m_yPos, CardWidth - dx, dy, &memoryDC, dx, 0, wxCOPY);
                memoryDC.Blit(0, 0, CardWidth - dx, CardHeight - dy,
                       &memoryDC, dx, dy, wxCOPY);
                memoryDC.Blit(0, CardHeight - dy, CardWidth - dx, dy,
                       &dc, m_xPos + dx, m_yPos + CardHeight, wxCOPY);
            }
            else
            {
                // dy < 0
                dc.Blit(m_xPos + dx, m_yPos + dy + CardHeight, CardWidth - dx, -dy,
                       &memoryDC, dx, CardHeight + dy, wxCOPY);
                memoryDC.Blit(0, -dy, CardWidth - dx, CardHeight + dy,
                       &memoryDC, dx, 0, wxCOPY);
                memoryDC.Blit(0, 0, CardWidth - dx, -dy,
                       &dc, m_xPos + dx, m_yPos + dy, wxCOPY);
            }
            memoryDC.Blit(CardWidth - dx, 0, dx, CardHeight,
                   &dc, m_xPos + CardWidth, m_yPos + dy, wxCOPY);
        }
        else
        {
            // dx < 0
            dc.Blit(m_xPos + CardWidth + dx, m_yPos, -dx, CardHeight,
                   &memoryDC, CardWidth + dx, 0, wxCOPY);
            if (dy >= 0)
            {
                dc.Blit(m_xPos, m_yPos, CardWidth + dx, dy, &memoryDC, 0, 0, wxCOPY);
                memoryDC.Blit(-dx, 0, CardWidth + dx, CardHeight - dy,
                       &memoryDC, 0, dy, wxCOPY);
                memoryDC.Blit(-dx, CardHeight - dy, CardWidth + dx, dy,
                       &dc, m_xPos, m_yPos + CardHeight, wxCOPY);
            }
            else
            {
                // dy < 0
                dc.Blit(m_xPos, m_yPos + CardHeight + dy, CardWidth + dx, -dy,
                       &memoryDC, 0, CardHeight + dy, wxCOPY);
                memoryDC.Blit(-dx, -dy, CardWidth + dx, CardHeight + dy,
                       &memoryDC, 0, 0, wxCOPY);
                memoryDC.Blit(-dx, 0, CardWidth + dx, -dy,
                       &dc, m_xPos, m_yPos + dy, wxCOPY);
            }
            memoryDC.Blit(0, 0, -dx, CardHeight,
                   &dc, m_xPos + dx, m_yPos + dy, wxCOPY);
        }
        m_xPos += dx;
        m_yPos += dy;

        // draw the card in its new position
        memoryDC.SelectObject(*m_bmapCard);
        dc.Blit(m_xPos, m_yPos, CardWidth, CardHeight,
               &memoryDC, 0, 0, wxCOPY);
    }
}
开发者ID:EdgarTx,项目名称:wx,代码行数:81,代码来源:game.cpp


示例16: OnDrawItem

// draws a line of symbols
void wxSymbolListCtrl::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
{
    wxColour oldTextColour = dc.GetTextForeground();
    int startSymbol = n*m_symbolsPerLine;

    int i;
    for (i = 0; i < m_symbolsPerLine; i++)
    {
        bool resetColour = false;
        int symbol = startSymbol+i;
        if (symbol == m_current)
        {
            dc.SetBrush(wxBrush(m_colBgSel));

            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
            resetColour = true;

            wxPen oldPen = dc.GetPen();
            dc.SetPen(*wxTRANSPARENT_PEN);

            dc.DrawRectangle(rect.x + i*m_cellSize.x, rect.y, m_cellSize.x, rect.y+rect.height);
            dc.SetPen(oldPen);
        }

        // Don't draw first line
        if (i != 0)
            dc.DrawLine(rect.x + i*m_cellSize.x, rect.y, i*m_cellSize.x, rect.y+rect.height);

        if (symbol >= m_minSymbolValue && symbol <= m_maxSymbolValue)
        {
            wxString text;
            text << (wxChar) symbol;

            wxCoord w, h;
            dc.GetTextExtent(text, & w, & h);

            int x = rect.x + i*m_cellSize.x + (m_cellSize.x - w)/2;
            int y = rect.y + (m_cellSize.y - h)/2;
            dc.DrawText(text, x, y);
        }

        if (resetColour)
            dc.SetTextForeground(oldTextColour);
    }

    // Draw horizontal separator line
    dc.DrawLine(rect.x, rect.y+rect.height-1, rect.x+rect.width, rect.y+rect.height-1);
}
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:49,代码来源:richtextsymboldlg.cpp


示例17: DoDraw

void wxSheetCellStringRendererRefData::DoDraw(wxSheet& sheet,
        const wxSheetCellAttr& attr,
        wxDC& dc,
        const wxRect& rectCell,
        const wxSheetCoords& coords,
        bool isSelected)
{
    wxRect rect = rectCell;
    rect.Inflate(-1);

    int align = attr.GetAlignment();
    int orient = attr.GetOrientation();

    wxString value( sheet.GetCellValue(coords) );
    int best_width = DoGetBestSize(sheet, attr, dc, value).GetWidth();
    wxSheetCoords cellSpan(sheet.GetCellSpan(coords)); // shouldn't get here if <=0
    int cell_rows = cellSpan.m_row;
    int cell_cols = cellSpan.m_col;

    bool is_grid_cell = coords.IsGridCell();
    // no overflow for row/col/corner labels
    bool overflow = is_grid_cell && (orient == wxSHEET_AttrOrientHoriz) ? attr.GetOverflow() : false;
    int overflowCols = 0;
    int num_cols = sheet.GetNumberCols();
    // 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ wxDataFormat类代码示例发布时间:2022-05-31
下一篇:
C++ wxCursor类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap