コード例 #1
1
void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
                               wxHtmlRenderingInfo& info)
{
#if 0 // useful for debugging
    dc.SetPen(*wxRED_PEN);
    dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width,m_Height);
#endif

    int xlocal = x + m_PosX;
    int ylocal = y + m_PosY;

    if (m_UseBkColour)
    {
        wxBrush myb = wxBrush(m_BkColour, wxBRUSHSTYLE_SOLID);

        int real_y1 = mMax(ylocal, view_y1);
        int real_y2 = mMin(ylocal + m_Height - 1, view_y2);

        dc.SetBrush(myb);
        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.DrawRectangle(xlocal, real_y1, m_Width, real_y2 - real_y1 + 1);
    }

    if (m_Border == 1)
    {
        // draw thin border using lines
        wxPen mypen1(m_BorderColour1, 1, wxPENSTYLE_SOLID);
        wxPen mypen2(m_BorderColour2, 1, wxPENSTYLE_SOLID);

        dc.SetPen(mypen1);
        dc.DrawLine(xlocal, ylocal, xlocal, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal, xlocal + m_Width, ylocal);
        dc.SetPen(mypen2);
        dc.DrawLine(xlocal + m_Width - 1, ylocal, xlocal +  m_Width - 1, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal + m_Height - 1, xlocal + m_Width, ylocal + m_Height - 1);
    }
    else if (m_Border> 0)
    {
        wxBrush mybrush1(m_BorderColour1, wxBRUSHSTYLE_SOLID);
        wxBrush mybrush2(m_BorderColour2, wxBRUSHSTYLE_SOLID);

        // draw upper left corner
        // 0---------------5
        // |              /
        // | 3-----------4
        // | |
        // | 2
        // |/
        // 1

        wxPoint poly[6];
        poly[0].x =m_PosX;
        poly[0].y = m_PosY ;
        poly[1].x =m_PosX;
        poly[1].y = m_PosY + m_Height;
        poly[2].x =m_PosX + m_Border;
        poly[2].y = poly[1].y - m_Border;
        poly[3].x =poly[2].x ;
        poly[3].y = m_PosY + m_Border;
        poly[4].x =m_PosX + m_Width - m_Border;
        poly[4].y = poly[3].y;
        poly[5].x =m_PosX + m_Width;
        poly[5].y = m_PosY;

        dc.SetBrush(mybrush1);
        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.DrawPolygon(6, poly, x, y);

        // draw lower right corner reusing point 1,2,4 and 5
        //                 5
        //                /|
        //               4 |
        //               | |
        //   2-----------3 |
        //  /              |
        // 1---------------0
        dc.SetBrush(mybrush2);
        poly[0].x = poly[5].x;
        poly[0].y = poly[1].y;
        poly[3].x = poly[4].x;
        poly[3].y = poly[2].y;
        dc.DrawPolygon(6, poly, x, y);

        // smooth color transition like firefox
        wxColour borderMediumColour(
            (m_BorderColour1.Red() + m_BorderColour2.Red()) /2 ,
            (m_BorderColour1.Green() + m_BorderColour2.Green()) /2 ,
            (m_BorderColour1.Blue() + m_BorderColour2.Blue()) /2
        );
        wxPen mypen3(borderMediumColour, 1, wxPENSTYLE_SOLID);
        dc.SetPen(mypen3);
        dc.DrawLines(2, &poly[1], x, y - 1); // between 1 and 2
        dc.DrawLines(2, &poly[4], x, y - 1); // between 4 and 5
    }
    if (m_Cells)
    {
        // draw container's contents:
        for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext())
        {

            // optimize drawing: don't render off-screen content:
            if ((ylocal + cell->GetPosY() <= view_y2) &&
                    (ylocal + cell->GetPosY() + cell->GetHeight() > view_y1))
            {
                // the cell is visible, draw it:
                UpdateRenderingStatePre(info, cell);
                cell->Draw(dc,
                           xlocal, ylocal, view_y1, view_y2,
                           info);
                UpdateRenderingStatePost(info, cell);
            }
            else
            {
                // the cell is off-screen, proceed with font+color+etc.
                // changes only:
                cell->DrawInvisible(dc, xlocal, ylocal, info);
            }
        }
    }
}
コード例 #2
0
void wxHtmlFontCell::DrawInvisible(wxDC& dc, int WXUNUSED(x), int WXUNUSED(y),
                                   wxHtmlRenderingInfo& WXUNUSED(info))
{
    dc.SetFont(m_Font);
}
コード例 #3
0
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();
    }
}
コード例 #4
0
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;
    }


    // if the caption is empty, measure some temporary text
    wxString caption = page.caption;
    if (caption.empty())
        caption = wxT("Xj");

    wxCoord textx;
    wxCoord texty;
    if (page.active)
#if wxCHECK_VERSION(2, 9, 3)
        dc.SetFont(m_selectedFont);
#else
        dc.SetFont(m_selected_font);
#endif
    else
コード例 #5
0
ファイル: instancectrl.cpp プロジェクト: Glought/MultiMC4
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);
	}
}
コード例 #6
0
ファイル: toolbar.cpp プロジェクト: czxxjtu/wxPython-1
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());
            rDc.GetTextExtent( pTool->GetLabel()
                              ,&vX
                              ,&vY
                             );
            vLeft += (wxCoord)((m_vTextX - vX)/2);
            rDc.DrawText( pTool->GetLabel()
                         ,vLeft
                         ,pTool->m_vY + m_vTextY - 1 // a bit of margin
                        );
        }
    }
} // end of wxToolBar::DrawTool
コード例 #7
0
ファイル: dockart.cpp プロジェクト: jonntd/dynamica
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);
}
コード例 #8
0
ファイル: dockart.cpp プロジェクト: jonntd/dynamica
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
}
コード例 #9
0
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
}
コード例 #10
0
ファイル: dovo_mainFrame.cpp プロジェクト: fvpolpeta/dovo
void dovo_mainFrame::renderPreview(wxDC& dc)
{
	dc.DrawBitmap(image, 0, 0, false );
}
コード例 #11
0
ファイル: skinbrush.cpp プロジェクト: niterain/digsby
void SkinColor::Draw(wxDC& dc, const wxRect& rect, int n) {
    dc.SetBrush(brush);
    dc.SetPen(pen);
    dc.DrawRectangle(rect);
}
コード例 #12
0
ファイル: GutterCtrl.cpp プロジェクト: lenoval/e
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);

					if (&*nextFold == m_currentFold) m_mdc.SetPen(wxPen(m_edgecolor, 2));
					else m_mdc.SetPen(m_edgecolor);
					m_mdc.DrawLine(m_foldStartX+4, box_y+9, m_foldStartX+4, ypos2);

					foldStack.push_back(&*nextFold);
					drawFoldLine = false;
					++nextFold;
				}
				else if (nextFold->type == EditorCtrl::cxFOLD_START_FOLDED) {
					const unsigned int box_y = ypos + line_middle - 5;
					m_mdc.DrawBitmap(m_bmFoldClosed, m_foldStartX, box_y);
					drawFoldLine = false;

					// Advance to end of fold
					i += nextFold->count;
					while (nextFold != folds.end() && nextFold->line_id <= i) ++nextFold;
				}
				else if (nextFold->type == EditorCtrl::cxFOLD_END) {
					if (!foldStack.empty()) {
						// check if end marker matches any starter on the stack (ignore unmatched)
						for (vector<const EditorCtrl::cxFold*>::reverse_iterator f = foldStack.rbegin(); f != foldStack.rend(); ++f) {
							if (nextFold->indent == (*f)->indent) {
								vector<const EditorCtrl::cxFold*>::iterator fb = (++f).base();

								// Check if we should highlight fold line
								if (*fb == m_currentFold) m_mdc.SetPen(wxPen(m_edgecolor, 2));
								else m_mdc.SetPen(m_edgecolor);

								// If we are closing other folds, we want to leave a gap
								const unsigned int ytop = (fb < foldStack.end()-1) ? ypos + 2 : ypos;

								// Draw end marker
								const unsigned int middle_y = ypos + line_middle+1;
								m_mdc.DrawLine(m_foldStartX+4, ytop, m_foldStartX+4, middle_y);
								m_mdc.DrawLine(m_foldStartX+4, middle_y, m_foldStartX+9, middle_y);

								foldStack.erase(fb, foldStack.end()); // pop
								drawFoldLine = false;
								break;
							}
						}
					}
					++nextFold;
				}

			}

			if (drawFoldLine) {
				const int ypos2 = lines.GetBottomYPosFromLine(i) - scrollPos;

				// Check if we should highlight fold line
				if (!foldStack.empty() && foldStack.back() == m_currentFold) {
					m_mdc.SetPen(wxPen(m_edgecolor, 2));
				}
				else m_mdc.SetPen(m_edgecolor);

				m_mdc.DrawLine(m_foldStartX+4, ypos, m_foldStartX+4, ypos2);
			}
		}
	}

	// Copy MemoryDC to Display
#ifdef __WXMSW__
	::BitBlt(GetHdcOf(dc), 0, 0,(int)size.x, (int)size.y, GetHdcOf(m_mdc), 0, 0, SRCCOPY);
#else
	dc.Blit(0, 0, size.x, size.y, &m_mdc, 0, 0);
#endif
}
コード例 #13
0
ファイル: tabartgtk.cpp プロジェクト: BauerBox/wxWidgets
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"),
                           tab_rect.x, tab_rect.y,
                           tab_rect.width, tab_rect.height,
                           GTK_POS_TOP);
    }
    else
    {
        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_TOP, 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"),
                           tab_rect.x, tab_rect.y,
                           tab_rect.width, tab_rect.height,
                           GTK_POS_BOTTOM);
    }

    // After drawing the inactive tab itself, draw a box with the same dimensions as the gap-box,
    // otherwise we don't get a gap-box, if the active tab is invisible
    if (!page.active)
        gtk_paint_box(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);

    wxCoord textX = tab_rect.x + padding + style_notebook->xthickness;

    int bitmap_offset = 0;
    if (page.bitmap.IsOk())
    {
        bitmap_offset = textX;

        // draw bitmap
        int bitmapY = tab_rect.y +(tab_rect.height - page.bitmap.GetHeight()) / 2;
        if(!page.active)
        {
            if (tab_pos == wxAUI_NB_TOP)
                bitmapY += style_notebook->ythickness / 2;
            else
                bitmapY -= style_notebook->ythickness / 2;
        }
        dc.DrawBitmap(page.bitmap,
                      bitmap_offset,
                      bitmapY,
                      true);

        textX += page.bitmap.GetWidth() + padding;
    }

    wxCoord textW, textH, textY;

    dc.SetFont(m_normalFont);
    dc.GetTextExtent(page.caption, &textW, &textH);
    textY = tab_rect.y + (tab_rect.height - textH) / 2;
    if(!page.active)
    {
        if (tab_pos == wxAUI_NB_TOP)
            textY += style_notebook->ythickness / 2;
        else
            textY -= style_notebook->ythickness / 2;
    }

    // draw tab text
    GdkColor text_colour = page.active ? style_notebook->fg[GTK_STATE_NORMAL] : style_notebook->fg[GTK_STATE_ACTIVE];
    dc.SetTextForeground(wxColor(text_colour));
    GdkRectangle focus_area;

    int padding_focus = padding - focus_width;
    focus_area.x = tab_rect.x + padding_focus;
    focus_area.y = textY - focus_width;
    focus_area.width = tab_rect.width - 2 * padding_focus;
    focus_area.height = textH + 2 * focus_width;

    if(page.active && (wnd->FindFocus() == wnd) && focus_area.x <= (area.x + area.width))
    {
        // clipping seems not to work here, so we we have to recalc the focus-area manually
        if((focus_area.x + focus_area.width) > (area.x + area.width))
            focus_area.width = area.x + area.width - focus_area.x + focus_width - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder;
        gtk_paint_focus (style_notebook, window,
                         GTK_STATE_ACTIVE, NULL, widget, "tab",
                         focus_area.x, focus_area.y, focus_area.width, focus_area.height);
    }

    dc.DrawText(page.caption, textX, textY);

    // draw close-button on tab (if enabled)
    if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
    {
        wxRect rect(tab_rect.x, tab_rect.y, tab_rect.width - style_notebook->xthickness, tab_rect.height);
        if(!page.active)
        {
            if (tab_pos == wxAUI_NB_TOP)
                rect.y += style_notebook->ythickness / 2;
            else
                rect.y -= style_notebook->ythickness / 2;
        }
        *out_button_rect = DrawCloseButton(dc, widget, close_button_state, rect, wxRIGHT, &area);
    }

    if ( clip_width < tab_rect.width )
        tab_rect.width = clip_width;
    *out_tab_rect = tab_rect;

    dc.DestroyClippingRegion();
}
コード例 #14
0
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);
            }
        }
    }
}
コード例 #15
0
// 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 );
}
コード例 #16
0
ファイル: game.cpp プロジェクト: EdgarTx/wx
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);
    }
}
コード例 #17
0
// 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);
}
コード例 #18
0
void wxSheetCellRendererRefData::Draw( wxSheet& sheet,
                                       const wxSheetCellAttr& attr,
                                       wxDC& dc,
                                       const wxRect& rect,
                                       const wxSheetCoords& UNUSE(coords),
                                       bool isSelected )
{
    dc.SetBackgroundMode( wxSOLID );

    // grey out fields if the sheet is disabled
    if ( sheet.IsEnabled() )
    {
        if ( isSelected )
            dc.SetBrush( wxBrush(sheet.GetSelectionBackground(), wxSOLID) );
        else
            dc.SetBrush( wxBrush(attr.GetBackgroundColour(), wxSOLID) );
    }
    else
        dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxSOLID));

    dc.SetPen( *wxTRANSPARENT_PEN );
    dc.DrawRectangle(rect);

#ifdef TEST_SELECTION_BLOCKS // colouring for identifying different blocks
    if (isSelected)
    {
        int i = sheet.GetSelection()->Index(coords);
        wxColour c(GetRainbow(i*10));
        dc.SetBrush( wxBrush(c, wxSOLID) );
        dc.DrawRectangle(rect);

        wxFont font = dc.GetFont();
        dc.SetFont(*wxSMALL_FONT);
        dc.DrawText(wxString::Format(wxT("%d"), i), rect.x, rect.y);
    }
#endif // TEST_SELECTION_BLOCKS

    //FIXME - border drawing code, maybe it goes here?
    //dc.SetPen( wxPen(sheet.GetGridLineColour(), 1, wxSOLID) );
    //dc.DrawRectangle(rect.x-1, rect.y-1, rect.width+2, rect.height+2);
}
コード例 #19
0
ファイル: dockart.cpp プロジェクト: jonntd/dynamica
void wxAuiDefaultDockArt::DrawGripper(wxDC& dc, wxWindow *WXUNUSED(window),
                                   const wxRect& rect,
                                   wxAuiPaneInfo& pane)
{
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_gripper_brush);

    dc.DrawRectangle(rect.x, rect.y, rect.width,rect.height);

    if (!pane.HasGripperTop())
    {
        int y = 5;
        while (1)
        {
            dc.SetPen(m_gripper_pen1);
            dc.DrawPoint(rect.x+3, rect.y+y);
            dc.SetPen(m_gripper_pen2);
            dc.DrawPoint(rect.x+3, rect.y+y+1);
            dc.DrawPoint(rect.x+4, rect.y+y);
            dc.SetPen(m_gripper_pen3);
            dc.DrawPoint(rect.x+5, rect.y+y+1);
            dc.DrawPoint(rect.x+5, rect.y+y+2);
            dc.DrawPoint(rect.x+4, rect.y+y+2);

            y += 4;
            if (y > rect.GetHeight()-5)
                break;
        }
    }
    else
    {
        int x = 5;
        while (1)
        {
            dc.SetPen(m_gripper_pen1);
            dc.DrawPoint(rect.x+x, rect.y+3);
            dc.SetPen(m_gripper_pen2);
            dc.DrawPoint(rect.x+x+1, rect.y+3);
            dc.DrawPoint(rect.x+x, rect.y+4);
            dc.SetPen(m_gripper_pen3);
            dc.DrawPoint(rect.x+x+1, rect.y+5);
            dc.DrawPoint(rect.x+x+2, rect.y+5);
            dc.DrawPoint(rect.x+x+2, rect.y+4);

            x += 4;
            if (x > rect.GetWidth()-5)
                break;
        }
    }
}
コード例 #20
0
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();
    // this is the right col which includes overflow
    int rightCol = coords.m_col + cell_cols - 1;

    // Check if this cell should overflow to right and for how many cells
    if (overflow)
    {
        bool is_editing = sheet.IsCellEditControlShown();
        wxSheetCoords editorCell = is_editing ? sheet.GetEditControlCoords() : wxNullSheetCoords;
        int row = coords.GetRow(), col = coords.GetCol();
        wxSheetCoords ownerCell;
        if ((best_width > rectCell.width) && (col < num_cols-1) && sheet.GetTable())
        {
            wxSheetCoords cell;
            for (cell.m_col = col+cell_cols; cell.m_col < num_cols; cell.m_col++)
            {
                bool is_empty = true;
                for (cell.m_row = row; cell.m_row < row+cell_rows; cell.m_row++)
                {
                    // check w/ anchor cell for spanned cell block
                    ownerCell = sheet.GetCellOwner(cell);
                    if ( sheet.GetTable()->HasValue(ownerCell) ||
                            (ownerCell == editorCell) )
                    {
                        is_empty = false;
                        break;
                    }
                }

                if (is_empty)
                    rect.width += sheet.GetColWidth(cell.m_col);
                else
                {
                    cell.m_col--;
                    break;
                }

                if (rect.width >= best_width)
                    break;
            }
            // this may extend out of sheet
            overflowCols = cell.m_col - col - cell_cols + 1;
            rightCol = wxMin(coords.m_col+cell_cols-1+overflowCols, num_cols - 1);
        }

        // redraw overflow cells individually for proper selection hilight
        if (overflowCols > 0)
        {
            // if overflowed then it's left aligned (yes I know ALIGN_LEFT=0)
            align &= ~wxSHEET_AttrAlignHoriz_Mask;
            align |= wxSHEET_AttrAlignLeft;

            wxRect clip(rect);
            clip.x += rectCell.width;

            int col_width;
            wxSheetCoords cell(coords);
            // draw each cell individually since it may be selected or not
            for (cell.m_col = col+cell_cols; cell.m_col <= rightCol; cell.m_col++)
            {
                col_width = sheet.GetColWidth(cell.m_col);
                clip.width = col_width - 1;
                dc.DestroyClippingRegion();
                dc.SetClippingRegion(clip);
                SetTextColoursAndFont(sheet, attr, dc, sheet.IsCellSelected(cell));
                sheet.DrawTextRectangle(dc, value, rect, align, orient);
                clip.x += col_width - 1;
            }

            rect = rectCell;
            rect.Inflate(-1);
            rect.width++;
            dc.DestroyClippingRegion();
        }
    }

    // Draw the text
    SetTextColoursAndFont(sheet, attr, dc, isSelected);
    sheet.DrawTextRectangle(dc, value, rect, align, orient);

    if (attr.GetOverflowMarker())
    {
        // Draw a marker to show that the contents has been clipped off
        int cellRight = sheet.GetColRight(rightCol);
        if (cellRight - rect.x < best_width)
        {
            int bmpWidth   = s_overflowBitmap.GetWidth();
            int bmpHeight  = s_overflowBitmap.GetHeight();
            int cellWidth  = sheet.GetColWidth(rightCol);
            int cellHeight = sheet.GetRowHeight(coords.m_row);

            if ((bmpWidth < cellWidth-3) && (bmpHeight < cellHeight-3))
            {
                int cellTop = sheet.GetRowTop(coords.m_row);

                int x = cellRight - bmpWidth - 2;
                int y = cellTop + (cellHeight - bmpHeight)/2;
                wxRect r(x-2, cellTop, bmpWidth+4-1, cellHeight-1);
                wxSheetCellAttr rightAttr(attr);
                if (overflowCols > 0)
                {
                    wxSheetCoords clipCell(coords.m_row, rightCol);
                    isSelected = sheet.IsCellSelected(clipCell);
                    rightAttr = sheet.GetAttr(clipCell);
                }

                // clear background for bitmap
                wxSheetCellRendererRefData::Draw(sheet, rightAttr, dc, r, coords, isSelected);
                dc.DrawBitmap( s_overflowBitmap, x, y, true );
            }
        }
    }
}
コード例 #21
0
void UICalculateDistance::render(wxDC& dc)
{
	int client_h = 0;
	int client_w = 0;
	GetClientSize (&client_w, &client_h);

	if (!(ApplicationConfiguration::GetInstance()->IsThemed()))
	  {
	    wxString str(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient2Colour().c_str(),wxConvUTF8);
	    wxColour c_pen   = (wxColour)str;
	    wxString str2(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient1Colour().c_str(),wxConvUTF8);
	    wxColour c_backg = (wxColour)str2;
	    wxString str3(ApplicationConfiguration::GetInstance()->GetBackgroundColour().c_str(),wxConvUTF8);
	    wxColour c_brush = (wxColour)str3;
	    wxString str4(cpw::ApplicationConfiguration::GetInstance()->GetFontLightColour().c_str(),wxConvUTF8);
	    dc.SetTextForeground((wxColour)str4);
	    dc.SetPen(wxPen(c_pen));
	    dc.SetBrush(wxBrush(c_brush));
	    dc.GradientFillLinear( wxRect(0,0,client_w,client_h), c_backg, c_pen, wxSOUTH);
	}

	std::ostringstream wop,wop2,wop3,wop4; 
	wop << std::fixed << std::setprecision(3) << (distance*factor);  
	
	double aux = 0.000;
	Position_x_Edit->GetValue().Trim().ToDouble(&aux);
	wop2 << std::fixed << std::setprecision (3) << aux;
	Position_y_Edit->GetValue().Trim().ToDouble(&aux);
	wop3 << std::fixed << std::setprecision (3) << aux;
	Position_z_Edit->GetValue().Trim().ToDouble(&aux);
	wop4 << std::fixed << std::setprecision (3) << aux;

	
	wxPoint box1_first(20-2,45-9);
	wxPoint box1_last(368,45+22);
	dc.DrawRoundedRectangle(box1_first.x, box1_first.y, box1_last.x-box1_first.x, box1_last.y-box1_first.y,3.1f);
	dc.DrawRotatedText(wxString(wop2.str().c_str(),wxConvUTF8),89+10-30-5,45, 0);
	dc.DrawRotatedText(wxString(wop3.str().c_str(),wxConvUTF8),89+10-30-5+92+10+15-3,45, 0);
	dc.DrawRotatedText(wxString(wop4.str().c_str(),wxConvUTF8),89+10-30-5+184+20+15+10-2,45, 0);

	wxFont font(10, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma"));
	wxFont font_ = dc.GetFont();
	dc.SetFont(font);
	dc.DrawRotatedText(_T("Distance:"),20,12, 0);
	dc.DrawRotatedText(wxString(wop.str().c_str(),wxConvUTF8),20+65,12, 0);
	dc.SetFont(font_);
}
コード例 #22
0
void wxSheetCellBoolRendererRefData::Draw(wxSheet& sheet,
        const wxSheetCellAttr& attr,
        wxDC& dc, const wxRect& rect,
        const wxSheetCoords& coords,
        bool isSelected)
{
    wxSheetCellRendererRefData::Draw(sheet, attr, dc, rect, coords, isSelected);

    // draw a check mark in the centre (ignoring alignment - TODO)
    wxSize size = GetBestSize(sheet, attr, dc, coords);

    // don't draw outside the cell
    wxCoord minSize = wxMin(rect.width, rect.height) - 1;
    if ((size.x >= minSize) || (size.y >= minSize))
        size.x = size.y = minSize - 2; // leave (at least) 1 pixel margin

    // draw a border around checkmark
    int align = attr.GetAlignment();

    wxRect rectBorder(rect.GetPosition(), size);

    if ((align & wxALIGN_RIGHT) != 0)
        rectBorder.x += rect.width - size.x - 2;
    else if ((align & wxALIGN_CENTRE_HORIZONTAL) != 0)
        rectBorder.x += rect.width/2 - size.x/2;
    else // wxALIGN_LEFT
        rectBorder.x += 2;

    if ((align & wxALIGN_BOTTOM) != 0)
        rectBorder.y += rect.height - size.y - 2;
    else if ((align & wxALIGN_CENTRE_VERTICAL) != 0)
        rectBorder.y += rect.height/2 - size.y/2;
    else // wxALIGN_TOP
        rectBorder.y += 2;

    bool value = false;
    if ( sheet.GetTable() && sheet.GetTable()->CanGetValueAs(coords, wxSHEET_VALUE_BOOL) )
        value = sheet.GetTable()->GetValueAsBool(coords);
    else
    {
        wxString strValue( sheet.GetCellValue(coords) );
        value = !( strValue.IsEmpty() || (strValue == wxT("0")) ||
                   (strValue.Lower() == wxT("f")) || (strValue.Lower() == wxT("false")));
    }

    if ( value )
    {
        wxRect rectMark = rectBorder;
#ifdef __WXMSW__
        // MSW DrawCheckMark() is weird (and should probably be changed...)
        rectMark.Inflate(-wxSHEET_CHECKMARK_MARGIN/2);
        rectMark.x++;
        rectMark.y++;
#else // !MSW
        rectMark.Inflate(-wxSHEET_CHECKMARK_MARGIN);
#endif // MSW/!MSW

        dc.SetTextForeground(attr.GetForegroundColour());
        dc.DrawCheckMark(rectMark);
    }

    dc.SetBrush(*wxTRANSPARENT_BRUSH);
    dc.SetPen(wxPen(attr.GetForegroundColour(), 1, wxSOLID));
    dc.DrawRectangle(rectBorder);
}
コード例 #23
0
ファイル: instancectrl.cpp プロジェクト: Glought/MultiMC4
/// Draw the item
bool InstanceVisual::Draw(wxDC& dc, InstanceCtrl* ctrl, const wxRect& rect, int style)
{
	wxColour backgroundColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
	wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
	wxColour highlightTextColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
	wxColour focus_color = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
	wxColour focussedSelection = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
	
	wxRect imageRect(rect.x + (rect.width - 32) / 2, rect.y, 32, 32);
	
	if (style & wxINST_SELECTED)
	{
		wxBrush brush(focus_color);
		wxPen pen(focus_color);
		dc.SetBrush(brush);
		dc.SetPen(pen);
	}
	else
	{
		wxBrush brush(backgroundColor);
		wxPen pen(backgroundColor);
		dc.SetBrush(brush);
		dc.SetPen(pen);
	}
	
	// Draw the label
	wxString name = m_inst->GetName();
	if (!name.IsEmpty())
	{
		int margin = ctrl->GetItemMargin();
		
		wxRect textRect;
		textRect.x = rect.x + margin;
		textRect.y = rect.y + imageRect.height + 2 * margin;
		textRect.width = rect.width - 2 * margin;
		
		dc.SetFont(ctrl->GetFont());
		if (style & wxINST_SELECTED)
			dc.SetTextForeground(highlightTextColor);
		else
			dc.SetTextForeground(textColor);
		dc.SetBackgroundMode(wxTRANSPARENT);
		
		int yoffset = 0;
		wxSize textsize = dc.GetMultiLineTextExtent(name_wrapped);
		textRect.height = textsize.GetHeight();
		if (style & wxINST_SELECTED)
		{
			wxRect hiRect;
			hiRect.x = rect.x + (rect.width - textsize.x) / 2 - margin;
			hiRect.y = textRect.y - margin;
			hiRect.SetSize(textsize + wxSize(2 * margin, 2 * margin));
			dc.DrawRectangle(hiRect);
		}
		dc.DrawLabel(name_wrapped, textRect, wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL);
	}
	
	// Draw the icon
	auto list = InstIconList::Instance();
	wxImage icon;
	if (style & wxINST_SELECTED)
		icon = list->getHLImageForKey(m_inst->GetIconKey());
	else
		icon = list->getImageForKey(m_inst->GetIconKey());
	wxBitmap bmap = wxBitmap(icon);
	int x = imageRect.x + (imageRect.width - bmap.GetWidth()) / 2;
	int y = imageRect.y + (imageRect.height - bmap.GetHeight()) / 2;
	dc.DrawBitmap(bmap , x, y, true);
	
	return true;
}
コード例 #24
0
ファイル: IsoLine.cpp プロジェクト: fzschornack/OpenCPN
//---------------------------------------------------------------
void IsoLine::drawIsoLine(GRIBOverlayFactory *pof, wxDC &dc, PlugIn_ViewPort *vp, bool bShowLabels, bool bHiDef)
{
      int nsegs = trace.size();
      if(nsegs < 1)
            return;

      GetGlobalColor ( _T ( "UITX1" ), &isoLineColor );
      wxPen ppISO ( isoLineColor, 2 );

#if wxUSE_GRAPHICS_CONTEXT
      wxMemoryDC *pmdc;
//      pmdc = dynamic_cast<wxMemoryDC*>(&dc);
      pmdc= wxDynamicCast(&dc, wxMemoryDC);
      wxGraphicsContext *pgc = wxGraphicsContext::Create(*pmdc);
      pgc->SetPen(ppISO);
#endif

      dc.SetPen(ppISO);



      std::list<Segment *>::iterator it;

    //---------------------------------------------------------
    // Dessine les segments
    //---------------------------------------------------------
    for (it=trace.begin(); it!=trace.end(); it++)
    {
        Segment *seg = *it;

        {
 //             wxPoint ab = vp->GetMercatorPixFromLL(seg->py1, seg->px1);
 //             wxPoint cd = vp->GetMercatorPixFromLL(seg->py2, seg->px2);
            wxPoint ab;
            GetCanvasPixLL(vp, &ab, seg->py1, seg->px1);
            wxPoint cd;
            GetCanvasPixLL(vp, &cd, seg->py2, seg->px2);


///            ClipResult res = cohen_sutherland_line_clip_i ( &ab.x, &ab.y, &cd.x, &cd.y,
///                         0, vp->pix_width, 0, vp->pix_height );
///            if ( res != Invisible )
             {
#if wxUSE_GRAPHICS_CONTEXT
                  if(bHiDef && pgc)
                        pgc->StrokeLine(ab.x, ab.y, cd.x, cd.y);
                  else 
                        dc.DrawLine(ab.x, ab.y, cd.x, cd.y);
#else
                  dc.DrawLine(ab.x, ab.y, cd.x, cd.y);
#endif
             }

        }
    }
//#endif

      int text_sx, text_sy;
      dc.GetTextExtent(_T("10000"), &text_sx, &text_sy);
//      double m = text_sy / 2;
      int label_size = text_sx;
      int label_space = 400;
//      double coef = .01;
      int len = label_space/4;

      //    Allocate an array big enough
      wxPoint *pPoints = new wxPoint[nsegs+1];

      MySegListList::Node *listnode;
      listnode = m_SegListList.GetFirst();
      while(listnode)
      {
            MySegList *listsort = listnode->GetData();

            //    Fill in the array
            MySegList::Node *node;
            Segment *seg;

            node = listsort->GetFirst();
            if(node)
            {
                  seg = node->GetData();
//                  wxPoint ab = vp->GetMercatorPixFromLL(seg->py1, seg->px1);
//                  wxPoint ab(0,0);
				  wxPoint ab;
				  GetCanvasPixLL(vp, &ab, seg->py1, seg->px1);
                  pPoints[0] = ab;
            }
            int ip=1;

            while (node)
            {
                  seg = node->GetData();
//                  wxPoint cd = vp->GetMercatorPixFromLL(seg->py2, seg->px2);
//                  wxPoint cd(0,0);
				  wxPoint cd;
				  GetCanvasPixLL(vp, &cd, seg->py2, seg->px2);
                  pPoints[ip++] = cd;

                  node=node->GetNext();
            }

            int np = listsort->GetCount() + 1;


            if(np > 1)
            {

      // Test code
      //          dc.DrawLines(np, pPoints);

                  GenerateSpline(np, pPoints);

      //    Test Code
      //            dc.DrawLines(&ocpn_wx_spline_point_list, 0, 0 );

                  bool bDrawing = true;
                  wxPoint lstart;

                  wxList::compatibility_iterator snode = ocpn_wx_spline_point_list.GetFirst();
                  wxPoint *point0 = (wxPoint *)snode->GetData();
                  snode=snode->GetNext();

                  while (snode)
                  {
                        wxPoint *point = (wxPoint *)snode->GetData();

                        ClipResult res = cohen_sutherland_line_clip_i ( &point0->x, &point0->y, &point->x, &point->y,
                                    0, vp->pix_width, 0, vp->pix_height );
                        if ( res != Invisible )
                        {
                              int dl = (int)sqrt(
                                            (double)((point0->x - point->x) * (point0->x - point->x))
                                          +(double)((point0->y - point->y) * (point0->y - point->y)));
                              if(bDrawing)
                              {
                                    len += dl;
                                    if(len > label_space)
                                    {
                                          bDrawing = false;
                                          len = 0;
                                          lstart = *point;
                                    }
                              }
                              else
                              {
                                    len += dl;
                                    if(len > label_size)
                                    {
                                          bDrawing = true;
                                          len = 0;
#if 0
                                          if(bShowLabels)
                                          {
                                                double label_angle = atan2((double)(lstart.y - point->y),
                                                    (double)(point->x - lstart.x)) * 180. / PI;
                                                wxString label;
                                                label.Printf(_T("%d"), (int)(value*coef+0.5));

                                                double xs = lstart.x - (m * sin(label_angle * PI / 180.));
                                                double ys = lstart.y - (m * cos(label_angle * PI / 180.));
                                                dc.DrawRotatedText(label, (int)xs, (int)ys, label_angle);
                                          }
#endif
                                    }
                              }

#if 0
//                              if(bDrawing || !bShowLabels)
                              {
                                    if(bHiDef)
                                          dc.StrokeLine(point0->x, point0->y, point->x, point->y);
                                    else
                                          dc.DrawLine(point0->x, point0->y, point->x, point->y);
                              }
#endif
                        }

                        *point0 = *point;
                        snode=snode->GetNext();
                  }

                  ClearSplineList();
            }

            listnode = listnode->GetNext();             // Next continuous chain

      }

      delete[] pPoints;

#if wxUSE_GRAPHICS_CONTEXT
      delete pgc;
#endif

}
コード例 #25
0
// Centre a list of strings in the given box. xOffset and yOffset are the
// the positions that these lines should be relative to, and this might be
// the same as m_xpos, m_ypos, but might be zero if formatting from left-justifying.
void oglCentreText(wxDC& dc, wxList *text_list,
                double m_xpos, double m_ypos, double width, double height,
                int formatMode)
{
  int n = text_list->GetCount();

  if (!text_list || (n == 0))
    return;

  // First, get maximum dimensions of box enclosing text

  long char_height = 0;
  long max_width = 0;
  long current_width = 0;

  // Store text extents for speed
  double *widths = new double[n];

  wxNode *current = text_list->GetFirst();
  int i = 0;
  while (current)
  {
    wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();
    dc.GetTextExtent(line->GetText(), &current_width, &char_height);
    widths[i] = current_width;

    if (current_width > max_width)
      max_width = current_width;
    current = current->GetNext();
    i ++;
  }

  double max_height = n*char_height;

  double xoffset, yoffset, xOffset, yOffset;

  if (formatMode & FORMAT_CENTRE_VERT)
  {
    if (max_height < height)
      yoffset = (double)(m_ypos - (height/2.0) + (height - max_height)/2.0);
    else
      yoffset = (double)(m_ypos - (height/2.0));
    yOffset = m_ypos;
  }
  else
  {
    yoffset = 0.0;
    yOffset = 0.0;
  }

  if (formatMode & FORMAT_CENTRE_HORIZ)
  {
    xoffset = (double)(m_xpos - width/2.0);
    xOffset = m_xpos;
  }
  else
  {
    xoffset = 0.0;
    xOffset = 0.0;
  }

  current = text_list->GetFirst();
  i = 0;

  while (current)
  {
    wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();

    double x;
    if ((formatMode & FORMAT_CENTRE_HORIZ) && (widths[i] < width))
      x = (double)((width - widths[i])/2.0 + xoffset);
    else
      x = xoffset;
    double y = (double)(i*char_height + yoffset);

    line->SetX( x - xOffset ); line->SetY( y - yOffset );
    current = current->GetNext();
    i ++;
  }

  delete widths;
}
コード例 #26
0
ファイル: areadraw.cpp プロジェクト: IGNF/wxfreechart
void FillAreaDraw::Draw(wxDC &dc, wxRect rc)
{
	dc.SetPen(m_borderPen);
	dc.SetBrush(m_fillBrush);
	dc.DrawRectangle(rc);
}
コード例 #27
0
ファイル: BackedPanel.cpp プロジェクト: jtrent238/audacity
void BackedPanel::RepairBitmap(wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
    dc.Blit(x, y, width, height, &mBackingDC, x, y);
}
コード例 #28
0
ファイル: game.cpp プロジェクト: EdgarTx/wx
void Game::DisplayScore(wxDC& dc)
{
    wxColour bgColour = FortyApp::BackgroundColour();
    wxPen* pen = wxThePenList->FindOrCreatePen(bgColour, 1, wxSOLID);
    dc.SetTextBackground(bgColour);
    dc.SetTextForeground(FortyApp::TextColour());
    dc.SetBrush(FortyApp::BackgroundBrush());
    dc.SetPen(* pen);

    // count the number of cards in foundations
    m_currentScore = 0;
    for (int i = 0; i < 8; i++)
    {
        m_currentScore += m_foundations[i]->GetNumCards();
    }

    int x, y;
    m_pack->GetTopCardPos(x, y);
    x += 12 * CardWidth - 105;

    int w, h;
    {
        long width, height;
        dc.GetTextExtent(_T("Average score:m_x"), &width, &height);
        w = width;
        h = height;
    }
    dc.DrawRectangle(x + w, y, 20, 4 * h);

    wxString str;
    str.Printf(_T("%d"), m_currentScore);
    dc.DrawText(_T("Score:"), x, y);
    dc.DrawText(str, x + w, y);
    y += h;

    str.Printf(_T("%d"), m_numGames);
    dc.DrawText(_T("Games played:"), x, y);
    dc.DrawText(str, x + w, y);
    y += h;

    str.Printf(_T("%d"), m_numWins);
    dc.DrawText(_T("Games won:"), x, y);
    dc.DrawText(str, x + w, y);
    y += h;

    int average = 0;
    if (m_numGames > 0)
    {
        average = (2 * (m_currentScore + m_totalScore) + m_numGames ) / (2 * m_numGames);
    }
    str.Printf(_T("%d"), average);
    dc.DrawText(_T("Average score:"), x, y);
    dc.DrawText(str, x + w, y);
}
コード例 #29
0
ファイル: SAuiTabArt.cpp プロジェクト: SanyaWaffles/SLADE
void SAuiTabArt::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)
{
	wxCoord normal_textx, normal_texty;
	wxCoord selected_textx, selected_texty;
	wxCoord texty;

	// if the caption is empty, measure some temporary text
	wxString caption = page.caption;
	if (caption.empty())
		caption = wxT("Xj");

	dc.SetFont(m_selectedFont);
	dc.GetTextExtent(caption, &selected_textx, &selected_texty);

	dc.SetFont(m_normalFont);
	dc.GetTextExtent(caption, &normal_textx, &normal_texty);

	bool bluetab = false;
	if (page.window->GetName() == "startpage")
		bluetab = true;

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

	wxCoord tab_height = m_tabCtrlHeight + 2;// -1;// -3;
	wxCoord tab_width = tab_size.x;
	wxCoord tab_x = in_rect.x;
	wxCoord tab_y = in_rect.y + in_rect.height - tab_height + 3;


	if (!page.active)
	{
		tab_height -= 2;
		tab_y += 2;
	}

	caption = page.caption;


	// select pen, brush and font for the tab to be drawn
	if (page.active)
	{
		dc.SetFont(m_selectedFont);
		texty = selected_texty;
	}
	else
	{
		dc.SetFont(m_normalFont);
		texty = normal_texty;
	}


	// create points that will make the tab outline
	int clip_width = tab_width;
	if (tab_x + clip_width > in_rect.x + in_rect.width)
		clip_width = (in_rect.x + in_rect.width) - tab_x;
	dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3);

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

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


	wxColour bgcol;
	if (page.active)
	{
		// draw active tab
		bgcol = m_activeColour;

		// draw base background color
		wxRect r(tab_x, tab_y, tab_width, tab_height);
		dc.SetPen(wxPen(bluetab ? wxColor(224, 238, 255) : m_activeColour));
		dc.SetBrush(wxBrush(bluetab ? wxColor(224, 238, 255) : m_activeColour));
		dc.DrawRectangle(r.x + 1, r.y + 1, r.width - 1, r.height - 5);

		// highlight top of tab
		wxColour col_hilight = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
		dc.SetPen(*wxTRANSPARENT_PEN);// *wxWHITE_PEN);
		dc.SetBrush(wxBrush(col_hilight));// *wxWHITE_BRUSH);
		dc.DrawRectangle(r.x + 1, r.y + 1, r.width - 1, 1);
	}
	else
	{
		bgcol = m_inactiveTabColour;

		wxRect r(tab_x, tab_y, tab_width, tab_height);
		wxPoint mouse = wnd->ScreenToClient(wxGetMousePosition());
		/*if (r.Contains(mouse))
		{
			dc.SetPen(wxPen(m_activeColour));
			dc.SetBrush(wxBrush(m_activeColour));
		}
		else
		{*/
			dc.SetPen(wxPen(m_inactiveTabColour));
			dc.SetBrush(wxBrush(m_inactiveTabColour));
		//}
		dc.DrawRectangle(r.x + 1, r.y + 1, r.width - 1, r.height - 4);
	}

	// draw tab outline
	dc.SetPen(m_borderPen);
	dc.SetBrush(*wxTRANSPARENT_BRUSH);
	dc.DrawPolygon(WXSIZEOF(border_points), border_points);

	// there are two horizontal grey lines at the bottom of the tab control,
	// this gets rid of the top one of those lines in the tab control
	if (page.active)
	{
		if (m_flags &wxAUI_NB_BOTTOM)
			dc.SetPen(wxPen(m_baseColour.ChangeLightness(170)));
		else
			dc.SetPen(wxPen(bluetab ? wxColor(224, 238, 255) : m_activeColour));
		dc.DrawLine(border_points[0].x + 1,
			border_points[0].y,
			border_points[5].x,
			border_points[5].y);
	}


	int text_offset = tab_x + 8;
	int close_button_width = 0;
	if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
	{
		close_button_width = m_activeCloseBmp.GetWidth();
	}

	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 += 4; // bitmap padding

	}
	else
	{
		text_offset = tab_x + 8;
	}

	dc.SetTextForeground((page.active && bluetab) ? wxColor(0,0,0) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
	wxString draw_text = wxAuiChopText(dc,
		caption,
		tab_width - (text_offset - tab_x) - close_button_width);

	// draw tab text
	dc.DrawText(draw_text,
		text_offset,
		drawn_tab_yoff + (drawn_tab_height) / 2 - (texty / 2) - 0);

	// draw focus rectangle
	if (page.active && (wnd->FindFocus() == wnd))
	{
		wxRect focusRectText(text_offset, (drawn_tab_yoff + (drawn_tab_height) / 2 - (texty / 2) - 1),
			selected_textx, selected_texty);

		wxRect focusRect;
		wxRect focusRectBitmap;

		if (page.bitmap.IsOk())
			focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height / 2) - (page.bitmap.GetHeight() / 2),
				page.bitmap.GetWidth(), page.bitmap.GetHeight());

		if (page.bitmap.IsOk() && draw_text.IsEmpty())
			focusRect = focusRectBitmap;
		else if (!page.bitmap.IsOk() && !draw_text.IsEmpty())
			focusRect = focusRectText;
		else if (page.bitmap.IsOk() && !draw_text.IsEmpty())
			focusRect = focusRectText.Union(focusRectBitmap);

		focusRect.Inflate(2, 2);

		wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0);
	}

	// draw close button if necessary
	if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
	{
		wxBitmap bmp = m_disabledCloseBmp;

		int offsetY = tab_y;
		if (m_flags & wxAUI_NB_BOTTOM)
			offsetY = 1;

		wxRect rect(tab_x + tab_width - close_button_width - 3,
			offsetY + (tab_height / 2) - (bmp.GetHeight() / 2),
			close_button_width,
			tab_height);

		IndentPressedBitmap(&rect, close_button_state);

		if (close_button_state == wxAUI_BUTTON_STATE_HOVER ||
			close_button_state == wxAUI_BUTTON_STATE_PRESSED)
		{
			/*wxColour bcol = m_borderPen.GetColour();
			float r = ((float)bcol.Red() * 0.2f) + ((float)m_activeColour.Red() * 0.8f);
			float g = ((float)bcol.Green() * 0.2f) + ((float)m_activeColour.Green() * 0.8f);
			float b = ((float)bcol.Blue() * 0.2f) + ((float)m_activeColour.Blue() * 0.8f);*/
			//captionAccentColour = wxColor(r, g, b);

			//dc.SetPen(*wxTRANSPARENT_PEN);
			dc.SetPen(wxPen(Drawing::darkColour(bgcol, 2.0f)));
			dc.SetBrush(wxBrush(Drawing::lightColour(bgcol, 1.0f)));
			dc.DrawRectangle(rect.x, rect.y + 1, rect.width - 1, rect.width - 2);

			bmp = m_activeCloseBmp;
			//dc.DrawBitmap(bmp, rect.x + 1, rect.y, true);
			//dc.DrawBitmap(bmp, rect.x - 1, rect.y, true);
			dc.DrawBitmap(bmp, rect.x, rect.y, true);
		}
		else
		{
			bmp = m_disabledCloseBmp;
			dc.DrawBitmap(bmp, rect.x, rect.y, true);
		}

		*out_button_rect = rect;
	}

	*out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height);

	dc.DestroyClippingRegion();
}
コード例 #30
0
ファイル: game.cpp プロジェクト: EdgarTx/wx
// Called when the left button is released after dragging a card
// Scan the piles to see if this card overlaps a pile and can be added
// to the pile. If the card overlaps more than one pile on which it can be placed
// then put it on the nearest pile.
void Game::LButtonUp(wxDC& dc, int x, int y)
{
    if (m_srcPile)
    {
        // work out the position of the dragged card
        x += m_xOffset;
        y += m_yOffset;

        Pile* nearestPile = 0;
        int distance = (CardHeight + CardWidth) * (CardHeight + CardWidth);

        // find the nearest pile which will accept the card
        int i;
        for (i = 0; i < 8; i++)
        {
            if (DropCard(x, y, m_foundations[i], m_liftedCard))
            {
                if (m_foundations[i]->CalcDistance(x, y) < distance)
                {
                    nearestPile = m_foundations[i];
                    distance = nearestPile->CalcDistance(x, y);
                }
            }
        }
        for (i = 0; i < 10; i++)
        {
            if (DropCard(x, y, m_bases[i], m_liftedCard))
            {
                if (m_bases[i]->CalcDistance(x, y) < distance)
                {
                    nearestPile = m_bases[i];
                    distance = nearestPile->CalcDistance(x, y);
                }
            }
        }

        // Restore the area under the card
        wxMemoryDC memoryDC;
        memoryDC.SelectObject(*m_bmap);
        dc.Blit(m_xPos, m_yPos, CardWidth, CardHeight,
               &memoryDC, 0, 0, wxCOPY);

        // Draw the card in its new position
        if (nearestPile)
        {
            // Add to new pile
            nearestPile->AddCard(dc, m_liftedCard);
            if (nearestPile != m_srcPile)
            {
                DoMove(dc, m_srcPile, nearestPile);
            }
        }
        else
        {
            // Return card to src pile
            m_srcPile->AddCard(dc, m_liftedCard);
        }
        m_srcPile = 0;
        m_liftedCard = 0;
    }
}