本文整理汇总了C++中wxDC::DrawPolygon方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::DrawPolygon方法的具体用法?C++ wxDC::DrawPolygon怎么用?C++ wxDC::DrawPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::DrawPolygon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawTab
//.........这里部分代码省略.........
wxRect r(tab_x, tab_y+1, tab_width, tab_height-3);
// start the gradent up a bit and leave the inside border inset
// by a pixel for a 3D look. Only the top half of the inactive
// tab will have a slight gradient
r.x += 3;
r.y++;
r.width -= 4;
r.height /= 2;
r.height--;
// -- draw top gradient fill for glossy look
wxColor top_color = m_base_colour;
wxColor bottom_color = gdAuiStepColour(top_color, 160);
dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH);
r.y += r.height;
r.y--;
// -- draw bottom fill for glossy look
top_color = m_base_colour;
bottom_color = m_base_colour;
dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH);
// Adapt text color
int average = (m_base_colour.Red()+m_base_colour.Green()+m_base_colour.Blue())/3;
if (average < 127) dc.SetTextForeground(*wxWHITE);
else dc.SetTextForeground(*wxBLACK);
}
// draw tab outline
dc.SetPen(m_border_pen);
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(wxColour(gdAuiStepColour(m_base_colour, 170))));
// else if (m_flags &wxAUI_NB_LEFT) {}
// else if (m_flags &wxAUI_NB_RIGHT) {}
else //for wxAUI_NB_TOP
dc.SetPen(m_base_colour_pen);
//Game Develop use white pen so as to conform to white background
dc.SetPen(*wxWHITE_PEN);
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_active_close_bmp.GetWidth();
}
int bitmap_offset = 0;
if (page.bitmap.IsOk())
{
示例2: Polygon
void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
BrushColour(back);
hdc->DrawPolygon(npts, (wxPoint*)pts);
}
示例3: Draw
void LabelTrack::Draw(wxDC & dc, wxRect & r, double h, double pps,
double sel0, double sel1)
{
double right = h + r.width / pps;
double dsel0 = sel0;
if (dsel0 < h)
dsel0 = h;
if (dsel0 > right)
dsel0 = right;
double dsel1 = sel1;
if (dsel1 < h)
dsel1 = h;
if (dsel1 > right)
dsel1 = right;
wxRect before = r;
before.width = int ((dsel0 - h) * pps);
dc.SetBrush(mUnselectedBrush);
dc.SetPen(mUnselectedPen);
dc.DrawRectangle(before);
wxRect selr = r;
selr.x += before.width;
selr.width = int ((dsel1 - dsel0) * pps);
dc.SetBrush(mSelectedBrush);
dc.SetPen(mSelectedPen);
dc.DrawRectangle(selr);
wxRect after = r;
after.x += (before.width + selr.width);
after.width -= (before.width + selr.width);
if (after.x < r.x) {
after.width -= (r.x - after.x);
after.x = r.x;
}
dc.SetBrush(mUnselectedBrush);
dc.SetPen(mUnselectedPen);
dc.DrawRectangle(after);
dc.SetBrush(mFlagBrush);
dc.SetPen(mFlagPen);
int nextx = 0;
for (int i = 0; i < (int)mLabels.Count(); i++) {
int x = r.x + (int) ((mLabels[i]->t - h) * pps);
int y = r.y;
int height = r.height;
if (x >= r.x && x < r.x + r.width) {
if (x < nextx && i != mSelIndex) {
// Draw flag obscured by the previous label
dc.DrawLine(x, y, x, y + 2);
dc.DrawLine(x, y + height - 2, x, y + height);
mLabels[i]->width = 0;
} else {
// Draw the flag and label
wxPoint tri[3];
tri[0].x = x;
tri[0].y = y;
tri[1].x = x - 8;
tri[1].y = y + 4;
tri[2].x = x;
tri[2].y = y + 8;
if (mSelIndex == i)
dc.SetBrush(*wxWHITE_BRUSH);
dc.DrawPolygon(3, tri);
if (mSelIndex == i)
dc.SetBrush(mFlagBrush);
dc.DrawLine(x, y, x, y + height);
dc.SetTextForeground(wxColour(204, 0, 0));
#ifdef __WXMAC__
long textWidth, textHeight;
#else
int textWidth, textHeight;
#endif
dc.GetTextExtent(mLabels[i]->title, &textWidth, &textHeight);
dc.DrawText(mLabels[i]->title, x + 4, y + 4);
if (i == mSelIndex) {
wxRect outline;
outline.x = x + 2;
outline.y = y + 2;
outline.width = textWidth + 4;
outline.height = height - 4;
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(outline);
dc.SetBrush(mFlagBrush);
//.........这里部分代码省略.........
示例4: DrawControlGroupBox
static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
{
switch (g->control_group->type)
{
case GROUP_TYPE_TILT :
case GROUP_TYPE_STICK :
case GROUP_TYPE_CURSOR :
{
// this is starting to be a mess combining all these in one case
ControlState x = 0, y = 0, z = 0;
switch (g->control_group->type)
{
case GROUP_TYPE_STICK :
((ControllerEmu::AnalogStick*)g->control_group)->GetState(&x, &y);
break;
case GROUP_TYPE_TILT :
((ControllerEmu::Tilt*)g->control_group)->GetState(&x, &y);
break;
case GROUP_TYPE_CURSOR :
((ControllerEmu::Cursor*)g->control_group)->GetState(&x, &y, &z);
break;
}
// ir cursor forward movement
if (GROUP_TYPE_CURSOR == g->control_group->type)
{
if (z)
{
dc.SetPen(*wxRED_PEN);
dc.SetBrush(*wxRED_BRUSH);
}
else
{
dc.SetPen(*wxGREY_PEN);
dc.SetBrush(*wxGREY_BRUSH);
}
dc.DrawRectangle(0, 31 - z*31, 64, 2);
}
// octagon for visual aid for diagonal adjustment
dc.SetPen(*wxLIGHT_GREY_PEN);
dc.SetBrush(*wxWHITE_BRUSH);
if (GROUP_TYPE_STICK == g->control_group->type)
{
// outline and fill colors
wxBrush LightGrayBrush("#dddddd");
wxPen LightGrayPen("#bfbfbf");
dc.SetBrush(LightGrayBrush);
dc.SetPen(LightGrayPen);
// polygon offset
ControlState max
, diagonal
, box = 64
, d_of = box / 256.0
, x_of = box / 2.0;
if (g->control_group->name == "Main Stick")
{
max = (87.0 / 127.0) * 100;
diagonal = (55.0 / 127.0) * 100;
}
else if (g->control_group->name == "C-Stick")
{
max = (74.0 / 127.0) * 100;
diagonal = (46.0 / 127.0) * 100;
}
else
{
max = (82.0 / 127.0) * 100;
diagonal = (58.0 / 127.0) * 100;
}
// polygon corners
wxPoint Points[8];
Points[0].x = (int)(0.0 * d_of + x_of); Points[0].y = (int)(max * d_of + x_of);
Points[1].x = (int)(diagonal * d_of + x_of); Points[1].y = (int)(diagonal * d_of + x_of);
Points[2].x = (int)(max * d_of + x_of); Points[2].y = (int)(0.0 * d_of + x_of);
Points[3].x = (int)(diagonal * d_of + x_of); Points[3].y = (int)(-diagonal * d_of + x_of);
Points[4].x = (int)(0.0 * d_of + x_of); Points[4].y = (int)(-max * d_of + x_of);
Points[5].x = (int)(-diagonal * d_of + x_of); Points[5].y = (int)(-diagonal * d_of + x_of);
Points[6].x = (int)(-max * d_of + x_of); Points[6].y = (int)(0.0 * d_of + x_of);
Points[7].x = (int)(-diagonal * d_of + x_of); Points[7].y = (int)(diagonal * d_of + x_of);
// draw polygon
dc.DrawPolygon(8, Points);
}
else
{
dc.DrawRectangle(16, 16, 32, 32);
}
if (GROUP_TYPE_CURSOR != g->control_group->type)
{
// deadzone circle
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
dc.DrawCircle(32, 32, g->control_group->settings[SETTING_DEADZONE]->value * 32);
}
//.........这里部分代码省略.........
示例5: Draw
void clTabRendererCurved::Draw(wxDC& dc, const clTabInfo& tabInfo, const clTabColours& colours, size_t style)
{
const int TOP_SMALL_HEIGHT = 0;
wxColour bgColour(tabInfo.IsActive() ? colours.activeTabBgColour : colours.inactiveTabBgColour);
wxColour penColour(tabInfo.IsActive() ? colours.activeTabPenColour : colours.inactiveTabPenColour);
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
dc.SetTextForeground(tabInfo.IsActive() ? colours.activeTabTextColour : colours.inactiveTabTextColour);
dc.SetFont(font);
if(style & kNotebook_BottomTabs) {
// Bottom tabs
{
wxPoint points[6];
points[0] = tabInfo.m_rect.GetTopLeft();
points[1].x = points[0].x + majorCurveWidth;
points[1].y = tabInfo.m_rect.GetBottomLeft().y - TOP_SMALL_HEIGHT;
points[2].x = points[1].x + smallCurveWidth;
points[2].y = points[1].y + TOP_SMALL_HEIGHT;
points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - (majorCurveWidth + smallCurveWidth));
points[3].y = points[2].y;
points[4].x = points[3].x + smallCurveWidth;
points[4].y = points[1].y;
points[5] = tabInfo.m_rect.GetTopRight();
dc.SetPen(penColour);
dc.SetBrush(bgColour);
dc.DrawPolygon(6, points);
}
{
wxPoint points[6];
points[0] = tabInfo.m_rect.GetTopLeft();
points[0].x += 1;
points[1].x = points[0].x + majorCurveWidth;
points[1].y = tabInfo.m_rect.GetBottomLeft().y - TOP_SMALL_HEIGHT - 1;
points[2].x = points[1].x + smallCurveWidth;
points[2].y = points[1].y + TOP_SMALL_HEIGHT;
points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - 2 - (majorCurveWidth + smallCurveWidth));
points[3].y = points[2].y;
points[4].x = points[3].x + smallCurveWidth;
points[4].y = points[1].y;
points[5] = tabInfo.m_rect.GetTopRight();
points[5].x -= 2;
dc.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour);
dc.SetBrush(bgColour);
dc.DrawPolygon(6, points);
}
} else if(IS_VERTICAL_TABS(style)) {
// Left side tabs
wxRect rotatedRect(0, 0, tabInfo.m_rect.GetHeight(), tabInfo.m_rect.GetWidth());
wxBitmap b(rotatedRect.GetSize());
wxMemoryDC tmpDC(b);
tmpDC.SetPen(colours.tabAreaColour);
tmpDC.SetBrush(colours.tabAreaColour);
tmpDC.DrawRectangle(rotatedRect);
tmpDC.SetFont(font);
tmpDC.SetTextForeground(tabInfo.IsActive() ? colours.activeTabTextColour : colours.inactiveTabTextColour);
tmpDC.SetPen(penColour);
tmpDC.SetBrush(bgColour);
if(tabInfo.IsActive()) {
{
wxPoint points[6];
points[0] = rotatedRect.GetBottomLeft();
points[1].x = points[0].x + majorCurveWidth;
points[1].y = rotatedRect.GetLeftTop().y + TOP_SMALL_HEIGHT;
points[2].x = points[1].x + smallCurveWidth;
points[2].y = points[1].y - TOP_SMALL_HEIGHT;
points[3].x = points[0].x + (rotatedRect.GetWidth() - (majorCurveWidth + smallCurveWidth));
points[3].y = points[2].y;
points[4].x = points[3].x + smallCurveWidth;
points[4].y = points[3].y + TOP_SMALL_HEIGHT;
points[5] = rotatedRect.GetBottomRight();
tmpDC.SetPen(penColour);
tmpDC.SetBrush(bgColour);
tmpDC.DrawPolygon(6, points);
}
{
wxPoint points[6];
points[0] = rotatedRect.GetBottomLeft();
points[0].x += 1;
//.........这里部分代码省略.........
示例6: DrawTab
//.........这里部分代码省略.........
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];
*/
// -- 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 - 3;
points[3].y = tab_y;
points[4].x = tab_x + tab_width + 3;
points[4].y = tab_y + 2;
points[5].x = tab_x + tab_width + tab_height;
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);
if (page.active)
{
dc.SetPen(*wxBLACK_PEN);
}
else
{
dc.SetPen(*wxBLACK_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);
}
// set minimum text offset
if (text_offset < tab_x + tab_height)
示例7: draw
//void simple_vector_layer::Draw(wxDC &dc, wxCoord x, wxCoord y, bool transparent, double zoomFactor, double translationX, double translationY, double resolution) const
void simple_vector_layer::draw(wxDC &dc, wxCoord x, wxCoord y, bool transparent) const
{
wxPen pen;
wxBrush brush;
// 2D
pen.SetWidth(m_polygon_border_width);
pen.SetColour(m_polygon_border_color);
pen.SetStyle(m_polygon_border_style);
brush.SetColour(m_polygon_inner_color);
brush.SetStyle(m_polygon_inner_style);
dc.SetPen(pen);
dc.SetBrush(brush);
for (unsigned int i = 0; i < m_circles.size(); i++)
{
wxPoint p = transform().from_local_int(m_circles[i]);
wxCoord r = static_cast<wxCoord>(m_circles[i].radius / transform().zoom_factor());
dc.DrawCircle(p, r);
}
// Ellipses alignees
for (unsigned int i=0;i<m_ellipses.size();++i)
{
wxPoint p = transform().from_local_int(m_ellipses[i]);
wxSize s(
static_cast<wxCoord>(2*m_ellipses[i].a/transform().zoom_factor()),
static_cast<wxCoord>(2*m_ellipses[i].b/transform().zoom_factor())
);
dc.DrawEllipse(p,s);
//dc.DrawEllipticArc(p,s,0.,90.);
//dc.DrawEllipticArcRot(p,s,0.,90.);
}
// Ellipses non alignees
for (unsigned int i=0;i<m_rotatedellipses.size();++i)
{
std::vector<wxPoint> points;
points.reserve( m_rotatedellipses[i].controlPoints.size() );
for (unsigned int j=0;j<m_rotatedellipses[i].controlPoints.size();++j)
points.push_back(transform().from_local_int(m_rotatedellipses[i].controlPoints[j]));
dc.DrawSpline(static_cast<int>(points.size()),&points.front());
}
for (unsigned int i=0;i<m_polygons.size();++i)
{
std::vector<wxPoint> points;
points.reserve( m_polygons[i].size() );
for (unsigned int j=0;j<m_polygons[i].size();++j)
points.push_back(transform().from_local_int(m_polygons[i][j]));
dc.DrawPolygon( static_cast<int>(points.size()) , &(points.front()) );
}
// 1D
pen.SetColour(m_line_color);
pen.SetWidth(m_line_width);
pen.SetStyle(m_line_style);
dc.SetPen(pen);
for (unsigned int i = 0; i < m_arcs.size(); i++)
{
const arc_type &local_tab = m_arcs[i];
for (unsigned int j = 0; j < local_tab.arc_points.size() - 1; ++j)
{
wxPoint p = transform().from_local_int(local_tab.arc_points[j ]);
wxPoint q = transform().from_local_int(local_tab.arc_points[j+1]);
dc.DrawLine(p,q);
}
}
// Splines
for (unsigned int i=0;i<m_splines.size();++i)
{
const spline_type& spline = m_splines[i];
std::vector<wxPoint> points;
unsigned int n = static_cast<int>(spline.size());
for (unsigned int j=0;j<n;++j)
{
wxPoint p = transform().from_local_int(spline[j]);
points.push_back(p);
}
dc.DrawSpline(n,&points.front());
}
// 0D
pen.SetColour(m_point_color);
pen.SetWidth(m_point_width);
dc.SetPen(pen);
for (unsigned int i = 0; i < m_points.size(); i++)
{
wxPoint p = transform().from_local_int(m_points[i]);
//dc.DrawLine(p);
dc.DrawPoint(p);
}
// Text
if(text_visibility())
{
pen.SetColour(m_text_color);
dc.SetPen(pen);
for (unsigned int i = 0; i < m_texts.size(); i++)
{
wxPoint p = transform().from_local_int(m_texts[i].first);
//dc.DrawLine(p);
dc.DrawText(wxString(m_texts[i].second.c_str(),*wxConvCurrent),p);
//.........这里部分代码省略.........
示例8: Draw
void wxGridCellChoiceRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
const wxRect& rectCell, int row, int col, bool isSelected)
{
wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected);
// first calculate button size
// don't draw outside the cell
int nButtonWidth = 17;
if (rectCell.height < 2) return;
wxRect rectButton;
rectButton.x = rectCell.x + rectCell.width - nButtonWidth;
rectButton.y = rectCell.y + 1;
int cell_rows, cell_cols;
attr.GetSize(&cell_rows, &cell_cols);
rectButton.width = nButtonWidth;
if (cell_rows == 1)
rectButton.height = rectCell.height-2;
else
rectButton.height = nButtonWidth;
SetTextColoursAndFont(grid, attr, dc, isSelected);
int hAlign, vAlign;
attr.GetAlignment(&hAlign, &vAlign);
// leave room for button
wxRect rect = rectCell;
rect.SetWidth(rectCell.GetWidth() - rectButton.GetWidth()-2);
rect.Inflate(-1);
grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), rect, hAlign, vAlign);
// don't bother drawing if the cell is too small
if (rectButton.height < 4 || rectButton.width < 4) return;
// draw 3-d button
wxColour colourBackGround = wxColour(COLORBASE);
dc.SetBrush(wxBrush(colourBackGround, wxSOLID));
dc.SetPen(wxPen(colourBackGround, 1, wxSOLID));
dc.DrawRectangle(rectButton);
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT), 1, wxSOLID));
dc.DrawLine(rectButton.GetLeft(), rectButton.GetBottom(),
rectButton.GetRight(), rectButton.GetBottom());
dc.DrawLine(rectButton.GetRight(), rectButton.GetBottom(),
rectButton.GetRight(), rectButton.GetTop()-1);
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW),
1, wxSOLID));
dc.DrawLine(rectButton.GetLeft()+1, rectButton.GetBottom()-1,
rectButton.GetRight()-1, rectButton.GetBottom()-1);
dc.DrawLine(rectButton.GetRight()-1, rectButton.GetBottom()-1,
rectButton.GetRight()-1, rectButton.GetTop());
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT),
1, wxSOLID));
dc.DrawLine(rectButton.GetRight()-2, rectButton.GetTop()+1,
rectButton.GetLeft()+1, rectButton.GetTop()+1);
dc.DrawLine(rectButton.GetLeft()+1, rectButton.GetTop()+1,
rectButton.GetLeft()+1, rectButton.GetBottom()-1);
// Draw little triangle
int nTriWidth = 7;
int nTriHeight = 4;
wxPoint point[3];
point[0] = wxPoint(rectButton.GetLeft() + (rectButton.GetWidth()-nTriWidth)/2,
rectButton.GetTop()+(rectButton.GetHeight()-nTriHeight)/2);
point[1] = wxPoint(point[0].x+nTriWidth-1, point[0].y);
point[2] = wxPoint(point[0].x+3, point[0].y+nTriHeight-1);
dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT), wxSOLID));
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT), 1, wxSOLID));
dc.DrawPolygon(3, point);
if (m_border == wxLAYOUT_TOP)
{
dc.SetPen(wxPen(*wxBLACK, 1, wxDOT));
dc.DrawLine(rectCell.GetRight(), rectCell.GetTop(),
rectCell.GetLeft(), rectCell.GetTop());
}
}
示例9: 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())
{
//.........这里部分代码省略.........
示例10: DrawTab
//.........这里部分代码省略.........
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),
示例11: Draw
void MyFrame::Draw(wxDC& dc)
{
// This routine just draws a bunch of random stuff on the screen so that we
// can check that different types of object are being drawn consistently
// between the screen image, the print preview image (at various zoom
// levels), and the printed page.
dc.SetBackground(*wxWHITE_BRUSH);
dc.Clear();
dc.SetFont(wxGetApp().m_testFont);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
// dc.SetBackground(*wxWHITE_BRUSH);
dc.DrawRectangle(0, 0, 230, 350);
dc.DrawLine(0, 0, 229, 349);
dc.DrawLine(229, 0, 0, 349);
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
dc.DrawRoundedRectangle(0, 20, 200, 80, 20);
dc.DrawText( wxT("Rectangle 200 by 80"), 40, 40);
dc.SetPen( wxPen(*wxBLACK,0,wxDOT_DASH) );
dc.DrawEllipse(50, 140, 100, 50);
dc.SetPen(*wxRED_PEN);
dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
#if wxUSE_UNICODE
//char *test = "Hebrew שלום -- Japanese (日本語)";
//wxString tmp = wxConvUTF8.cMB2WC( test );
//dc.DrawText( tmp, 10, 200 );
#endif
wxPoint points[5];
points[0].x = 0;
points[0].y = 0;
points[1].x = 20;
points[1].y = 0;
points[2].x = 20;
points[2].y = 20;
points[3].x = 10;
points[3].y = 20;
points[4].x = 10;
points[4].y = -20;
dc.DrawPolygon( 5, points, 20, 250, wxODDEVEN_RULE );
dc.DrawPolygon( 5, points, 50, 250, wxWINDING_RULE );
dc.DrawEllipticArc( 80, 250, 60, 30, 0.0, 270.0 );
points[0].x = 150;
points[0].y = 250;
points[1].x = 180;
points[1].y = 250;
points[2].x = 180;
points[2].y = 220;
points[3].x = 200;
points[3].y = 220;
dc.DrawSpline( 4, points );
dc.DrawArc( 20,10, 10,10, 25,40 );
wxString str;
int i = 0;
str.Printf( wxT("---- Text at angle %d ----"), i );
dc.DrawRotatedText( str, 100, 300, i );
i = m_angle;
str.Printf( wxT("---- Text at angle %d ----"), i );
dc.DrawRotatedText( str, 100, 300, i );
wxIcon my_icon = wxICON(mondrian) ;
dc.DrawIcon( my_icon, 100, 100);
if (m_bitmap.Ok())
{
dc.DrawBitmap(m_bitmap, 10, 25);
}
if (m_imgUp.Ok())
{
dc.DrawBitmap(m_imgUp, 300, 200);
dc.DrawBitmap(m_imgUp, 300, 250, true);
}
}
示例12: DrawNeedle
void kwxAngularMeter::DrawNeedle(wxDC &dc)
{
//Triangular
double dxi,dyi, val;
wxPoint ppoint[6];
int w, h ;
GetClientSize(&w,&h);
dc.SetPen(*wxThePenList->FindOrCreatePen(m_cNeedleColour, 1,wxSOLID));
val = (m_nScaledVal + m_nAngleStart) * m_dPI / 180; //radians angle parameter
dyi = sin(val - 90) * 2; //coordinates of the left base
dxi = cos(val - 90) * 2;
ppoint[0].x = (w / 2) - dxi; //left base
ppoint[0].y = (h / 2) - dyi;
dxi = cos(val) * ((h / 2) - 4); //coordinates of the tip marker
dyi = sin(val) * ((h / 2) - 4);
ppoint[2].x = (w / 2) - dxi; //points
ppoint[2].y = (h / 2) - dyi;
dxi = cos(val + 90) * 2; //coordinates basic right
dyi = sin(val + 90) * 2;
ppoint[4].x = (w / 2) - dxi; //right based
ppoint[4].y = (h / 2) - dyi;
ppoint[5].x = ppoint[0].x; //return the left base
ppoint[5].y = ppoint[0].y;
//////////////////////////
val = (m_nScaledVal + m_nAngleStart + 1) * m_dPI / 180;
dxi = cos(val) * ((h / 2) - 10); //coordinates of the right middle
dyi = sin(val) * ((h / 2) - 10);
ppoint[3].x = (w / 2) - dxi; //average basis right
ppoint[3].y = (h / 2) - dyi;
val = (m_nScaledVal + m_nAngleStart - 1) * m_dPI / 180;
dxi = cos(val) * ((h / 2) - 10); //coordinates of the left middle
dyi = sin(val) * ((h / 2) - 10);
ppoint[1].x = (w / 2) - dxi; //average basis the left
ppoint[1].y = (h / 2) - dyi;
/////////////////////////
dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(m_cNeedleColour,wxSOLID));
dc.DrawPolygon(6, ppoint, 0, 0, wxODDEVEN_RULE);
//Circle indicator
dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*wxWHITE,wxSOLID));
dc.DrawCircle(w / 2, h / 2, 4);
}
示例13: 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);
//.........这里部分代码省略.........
示例14: drawHead
void LineShape::drawHead(wxDC& dc)
{
int arrowHeadSize = 10;
// First we draw a triangle at (0.0)
// Second we rotate the triangle with the angle the line makes with the
// Y-axis around it's centre
// Than we move the centre of the triangle to the end of the line, but
// outside the node
top = Point(0, -arrowHeadSize);
right = Point(arrowHeadSize * std::sin(PI / 3), arrowHeadSize * std::cos(PI / 3));
left = Point(-arrowHeadSize * std::sin(PI / 3), arrowHeadSize * std::cos(PI / 3));
// double angle = getAngle();
double angle = Shape2DUtils::getAngle(node1->getCentre(), node2->getCentre()) + 0.5 * PI;
top = Shape2DUtils::rotate(top, angle);
right = Shape2DUtils::rotate(right, angle);
left = Shape2DUtils::rotate(left, angle);
double shortenLine = 0.0;
double dxRect = node2->getSize().x / 2;
double dyRect = node2->getSize().y / 2;
double boundaryAngle = std::atan(dxRect / dyRect);
if (0.0 < angle && angle <= PI / 2) {
if (angle < boundaryAngle) {
shortenLine = dyRect / std::cos(angle);
} else {
shortenLine = dxRect / std::cos(PI / 2 - angle);
}
} else if (PI / 2 < angle && angle <= 2 * PI / 2) {
if (angle < PI - boundaryAngle) {
shortenLine = dxRect / std::cos(angle - PI / 2);
} else {
shortenLine = dyRect / std::cos(PI - angle);
}
} else if (2 * PI / 2 < angle && angle <= 3 * PI / 2) {
if (angle < boundaryAngle + PI) {
shortenLine = dyRect / std::cos(angle - PI);
} else {
shortenLine = dxRect / std::cos(3 * PI / 2 - angle);
}
} else if (3 * PI / 2 < angle && angle <= 4 * PI / 2) {
if (angle < 2 * PI - boundaryAngle) {
shortenLine = dxRect / std::cos(angle - PI / 2);
} else {
shortenLine = dyRect / std::cos(PI / 2 - angle);
}
} else {
if (angle < 2 * PI - boundaryAngle) {
shortenLine = dxRect / std::cos(angle - 3 * PI / 2);
} else {
shortenLine = dyRect / std::cos(2 * PI - angle);
}
}
shortenLine += arrowHeadSize;
double dX = (getLength() - shortenLine) * sin(angle);
double dY = (getLength() - shortenLine) * cos(angle);
Point triangleCentre(getBegin().x + dX, getBegin().y - dY);
top += triangleCentre;
right += triangleCentre;
left += triangleCentre;
Point triangle[] = {top, right, left};
if (isSelected()) {
dc.SetPen(wxPen(WXSTRING("RED"), lineWidth, wxSOLID));
dc.SetBrush(wxBrush(wxColour(WXSTRING("RED"))));
} else {
dc.SetPen(wxPen(WXSTRING("BLACK"), lineWidth, wxSOLID));
dc.SetBrush(wxBrush(wxColour(WXSTRING("BLACK"))));
}
dc.DrawPolygon(3, triangle);
// For debugging purposes
dc.SetPen(wxPen(WXSTRING("ORANGE"), 2, wxSOLID));
dc.SetBrush(wxBrush(wxColour(WXSTRING("ORANGE"))));
dc.DrawCircle(top, 2);
dc.SetPen(wxPen(WXSTRING("GREEN"), 2, wxSOLID)); // stuuRRRRRRboord RRRRRRechts gRRRRRRoen
dc.SetBrush(wxBrush(wxColour(WXSTRING("GREEN"))));
dc.DrawCircle(right, 2);
dc.SetPen(wxPen(WXSTRING("RED"), 2, wxSOLID));
dc.SetBrush(wxBrush(wxColour(WXSTRING("RED"))));
dc.DrawCircle(left, 2);
}
示例15: DrawNeedle
void AngularMeter::DrawNeedle(wxDC &dc)
{
//indicatore triangolare
double dxi,dyi, val;
wxPoint ppoint[6];
int w, h ;
GetClientSize(&w,&h);
int hOffset = 0;
int wOffset = 0;
if (w > h) wOffset = (w - h) / 2;
if (h > w) hOffset = (h - w) / 2;
//square out the size
if (w > h) w=h;
if (h > w) h=w;
dc.SetPen(*wxThePenList->FindOrCreatePen(_needleColor, 1,wxSOLID));
val = (_scaledValue + _angleStart) * _PI / 180; //radianti parametro angolo
dyi = sin(val - 90) * 2; //coordinate base sinistra
dxi = cos(val - 90) * 2;
ppoint[0].x = (int)((w / 2) - dxi); //base sinistra
ppoint[0].y = (int)((h / 2) - dyi);
dxi = cos(val) * ((h / 2) - 4); //coordinate punta indicatore
dyi = sin(val) * ((h / 2) - 4);
ppoint[2].x = (int)((w / 2) - dxi); //punta
ppoint[2].y = (int)((h / 2) - dyi);
dxi = cos(val + 90) * 2; //coordinate base destra
dyi = sin(val + 90) * 2;
ppoint[4].x = (int)((w / 2) - dxi); //base destra
ppoint[4].y = (int)((h / 2) - dyi);
ppoint[5].x = ppoint[0].x; //ritorno base sinistra
ppoint[5].y = ppoint[0].y;
//////////////////////////
val = (_scaledValue + _angleStart + 1) * _PI / 180;
dxi = cos(val) * ((h / 2) - 10); //coordinate medio destra
dyi = sin(val) * ((h / 2) - 10);
ppoint[3].x = (int)((w / 2) - dxi); //base media destra
ppoint[3].y = (int)((h / 2) - dyi);
val = (_scaledValue + _angleStart - 1) * _PI / 180;
dxi = cos(val) * ((h / 2) - 10); //coordinate medio sinistra
dyi = sin(val) * ((h / 2) - 10);
ppoint[1].x = (int)((w / 2) - dxi); //base media sinistra
ppoint[1].y = (int)((h / 2) - dyi);
/////////////////////////
dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(_needleColor,wxSOLID));
dc.DrawPolygon(6, ppoint, wOffset, hOffset, wxODDEVEN_RULE);
//cerchio indicatore
dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(_needleColor,wxSOLID));
dc.DrawCircle((w / 2) + wOffset, (h / 2) + hOffset, 10);
}