本文整理汇总了C++中wxDC::DrawLines方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::DrawLines方法的具体用法?C++ wxDC::DrawLines怎么用?C++ wxDC::DrawLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::DrawLines方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawTab
void wxAuiSimpleTabArt::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 textx, 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);
// 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 = tab_size.y;
wxCoord tab_width = tab_size.x;
wxCoord tab_x = in_rect.x;
wxCoord tab_y = in_rect.y + in_rect.height - tab_height;
caption = page.caption;
// select pen, brush and font for the tab to be drawn
if (page.active)
{
dc.SetPen(m_selectedBkPen);
dc.SetBrush(m_selectedBkBrush);
dc.SetFont(m_selectedFont);
textx = selected_textx;
texty = selected_texty;
}
else
{
dc.SetPen(m_normalBkPen);
dc.SetBrush(m_normalBkBrush);
dc.SetFont(m_normalFont);
textx = normal_textx;
texty = normal_texty;
}
// -- draw line --
wxPoint points[7];
points[0].x = tab_x;
points[0].y = tab_y + tab_height - 1;
points[1].x = tab_x + tab_height - 3;
points[1].y = tab_y + 2;
points[2].x = tab_x + tab_height + 3;
points[2].y = tab_y;
points[3].x = tab_x + tab_width - 2;
points[3].y = tab_y;
points[4].x = tab_x + tab_width;
points[4].y = tab_y + 2;
points[5].x = tab_x + tab_width;
points[5].y = tab_y + tab_height - 1;
points[6] = points[0];
dc.SetClippingRegion(in_rect);
dc.DrawPolygon(WXSIZEOF(points) - 1, points);
dc.SetPen(*wxGREY_PEN);
//dc.DrawLines(active ? WXSIZEOF(points) - 1 : WXSIZEOF(points), points);
dc.DrawLines(WXSIZEOF(points), points);
int text_offset;
int close_button_width = 0;
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
{
close_button_width = m_activeCloseBmp.GetWidth();
text_offset = tab_x + (tab_height/2) + ((tab_width-close_button_width)/2) - (textx/2);
}
else
{
text_offset = tab_x + (tab_height/3) + (tab_width/2) - (textx/2);
}
//.........这里部分代码省略.........
示例2: DrawTab
void wxRibbonAUIArtProvider::DrawTab(wxDC& dc,
wxWindow* WXUNUSED(wnd),
const wxRibbonPageTabInfo& tab)
{
if(tab.rect.height <= 1)
return;
dc.SetFont(m_tab_label_font);
dc.SetPen(*wxTRANSPARENT_PEN);
if(tab.active || tab.hovered)
{
if(tab.active)
{
dc.SetFont(m_tab_active_label_font);
dc.SetBrush(m_background_brush);
dc.DrawRectangle(tab.rect.x, tab.rect.y + tab.rect.height - 1,
tab.rect.width - 1, 1);
}
wxRect grad_rect(tab.rect);
grad_rect.height -= 4;
grad_rect.width -= 1;
grad_rect.height /= 2;
grad_rect.y = grad_rect.y + tab.rect.height - grad_rect.height - 1;
dc.SetBrush(m_tab_active_top_background_brush);
dc.DrawRectangle(tab.rect.x, tab.rect.y + 3, tab.rect.width - 1,
grad_rect.y - tab.rect.y - 3);
dc.GradientFillLinear(grad_rect, m_tab_active_background_colour,
m_tab_active_background_gradient_colour, wxSOUTH);
}
else
{
wxRect btm_rect(tab.rect);
btm_rect.height -= 4;
btm_rect.width -= 1;
btm_rect.height /= 2;
btm_rect.y = btm_rect.y + tab.rect.height - btm_rect.height - 1;
dc.SetBrush(m_tab_hover_background_brush);
dc.DrawRectangle(btm_rect.x, btm_rect.y, btm_rect.width,
btm_rect.height);
wxRect grad_rect(tab.rect);
grad_rect.width -= 1;
grad_rect.y += 3;
grad_rect.height = btm_rect.y - grad_rect.y;
dc.GradientFillLinear(grad_rect, m_tab_hover_background_top_colour,
m_tab_hover_background_top_gradient_colour, wxSOUTH);
}
wxPoint border_points[5];
border_points[0] = wxPoint(0, 3);
border_points[1] = wxPoint(1, 2);
border_points[2] = wxPoint(tab.rect.width - 3, 2);
border_points[3] = wxPoint(tab.rect.width - 1, 4);
border_points[4] = wxPoint(tab.rect.width - 1, tab.rect.height - 1);
dc.SetPen(m_tab_border_pen);
dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y);
wxRect old_clip;
dc.GetClippingBox(old_clip);
bool is_first_tab = false;
wxRibbonBar* bar = wxDynamicCast(tab.page->GetParent(), wxRibbonBar);
if(bar && bar->GetPage(0) == tab.page)
is_first_tab = true;
wxBitmap icon;
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
{
icon = tab.page->GetIcon();
if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0)
{
if(icon.IsOk())
{
int x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2;
dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 -
icon.GetHeight()) / 2, true);
}
}
}
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
{
wxString label = tab.page->GetLabel();
if(!label.IsEmpty())
{
dc.SetTextForeground(m_tab_label_colour);
dc.SetBackgroundMode(wxTRANSPARENT);
int offset = 0;
if(icon.IsOk())
offset += icon.GetWidth() + 2;
int text_height;
int text_width;
dc.GetTextExtent(label, &text_width, &text_height);
int x = (tab.rect.width - 2 - text_width - offset) / 2;
if(x > 8)
x = 8;
else if(x < 1)
x = 1;
int width = tab.rect.width - x - 2;
x += tab.rect.x + offset;
int y = tab.rect.y + (tab.rect.height - text_height) / 2;
//.........这里部分代码省略.........
示例3: OnDraw
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
// vars to use ...
#if wxUSE_STATUSBAR
wxString s;
#endif // wxUSE_STATUSBAR
wxPen wP;
wxBrush wB;
wxPoint points[6];
wxColour wC;
wxFont wF;
dc.SetFont(*wxSWISS_FONT);
dc.SetPen(*wxGREEN_PEN);
switch (m_index)
{
default:
case 0:
// draw lines to make a cross
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
// draw point colored line and spline
wP = *wxCYAN_PEN;
wP.SetWidth(3);
dc.SetPen(wP);
dc.DrawPoint (25,15);
dc.DrawLine(50, 30, 200, 30);
dc.DrawSpline(50, 200, 50, 100, 200, 10);
#if wxUSE_STATUSBAR
s = wxT("Green Cross, Cyan Line and spline");
#endif // wxUSE_STATUSBAR
break;
case 1:
// draw standard shapes
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
dc.DrawRectangle(10, 10, 100, 70);
wB = wxBrush (wxT("DARK ORCHID"), wxBRUSHSTYLE_TRANSPARENT);
dc.SetBrush (wB);
dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
dc.SetBrush (wxBrush(wxT("GOLDENROD")) );
dc.DrawEllipse(100, 100, 100, 50);
points[0].x = 100; points[0].y = 200;
points[1].x = 70; points[1].y = 260;
points[2].x = 160; points[2].y = 230;
points[3].x = 40; points[3].y = 230;
points[4].x = 130; points[4].y = 260;
points[5].x = 100; points[5].y = 200;
dc.DrawPolygon(5, points);
dc.DrawLines (6, points, 160);
#if wxUSE_STATUSBAR
s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
#endif // wxUSE_STATUSBAR
break;
case 2:
// draw text in Arial or similar font
dc.DrawLine(50,25,50,35);
dc.DrawLine(45,30,55,30);
dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
wC = dc.GetTextForeground();
dc.SetTextForeground (wxT("FIREBRICK"));
// no effect in msw ??
dc.SetTextBackground (wxT("WHEAT"));
dc.DrawText(wxT("This is a Red string"), 50, 200);
dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45);
dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90);
wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
dc.SetFont(wF);
dc.SetTextForeground (wC);
dc.DrawText(wxT("This is a Times-style string"), 50, 60);
#if wxUSE_STATUSBAR
s = wxT("Swiss, Times text; red text, rotated and colored orange");
#endif // wxUSE_STATUSBAR
break;
case 3 :
// four arcs start and end points, center
dc.SetBrush(*wxGREEN_BRUSH);
dc.DrawArc ( 200,300, 370,230, 300,300 );
dc.SetBrush(*wxBLUE_BRUSH);
dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
dc.SetDeviceOrigin(-10,-10);
dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
dc.SetDeviceOrigin(0,0);
wP.SetColour (wxT("CADET BLUE"));
dc.SetPen(wP);
dc.DrawArc ( 75,125, 110, 40, 75, 75 );
wP.SetColour (wxT("SALMON"));
dc.SetPen(wP);
dc.SetBrush(*wxRED_BRUSH);
//.........这里部分代码省略.........
示例4: Draw
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())
{
//.........这里部分代码省略.........
示例5: ShowModeSprShow_DrawHelper
void ShowModeSprShow_DrawHelper(wxDC& dc, const CalChartConfiguration& config, const ShowModeSprShow& mode, HowToDraw howToDraw)
{
wxPoint points[2];
CC_coord fieldsize = mode.FieldSize();
// Draw vertical lines
for (Coord j = 0; j <= fieldsize.x; j+=Int2Coord(8))
{
// draw solid yardlines
points[0] = wxPoint(j, 0);
points[1] = wxPoint(j, fieldsize.y);
dc.DrawLines(2, points, mode.Border1().x, mode.Border1().y);
}
for (Coord j = Int2Coord(4); (howToDraw == ShowMode_kFieldView || howToDraw == ShowMode_kPrinting) && j < fieldsize.x; j += Int2Coord(8))
{
// draw mid-dotted lines
for (Coord k = 0; k < fieldsize.y; k += Int2Coord(2))
{
points[0] = wxPoint(j, k);
points[1] = wxPoint(j, k + Int2Coord(1));
dc.DrawLines(2, points, mode.Border1().x, mode.Border1().y);
}
}
// Draw horizontal lines
for (Coord j = 0; j <= fieldsize.y; j+=Int2Coord(8))
{
// draw solid yardlines
points[0] = wxPoint(0, j);
points[1] = wxPoint(fieldsize.x, j);
dc.DrawLines(2, points, mode.Border1().x, mode.Border1().y);
}
// Draw horizontal mid-dotted lines
for (Coord j = Int2Coord(4); (howToDraw == ShowMode_kFieldView || howToDraw == ShowMode_kPrinting) && j <= fieldsize.y; j += Int2Coord(8))
{
for (Coord k = 0; k < fieldsize.x; k += Int2Coord(2))
{
points[0] = wxPoint(k, j);
points[1] = wxPoint(k + Int2Coord(1), j);
dc.DrawLines(2, points, mode.Border1().x, mode.Border1().y);
}
}
// Draw labels
wxFont *yardLabelFont = wxTheFontList->FindOrCreateFont((int)Float2Coord(config.Get_YardsSize()),
wxSWISS, wxNORMAL, wxNORMAL);
dc.SetFont(*yardLabelFont);
for (int i = 0; (howToDraw == ShowMode_kFieldView || howToDraw == ShowMode_kPrinting) && i < Coord2Int(fieldsize.x)/8+1; i++)
{
wxCoord textw, texth, textd;
dc.GetTextExtent(config.Get_yard_text(i+(mode.StepsX()+(kYardTextValues-1)*4)/8), &textw, &texth, &textd);
if (mode.WhichYards() & SPR_YARD_ABOVE)
dc.DrawText(config.Get_yard_text(i+(mode.StepsX()+(kYardTextValues-1)*4)/8), Int2Coord(i*8) - textw/2 + mode.Border1().x, mode.Border1().y - texth);
if (mode.WhichYards() & SPR_YARD_BELOW)
dc.DrawText(config.Get_yard_text(i+(mode.StepsX()+(kYardTextValues-1)*4)/8), Int2Coord(i*8) - textw/2 + mode.Border1().x, mode.FieldSize().y + mode.Border1().y);
}
for (int i = 0; (howToDraw == ShowMode_kFieldView || howToDraw == ShowMode_kPrinting) && i <= Coord2Int(fieldsize.y); i+=8)
{
wxCoord textw, texth, textd;
dc.GetTextExtent(config.Get_spr_line_text(i/8), &textw, &texth, &textd);
if (mode.WhichYards() & SPR_YARD_LEFT)
dc.DrawText(config.Get_spr_line_text(i/8), mode.Border1().x - textw, mode.Border1().y - texth/2 + Int2Coord(i));
if (mode.WhichYards() & SPR_YARD_RIGHT)
dc.DrawText(config.Get_spr_line_text(i/8), fieldsize.x + mode.Border1().x, mode.Border1().y - texth/2 + Int2Coord(i));
}
}
示例6: ShowModeStandard_DrawHelper
void ShowModeStandard_DrawHelper(wxDC& dc, const CalChartConfiguration& config, const ShowModeStandard& mode, HowToDraw howToDraw)
{
wxPoint points[5];
auto fieldsize = mode.FieldSize();
CC_coord border1 = mode.Border1();
if (howToDraw == ShowMode_kOmniView)
{
border1 = CC_coord(0, 0);
}
auto offsetx = 0;//-fieldsize.x/2;
auto offsety = 0;//-fieldsize.y/2;
auto borderoffsetx = 0;//-border1.x;
auto borderoffsety = 0;//-border1.y;
points[0] = wxPoint(0+offsetx, 0+offsety);
points[1] = wxPoint(fieldsize.x+offsetx, 0+offsety);
points[2] = wxPoint(fieldsize.x+offsetx, fieldsize.y+offsety);
points[3] = wxPoint(0+offsetx, fieldsize.y+offsety);
points[4] = points[0];
// Draw outline
dc.DrawLines(5, points, border1.x+borderoffsetx, border1.y+borderoffsety);
// Draw vertical lines
for (Coord j = Int2Coord(8)+offsetx; j < fieldsize.x+offsetx; j += Int2Coord(8))
{
// draw solid yardlines
points[0] = wxPoint(j, 0+offsety);
points[1] = wxPoint(j, fieldsize.y+offsety);
dc.DrawLines(2, points, border1.x+borderoffsetx, border1.y+borderoffsety);
}
for (Coord j = Int2Coord(4)+offsetx; (howToDraw == ShowMode_kFieldView || howToDraw == ShowMode_kPrinting) && j < fieldsize.x+offsetx; j += Int2Coord(8))
{
// draw mid-dotted lines
for (Coord k = 0+offsety; k < fieldsize.y+offsety; k += Int2Coord(2))
{
points[0] = wxPoint(j, k);
points[1] = wxPoint(j, k + Int2Coord(1));
dc.DrawLines(2, points, border1.x+borderoffsetx, border1.y+borderoffsety);
}
}
// Draw horizontal mid-dotted lines
for (Coord j = Int2Coord(4)+offsety; (howToDraw == ShowMode_kFieldView || howToDraw == ShowMode_kPrinting) && j < fieldsize.y+offsety; j += Int2Coord(4))
{
if ((j == Int2Coord(mode.HashW())) || j == Int2Coord(mode.HashE()))
continue;
for (Coord k = 0+offsetx; k < fieldsize.x+offsetx; k += Int2Coord(2))
{
points[0] = wxPoint(k, j);
points[1] = wxPoint(k + Int2Coord(1), j);
dc.DrawLines(2, points, border1.x+borderoffsetx, border1.y+borderoffsety);
}
}
// Draw hashes
for (Coord j = Int2Coord(0)+offsetx; j < fieldsize.x+offsetx; j += Int2Coord(8))
{
points[0] = wxPoint(j+Float2Coord(0.0*8), Int2Coord(mode.HashW()));
points[1] = wxPoint(j+Float2Coord(0.1*8), Int2Coord(mode.HashW()));
dc.DrawLines(2, points, border1.x+borderoffsetx, border1.y+borderoffsety);
points[0] = wxPoint(j+Float2Coord(0.9*8), Int2Coord(mode.HashW()));
points[1] = wxPoint(j+Float2Coord(1.0*8), Int2Coord(mode.HashW()));
dc.DrawLines(2, points, border1.x+borderoffsetx, border1.y+borderoffsety);
points[0] = wxPoint(j+Float2Coord(0.0*8), Int2Coord(mode.HashE()));
points[1] = wxPoint(j+Float2Coord(0.1*8), Int2Coord(mode.HashE()));
dc.DrawLines(2, points, border1.x+borderoffsetx, border1.y+borderoffsety);
points[0] = wxPoint(j+Float2Coord(0.9*8), Int2Coord(mode.HashE()));
points[1] = wxPoint(j+Float2Coord(1.0*8), Int2Coord(mode.HashE()));
dc.DrawLines(2, points, border1.x+borderoffsetx, border1.y+borderoffsety);
for (size_t midhash = 1; (howToDraw == ShowMode_kFieldView || howToDraw == ShowMode_kPrinting) && midhash < 5; ++midhash)
{
points[0] = wxPoint(j+Float2Coord(midhash/5.0*8), Int2Coord(mode.HashW()));
points[1] = wxPoint(j+Float2Coord(midhash/5.0*8), Float2Coord(mode.HashW()-(0.2*8)));
dc.DrawLines(2, points, border1.x+borderoffsetx, border1.y+borderoffsety);
points[0] = wxPoint(j+Float2Coord(midhash/5.0*8), Int2Coord(mode.HashE()));
points[1] = wxPoint(j+Float2Coord(midhash/5.0*8), Float2Coord(mode.HashE()+(0.2*8)));
dc.DrawLines(2, points, border1.x+borderoffsetx, border1.y+borderoffsety);
}
}
// Draw labels
wxFont *yardLabelFont = wxTheFontList->FindOrCreateFont((int)Float2Coord(config.Get_YardsSize()),
wxSWISS, wxNORMAL, wxNORMAL);
dc.SetFont(*yardLabelFont);
for (int i = 0; (howToDraw == ShowMode_kFieldView || howToDraw == ShowMode_kOmniView || howToDraw == ShowMode_kPrinting) && i < Coord2Int(fieldsize.x)/8+1; i++)
{
CC_coord fieldedge = mode.Offset() - mode.Border1();
wxCoord textw, texth, textd;
auto text = config.Get_yard_text(i+(-Coord2Int(fieldedge.x)+(kYardTextValues-1)*4)/8);
dc.GetTextExtent(text, &textw, &texth, &textd);
dc.DrawText(text, offsetx + Int2Coord(i*8) - textw/2 + border1.x+borderoffsetx, border1.y+borderoffsety - offsety - texth + ((howToDraw == ShowMode_kOmniView) ? Int2Coord(8) : 0));
dc.DrawText(text, offsetx + Int2Coord(i*8) - textw/2 + border1.x+borderoffsetx, border1.y+borderoffsety + fieldsize.y-offsety - ((howToDraw == ShowMode_kOmniView) ? Int2Coord(8) : 0));
}
}
示例7: OnDraw
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
// vars to use ...
#if wxUSE_STATUSBAR
wxString s ;
#endif // wxUSE_STATUSBAR
wxPen wP ;
wxBrush wB ;
wxPoint points[6];
wxColour wC;
wxFont wF ;
dc.SetFont(*wxSWISS_FONT);
dc.SetPen(*wxGREEN_PEN);
switch (m_index)
{
default:
case 0:
// draw lines to make a cross
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
// draw point colored line and spline
wP = *wxCYAN_PEN ;
wP.SetWidth(3);
dc.SetPen(wP);
dc.DrawPoint (25,15) ;
dc.DrawLine(50, 30, 200, 30);
dc.DrawSpline(50, 200, 50, 100, 200, 10);
#if wxUSE_STATUSBAR
s = wxT("Green Cross, Cyan Line and spline");
#endif // wxUSE_STATUSBAR
break ;
case 1:
// draw standard shapes
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
dc.DrawRectangle(10, 10, 100, 70);
wB = wxBrush (_T("DARK ORCHID"), wxTRANSPARENT);
dc.SetBrush (wB);
dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
dc.SetBrush (wxBrush(_T("GOLDENROD"), wxSOLID) );
dc.DrawEllipse(100, 100, 100, 50);
points[0].x = 100; points[0].y = 200;
points[1].x = 70; points[1].y = 260;
points[2].x = 160; points[2].y = 230;
points[3].x = 40; points[3].y = 230;
points[4].x = 130; points[4].y = 260;
points[5].x = 100; points[5].y = 200;
dc.DrawPolygon(5, points);
dc.DrawLines (6, points, 160);
#if wxUSE_STATUSBAR
s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
#endif // wxUSE_STATUSBAR
break ;
case 2:
// draw text in Arial or similar font
dc.DrawLine(50,25,50,35);
dc.DrawLine(45,30,55,30);
dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
wC = dc.GetTextForeground() ;
dc.SetTextForeground (_T("FIREBRICK"));
// no effect in msw ??
dc.SetTextBackground (_T("WHEAT"));
dc.DrawText(wxT("This is a Red string"), 50, 200);
dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45);
dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90);
wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
dc.SetFont(wF);
dc.SetTextForeground (wC) ;
dc.DrawText(wxT("This is a Times-style string"), 50, 60);
#if wxUSE_STATUSBAR
s = wxT("Swiss, Times text; red text, rotated and colored orange");
#endif // wxUSE_STATUSBAR
break ;
case 3 :
// four arcs start and end points, center
dc.SetBrush(*wxGREEN_BRUSH);
dc.DrawArc ( 200,300, 370,230, 300,300 );
dc.SetBrush(*wxBLUE_BRUSH);
dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
dc.SetDeviceOrigin(-10,-10);
dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
dc.SetDeviceOrigin(0,0);
wP.SetColour (_T("CADET BLUE"));
dc.SetPen(wP);
dc.DrawArc ( 75,125, 110, 40, 75, 75 );
wP.SetColour (_T("SALMON"));
dc.SetPen(wP);
//.........这里部分代码省略.........
示例8: DrawTab
void wxRibbonMetroArtProvider::DrawTab(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRibbonPageTabInfo& tab)
{
if(tab.rect.height <= 2) return;
if(tab.active || tab.hovered) {
if(tab.active) {
wxRect background(tab.rect);
background.x += 2;
background.y += 1;
background.width -= 3;
background.height -= 1;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(m_tab_active_background_colour);
dc.DrawRectangle(background);
// TODO: active and hovered
} else if(tab.hovered) {
wxRect background(tab.rect);
background.x += 2;
background.y += 1;
background.width -= 3;
background.height -= 2;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(m_tab_hover_background_colour);
dc.DrawRectangle(background);
}
wxPoint border_points[4];
border_points[0] = wxPoint(1, tab.rect.height - 2);
border_points[1] = wxPoint(1, 0);
border_points[2] = wxPoint(tab.rect.width - 1, 0);
border_points[3] = wxPoint(tab.rect.width - 1, tab.rect.height - 1);
if(tab.active)
dc.SetPen(m_tab_border_pen);
else
dc.SetPen(m_tab_border_pen); // TODO: introduce hover border pen colour
dc.DrawLines(sizeof(border_points) / sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y);
}
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) {
wxBitmap icon = tab.page->GetIcon();
if(icon.IsOk()) {
int x = tab.rect.x + 4;
if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2;
dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - icon.GetHeight()) / 2, true);
}
}
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) {
wxString label = tab.page->GetLabel();
if(!label.IsEmpty()) {
dc.SetFont(m_tab_label_font);
dc.SetTextForeground(m_tab_label_colour);
dc.SetBackgroundMode(wxTRANSPARENT);
int text_height;
int text_width;
dc.GetTextExtent(label, &text_width, &text_height);
int width = tab.rect.width - 5;
int x = tab.rect.x + 3;
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) {
x += 3 + tab.page->GetIcon().GetWidth();
width -= 3 + tab.page->GetIcon().GetWidth();
}
int y = tab.rect.y + (tab.rect.height - text_height) / 2;
if(width <= text_width) {
dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height);
dc.DrawText(label, x, y);
} else {
dc.DrawText(label, x + (width - text_width) / 2 + 1, y);
}
}
}
}