本文整理汇总了C++中wxPaintDC::SetBrush方法的典型用法代码示例。如果您正苦于以下问题:C++ wxPaintDC::SetBrush方法的具体用法?C++ wxPaintDC::SetBrush怎么用?C++ wxPaintDC::SetBrush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxPaintDC
的用法示例。
在下文中一共展示了wxPaintDC::SetBrush方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawBoardBackground
void SudokuSolverFrame::DrawBoardBackground(wxPaintDC &dc)
{
unsigned int spSq = 0;
unsigned int smallSide;
unsigned int i,j;
wxColour LGray;
wxBrush LGrayBr;
LGray.Set(210,210,210);
LGrayBr.SetColour(LGray);
wxSize sz = GameBoardPanel->GetClientSize();
if (sz.x < sz.y)
smallSide = sz.x;
else
smallSide = sz.y;
spSq = smallSide / 9;
smallSide -= 10;
// Set the Brush and Pen to red
dc.SetBrush( LGrayBr );
dc.SetPen(*wxBLACK_PEN );
// Draw rectangle 40 pixels wide and 40 high
// with upper left corner at 10 , 10.
for(i=0;i<9;i++)
for(j=0;j<9;j++)
{
if(i == col && j == row)
dc.SetBrush(*wxBLUE_BRUSH);
else
dc.SetBrush(LGrayBr);
dc.DrawRectangle( 0 + spSq*i, 0 + spSq*j, spSq - 5, spSq - 5 );
}
wxColor Black(0,0,0);
wxPen myBlackPen(Black,5,wxSOLID);
dc.SetPen(myBlackPen);
// Section Borders
dc.DrawLine( 0, smallSide/3 - 2, smallSide, smallSide/3 - 2);
dc.DrawLine( 0, smallSide*2/3 - 1, smallSide, smallSide*2/3 - 1);
dc.DrawLine( smallSide/3 - 2, 0, smallSide/3 - 2, smallSide);
dc.DrawLine( smallSide*2/3 - 1, 0, smallSide*2/3 - 1, smallSide);
// Edge Borders
dc.DrawLine( 0, 0, smallSide, 0);
dc.DrawLine( 0, 0, 0, smallSide);
dc.DrawLine( 0, smallSide, smallSide, smallSide);
dc.DrawLine( smallSide, 0, smallSide, smallSide);
}
示例2: DrawTrigger
void THISCLASS::DrawTrigger(wxPaintDC &dc, const SwisTrackCoreEventRecorder::Timeline *timeline) {
// Prepare
wxSize dcsize = dc.GetSize();
int dw = dcsize.GetWidth();
int dh = dcsize.GetHeight();
dc.SetBrush(wxBrush(wxColour(0xee, 0xee, 0xee)));
dc.SetPen(wxPen(wxColour(0xee, 0xee, 0xee)));
// Draw
double starttime = -1;
bool active = timeline->mBeginState.mTriggerActive;
SwisTrackCoreEventRecorder::Timeline::tEventList::const_iterator it = timeline->mEvents.begin();
while (it != timeline->mEvents.end()) {
if (it->mType == SwisTrackCoreEventRecorder::sType_BeforeTriggerStart) {
starttime = mSwisTrack->mSwisTrackCore->mEventRecorder->CalculateDuration(&(timeline->mBegin), &(*it));;
active = true;
} else if (it->mType == SwisTrackCoreEventRecorder::sType_AfterTriggerStop) {
double time = mSwisTrack->mSwisTrackCore->mEventRecorder->CalculateDuration(&(timeline->mBegin), &(*it));
DrawTrigger(dc, dw, dh, starttime, time);
starttime = time;
active = false;
}
it++;
}
// Draw last event
if (active) {
DrawTrigger(dc, dw, dh, starttime, -1);
}
}
示例3: RenderPreview
void ImageResource::RenderPreview(wxPaintDC & dc, wxPanel & previewPanel, gd::Project & project)
{
wxLogNull noLog; //We take care of errors.
wxSize size = previewPanel.GetSize();
//Checkerboard background
dc.SetBrush(gd::CommonBitmapProvider::Get()->transparentBg);
dc.DrawRectangle(0,0, size.GetWidth(), size.GetHeight());
wxString fullFilename = GetAbsoluteFile(project);
if ( !wxFile::Exists(fullFilename) )
return;
wxBitmap bmp( fullFilename, wxBITMAP_TYPE_ANY);
if ( bmp.GetWidth() != 0 && bmp.GetHeight() != 0 && (bmp.GetWidth() > previewPanel.GetSize().x || bmp.GetHeight() > previewPanel.GetSize().y) )
{
//Rescale to fit in previewPanel
float xFactor = static_cast<float>(previewPanel.GetSize().x)/static_cast<float>(bmp.GetWidth());
float yFactor = static_cast<float>(previewPanel.GetSize().y)/static_cast<float>(bmp.GetHeight());
float factor = std::min(xFactor, yFactor);
wxImage image = bmp.ConvertToImage();
if ( bmp.GetWidth()*factor >= 5 && bmp.GetHeight()*factor >= 5)
bmp = wxBitmap(image.Scale(bmp.GetWidth()*factor, bmp.GetHeight()*factor));
}
//Display image in the center
if ( bmp.IsOk() )
dc.DrawBitmap(bmp,
(size.GetWidth() - bmp.GetWidth()) / 2,
(size.GetHeight() - bmp.GetHeight()) / 2,
true /* use mask */);
}
示例4: render
void LaserPanelLayer::render(wxPaintDC &dc, const CoordScale &drawscale) const {
static wxPen pens[] = {
wxPen(*wxBLUE),
wxPen(*wxGREEN),
wxPen(*wxRED)
};
static wxBrush brushes[] = {
wxBrush(*wxBLUE),
wxBrush(*wxGREEN),
wxBrush(*wxRED)
};
for (int laser=0; laser < readings.size(); laser++) {
const LaserSensor::DistAngleVec &distangles = readings[laser];
for (LaserSensor::DistAngleVec::const_iterator i = distangles.begin(); i != distangles.end(); ++i) {
Coord coord = i->toCoord(M_PI/2);
Pos pos = drawscale.coordToPos(coord.x + 50, 100 - coord.y);
int num = min(laser, 3);
dc.SetPen(pens[num]);
dc.SetBrush(brushes[num]);
dc.DrawCircle(pos.x, pos.y, 1);
}
}
}
示例5: DrawSquare
void Board::DrawSquare (wxPaintDC &dc, int x, int y, Tetrominoes shape)
{
static wxColour colors[] = { wxColour (0, 0, 0), wxColour (204, 102, 102),
wxColour (102, 204, 102), wxColour (102, 102, 204),
wxColour (204, 204, 102), wxColour (204, 102, 204),
wxColour (102, 204, 204), wxColour (218, 170, 0)
};
static wxColour light[] = { wxColour (0, 0, 0), wxColour (248, 159, 171),
wxColour (121, 252, 121), wxColour (121, 121, 252),
wxColour (252, 252, 121), wxColour (252, 121, 252),
wxColour (121, 252, 252), wxColour (252, 198, 0)
};
static wxColour dark[] = { wxColour (0, 0, 0), wxColour (128, 59, 59),
wxColour (59, 128, 59), wxColour (59, 59, 128),
wxColour (128, 128, 59), wxColour (128, 59, 128),
wxColour (59, 128, 128), wxColour (128, 98, 0)
};
wxPen pen (light[int (shape)]);
pen.SetCap (wxCAP_PROJECTING);
dc.SetPen (pen);
dc.DrawLine (x, y + SquareHeight() - 1, x, y);
dc.DrawLine (x, y, x + SquareWidth() - 1, y);
wxPen darkpen (dark[int (shape)]);
darkpen.SetCap (wxCAP_PROJECTING);
dc.SetPen (darkpen);
dc.DrawLine (x + 1, y + SquareHeight() - 1,
x + SquareWidth() - 1, y + SquareHeight() - 1);
dc.DrawLine (x + SquareWidth() - 1,
y + SquareHeight() - 1, x + SquareWidth() - 1, y + 1);
dc.SetPen (*wxTRANSPARENT_PEN);
dc.SetBrush (wxBrush (colors[int (shape)]));
dc.DrawRectangle (x + 1, y + 1, SquareWidth() - 2,
SquareHeight() - 2);
}
示例6: DrawAxis
void TimeLogChart::DrawAxis(wxPaintDC &dc)
{
const int MARKER_OFFSET = 5;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(*wxWHITE_BRUSH);
dc.DrawRectangle(m_axisBounds);
dc.SetPen(wxPen(wxColour(*wxBLACK), 1, wxPENSTYLE_DOT));
int topBound = m_axisBounds.GetTop();
int leftBound = m_axisBounds.GetLeft();
int rightBound = m_axisBounds.GetRight();
int bottomBound = m_axisBounds.GetBottom();
int dx = leftBound;
wxFont savedFont = dc.GetFont();
dc.SetFont(*m_valueFont);
int n = m_logDuration -1;
for (int i = 0; i <= n; i++)
{
dx = leftBound + (int)floor(i*m_axisBounds.GetWidth() / (double)n);
if (i % m_logTickFrequency == 0)
{
dc.DrawLine(dx, topBound, dx, bottomBound);
if (i % (m_logTickFrequency*2) == 0)
{
// draw axis marker
wxString s = wxString::Format(wxT("%d secs"), (m_logDuration-i));
wxSize ext = dc.GetTextExtent(s);
dc.DrawText(s, dx - ext.GetWidth()/2, bottomBound + MARKER_OFFSET);
}
}
}
dc.DrawLine(dx, topBound, dx, bottomBound);
int yValue = m_maxValue;
int yValueSteps = (m_minValue-m_maxValue)/m_valueDivisions;
int ySteps = ValueToPixel((m_maxValue - m_minValue)/m_valueDivisions);
int dy = topBound;
for (int n = 0; n < m_valueDivisions; n++)
{
dc.DrawLine(leftBound, dy, rightBound, dy);
wxString s = wxString::Format(m_valueAxisFormat, (double)yValue/m_valueAxisScale);
wxSize ext = dc.GetTextExtent(s);
dc.DrawText(s, m_axisBounds.GetLeft()-ext.GetWidth() - MARKER_OFFSET, dy - ext.GetHeight()/2);
dy += ySteps;
yValue += yValueSteps;
}
dc.DrawLine(leftBound, bottomBound, rightBound, bottomBound);
dc.SetFont(savedFont);
}
示例7: doHandPaint
void gcProgressBar::doHandPaint(wxPaintDC& dc)
{
wxSize size = GetSize();
uint32 w = size.GetWidth();
uint32 h = size.GetHeight()-2;
uint32 wp = w*m_uiProg/100;
wxColour green(0, 255, 0);
wxColour white(255, 255, 255);
wxColour black(0, 0, 0);
dc.SetPen(wxPen(green,1));
dc.SetBrush(wxBrush(green));
dc.DrawRectangle(0,0, wp, h);
dc.SetPen(wxPen(white,1));
dc.SetBrush(wxBrush(white));
dc.DrawRectangle(wp,0, w, h);
}
示例8: render
void RobotPanelLayer::render(wxPaintDC &dc, const CoordScale &drawscale) const {
const float minsize = min(drawscale.sx/gridscale.sx, drawscale.sy/gridscale.sy);
Pos pos = drawscale.coordToPos(robot.getPosition());
const float thickness = minsize * .3;
const float dir = robot.getDirection();
wxPoint points[3];
points[0].x = (int)(pos.x + thickness*cos(dir));
points[0].y = (int)(pos.y - thickness*sin(dir));
points[1].x = (int)(pos.x + thickness*cos(dir + 5*M_PI/4));
points[1].y = (int)(pos.y - thickness*sin(dir + 5*M_PI/4));
points[2].x = (int)(pos.x + thickness*cos(dir - 5*M_PI/4));
points[2].y = (int)(pos.y - thickness*sin(dir - 5*M_PI/4));
dc.DrawPolygon(3, points);
wxBrush victimbrush(wxColour(150, 200, 130));
const RoomPlanner::Plan &plan = robot.getPlan();
if (plan.identifyvictim)
dc.SetBrush(victimbrush);
const float radius = max(minsize*.1f, 3.0f);
for (int i = 0; i != plan.coords.size(); ++i) {
Pos p = drawscale.coordToPos(plan.coords[i]);
float dirrad = dirToRad(plan.facedirs[i]);
dc.DrawCircle(p.x, p.y, radius);
const float len = minsize*0.3;
const float endx = p.x+len*cos(dirrad);
const float endy = p.y-len*sin(dirrad);
dc.DrawLine(p.x, p.y, endx, endy);
dc.DrawCircle(endx, endy, 1);
}
const int crossdelta = (int)(minsize*0.15f);
const PosSet &victims = robot.getIdentifiedVictims();
for (PosSet::const_iterator i = victims.begin(); i != victims.end(); ++i) {
Pos pos = drawscale.coordToPos(victimscale.posToCoord(*i));
dc.DrawLine(pos.x-crossdelta, pos.y-crossdelta, pos.x+crossdelta+1, pos.y+crossdelta+1);
dc.DrawLine(pos.x-crossdelta, pos.y+crossdelta, pos.x+crossdelta+1, pos.y-crossdelta-1);
}
}