本文整理汇总了C++中wxDC::GetBrush方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::GetBrush方法的具体用法?C++ wxDC::GetBrush怎么用?C++ wxDC::GetBrush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::GetBrush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void wxlCanObj::Draw( wxDC& dc, double absx, double absy )
{
if ( m_brush.Ok() )
dc.SetBrush( m_brush );
if ( m_pen.Ok() )
dc.SetPen( m_pen );
wxBrush currentBrush = dc.GetBrush();
wxPen currentPen = dc.GetPen();
absx += m_x;
absy += m_y;
DoDraw( dc, absx, absy );
// iterate over the child list
for ( wxlCanObjList::Node *node = m_objects.GetFirst(); node; node = node->GetNext() )
{
wxlCanObj *drawobj = node->GetData();
// restore brush and pen
dc.SetBrush( currentBrush );
dc.SetPen( currentPen );
drawobj->Draw( dc , absx, absy );
}
}
示例2: Draw
bool RedHatchDrawlet::Draw(wxDC &dc)
{
#if wxCHECK_VERSION(2, 9, 0)
wxRasterOperationMode old_lf = dc.GetLogicalFunction();
#else
int old_lf = dc.GetLogicalFunction();
#endif
dc.SetLogicalFunction(wxXOR);
wxPen old_pen = dc.GetPen();
wxBrush old_brush = dc.GetBrush();
wxColor red = wxColor( ~wxRED->Red(), ~wxRED->Green(), ~wxRED->Blue());
#if wxCHECK_VERSION(2,9,0)
wxBrush brush = wxBrush(red, wxHATCHSTYLE_CROSSDIAG );
#else
wxBrush brush = wxBrush(red, wxCROSSDIAG_HATCH );
#endif
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(brush);
dc.DrawRectangle(m_rect);
dc.SetLogicalFunction(old_lf);
dc.SetPen(old_pen);
dc.SetBrush(old_brush);
return true;
}
示例3: wxDrawRectangle
// For some reason, drawing a rectangle on a memory DC has problems.
// Use this substitute if we can.
static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
wxBrush brush(dc.GetBrush());
wxPen pen(dc.GetPen());
if (brush.Ok() && brush.GetStyle() != wxTRANSPARENT)
{
HBRUSH hBrush = (HBRUSH) brush.GetResourceHandle() ;
if (hBrush)
{
RECT rect;
rect.left = x;
rect.top = y;
rect.right = x + width - 1;
rect.bottom = y + height - 1;
::FillRect((HDC) dc.GetHDC(), &rect, hBrush);
}
}
width --;
height --;
if (pen.Ok() && pen.GetStyle() != wxTRANSPARENT)
{
dc.DrawLine(x, y, x + width, y);
dc.DrawLine(x, y, x, y + height);
dc.DrawLine(x, y+height, x+width, y + height);
dc.DrawLine(x+width, y+height, x+width, y);
}
}
示例4: DoProgressDrawing
/* paints the progress bar */
void CBOINCGridCellProgressRenderer::DoProgressDrawing(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) {
wxRect rect = rectCell;
rect.Inflate(-1);
// erase only this cells background, overflow cells should have been erased
this->DrawBackground(grid, dc, rectCell, row, isSelected);
// set text attributes
int hAlign, vAlign;
attr.GetAlignment(&hAlign, &vAlign);
SetTextColoursAndFont(grid, attr, dc, isSelected);
//calculate the two parts of the progress rect
//
double dv = 0.0;
wxString strValue = grid.GetCellValue(row,col);
if(m_bDoPercentAppending) {
strValue = strValue + wxT(" %");
}
// Project view uses the format: %0.0f (%0.2f%%)
// Everyone else uses: %.3f%%
if (strValue.Find(wxT("(")) != wxNOT_FOUND) {
strValue.SubString(strValue.Find(wxT("(")) + 1, strValue.Find(wxT(")")) - 1).ToDouble( &dv );
} else {
strValue.ToDouble ( &dv ); // NOTE: we should do error-checking/reporting here!!
}
wxRect p1(rect);
wxRect p2(rect);
int r = (int)((rect.GetRight()-rect.GetLeft())*dv / 100.0);
p1.SetRight(rect.GetLeft()+r);
p2.SetLeft(rect.GetLeft()+r+1);
p2.SetRight(rect.GetRight()-1);
//start drawing
dc.SetClippingRegion(rect);
wxBrush old = dc.GetBrush();
wxColour progressColour = wxTheColourDatabase->Find(wxT("LIGHT BLUE"));
wxBrush* progressBrush = wxTheBrushList->FindOrCreateBrush(progressColour);
wxPen* progressPen = wxThePenList->FindOrCreatePen(progressColour,1,wxSOLID);
//draw the outline rectangle
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.SetPen(*progressPen);
dc.DrawRectangle(rect);
// Draw the left part
dc.SetBrush(*progressBrush);
dc.DrawRectangle(p1);
//draw the right part
dc.SetBrush(old);
dc.DrawRectangle(p2);
//
dc.DestroyClippingRegion();
// draw the text
grid.DrawTextRectangle(dc, strValue, rect, hAlign, vAlign);
}
示例5: DrawBG
void CPathItem::DrawBG(wxDC &dc, wxRect &rc)
{
wxPen oldpen = dc.GetPen();
wxPen pen( IsSelected() ? *wxBLACK_PEN : *wxMEDIUM_GREY_PEN );
pen.SetWidth(IsSelected() ? 2 : 1);
dc.SetPen( pen );
wxBrush oldBrush = dc.GetBrush();
wxBrush brush(m_color, NULL!=m_pInput ? wxSOLID : wxTRANSPARENT);
dc.SetBrush(brush);
int x = rc.GetX();
int y = rc.GetY();
int w = rc.GetWidth();
int h = rc.GetHeight();
int n = 0;
wxPoint points[6];
if(NULL != m_pInput)
{
points[0] = wxPoint(x, y);
points[1] = wxPoint(x+w-GAP_LENGTH, y);
points[2] = wxPoint(x+w+CORNER_LENGTH-GAP_LENGTH, y+h/2);
points[3] = wxPoint(x+w-GAP_LENGTH, y+h);
points[4] = wxPoint(x, y+h);
points[5] = wxPoint(x+CORNER_LENGTH, y+h/2);
n = m_bFirst ? 5 : 6;
}
else
{
// Last component: mixer
points[0] = wxPoint(x, y);
points[1] = wxPoint(x+w, y);
points[2] = wxPoint(x+w, y+h);
points[3] = wxPoint(x, y+h);
points[4] = wxPoint(x+CORNER_LENGTH, y+h/2);
n = 5;
}
if(m_pRegion)
delete m_pRegion;
m_pRegion = new wxRegion(n, points);
dc.DrawPolygon(n, points);
dc.SetBrush( oldBrush );
dc.SetPen(oldpen);
}
示例6: draw
void FloorTruss::draw(wxDC &dc, unsigned left, unsigned top, unsigned right,
unsigned bottom) {
// Trusses should be drawn 6" from the left side.
float six_inches = (right-left) / (60.0f*2);
float one_inch = (right-left) / 60.0f / 12.0f;
unsigned px_width = one_inch * width;
unsigned px_height = one_inch * height;
const wxBrush &old_brush = dc.GetBrush();
dc.SetBrush(*wxGREY_BRUSH);
dc.DrawRectangle(left + six_inches, bottom - px_height, px_width+1,
px_height+1);
dc.SetBrush(old_brush);
}
示例7: DrawBG
void CFloopyControl::DrawBG(wxDC& dc, wxRect& rc)
{
wxBrush oldBrush = dc.GetBrush();
wxPen oldpen = dc.GetPen();
wxPen pen( *wxLIGHT_GREY );
pen.SetWidth(1);
dc.SetPen( pen );
wxBrush brush(GetParent()->GetColor(), wxSOLID);
dc.SetBrush(brush);
dc.DrawRoundedRectangle(rc.GetX(), rc.GetTop(),
rc.GetWidth(), rc.GetHeight(), 2);
dc.SetPen(oldpen);
dc.SetBrush( oldBrush );
}
示例8: _Draw_Box
//---------------------------------------------------------
inline void CWKSP_Layer_Legend::_Draw_Box(wxDC &dc, int y, int dy, wxColour Color)
{
wxPen Pen;
wxBrush Brush;
//-----------------------------------------------------
_Set_Size(0, dy);
dy -= BOX_SPACE;
//-----------------------------------------------------
if( m_Box_bOutline == false )
{
Pen = dc.GetPen();
Pen.SetColour(Color);
dc.SetPen(Pen);
}
if( m_Box_bFill )
{
Brush = dc.GetBrush();
Brush.SetColour(Color);
dc.SetBrush(Brush);
}
//-----------------------------------------------------
switch( m_BoxStyle )
{
case BOXSTYLE_LINE:
dc.DrawLine(m_xBox , y + dy / 2, m_xBox + m_dxBox / 4, y);
dc.DrawLine(m_xBox + m_dxBox / 4, y , m_xBox + 3 * m_dxBox / 4, y + dy);
dc.DrawLine(m_xBox + 3 * m_dxBox / 4, y + dy , m_xBox + m_dxBox , y + dy / 2);
break;
case BOXSTYLE_CIRCLE:
dc.DrawCircle(m_xBox + m_dxBox / 2, y + dy / 2, dy / 2);
break;
case BOXSTYLE_RECT: default:
dc.DrawRectangle(m_xBox, y, m_dxBox, dy);
break;
}
}
示例9: drawIndicatorAtArea
void StateEvaluationTreePanel::drawIndicatorAtArea(wxDC &DC,
IndicatorStyle const &Style,
wxCoord X, wxCoord Y,
wxCoord W, wxCoord H)
{
auto const Kind = Style.GetKind();
auto const FG = Style.GetForeground();
wxPen const PrevPen = DC.GetPen();
wxBrush const PrevBrush = DC.GetBrush();
switch (Kind) {
case IndicatorStyle::EKind::Plain:
DC.SetPen(wxPen{FG, Settings.PenWidth});
DC.DrawLine(X, Y+H, X+W, Y+H);
break;
case IndicatorStyle::EKind::Box:
DC.SetPen(wxPen{FG, Settings.PenWidth});
DC.DrawRectangle(X, Y, W, H);
break;
case IndicatorStyle::EKind::StraightBox:
// Many DCs don't support alpha at all, so manually calculate an alpha
// against the background colour.
auto const BG = PrevBrush.GetColour();
double const Alpha = (double)Style.GetAlpha() / 255;
double const OutlineAlpha = (double)Style.GetOutlineAlpha() / 255;
DC.SetPen(wxPen{
wxColour(wxColour::AlphaBlend(FG.Red(), BG.Red(), OutlineAlpha),
wxColour::AlphaBlend(FG.Green(), BG.Green(), OutlineAlpha),
wxColour::AlphaBlend(FG.Blue(), BG.Blue(), OutlineAlpha)),
Settings.PenWidth});
DC.SetBrush(wxBrush{
wxColour(wxColour::AlphaBlend(FG.Red(), BG.Red(), Alpha),
wxColour::AlphaBlend(FG.Green(), BG.Green(), Alpha),
wxColour::AlphaBlend(FG.Blue(), BG.Blue(), Alpha))});
DC.DrawRectangle(X, Y, W, H);
break;
}
DC.SetPen(PrevPen);
DC.SetBrush(PrevBrush);
}
示例10: PaintStraightGradientBox
void DrawingUtils::PaintStraightGradientBox(wxDC& dc,
const wxRect& rect,
const wxColour& startColor,
const wxColour& endColor,
bool vertical)
{
int rd, gd, bd, high = 0;
rd = endColor.Red() - startColor.Red();
gd = endColor.Green() - startColor.Green();
bd = endColor.Blue() - startColor.Blue();
/// Save the current pen and brush
wxPen savedPen = dc.GetPen();
wxBrush savedBrush = dc.GetBrush();
if ( vertical )
high = rect.GetHeight()-1;
else
high = rect.GetWidth()-1;
if ( high < 1 )
return;
for (int i = 0; i <= high; ++i) {
int r = startColor.Red() + ((i*rd*100)/high)/100;
int g = startColor.Green() + ((i*gd*100)/high)/100;
int b = startColor.Blue() + ((i*bd*100)/high)/100;
wxPen p(wxColor(r, g, b));
dc.SetPen(p);
if ( vertical )
dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i);
else
dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);
}
/// Restore the pen and brush
dc.SetPen( savedPen );
dc.SetBrush( savedBrush );
}
示例11: Draw
void ColourGridCellRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected)
{
//Call base class to clear the full drawing area and render the string
OffsetStringGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
//Get the old state
wxBrush oldBrush = dc.GetBrush();
wxPen oldPen = dc.GetPen();
//Set the new state
dc.SetBrush(wxBrush(renderColour));
dc.SetPen(wxPen(*wxBLACK));
//Render the color box
wxRect renderRect = wxRect(rect.x + 5,rect.y + 1, 17, 14).Intersect(rect);
dc.DrawRectangle(renderRect);
//Restore the old state
dc.SetBrush(oldBrush);
dc.SetPen(oldPen);
}
示例12: Fill
void SkinColor::Fill(wxDC& dc, const wxRect& rect)
{
if (IsOpaque()) {
if (rounded)
dc.DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, rounded);
else
dc.DrawRectangle(rect);
} else {
#if __WXMSW__
wxGraphicsContext* gc = wxGraphicsContext::Create(dc);
gc->SetBrush(dc.GetBrush());
gc->SetPen(*wxTRANSPARENT_PEN);
if (rounded)
gc->DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, rounded);
else
gc->DrawRectangle(rect.x, rect.y, rect.width, rect.height);
delete gc;
#endif
}
}
示例13: SetBrushColour
void TLView::SetBrushColour( wxDC& dc, wxColour colour )
{
wxBrush brush1 = dc.GetBrush();
brush1.SetColour( colour );
dc.SetBrush( brush1 );
}
示例14: DrawBG
void CLabel::DrawBG(wxDC& dc, wxRect& rc)
{
CTrack *track = getTrack();
m_rcLabel = rc;
wxBrush oldBrush = dc.GetBrush();
wxPen oldpen = dc.GetPen();
wxPen pen( *wxMEDIUM_GREY_PEN );
pen.SetWidth(1);
dc.SetPen( pen );
//wxBrush brush(m_color, (IsSelected() ? wxCROSSDIAG_HATCH : wxSOLID));
wxBrush brush(track->GetBGColor(), wxSOLID);
dc.SetBrush(brush);
int left, top, width, height;
if(m_bDrawAquaBG)
{
// Draw aqua background
left = 0;
top = rc.GetTop();
width = rc.GetWidth()-left;
height = rc.GetHeight();
//dc.DrawRectangle(left, top, width, height);
wxRect rc(left+1, top+1, width-2, height-2);
DrawAquaRect(dc, rc, 4);
}
else
{
// Draw background
left = 1;//m_nLevel*4+2;
top = rc.GetTop()+1;
width = rc.GetWidth()-1;//left-3;
height = rc.GetHeight()-2;
//dc.DrawRoundedRectangle(left, top, width, height, 4);
//DrawRect3D(dc, wxRect(left, top, width, height));
DrawRect3D(dc, rc);
}
dc.SetTextForeground( track->GetForeColor() );
wxFont oldFont = dc.GetFont();
wxFont font(9, wxSWISS, wxNORMAL, wxBOLD);
//wxFont font = oldFont;
//font.SetWeight(IsSelected() ? wxBOLD : wxNORMAL);
//font.SetPointSize(GetHeight() / 4);
font.SetPointSize( 9 );
dc.SetFont(font);
//wxFont font(12, wxDEFAULT, wxITALIC, (IsSelected() ? wxBOLD : wxNORMAL));
//dc.SetFont(font);
////dc.SetFont((IsSelected() ? *wxITALIC_FONT : *wxNORMAL_FONT));
// Get text dimensions
wxCoord w=0, h=0;
wxString csName;
track->GetName(csName);
dc.GetTextExtent(csName, &w, &h);
/*int ptSize = GetHeight() / 2;
// Get text dimensions
wxCoord w=0, h=0;
do {
font.SetPointSize(ptSize);
dc.GetTextExtent(m_name, &w, &h);
ptSize--;
} while (w>width && ptSize > 5);*/
// Draw text
int x = left + 5;//width/2 - w/2;
int y = (rc.GetTop() + (rc.GetHeight()/4) - h/2);
dc.DrawText( csName, x, y );
m_rcLabel.SetHeight(rc.GetHeight());
/*
int n = rc.GetHeight()/2-2;
if(n > 20)
n = 20;
drawLoopSign(dc, wxRect(5, top+height-n-2, n, n));
drawCacheSign(dc, wxRect(n+5+1, top+height-n-2, n, n));
*/
wxRect rcTmp = getPathRect(rc);
m_pPathCtrl->DrawBG(dc, rcTmp);
dc.SetFont(oldFont);
dc.SetPen(oldpen);
dc.SetBrush( oldBrush );
}
示例15: _Draw_Point
//---------------------------------------------------------
void CWKSP_Layer_Legend::_Draw_Point(wxDC &dc, CWKSP_Shapes_Point *pLayer)
{
bool bSize;
int min_Size, max_Size;
double min_Value, d_Value;
wxString Name, Name_Size;
wxPen Pen;
wxBrush Brush;
//-----------------------------------------------------
m_BoxStyle = BOXSTYLE_CIRCLE;
m_Box_bFill = true;
//-----------------------------------------------------
bSize = pLayer->Get_Style_Size(min_Size, max_Size, min_Value, d_Value, &Name_Size);
pLayer->Get_Style(Pen, Brush, m_Box_bOutline, &Name);
if( m_pClassify->Get_Mode() != CLASSIFY_UNIQUE || !bSize )
{
dc.SetBrush(Brush);
dc.SetPen(Pen);
if( Name.Length() > 0 )
{
_Draw_Title(dc, FONT_SUBTITLE, Name);
}
// _Draw_Boxes(dc, m_Position.y);
for(int i=m_pClassify->Get_Class_Count()-1, y=m_Position.y; i>=0; i--, y+=BOX_HEIGHT)
{
// _Draw_Box (dc, y, BOX_HEIGHT, Get_Color_asWX(m_pClassify->Get_Class_Color(i)));
_Set_Size(0, BOX_HEIGHT);
if( m_Box_bOutline == false )
{
Pen = dc.GetPen();
Pen.SetColour(Get_Color_asWX(m_pClassify->Get_Class_Color(i)));
dc.SetPen(Pen);
}
if( m_Box_bFill )
{
Brush = dc.GetBrush();
Brush.SetColour(Get_Color_asWX(m_pClassify->Get_Class_Color(i)));
dc.SetBrush(Brush);
}
pLayer->Draw_Symbol(dc, m_xBox + m_dxBox / 2, y + (BOX_HEIGHT - BOX_SPACE) / 2, (BOX_HEIGHT - BOX_SPACE) / 2);
_Draw_Label(dc, y, m_pClassify->Get_Class_Name(i), TEXTALIGN_TOP);
}
}
//-----------------------------------------------------
if( bSize )
{
dc.SetBrush(Brush);
dc.SetPen(Pen);
_Draw_Title(dc, FONT_SUBTITLE, Name_Size);
_Draw_Point_Sizes(dc, pLayer, min_Size, max_Size, min_Value, d_Value);
_Set_Size(0, SIZE_HEIGHT + dc.GetFont().GetPointSize());
}
}