本文整理汇总了C++中wxDC::DrawRotatedText方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::DrawRotatedText方法的具体用法?C++ wxDC::DrawRotatedText怎么用?C++ wxDC::DrawRotatedText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::DrawRotatedText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
wxBannerWindow::DrawBannerTextLine(wxDC& dc,
const wxString& str,
const wxPoint& pos)
{
switch ( m_direction )
{
case wxTOP:
case wxBOTTOM:
// The simple case: we just draw the text normally.
dc.DrawText(str, pos);
break;
case wxLEFT:
// We draw the text vertically and start from the lower left
// corner and not the upper left one as usual.
dc.DrawRotatedText(str, pos.y, GetClientSize().y - pos.x, 90);
break;
case wxRIGHT:
// We also draw the text vertically but now we start from the upper
// right corner and draw it from top to bottom.
dc.DrawRotatedText(str, GetClientSize().x - pos.y, pos.x, -90);
break;
case wxALL:
wxFAIL_MSG( wxS("Unreachable") );
}
}
示例2: draw
void LineShape::draw(wxDC& dc)
{
if (isSelected()) {
dc.SetPen(wxPen(WXSTRING("RED"), lineWidth, wxSOLID));
} else {
dc.SetPen(wxPen(WXSTRING("BLACK"), lineWidth, wxSOLID));
}
dc.DrawLine(node1->getCentre().x, node1->getCentre().y, node2->getCentre().x,
node2->getCentre().y);
if (arrowHeadSize > 0) {
drawHead(dc);
}
if (title == "" && node1->getTitle() != "" && node2->getTitle() != "") {
title = node1->getTitle() + " to " + node2->getTitle();
}
Size textSize = dc.GetTextExtent(WXSTRING(title));
Point textPoint = getBegin();
// double angle = getAngle();
double angle = Shape2DUtils::getAngle(node1->getCentre(), node2->getCentre());
double dX = (getLength() / 2 - textSize.x / 2) * sin(angle);
double dY = (getLength() / 2 - textSize.x / 2) * cos(angle);
textPoint.x += dX;
textPoint.y -= dY;
double degreeAngle = angle * (180.0 / PI);
double rotationAngle = 90 - degreeAngle;
dc.DrawRotatedText(WXSTRING(title), textPoint, rotationAngle);
}
示例3: render
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_);
}
示例4: DrawStaticBox
void UIElementVectorial::DrawStaticBox(wxDC& dc,const wxString& label, const wxPoint& pos, const wxSize& size)
{
wxColour c_pen = dc.GetPen().GetColour();
dc.SetPen(wxPen(dc.GetTextForeground()));
dc.DrawRoundedRectangle(pos.x, pos.y, size.x, size.y,3.1f);
dc.SetPen(wxPen(c_pen));
dc.DrawRotatedText(label,pos.x+10,pos.y,0);
}
示例5: DrawTicks
void kwxAngularMeter::DrawTicks(wxDC &dc)
{
double intervallo = (m_nAngleEnd - m_nAngleStart) / (m_nTick + 1.0);
double valint = intervallo + m_nAngleStart;
double tx, ty;
double val;
double dx, dy;
int n, w, h;
int tw, th;
wxString s;
GetClientSize(&w, &h);
for(n = 0;n < m_nTick;n++)
{
val=(valint * m_dPI) / 180;
//wxLogTrace("v: %f",valint);
dx = cos(val) * (h/2); //punto sul cerchio
dy = sin(val) * (h/2);
tx = cos(val) * ((h / 2) - 10); //punto nel cerchio
ty = sin(val) * ((h / 2) - 10);
dc.DrawLine( static_cast<int>((w / 2) - tx)
, static_cast<int>((h / 2) - ty)
, static_cast<int>((w / 2) - dx)
, static_cast<int>((h / 2) - dy));
int deltarange = m_nRangeEnd - m_nRangeStart;
int deltaangle = m_nAngleEnd - m_nAngleStart;
double coeff = (double)deltaangle / (double)deltarange;
int rightval = (int)(((valint - (double)m_nAngleStart)) / coeff) + m_nRangeStart;
s.Printf("%d", rightval);
dc.GetTextExtent(s, &tw, &th);
val = ((valint - 4) * m_dPI) / 180; //angolo spostato
tx = cos(val) * ((h / 2) - 12); //punto testo
ty = sin(val) * ((h / 2) - 12);
dc.SetFont(m_Font);
dc.DrawRotatedText( s
, static_cast<int>((w / 2) - tx)
, static_cast<int>((h / 2) - ty)
, 90 - valint);
valint = valint + intervallo;
}
}
示例6: render
void UIEAttributes::render(wxDC& dc)
{
int client_h = 0;
int client_w = 0;
GetClientSize (&client_w, &client_h);
if (!(cpw::ApplicationConfiguration::GetInstance()->IsThemed()))
{
wxColour c_pen = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient2Colour().c_str(),wxConvUTF8);
wxColour c_backg = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient1Colour().c_str(),wxConvUTF8);
wxColour c_brush = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundColour().c_str(),wxConvUTF8);
dc.SetTextForeground(wxColour(wxString(cpw::ApplicationConfiguration::GetInstance()->GetFontLightColour().c_str(),wxConvUTF8)));
dc.SetPen(wxPen(c_pen));
dc.SetBrush(wxBrush(c_brush));
dc.GradientFillLinear( wxRect(0,0,client_w,client_h), c_backg, c_pen, wxSOUTH);
}
dc.DrawRotatedText(_T("Name: "),20,163, 0);
dc.DrawRotatedText(_T("Type: "),20,188, 0);
dc.DrawRotatedText(_T("Value:"),20,213, 0);
}
示例7: render
void UIElementPrimitive::render(wxDC& dc)
{
int client_h = 0;
int client_w = 0;
GetClientSize (&client_w, &client_h);
if (!(cpw::ApplicationConfiguration::GetInstance()->IsThemed()))
{
wxColour c_pen = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient2Colour().c_str(),wxConvUTF8);
wxColour c_backg = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient1Colour().c_str(),wxConvUTF8);
wxColour c_brush = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundColour().c_str(),wxConvUTF8);
dc.SetTextForeground(wxColour(wxString(cpw::ApplicationConfiguration::GetInstance()->GetFontLightColour().c_str(),wxConvUTF8)));
dc.SetPen(wxPen(c_pen));
dc.SetBrush(wxBrush(c_brush));
dc.GradientFillLinear( wxRect(0,0,client_w,client_h), c_backg, c_pen, wxSOUTH);
}
dc.DrawRotatedText(_T("Name: "),20,20, 0);
dc.DrawRotatedText(_T("Model: "),20,40, 0);
dc.DrawRotatedText(_T("Icon:"),20,60, 0);
dc.DrawRotatedText(_T("Font:"),20,80, 0);
dc.DrawRotatedText(_T("Description"),20,100, 0);
}
示例8: draw_sample_labels
void Plotter::draw_sample_labels(wxDC& dc){
int x_cur = this->margin_x;
dc.SetFont(wxFont(8,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD));
for(int i=0; i<(int)this->sample_labels.size(); i++){
int nchar = this->sample_labels.at(i).size();
int y_cur = this->y_orig;
if( nchar < 8 )
y_cur = y_cur+50;
else if( nchar < 20 )
y_cur += 80;
else
y_cur += 95;
dc.DrawRotatedText( wxString::FromAscii(this->sample_labels.at(i).c_str()), x_cur-5, y_cur, 90);
x_cur += this->scale_h;
}
}
示例9: render
void UIElementVectorial::render(wxDC& dc)
{
int client_h = 0;
int client_w = 0;
GetClientSize (&client_w, &client_h);
if (!(cpw::ApplicationConfiguration::GetInstance()->IsThemed()))
{
wxColour c_pen = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient2Colour().c_str(),wxConvUTF8);
wxColour c_backg = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient1Colour().c_str(),wxConvUTF8);
wxColour c_brush = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundColour().c_str(),wxConvUTF8);
dc.SetTextForeground(wxColour(wxString(cpw::ApplicationConfiguration::GetInstance()->GetFontLightColour().c_str(),wxConvUTF8)));
dc.SetPen(wxPen(c_pen));
dc.SetBrush(wxBrush(c_brush));
dc.GradientFillLinear( wxRect(0,0,client_w,client_h), c_backg, c_pen, wxSOUTH);
}
DrawStaticBox(dc,_T("Position"), wxPoint(20,294-60), wxSize(350,50));
wxPoint box1_first(20-2,10-2);
wxPoint box1_last(368,82+2);
dc.DrawRotatedText(_T("Name:"),20,10, 0);
//dc.DrawRotatedText(_T("Border thickness"),20,40, 0);
//dc.DrawRotatedText(_T("Border colour"),188,40, 0);
}
示例10: 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);
//.........这里部分代码省略.........
示例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: drawIsoLine
//.........这里部分代码省略.........
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
}
示例13: Draw
void MyApp::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(m_testFont);
// dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxLIGHT_GREY_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, wxPENSTYLE_DOT_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
const 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(sample);
dc.DrawIcon( my_icon, 100, 100);
if (m_bitmap.IsOk())
dc.DrawBitmap( m_bitmap, 10, 10 );
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsContext *gc = NULL;
wxPrinterDC *printer_dc = wxDynamicCast( &dc, wxPrinterDC );
if (printer_dc)
gc = wxGraphicsContext::Create( *printer_dc );
wxWindowDC *window_dc = wxDynamicCast( &dc, wxWindowDC );
if (window_dc)
gc = wxGraphicsContext::Create( *window_dc );
#ifdef __WXMSW__
wxEnhMetaFileDC *emf_dc = wxDynamicCast( &dc, wxEnhMetaFileDC );
if (emf_dc)
gc = wxGraphicsContext::Create( *emf_dc );
#endif
//.........这里部分代码省略.........
示例14: Draw
void ChipPackage::Draw(wxDC& dc, const wxSize& sz, const wxString& chipModel)
{
// set some GUI objects common to all packages-drawing code
dc.SetPen(*wxBLACK_PEN);
switch (Type)
{
case PDIP:
case SOIC:
case SSOP:
{
// some drawing constants:
// in these package types, pins are organized in two columns:
const unsigned int PinPerSide = GetPinCount()/2;
if ((GetPinCount()%2) != 0)
{
wxLogWarning(_("Invalid odd pin count: %d"), GetPinCount());
return;
}
// choose reasonable package width&height to
// - make best use of the available space
// - avoid drawing package excessively big
const unsigned int BoxW = sz.GetWidth()/3;
const unsigned int BoxH = (unsigned int)((double)sz.GetHeight()*0.8);
const unsigned int BoxX = (sz.GetWidth()-BoxW)/2;
const unsigned int BoxY = (sz.GetHeight()-BoxH)/2;
const unsigned int R = BoxW/6;
if (int(BoxW/8) == 0)
return; // this happens for very small package sizes;
// the check avoids an assertion failure from wxFont ctor later
// draw the PIC package box
dc.DrawRectangle(BoxX, BoxY, BoxW, BoxH);
dc.DrawArc(sz.GetWidth()/2-R, BoxY + 1,
sz.GetWidth()/2+R, BoxY + 1,
sz.GetWidth()/2, BoxY + 1);
dc.SetFont(wxFont(wxSize(0, BoxW/8), wxFONTFAMILY_DEFAULT,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
const wxSize& nameSz = dc.GetTextExtent(chipModel);
dc.DrawRotatedText(chipModel,
(sz.GetWidth() + nameSz.GetHeight())/2,
(sz.GetHeight() - nameSz.GetWidth())/2,
-90);
// draw the pins
DrawPins(dc, wxPoint(BoxX, BoxY), BoxH, 0, PinPerSide,
0, wxLEFT);
DrawPins(dc, wxPoint(BoxX+BoxW, BoxY), BoxH, PinPerSide, GetPinCount(),
DRAWPIN_INVERTED_ORDER, wxRIGHT);
}
break;
case MQFP:
case TQFP:
case PLCC:
case QFN:
{
// some drawing constants:
// in these package types, pins are organized in two columns:
const unsigned int PinPerSide = GetPinCount()/4;
if ((GetPinCount()%4) != 0)
{
wxLogWarning(_("Invalid pin count: %d"), GetPinCount());
return;
}
// choose reasonable package width&height to
// - make best use of the available space
// - avoid drawing package excessively big
const unsigned int BoxL = max(sz.GetWidth()/2,80);
const unsigned int BoxX = (sz.GetWidth()-BoxL)/2;
const unsigned int BoxY = (sz.GetHeight()-BoxL)/2;
const unsigned int R = BoxL/10;
if (int(BoxL/10) == 0)
return; // this happens for very small package sizes;
// the check avoids an assertion failure from wxFont ctor later
// draw the PIC package box
dc.DrawRectangle(BoxX, BoxY, BoxL, BoxL);
dc.DrawCircle(BoxX+int(R*1.3), BoxY+int(R*1.3), R/2);
// draw the name of the PIC model in the centre of the box
dc.SetFont(wxFont(wxSize(0, BoxL/10), wxFONTFAMILY_DEFAULT,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
const wxSize& nameSz = dc.GetTextExtent(chipModel);
dc.DrawText(chipModel,
(sz.GetWidth() - nameSz.GetWidth())/2,
(sz.GetHeight() - nameSz.GetHeight())/2);
// draw the pins
DrawPins(dc, wxPoint(BoxX, BoxY), BoxL, 0, PinPerSide,
DRAWPIN_NUMBERS_INSIDE_PINS, wxLEFT);
DrawPins(dc, wxPoint(BoxX, BoxY+BoxL), BoxL, PinPerSide, PinPerSide*2,
//.........这里部分代码省略.........
示例15: DrawPins
//.........这里部分代码省略.........
wxASSERT(PinOffset>=0);
if (int(PinH*0.8) == 0)
return; // this happens for very small package sizes;
// the check avoids an assertion failure from wxFont ctor
// select a font suitable for the PinH we have computed above:
int fSize = int(PinH*0.8);
if(fSize>12)fSize=12;
wxFont fnt(wxSize(0,fSize), wxFONTFAMILY_DEFAULT,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
dc.SetFont(fnt);
const unsigned int PinNumberW = 2*dc.GetCharWidth();
const unsigned int PinNumberH = dc.GetCharHeight();
bool invertOrder = (flags & DRAWPIN_INVERTED_ORDER) != 0;
unsigned int start = invertOrder ? LastPin-1 : FirstPin;
unsigned int end = invertOrder ? FirstPin-1 : LastPin;
int inc = invertOrder ? -1 : +1;
if (dir == wxLEFT || dir == wxRIGHT)
{
unsigned int PinX = (dir == wxLEFT) ? pt.x-PinW+1 : pt.x-1;
unsigned int PinY = pt.y + PinOffset + PinSpacing;
unsigned int PinNumberX = (dir == wxLEFT) ?
pt.x+PinSpacing : pt.x-PinNumberW-PinSpacing;
if (flags & DRAWPIN_NUMBERS_INSIDE_PINS)
PinNumberX = PinX + (PinW-PinNumberW)/2;
// draw the pins organizing them in a vertical column
for (unsigned int i=start; i != end; i+=inc)
{
unsigned int PinNumberY = PinY + (PinH-PinNumberH)/2;
unsigned int pinLabelX = (dir == wxLEFT) ?
PinX-PinSpacing-dc.GetTextExtent(PinNames[i]).GetWidth() :
PinX+PinW+PinSpacing;
unsigned int pinLabelY = PinNumberY;
// draw the pin rect
dc.DrawRectangle(PinX, PinY, PinW, PinH);
// print the pin number
dc.SetTextForeground(IsICSPPin(i) ? *wxRED : *wxBLACK);
dc.DrawText(wxString::Format(("%d"), i+1), PinNumberX, PinNumberY);
// print the pin name
dc.DrawText(PinNames[i], pinLabelX, pinLabelY);
PinY += PinH+PinSpacing;
}
}
else if (dir == wxTOP || dir == wxBOTTOM)
{
SWAP(PinH, PinW, unsigned int);
// in this case the PackageLen is the number of horizontal pixels available
// for drawing the pin strip; thus we want to compute PinW and set PinH
// VERY IMPORTANT: the code below is the dual of the code for wxLEFT|wxRIGHT case!
// If you change something here, you may want to change it also
// above, with the appropriate differences
// NOTE: remember however that the text is drawn rotated by 90 degrees
unsigned int PinX = pt.x + PinOffset + PinSpacing;
unsigned int PinY = (dir == wxTOP) ? pt.y-PinH+1 : pt.y-1;
unsigned int PinNumberY = (dir == wxTOP) ?
pt.y+PinSpacing : pt.y-PinNumberH-PinSpacing;
if (flags & DRAWPIN_NUMBERS_INSIDE_PINS)
PinNumberY = PinY + (PinH-PinNumberW)/2;
// draw the pins organizing them in a horizontal column
for (unsigned int i=start; i != end; i+=inc)
{
unsigned int PinNumberX = PinX + PinNumberH + (PinW-PinNumberH)/2;
unsigned int pinLabelX = PinNumberX;
unsigned int pinLabelY = (dir == wxTOP) ?
PinY-PinSpacing-dc.GetTextExtent(PinNames[i]).GetWidth() :
PinY+PinH+PinSpacing;
// draw the pin rect
dc.DrawRectangle(PinX, PinY, PinW, PinH);
// print the pin number
dc.SetTextForeground(IsICSPPin(i) ? *wxRED : *wxBLACK);
dc.DrawRotatedText(wxString::Format(("%d"), i+1), PinNumberX, PinNumberY, -90);
// print the pin name
dc.DrawRotatedText(PinNames[i], pinLabelX, pinLabelY, -90);
PinX += PinW+PinSpacing;
}
}
else
wxLogWarning(_("Invalid direction"));
}